MainActivity.java 465 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077
  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.SharedPreferences;
  12. import android.content.pm.PackageInfo;
  13. import android.content.pm.PackageManager;
  14. import android.database.SQLException;
  15. import android.graphics.Color;
  16. import android.hardware.Camera;
  17. import android.media.AudioManager;
  18. import android.net.Uri;
  19. import android.net.ethernet.EthernetDevInfo;
  20. import android.net.ethernet.EthernetManager;
  21. import android.os.Build;
  22. import android.os.Bundle;
  23. import android.os.Handler;
  24. import android.os.Looper;
  25. import android.os.Message;
  26. import android.os.PowerManager;
  27. import android.provider.Settings;
  28. import android.util.Log;
  29. import android.view.KeyEvent;
  30. import android.view.MotionEvent;
  31. import android.view.SurfaceHolder;
  32. import android.view.SurfaceView;
  33. import android.view.View;
  34. import android.view.WindowManager;
  35. import android.view.animation.Animation;
  36. import android.view.animation.AnimationUtils;
  37. import android.widget.ImageView;
  38. import android.widget.RelativeLayout;
  39. import android.widget.ViewFlipper;
  40. import com.artncore.WallPadDataMgr.WallpadCallHistoryData;
  41. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  42. import com.artncore.WallPadDataMgr.WallpadParkInfo;
  43. import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
  44. import com.artncore.WallPadDataMgr.WallpadScheduleData;
  45. import com.artncore.WallPadDataMgr.WallpadStatusData;
  46. import com.artncore.WallPadDataMgr.WallpadVisitorPicData_A20;
  47. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  48. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
  49. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSetBackup;
  50. import com.artncore.commons.APIErrorCode;
  51. import com.artncore.commons.DataClasses.CarParkingData;
  52. import com.artncore.commons.define;
  53. import com.artncore.deviceinterface.WallPadInterface;
  54. import com.artncore.wallpadapi.IntLightAPI;
  55. import com.artncore.wallpadapi.LightAPI;
  56. import com.artncore.wallpadapi.MultiSwitchAPI;
  57. import com.artncore.wallpadapi.SdbAPI;
  58. import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
  59. import com.artncore.wallpadapi.WallPadAPI;
  60. import com.artncore.wallpadimap.RetProci;
  61. import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
  62. import com.bumptech.glide.Glide;
  63. import com.bumptech.glide.load.engine.DiskCacheStrategy;
  64. import com.util.LogUtil;
  65. import java.io.BufferedReader;
  66. import java.io.BufferedWriter;
  67. import java.io.File;
  68. import java.io.FileInputStream;
  69. import java.io.FileOutputStream;
  70. import java.io.IOException;
  71. import java.io.InputStream;
  72. import java.io.InputStreamReader;
  73. import java.io.OutputStream;
  74. import java.io.OutputStreamWriter;
  75. import java.net.InetAddress;
  76. import java.net.NetworkInterface;
  77. import java.text.SimpleDateFormat;
  78. import java.util.ArrayList;
  79. import java.util.Calendar;
  80. import java.util.Collections;
  81. import java.util.Date;
  82. import java.util.GregorianCalendar;
  83. import java.util.List;
  84. import java.util.regex.Pattern;
  85. import kr.co.icontrols.v40ioctl.V40IOInterface;
  86. import kr.co.icontrols.wallpadmain.declare.Common;
  87. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
  88. import kr.co.icontrols.wallpadmain.declare.DataClasses.IconInfoTable;
  89. import kr.co.icontrols.wallpadmain.declare.ID;
  90. import kr.co.icontrols.wallpadmain.declare.ID_OLD;
  91. import kr.co.icontrols.wallpadmain.declare.LayoutDevice;
  92. import kr.co.icontrols.wallpadmain.imap.iMAPAlarmOperation;
  93. import kr.co.icontrols.wallpadmain.imap.iMAPCarParking;
  94. import kr.co.icontrols.wallpadmain.imap.iMAPCarParking_UPIS;
  95. import kr.co.icontrols.wallpadmain.imap.iMAPElecCarChargingInfo;
  96. import kr.co.icontrols.wallpadmain.imap.iMAPEnergyServer_EnergyMeter;
  97. import kr.co.icontrols.wallpadmain.imap.iMAPEnergyServer_EnergyModule;
  98. import kr.co.icontrols.wallpadmain.imap.iMAPEnergyServer_Realmeter;
  99. import kr.co.icontrols.wallpadmain.imap.iMAPRemotemeter;
  100. import kr.co.icontrols.wallpadmain.menu.CallSubMenuScreen;
  101. import kr.co.icontrols.wallpadmain.screen.EASYUI_MAIN;
  102. import kr.co.icontrols.wallpadmain.screen.HYOSUNGUI_MAIN_HA;
  103. import kr.co.icontrols.wallpadmain.screen.HYOSUNGUI_MAIN_HN;
  104. import kr.co.icontrols.wallpadmain.screen.MAIN;
  105. import kr.co.icontrols.wallpadmain.screen.METROUI_MAIN;
  106. import kr.co.icontrols.wallpadmain.screen.METROUI_SUB_01;
  107. import kr.co.icontrols.wallpadmain.screen.METROUI_SUB_02;
  108. import kr.co.icontrols.wallpadmain.screen.METROUI_SUB_GROUP;
  109. import kr.co.icontrols.wallpadmain.screen.SUB_01;
  110. import kr.co.icontrols.wallpadmain.screen.SUB_02;
  111. import kr.co.icontrols.wallpadmain.util.EnergyAlramPopupMgr;
  112. import kr.co.icontrols.wallpadmain.util.IconManager;
  113. import kr.co.icontrols.wallpadmain.util.MobileProcService;
  114. import kr.co.icontrols.wallpadmain.util.StringUtil;
  115. import kr.co.icontrols.wallpadmain.util.iMapServer;
  116. import kr.co.icontrols.wallpadsupport.Version;
  117. import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
  118. import kr.co.icontrols.wallpadsupport.WpadActivity;
  119. import kr.co.icontrols.wallpadsupport.WpadRelativeLayoutParams;
  120. import kr.co.icontrols.wallpadsupport.WpadScale;
  121. import kr.co.icontrols.wallpadsupport.WpadSound;
  122. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  123. import kr.co.icontrols.wallpadsupport.WpadUtil;
  124. import kr.co.icontrols.wallpadmain.imap.iMAPAlarmOperation.EMER_STATE;
  125. import kr.co.icontrols.wallpadmain.imap.iMAPAlarmOperation.EMER_DETAIL_INFO;
  126. import static android.content.Intent.ACTION_TIME_TICK;
  127. import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
  128. import static com.artncore.commons.define.ALBUM_PICTURE_LOCATION;
  129. import static com.artncore.commons.define.BESTIN_LOCATION;
  130. /**
  131. * @description
  132. * 월패드 [설정기능] 메인화면 이다.<br>
  133. * 상단의 Top 메뉴, [홈] [돌아가기]<br>
  134. * 좌측의 Tab 메뉴, [조명] [난방] [가스] ... 등 선택 메뉴<br>
  135. * 를 여기서 처리한다.
  136. */
  137. public class MainActivity extends WpadActivity {
  138. private final static String TAG = "MainActivity";
  139. private void DebugLogOutput(String s) { if(Common.DEBUG_LOG_ON) Log.d(TAG, s); }
  140. // =================================================================================================
  141. // [[ Declaration ]] region
  142. // =================================================================================================
  143. protected Context mContext = null;
  144. static Context mContext_call = null;
  145. public Context getContext() { return mContext; }
  146. private WallPadAPI mWallPadAPI = null;
  147. public static IOInterface mIOInterface = null;
  148. private int DEVICE_OPERATION_MODE = Common.MODE;
  149. boolean bEasyModeUsage = false;
  150. public static boolean bGoodDesign2020 = false;
  151. // Layout
  152. private RelativeLayout MainLayout; // 메인화면
  153. private RelativeLayout MainScreenLayout;
  154. private RelativeLayout SubLayout_01; // 서브 01 화면
  155. private RelativeLayout SubScreenLayout_01;
  156. private RelativeLayout SubLayout_02; // 서브 02 화면
  157. private RelativeLayout SubScreenLayout_02;
  158. private RelativeLayout EasyMainLayout; // 간편모드 메인화면
  159. private RelativeLayout EasyMainScreenLayout;
  160. private ViewFlipper mViewFlipper;
  161. Animation aniSlideIn, aniSlideOut;
  162. public static ImageView IMG_LCD_KEEPER;
  163. // PopupActivityRun
  164. private static boolean PopupActivityRun = false;
  165. public static boolean getPopupActivityRun() { return PopupActivityRun; }
  166. public static void setPopupActivityRun(boolean run) { PopupActivityRun = run; }
  167. // InfoActivityRun
  168. private static boolean InfoActivityRun = false;
  169. public static boolean getInfoActivityRun() {
  170. Log.d(TAG, "[getInfoActivityRun] InfoActivityRun: " + InfoActivityRun);
  171. return InfoActivityRun;
  172. }
  173. public static void setInfoActivityRun(boolean run) {
  174. InfoActivityRun = run;
  175. if (!InfoActivityRun) resetCurrentInfoScreenID();
  176. }
  177. // Menu & TabData
  178. private Menu mMenu = null;
  179. // private TabData mTabData = null;
  180. // CurrentScreenId
  181. private int mCurrentScreenId = -1;
  182. private int mTempCurrentScreenId = -1;
  183. private static int mCurrentInfoScreenId = -1;
  184. // Screen
  185. private MAIN MainScreen = null;
  186. private SUB_01 SUB_01Screen = null;
  187. private SUB_02 SUB_02Screen = null;
  188. private METROUI_MAIN MetroUI_MainScreen = null;
  189. private METROUI_SUB_01 MetroUI_SUB_01Screen = null;
  190. private METROUI_SUB_02 MetroUI_SUB_02Screen = null;
  191. private METROUI_SUB_GROUP MetroUI_SUB_GroupScreen = null;
  192. private HYOSUNGUI_MAIN_HN Hyosung_HN_MainScreen = null;
  193. private HYOSUNGUI_MAIN_HA Hyosung_HA_MainScreen = null;
  194. private EASYUI_MAIN EasyUI_MainScreen = null;
  195. // 메뉴 리스트 처리 및 서브 스크린 호출
  196. public CallSubMenuScreen m_CallSubMenuScreen = null;
  197. ///////////////////////////// AnC 메인어플에서 사용되는 변수 모음
  198. int LastTimeSync = 0;
  199. boolean HomeCTROn = true;
  200. //int PSTNStatus = 0;
  201. int MAINStatus = 0;
  202. public static final int MAIN_NORMAL = 0;
  203. public static final int MAIN_WAIT_SETIP = 1;
  204. static boolean Alert_App_On = false;
  205. byte bootupretryCNT = 0;
  206. static final int MAX_BOOTUP_RETRY_COUNT = 1200;
  207. ScheduleManager SCManager;
  208. boolean SYSTEM_TIME_SET = false;
  209. static boolean CALLSVCSTARTED = false;
  210. public Thread mThread_getAppsVersion = null;
  211. ///////////////////////////// end
  212. // 거실조명 제어드라이버
  213. private IntLightAPI mIntLightAPI = null;
  214. // 에너지미터 제어드라이버
  215. private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null;
  216. private SdbAPI mSdbAPI = null;
  217. // 멀티스위치 제어 드라이버
  218. private MultiSwitchAPI m_MultiSwitch = null;
  219. // 대외향 거실 스위치 드라이버
  220. private LightAPI m_LightCtrl = null;
  221. private boolean m_ModelHouseSleepModeRelease = false;
  222. //주차정보 관련 변수
  223. public static boolean bUseofNot_ParkingInfo = false;
  224. public static int nParkingSystemType = Common.PARKING_SYSTEM_ICONTROLS;
  225. private String ParkingServerIP = null;
  226. private int ParkingServerPort = 10000;
  227. private int cGetParkingMin = 18;
  228. private boolean bSetMSG_GetParkingInfo = false;
  229. iMAPCarParking iMAPcarParking;
  230. iMAPCarParking_UPIS iMapcarParking_UPIS;
  231. //일정 알림 관련 변수
  232. private int AlarmScheduleCount = 0;
  233. private String AlarmScheduleString = null;
  234. private boolean bAlarmScheduleString = false;
  235. //전기차 충전 관련 변수
  236. iMAPElecCarChargingInfo imapElecCarChargingInfo;
  237. //제로 에너지 하우스 관련 변수
  238. private boolean bUseofNot_ZeroEnergyHouseInfo = false;
  239. private int cGetZeroEnergyHouseMin = 12;
  240. iMAPEnergyServer_Realmeter iMAPenergyServer_Realmeter;
  241. iMAPEnergyServer_EnergyMeter iMAPenergyServer_EnergyMeter;
  242. iMAPEnergyServer_EnergyModule iMAPenergyServer_EnergyModule;
  243. String DayofLastSecond = "2000-01-01 00:00:00";
  244. boolean DayofLastBoolean = false;
  245. //에너지관리서버 관련 변수
  246. private boolean bUseofNot_EnergyServer = false;
  247. //에너지 알람 발생 관련 변수
  248. private boolean bUseofNot_EnergyAlarm = false;
  249. private boolean ResultGetIntent = false;
  250. private String elect_target = "Error";
  251. private String elect_used = "Error";
  252. private String elect_info = "Error";
  253. private String water_target = "Error";
  254. private String water_used = "Error";
  255. private String water_info = "Error";
  256. private String gas_target = "Error";
  257. private String gas_used = "Error";
  258. private String gas_info = "Error";
  259. private String hotwater_target = "Error";
  260. private String hotwater_used = "Error";
  261. private String hotwater_info = "Error";
  262. private String heating_target = "Error";
  263. private String heating_used = "Error";
  264. private String heating_info = "Error";
  265. /**
  266. * 월패드 이벤트 알림 관련 변수
  267. */
  268. // 스마트 우편, 전기차 충전 사용 여부
  269. public static boolean bSmartPostUsage = false, bElecVehicleUsage = false;
  270. // 부재중 전화, 방문객 사진, 공지사항, 택배, 스마트 우편, 전기차 충전 이벤트 개수
  271. public static int nMissedCallCnt = 0, nVisitorPicCnt = 0, nNoticeCnt = 0, nParcelCnt = 0, nPostCnt = 0, nElecVehicleChangingCnt = 0;
  272. // 끝
  273. IconManager mIconManager;
  274. public IconInfoTable mIconInfoTable;
  275. public static int nShortcutCnt = 0;
  276. public static int nShortcutMax = 12;
  277. public static int nShortcutCnt_HS = 0;
  278. public static int nShortcutMax_HS = 9;
  279. public static int nShortcutCnt_Metro = 0;
  280. public static int nShortcutMax_Metro = 3;
  281. int nIconsOnSubScreen = 24;
  282. public static List<WallpadStatusData.WidgetItem> MainScreenShortcutList;
  283. public static List<WallpadStatusData.WidgetItem> HSScreenShortcutList;
  284. public static List<WallpadStatusData.WidgetItem> MetroScreenShortcutList;
  285. // 조명상태를 관리하기 위한 클래스
  286. public static class LightInfo {
  287. public class Preset {
  288. public class Lights {
  289. public String ONOFF = "none";
  290. public int DIM = 0;
  291. public int COLOR = 0;
  292. public Lights() {
  293. ONOFF = "none";
  294. DIM = 0;
  295. COLOR = 0;
  296. }
  297. }
  298. public Lights[] mLights;
  299. public Preset() {
  300. mLights = new Lights[9]; // 0번지는 프리셋별 그룹제어 설정값 (조명 1~8)
  301. for (int i = 0; i < mLights.length; i++) {
  302. mLights[i] = new Lights();
  303. }
  304. }
  305. }
  306. public Preset[] mPreset;
  307. public int nLightPresetNo;
  308. public LightInfo() {
  309. mPreset = new Preset[9]; // 0번지는 전체제어 설정값 (프리셋 1~8)
  310. for (int i = 0; i < mPreset.length; i++) {
  311. mPreset[i] = new Preset();
  312. }
  313. nLightPresetNo = 0;
  314. }
  315. }
  316. public static LightInfo mLightInfo;
  317. public String BR_CTRL_LIGHT_LIVINGROOM = "kr.co.icontrols.wallpadglobalscreen.BR_CTRL_LIGHT_LIVINGROOM";
  318. public static WpadSound mSound;
  319. public void getLivinglightPreset() {
  320. try {
  321. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  322. String[] strEntireValue = mWallpadStatusData.getLivinglightModeCtrlEntireValue();
  323. mWallpadStatusData.closeDB();
  324. Log.i(TAG, "[getLivinglightPreset] strEntireValue.length = " + strEntireValue.length);
  325. for (int i = 0; i < strEntireValue.length; i++) {
  326. Log.i(TAG, "[getLivinglightPreset] strEntireValue[" + i + "] = " + strEntireValue[i]);
  327. }
  328. } catch (RuntimeException re) {
  329. LogUtil.errorLogInfo("", TAG, re);
  330. }
  331. catch (Exception e) {
  332. Log.e(TAG, "[Exception] getLivinglightPreset()");
  333. LogUtil.errorLogInfo("", TAG, e);
  334. }
  335. }
  336. public void initLivinglightPreset() {
  337. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  338. try {
  339. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  340. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  341. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  342. Log.i(TAG, "[initLivinglightPreset] Initialize preset for IHN-D101");
  343. for (int i = 1; i < 5; i++) {
  344. String strPreset = mWallpadStatusData.getLivinglightModeCtrlUnitValues(i, 0);
  345. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  346. String[] strParse = strPreset.split(":");
  347. if (strParse[1].equalsIgnoreCase("0") || strParse[2].equalsIgnoreCase("0")) {
  348. if (i == 1) {
  349. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  350. mLightInfo.mPreset[i].mLights[0].DIM = 7;
  351. mLightInfo.mPreset[i].mLights[0].COLOR = 5;
  352. }
  353. else if (i == 2) {
  354. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  355. mLightInfo.mPreset[i].mLights[0].DIM = 3;
  356. mLightInfo.mPreset[i].mLights[0].COLOR = 2;
  357. }
  358. else if (i == 3) {
  359. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  360. mLightInfo.mPreset[i].mLights[0].DIM = 1;
  361. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  362. }
  363. mWallpadStatusData.setLivinglightModeCtrlUnitValues(i, 0, mLightInfo.mPreset[i].mLights[0].ONOFF, mLightInfo.mPreset[i].mLights[0].DIM, mLightInfo.mPreset[i].mLights[0].COLOR);
  364. }
  365. else {
  366. mLightInfo.mPreset[i].mLights[0].ONOFF = strParse[0];
  367. mLightInfo.mPreset[i].mLights[0].DIM = Integer.parseInt(strParse[1]);
  368. mLightInfo.mPreset[i].mLights[0].COLOR = Integer.parseInt(strParse[2]);
  369. }
  370. }
  371. }
  372. else if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I
  373. || Version.getModelType() == MODEL_TYPE.IHN_1010_I_2443
  374. ) {
  375. Log.i(TAG, "[initLivinglightPreset] Initialize preset for IHN-1010(-I)");
  376. if (getKCCDimmingCtrl()) {
  377. for (int i = 1; i < 5; i++) {
  378. String strPreset = mWallpadStatusData.getLivinglightModeCtrlUnitValues(i, 0);
  379. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  380. String[] strParse = strPreset.split(":");
  381. if (strParse[1].equalsIgnoreCase("0") || strParse[2].equalsIgnoreCase("0")) {
  382. if (i == 1) {
  383. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  384. mLightInfo.mPreset[i].mLights[0].DIM = 10;
  385. mLightInfo.mPreset[i].mLights[0].COLOR = 5;
  386. }
  387. else if (i == 2) {
  388. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  389. mLightInfo.mPreset[i].mLights[0].DIM = 7;
  390. mLightInfo.mPreset[i].mLights[0].COLOR = 2;
  391. }
  392. else if (i == 3) {
  393. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  394. mLightInfo.mPreset[i].mLights[0].DIM = 5;
  395. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  396. }
  397. else if (i == 4) {
  398. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  399. mLightInfo.mPreset[i].mLights[0].DIM = 2;
  400. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  401. }
  402. mWallpadStatusData.setLivinglightModeCtrlUnitValues(i, 0, mLightInfo.mPreset[i].mLights[0].ONOFF, mLightInfo.mPreset[i].mLights[0].DIM, mLightInfo.mPreset[i].mLights[0].COLOR);
  403. }
  404. else {
  405. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  406. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].ONOFF);
  407. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].DIM);
  408. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].COLOR);
  409. }
  410. }
  411. }
  412. }
  413. } catch (RuntimeException re) {
  414. LogUtil.errorLogInfo("", TAG, re);
  415. }
  416. catch (Exception e) {
  417. Log.e(TAG, "[Exception] initLivinglightPreset()");
  418. LogUtil.errorLogInfo("", TAG, e);
  419. }
  420. mWallpadStatusData.closeDB();
  421. }
  422. private boolean getKCCDimmingCtrl() {
  423. try {
  424. Log.i(TAG, "[getKCCDimmingCtrl] ========== START ==========");
  425. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  426. int nEnable = mWallpadDeviceSet.GetDeviceSetted("KCC디밍제어기");
  427. mWallpadDeviceSet.closeDB();
  428. Log.i(TAG, "[getKCCDimmingCtrl] nEnable [" + nEnable + "]");
  429. if (nEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
  430. Log.i(TAG, "[getKCCDimmingCtrl] Enabled");
  431. return true;
  432. }
  433. else {
  434. Log.i(TAG, "[getKCCDimmingCtrl] Disabled");
  435. return false;
  436. }
  437. } catch (RuntimeException re) {
  438. LogUtil.errorLogInfo("", TAG, re);
  439. return false;
  440. }
  441. catch (Exception e) {
  442. Log.e(TAG, "[Exception] setKCCDimmingCtrl()");
  443. LogUtil.errorLogInfo("", TAG, e);
  444. return false;
  445. }
  446. }
  447. private void initEscapeLadderDownSend() {
  448. try {
  449. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getContext());
  450. if(deviceSet!=null)
  451. {
  452. int ladderDownSend = deviceSet.getEscapeLadderDownSend();
  453. boolean ladderDownRecv = deviceSet.GetEscapeLadderDownRecv(); // 기존 '피난사다리입하수신' 설정정보 (더이상 사용하지 않음 2021.01.28)\
  454. Log.d(TAG, "[initEscapeLadderDownSend] ladderDownRecv [" + ladderDownRecv + "]");
  455. if (ladderDownRecv) {
  456. if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_NONE) {
  457. Log.d(TAG, "[initEscapeLadderDownSend] ===== first setting =====");
  458. deviceSet.setEscapeLadderDownSend(WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER); // 신규 /'피난사다리전송' 설정정보 '윗집'
  459. } else {
  460. Log.d(TAG, "[initEscapeLadderDownSend] ladderDownSend [" + ladderDownSend + "]");
  461. }
  462. }
  463. deviceSet.closeDB();
  464. }
  465. } catch (RuntimeException re) {
  466. LogUtil.errorLogInfo("", TAG, re);
  467. } catch (Exception e) {
  468. Log.e(TAG, "[Exception] initEscapeLadderDownSend()");
  469. LogUtil.errorLogInfo("", TAG, e);
  470. }
  471. }
  472. public void CallSubMenuScreen(int screenID) {
  473. if (screenID >= ID.LINKEDSCREEN.SubMenuAddService.Notice && screenID <= ID.LINKEDSCREEN.SubMenuAddService.ElecCar) m_CallSubMenuScreen.callStartAddServiceAPK(screenID);
  474. else if (screenID >= ID.LINKEDSCREEN.SubMenuEnergy.RealTimeCheckMeter && screenID <= ID.LINKEDSCREEN.SubMenuEnergy.IEnergy) m_CallSubMenuScreen.callStartEnergyAPK(screenID);
  475. }
  476. private void restoreSystemVolume() {
  477. try {
  478. String strCurrentTopPackage = getTopActivity();
  479. Log.i(TAG, "[restoreSystemVolume] strCurrentTopPackage = " + strCurrentTopPackage);
  480. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  481. int nSavedVolume = wdb.GetWallPadMasterVolume();
  482. wdb.closeDB();
  483. final AudioManager audioManager = (AudioManager)this.getContext().getSystemService(this.getContext().AUDIO_SERVICE);
  484. int nCurrentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
  485. audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume , 0);
  486. Log.i(TAG, "[restoreSystemVolume] #Before# nCurrentVolume = " + nCurrentVolume + ", #After# nSavedVolume = " + nSavedVolume);
  487. } catch (RuntimeException re) {
  488. LogUtil.errorLogInfo("", TAG, re);
  489. }
  490. catch (Exception e) {
  491. Log.e(TAG, "[Exception] restoreSystemVolume()");
  492. LogUtil.errorLogInfo("", TAG, e);
  493. }
  494. }
  495. // =================================================================================================
  496. // [[ Activity Life Cycle ]] region
  497. // =================================================================================================
  498. /**
  499. * Activity Constructors
  500. */
  501. @Override
  502. protected void onCreate(Bundle savedInstanceState) {
  503. super.onCreate(savedInstanceState);
  504. Log.i(TAG, "[onCreate] ========== START ==========");
  505. Log.w(TAG, "[onCreate] Start to check booting status!!!");
  506. Runtime mRuntime = Runtime.getRuntime();
  507. Process mProcess;
  508. int iDelayCount = 0;
  509. while (true) {
  510. try {
  511. String cmd = "getprop dev.bootcomplete";
  512. mProcess = mRuntime.exec(cmd);
  513. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  514. String line;
  515. String strResult = null;
  516. while ((line = br.readLine()) != null) {
  517. strResult = line;
  518. }
  519. if (strResult!=null && strResult.equals("1")) {
  520. File sdcard = new File("/storage/emulated/0");
  521. if(sdcard.exists() == true) {
  522. iDelayCount = 0;
  523. Thread.sleep(1000);
  524. break;
  525. }
  526. }
  527. {
  528. iDelayCount++;
  529. Thread.sleep(100);
  530. }
  531. if (iDelayCount > 400) {
  532. cmd = "setprop persist.sys.reboot 1";
  533. mProcess = mRuntime.exec(cmd);
  534. }
  535. } catch (RuntimeException re) {
  536. LogUtil.errorLogInfo("", TAG, re);
  537. }
  538. catch (Exception e) {
  539. Log.e(TAG, "[Exception] Checking device booting status -> Unable to execute top command");
  540. e.fillInStackTrace();
  541. LogUtil.errorLogInfo("", TAG, e);
  542. }
  543. }
  544. Log.w(TAG, "[onCreate] Device booting completed!!");
  545. Log.i(TAG, "[onCreate] Wallpad model name [" + Version.getModelType() + "]");
  546. if (Common.DIAGNOSTIC_MODE) {
  547. Log.i(TAG, "------------------ [START - DIAGNOSTIC_MODE] -------------------");
  548. setNetworkAddr( 2, 1, 3);
  549. }
  550. // @ AutoScale 설정 - 1.
  551. if (WpadScale.getWidthPixels() == 800 && WpadScale.getHeightPixels() == 480) {
  552. // 800x480 일 경우에만 AutoScale 을 설정한다.
  553. Log.i(TAG, "[onCreate] Wallpad LCD resolution. -> Width [" + WpadScale.getWidthPixels() + "], Height [" + WpadScale.getHeightPixels() + "] -> setAutoScale ON !!!");
  554. WpadScale.setAutoScale(true);
  555. }
  556. else if (WpadScale.getWidthPixels() == 1366 && WpadScale.getHeightPixels() == 768) {
  557. // 800x480 일 경우에만 AutoScale 을 설정한다.
  558. Log.i(TAG, "[onCreate] Wallpad LCD resolution. -> Width [" + WpadScale.getWidthPixels() + "], Height [" + WpadScale.getHeightPixels() + "] -> setAutoScale ON !!!");
  559. WpadScale.setAutoScale(true);
  560. WpadScale.changeAutoScaleValue(1024, 600);
  561. }
  562. // @ AutoScale 설정 - 2. 에너지관리화면을 위한 구분자 설정
  563. if ((WpadScale.getWidthPixels() == 1024) && (WpadScale.getHeightPixels() == 600)) {
  564. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1024x600;
  565. }
  566. else if ((WpadScale.getWidthPixels() == 1280) && (WpadScale.getHeightPixels() == 800)) {
  567. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1280x800;
  568. }
  569. else if ((WpadScale.getWidthPixels() == 800) && (WpadScale.getHeightPixels() == 480)) {
  570. Common.SCREEN_TYPE = Common.SCREEN_TYPE_800x480;
  571. }
  572. else if ((WpadScale.getWidthPixels() == 1366) && (WpadScale.getHeightPixels() == 768)) {
  573. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1024x600;
  574. }
  575. Log.d(TAG, "[onCreate] SCREEN_TYPE: " + Common.SCREEN_TYPE);
  576. super.setFinishBrEnable(false);
  577. super.AppVersionLogOut(); // [APP Version] + [WallPadSupport Lib Version] 을 로그로 출력한다.
  578. LayoutDevice.InitGetScreenSize(this.getWindowManager(), getApplicationContext() );
  579. try {
  580. // 최초 DB 폴더가 생성되어 있지 않으면 폴더를 생성하도록 한다.
  581. File dbhome = new File(wallpaddbmgr.dblocation);
  582. Log.d(TAG, "[Create] - Step0.3 : dbhome path [" + dbhome.getPath() + "]");
  583. if (dbhome.exists() == false) {
  584. dbhome.mkdir();
  585. Log.d(TAG, "[Create] - Step0.3 : Make DB Folder");
  586. }
  587. else {
  588. Log.d(TAG, "[Create] - Step0.3 : DB exists");
  589. }
  590. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  591. if (mWallpadStatusData != null) {
  592. DebugLogOutput("[Create] - Step0.3 : WallpadStatusData Open OK");
  593. mWallpadStatusData.closeDB();
  594. }
  595. else {
  596. DebugLogOutput("[Create] - Step0.3 : WallpadStatusData Open FAIL");
  597. }
  598. } catch (RuntimeException re) {
  599. LogUtil.errorLogInfo("", TAG, re);
  600. }
  601. catch (Exception e) {
  602. LogUtil.errorLogInfo("", TAG, e);
  603. }
  604. DebugLogOutput("[Create] - Step0.5 : WallpadStatusData end");
  605. Log.i("Version", "<><><><> WallPadAPI Version = [" + define.WALLPADAPI_VERSION + "] " + "<><><><>");
  606. checkISSEnergyType();
  607. runDeviceService();
  608. // 1. 변수 초기화
  609. DebugLogOutput("[Create] - Step1 : EMData Create");
  610. PopupActivityRun = false;
  611. InfoActivityRun = false;
  612. mContext = this;
  613. mContext_call = mContext;
  614. setCallAppRunning(false); // 메인앱 초기화시 통화앱 미실행값을 DB에 저장
  615. // 2. 자동 종료 셋팅
  616. DebugLogOutput("[Create] - Step2 : Auto Finish Setting");
  617. // 3. API 호출
  618. DebugLogOutput("[Create] - Step3 : API Call");
  619. // 3.1. mWallPadAPI 생성
  620. try {
  621. mWallPadAPI = new WallPadAPI(this);
  622. } catch (RuntimeException re) {
  623. LogUtil.errorLogInfo("", TAG, re);
  624. }
  625. catch (Exception e) {
  626. Log.e(TAG, "[ExceptionError] - new WallPadAPI : " + e);
  627. LogUtil.errorLogInfo("", TAG, e);
  628. }
  629. initIOInterface(mWallPadAPI);
  630. Common.CurrentBoardType = mIOInterface.getBoardType(Version.getModelType());
  631. DebugLogOutput("[Create] - Step3.5 : API Call end");
  632. if (Common.GetDeviceSampleMode(this)) {
  633. Log.d(TAG, "[Create] OperationMode = MODE_BUSINESS_SAMPLE");
  634. DEVICE_OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE;
  635. }
  636. else {
  637. Log.d(TAG, "[Create] OperationMode = MODE_NOMAL");
  638. DEVICE_OPERATION_MODE = Common.MODE_NOMAL;
  639. }
  640. // 분전반 정보 가져오기
  641. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  642. Common.CurrentDistributionPanelType = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  643. mWallpadDeviceSet.closeDB();
  644. // 4. Layout registration
  645. DebugLogOutput("[Create] - Step4 : Layout registration");
  646. Common.eGUIType = checkGUIType(this.getContext());
  647. Log.i(TAG, "[Create] eGUIType = " + Common.eGUIType);
  648. mIconManager = new IconManager(mContext, mWallPadAPI);
  649. if (mIconManager == null) {
  650. Log.w(TAG, "[Create] mIconManager is null!!");
  651. }
  652. mIconInfoTable = mIconManager.getAvailableIcons();
  653. if (mIconInfoTable == null) {
  654. Log.w(TAG, "[Create] mIconInfoTable is null!!");
  655. }
  656. else {
  657. Log.i(TAG, "[Create] mIconInfoTable.getCnt() = " + mIconInfoTable.getCnt());
  658. }
  659. WallpadDeviceSet deviceSet = new WallpadDeviceSet(mContext);
  660. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  661. deviceSet.closeDB();
  662. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  663. if (!bSupport) {
  664. mWallpadStatusData.SetEasyModeUxUse(false);
  665. }
  666. bEasyModeUsage = bSupport & mWallpadStatusData.GetEasyModeUxUse();
  667. mWallpadStatusData.closeDB();
  668. // Sound API 등록
  669. mSound = new WpadSound(this);
  670. // 메인화면 레이아웃
  671. MainLayout = new RelativeLayout(this);
  672. RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  673. MainLayout.setLayoutParams(params);
  674. MainLayout.setId(ID_OLD.main.layout.ALL);
  675. super.setAllLayoutRegistration(MainLayout);
  676. // 메인화면 스크린 레이아웃
  677. MainScreenLayout = new RelativeLayout(this);
  678. WpadUtil.LayoutRegistration(MainLayout, MainScreenLayout, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  679. if (getWallPadCameraUsage() && (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT)) {
  680. Log.i(TAG, "[Create] SurfaceLayout Registration!!!");
  681. SurfaceLayout = new RelativeLayout(this);
  682. WpadUtil.LayoutRegistration(MainLayout, SurfaceLayout, WpadScale.getWidthPixels(), WpadScale.getWidthPixels(), 0, 0, ID.MAINACTIVITY.LAYOUT.SURFACE);
  683. }
  684. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) nIconsOnSubScreen = 24;
  685. // else if (eGUIType == GUI_TYPE.METRO) nIconsOnSubScreen = 15;
  686. else nIconsOnSubScreen = 24;
  687. // 서브화면 1 레이아웃
  688. if (mIconInfoTable.getCnt() > 0) {
  689. SubLayout_01 = new RelativeLayout(this);
  690. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  691. SubLayout_01.setLayoutParams(params);
  692. SubLayout_01.setId(ID_OLD.main.layout.ALL);
  693. super.setAllLayoutRegistration(SubLayout_01);
  694. // 서브화면 1 스크린 레이아웃
  695. SubScreenLayout_01 = new RelativeLayout(this);
  696. WpadUtil.LayoutRegistration(SubLayout_01, SubScreenLayout_01, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  697. }
  698. // 서브화면 2 레이아웃
  699. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) {
  700. SubLayout_02 = new RelativeLayout(this);
  701. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  702. SubLayout_02.setLayoutParams(params);
  703. SubLayout_02.setId(ID_OLD.main.layout.ALL);
  704. super.setAllLayoutRegistration(SubLayout_02);
  705. // 서브화면 2 스크린 레이아웃
  706. SubScreenLayout_02 = new RelativeLayout(this);
  707. WpadUtil.LayoutRegistration(SubLayout_02, SubScreenLayout_02, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  708. }
  709. // 간편모드 메인화면 레이아웃
  710. if (bEasyModeUsage) {
  711. EasyMainLayout = new RelativeLayout(this);
  712. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  713. EasyMainLayout.setLayoutParams(params);
  714. EasyMainLayout.setId(ID_OLD.main.layout.ALL);
  715. super.setAllLayoutRegistration(EasyMainLayout);
  716. // 간편모드 메인화면 스크린 레이아웃
  717. EasyMainScreenLayout = new RelativeLayout(this);
  718. WpadUtil.LayoutRegistration(EasyMainLayout, EasyMainScreenLayout, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  719. }
  720. m_ModelHouseSleepModeRelease= Common.GetModelHouseSleepModeRelease(this);
  721. Log.d(TAG, " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% =====> GetModelHouseSleepModeRelease :" + m_ModelHouseSleepModeRelease);
  722. if (m_ModelHouseSleepModeRelease) {
  723. mLCD_SleepHandler.sendEmptyMessageDelayed(0, (30 * 1000));
  724. }
  725. // 5. Top Menu - ImageView registration
  726. DebugLogOutput("[Create] - Step5 : Top Menu - ImageView registration");
  727. // 6. Tab Menu - ImageView registration
  728. restoreSystemVolume();
  729. initProximitySensor();
  730. // 서브 스크린 호출하기 위한 메뉴 리스트 관리 클래스
  731. m_CallSubMenuScreen = new CallSubMenuScreen( this , mWallPadAPI);
  732. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  733. // 메인화면 3가지 등록으로 인해 변경
  734. MainScreen = new MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  735. // EasyUI_MainScreen = new EASYUI_MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  736. }
  737. else if (Common.eGUIType == Common.GUI_TYPE.METRO) {
  738. MetroUI_MainScreen = new METROUI_MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  739. }
  740. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) {
  741. Hyosung_HN_MainScreen = new HYOSUNGUI_MAIN_HN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  742. }
  743. else {
  744. MainScreen = new MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  745. }
  746. DebugLogOutput("[Create] - Step6 : Main Screen registration");
  747. // 7. Draw
  748. DebugLogOutput("[Create] - Step7 : setContentView");
  749. try {
  750. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  751. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) setContentView(R.layout.main);
  752. else setContentView(R.layout.main_2);
  753. }
  754. else if (Common.eGUIType == Common.GUI_TYPE.METRO) setContentView(R.layout.main_metro);
  755. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) setContentView(R.layout.main_hyosung);
  756. else {
  757. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) setContentView(R.layout.main);
  758. else setContentView(R.layout.main_2);
  759. }
  760. if (bEasyModeUsage) setContentView(R.layout.main_easy);
  761. // setContentView(R.layout.main);
  762. // 메인화면 3가지로 슬라이딩 방식으로 구현하기 위하여 뷰플리퍼를 사용하여 처리
  763. mViewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);
  764. if (mViewFlipper != null) {
  765. if (MainLayout != null) mViewFlipper.addView(MainLayout);
  766. if (SubLayout_01 != null) mViewFlipper.addView(SubLayout_01);
  767. if (SubLayout_02 != null && Common.eGUIType == Common.GUI_TYPE.STANDARD) mViewFlipper.addView(SubLayout_02);
  768. if (EasyMainLayout != null && bEasyModeUsage) mViewFlipper.addView(EasyMainLayout);
  769. DebugLogOutput("[Create] - Step8 : Add Flipper !!! ");
  770. }
  771. } catch (RuntimeException re) {
  772. LogUtil.errorLogInfo("", TAG, re);
  773. }
  774. catch (Exception e) {
  775. LogUtil.errorLogInfo("", TAG, e);
  776. }
  777. registerBroadcastReceiver();
  778. Check_Upgrade_File();
  779. //앱 버전정보 DB저장
  780. try {
  781. Log.d(TAG, "mThread_getAppsVersion Start!! ");
  782. if (mThread_getAppsVersion== null) {
  783. mThread_getAppsVersion = new getInstalledPackageInfo();
  784. mThread_getAppsVersion.start();
  785. }
  786. else {
  787. Log.w(TAG, "mThread_getAppsVersion is null!!");
  788. }
  789. Log.d(TAG, "mThread_getAppsVersion End!! ");
  790. } catch (RuntimeException re) {
  791. LogUtil.errorLogInfo("", TAG, re);
  792. }
  793. catch (Exception e) {
  794. LogUtil.errorLogInfo("", TAG, e);
  795. }
  796. try {
  797. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  798. AddressSet addc = SetData.getAddressMGR();
  799. AddressSetBackup addc_Backup = SetData.getAddressMGR_Backup();
  800. overridePendingTransition(0, 0);
  801. if (!isSystemIPSet()) {
  802. Log.w(TAG, "[onCreate] The IP Address of OS is not set!");
  803. startManagerSettingSetAddress();
  804. }
  805. else if (addc.Dong.equals("NONE") || addc.Ho.equals("NONE")) {
  806. Log.w(TAG, "[onCreate] The info. of resi. is not set! [primary db]");
  807. if (addc_Backup.Dong.equals("NONE") || addc_Backup.Ho.equals("NONE")) {
  808. Log.w(TAG, "[onCreate] The info. of resi. is not set! [secondary db]");
  809. startManagerSettingSetAddress();
  810. }
  811. else {
  812. addc.setAddress(addc_Backup.Dong, addc_Backup.Ho);
  813. addc.setIPAddress(addc_Backup.IPAddress);
  814. m_IPActivity = true;
  815. if (addc.IPAddress!=null && !addc.IPAddress.equals("NONE")) {
  816. Log.w(TAG, "[onCreate] ========== start iMapServer service ========== [secondary db]");
  817. Intent intent = new Intent(getApplicationContext(), iMapServer.class);
  818. startService(intent);
  819. Intent intentMobile = new Intent(getApplicationContext(), MobileProcService.class);
  820. Log.w(TAG, "[onCreate] ========== start MobileProcServicee ========== [secondary db]");
  821. startService(intentMobile);
  822. }
  823. MAINStatus = MAIN_NORMAL;
  824. }
  825. }
  826. else {
  827. m_IPActivity = true;
  828. if (!addc.IPAddress.equals("NONE")) {
  829. Log.w(TAG, "[onCreate] ========== start iMapServer service ========== [primary db]");
  830. Intent intent = new Intent(this, iMapServer.class);
  831. startService(intent);
  832. Intent intentMobile = new Intent(getApplicationContext(), MobileProcService.class);
  833. Log.w(TAG, "[onCreate] ========== start MobileProcServicee ========== [secondary db]");
  834. startService(intentMobile);
  835. }
  836. MAINStatus = MAIN_NORMAL;
  837. }
  838. SetData.closeDB();
  839. } catch (RuntimeException re) {
  840. LogUtil.errorLogInfo("", TAG, re);
  841. }
  842. catch (Exception e) {
  843. Log.e(TAG, "[Exception] check device addresses(ip, resi. info.)");
  844. LogUtil.errorLogInfo("", TAG, e);
  845. }
  846. //주차정보 사용여부 체크
  847. getParkedVehicleLocationSysInfo();
  848. //전기차 정보 가져오기
  849. GetElectricCarInfo();
  850. //에너지관리서버 사용여부 가져오기
  851. GetEnergyServerInfo();
  852. //에너지 알람 사용여부 가져오기
  853. GetEnergyAlarm();
  854. //통화타임아웃 초기화
  855. setCallAppTimeoutAsDefault();
  856. //카카오홈 사용 여부 체크(카카오홈)
  857. boolean isUseKakao = getKakaoHomeCheck();
  858. if(isUseKakao)
  859. {
  860. Handler mHandler = new Handler();
  861. mHandler.postDelayed(mLaunchTaskKakao, 500);
  862. mHandler = null;
  863. }
  864. try {
  865. mWallPadApiCheckHandler.sendEmptyMessage(0);
  866. // Checker.sendEmptyMessageDelayed(0, 1000);
  867. } catch (RuntimeException re) {
  868. LogUtil.errorLogInfo("", TAG, re);
  869. }
  870. catch (Exception e) {
  871. LogUtil.errorLogInfo("", TAG, e);
  872. }
  873. // sip 서비스 실행 옮김
  874. Log.d(TAG, "[onCreate] startCallService start");
  875. try {
  876. runCallServices startCallService = new runCallServices();
  877. startCallService.start();
  878. } catch (RuntimeException re) {
  879. LogUtil.errorLogInfo("", TAG, re);
  880. }
  881. catch (Exception e) {
  882. LogUtil.errorLogInfo("", TAG, e);
  883. }
  884. Log.d(TAG, "[onCreate] startCallService end");
  885. try {
  886. // 부팅하고 나서 업그레이드 상태를 false 로 해주지 않으면 통화 수신이 안됨
  887. // 꼭 들어가야 함
  888. // 전체 정전시험시 단지서버도 재부팅은 하나 로긴을 하지 않으면 그시간동안 세대기가 보낸 부트업 메세지를 못 받기 때문에....단말기 시간을 재 셋팅해주도록 한다.
  889. Calendar cal = new GregorianCalendar();
  890. 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));
  891. WallpadStatusData wpd = new WallpadStatusData(getApplicationContext());
  892. wpd.SetUpgradeState(false);
  893. wpd.SetLastHeartbeat(timedata);
  894. wpd.closeDB();
  895. } catch (RuntimeException re) {
  896. LogUtil.errorLogInfo("", TAG, re);
  897. }
  898. catch (Exception e) {
  899. LogUtil.errorLogInfo("", TAG, e);
  900. }
  901. try {
  902. Calendar m_CurCalendar = Calendar.getInstance();
  903. //CurYear , CurMonth, CurDate, CurHour, CurMin, CurSecond;
  904. int CurYear = m_CurCalendar.get(Calendar.YEAR);
  905. if (CurYear < 2018) {
  906. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  907. DBMGR.setSystemTime(2018, 8, 1, 13, 0, 0);
  908. DBMGR.closeDB();
  909. }
  910. } catch (RuntimeException re) {
  911. LogUtil.errorLogInfo("", TAG, re);
  912. }
  913. catch (Exception e) {
  914. LogUtil.errorLogInfo("", TAG, e);
  915. }
  916. mLightInfo = new LightInfo();
  917. getLivinglightPreset();
  918. initLivinglightPreset();
  919. getLivinglightPreset();
  920. initEscapeLadderDownSend();
  921. setPageIndicator();
  922. mGetCallHistoryCheckHandler.sendEmptyMessageDelayed(0, 10000);
  923. try {
  924. int getSleepTime = Settings.System.getInt(this.getContext().getContentResolver(), SCREEN_OFF_TIMEOUT);
  925. int mSleepModeTime = (getSleepTime / 1000);
  926. Log.d(TAG, "[Create] mSleepModeTime [" + mSleepModeTime + "]");
  927. if (mSleepModeTime <= 30) {
  928. Log.d(TAG, "[Create] Reset mSleepModeTime ===== [" + mSleepModeTime + "] =====");
  929. Settings.System.putInt(this.getContext().getContentResolver(), SCREEN_OFF_TIMEOUT, 28 * 1000); // 백라이트 off와 앱 종료가 동시에 일어나면 월패드가 비정상 종료되므로 수정 (2021.04.06 메이드인랩 김수진 선임 요청)
  930. }
  931. } catch (Settings.SettingNotFoundException e) {
  932. e.printStackTrace();
  933. }
  934. try {
  935. handlerEverySecond.sendEmptyMessageDelayed(0, 1000);
  936. // BSP 수정으로 인하여 해당 코드 삭제 (2021.02.24, SEULKI)
  937. // // 월패드 카메라 녹색 노이즈 시험 코드 (월패드 부팅시 월패드 카메라 영상을 잠시 띄운후 없앤다. JEFF/2020.01.21.01)
  938. // /**
  939. // * 부팅시 카메라 서비스 정상동작 여부를 확인한다. (Edited by jeff, 2020.09.08)
  940. // */
  941. // sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_CHECK, 0, 0, 0); // 5초후 월패드 카메라를 초기화 한다. (그냥 화면밖에 영상을 잠시 띄우고 5초뒤에 없앤다.)
  942. } catch (RuntimeException re) {
  943. LogUtil.errorLogInfo("", TAG, re);
  944. }
  945. catch (Exception e) {
  946. LogUtil.errorLogInfo("", TAG, e);
  947. }
  948. if (bKakaoiEnable) {
  949. Log.i(TAG, "[onCreate] ========== Kakao function enabled ==========");
  950. startKakaoiFloatingBTN();
  951. }
  952. // forceCtrlStrangerRecordingUserSettingDisable(false);
  953. getLCDKeeperUsage();
  954. Log.i(TAG, "[onCreate] ==================== onCreate end ====================");
  955. }
  956. /**
  957. * 카카오 실행 관련 핸들러
  958. */
  959. private Runnable mLaunchTaskKakao = new Runnable() {
  960. public void run() {
  961. String Packagename = "com.kakao.i.test.real.wallpad";
  962. //Handler를 이용하여 Timer 사용
  963. Intent mainIntent = mContext.getPackageManager().getLaunchIntentForPackage(Packagename);
  964. if (mainIntent != null) {
  965. boolean isShowKakao = getShowKakaoCheck();
  966. if(isShowKakao)
  967. mainIntent.putExtra("ShowKakao", true);
  968. mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  969. startActivity(mainIntent);
  970. };
  971. }
  972. };
  973. private int nLCDKeeperType = WallpadDeviceSet.LCDKEEPER_NONE;
  974. private String getLCDKeeperType(int nLCDKeeperType) {
  975. try {
  976. Log.i(TAG, "[getLCDKeeperUsage] nLCDKeeperType [" + nLCDKeeperType + "]");
  977. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_NONE) return "LCDKEEPER_NONE";
  978. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT) return "LCDKEEPER_PROTECT";
  979. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER) return "LCDKEEPER_RECOVER";
  980. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) return "LCDKEEPER_PROTECT_RECOVER";
  981. else return "UNKNOWN";
  982. } catch (RuntimeException re) {
  983. LogUtil.errorLogInfo("", TAG, re);
  984. return "ERROR";
  985. }
  986. catch (Exception e) {
  987. Log.e(TAG, "[Exception] getLCDKeeperType(int nLCDKeeperType)");
  988. LogUtil.errorLogInfo("", TAG, e);
  989. return "ERROR";
  990. }
  991. }
  992. private boolean bLCDKeeperUsage = false;
  993. private void getLCDKeeperUsage() {
  994. try {
  995. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  996. nLCDKeeperType = mWallpadDeviceSet.getLCDKeeperUsage();
  997. mWallpadDeviceSet.closeDB();
  998. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT || nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER || nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) {
  999. bLCDKeeperUsage = true;
  1000. }
  1001. Log.i(TAG, "[getLCDKeeperUsage] bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  1002. } catch (RuntimeException re) {
  1003. LogUtil.errorLogInfo("", TAG, re);
  1004. }
  1005. catch (Exception e) {
  1006. Log.e(TAG, "[Exception] getLCDKeeperUsage()");
  1007. LogUtil.errorLogInfo("", TAG, e);
  1008. }
  1009. }
  1010. public boolean isSystemIPSet() {
  1011. try {
  1012. Log.i(TAG, "[isSystemIPSet] START!");
  1013. String strResult = "";
  1014. if (Build.VERSION.SDK_INT > 23) {
  1015. // Android 7
  1016. strResult = getIPAddress();
  1017. }
  1018. else {
  1019. // Android 6
  1020. if(NetworkInterface.getByName("eth0")!=null)
  1021. {
  1022. String strNetInfo = NetworkInterface.getByName("eth0").toString();
  1023. Log.i(TAG, "[isSystemIPSet] strNetInfo : " + strNetInfo + "]");
  1024. strNetInfo.trim();
  1025. String[] Parse_01 = strNetInfo.split("\\]");
  1026. // for (int i = 0; i < Parse_01.length; i++) {
  1027. // LOG_DEBUG("[getDeviceIPAddress] Parse_01[" + i + "] : " + Parse_01[i]);
  1028. // }
  1029. String[] Parse_02 = Parse_01[Parse_01.length - 1].split("\\/");
  1030. // for (int i = 0; i < Parse_02.length; i++) {
  1031. // LOG_DEBUG("[getDeviceIPAddress] Parse_02[" + i + "] : " + Parse_02[i]);
  1032. // }
  1033. strResult = Parse_02[1];
  1034. }
  1035. }
  1036. Log.i(TAG, "[isSystemIPSet] DONE! [IP Address : " + strResult + "]");
  1037. 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])$");
  1038. return mPattern.matcher(strResult).matches();
  1039. } catch (RuntimeException re) {
  1040. LogUtil.errorLogInfo("", TAG, re);
  1041. return false;
  1042. }
  1043. catch (Exception e) {
  1044. Log.e(TAG, "[Exception] isSystemIPSet()");
  1045. LogUtil.errorLogInfo("", TAG, e);
  1046. return false;
  1047. }
  1048. }
  1049. public static String getIPAddress() {
  1050. try {
  1051. List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
  1052. for (NetworkInterface intf : interfaces) {
  1053. List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
  1054. for (InetAddress addr : addrs) {
  1055. if (!addr.isLoopbackAddress()) {
  1056. String sAddr = addr.getHostAddress();
  1057. //boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
  1058. boolean isIPv4 = sAddr.indexOf(':')<0;
  1059. if (isIPv4)
  1060. return sAddr;
  1061. }
  1062. }
  1063. }
  1064. } catch (RuntimeException re) {
  1065. LogUtil.errorLogInfo("", TAG, re);
  1066. }
  1067. catch (Exception e) {
  1068. Log.e(TAG, "[Exception] isSystemIPSet()");
  1069. LogUtil.errorLogInfo("", TAG, e);
  1070. }
  1071. return "";
  1072. }
  1073. public void initIOInterface(WallPadAPI wallpadapi) {
  1074. try {
  1075. mIOInterface = new IOInterface(getContext(), wallpadapi);
  1076. } catch (RuntimeException re) {
  1077. LogUtil.errorLogInfo("", TAG, re);
  1078. }
  1079. catch (Exception e) {
  1080. Log.e(TAG, "[Exception] initIOInterface(WallPadAPI wallpadapi)");
  1081. LogUtil.errorLogInfo("", TAG, e);
  1082. }
  1083. }
  1084. public void checkDongHoSetting() {
  1085. try {
  1086. Log.d(TAG, "[checkDongHoSetting] ========== START ==========");
  1087. boolean IP_ExpansionSettingFlag = false;
  1088. EthernetDevInfo info = new EthernetDevInfo();
  1089. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  1090. AddressSet addc = mWallpadStatusData.getAddressMGR();
  1091. mWallpadStatusData.SetCallAPKStatus(false);
  1092. mWallpadStatusData.closeDB();
  1093. if (addc.Dong!=null && !addc.Dong.equals("NONE") && addc.Ho!=null&& !addc.Ho.equals("NONE") && addc.IPAddress!=null&& !addc.IPAddress.equals("NONE")) {
  1094. if (Version.getModelType() == MODEL_TYPE.IHN_1020GL && Version.getModelType() == MODEL_TYPE.IHN_1020B_A
  1095. && Version.getModelType() == MODEL_TYPE.IHN_1020SA_A && Version.getModelType() == MODEL_TYPE.IHN_750) {
  1096. // LH 게이트웨이 때문에 위치 옮김 제어 서비스 보다 먼저 처리
  1097. if(addc.IPAddress!=null)
  1098. {
  1099. String[] iptbl = addc.IPAddress.split("[.]");
  1100. Log.d(TAG, "[checkDongHoSetting] Mac Set -> IP : " + addc.IPAddress +", Length : " + iptbl.length);
  1101. // BSP에서 초기 이더넷 비활성화시 jni 맥 셋팅시 메인어플 다이~~
  1102. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1103. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1104. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_DISABLED!!!");
  1105. if (IP_ExpansionSettingFlag == true) {
  1106. mEthManager.UpdateEthDevInfo(info);
  1107. }
  1108. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1109. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_ENABLING!!!");
  1110. if (iptbl.length == 4) {
  1111. 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]));
  1112. Log.d(TAG, "[checkDongHoSetting] Mac Set "+macadd);
  1113. try {
  1114. WallPadInterface wpdifc = new WallPadInterface();
  1115. wpdifc.setMacAddr(macadd);
  1116. } catch (RuntimeException re) {
  1117. LogUtil.errorLogInfo("", TAG, re);
  1118. }
  1119. catch (Exception ex) {
  1120. //ex.printStackTrace();
  1121. LogUtil.errorLogInfo("", TAG, ex);
  1122. }
  1123. Log.d(TAG, "[checkDongHoSetting] -----------------------------------MacSet");
  1124. }
  1125. else {
  1126. Log.d(TAG,"[checkDongHoSetting] -----------------------------------Mac iptbl.length fail !!");
  1127. }
  1128. //EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1129. //mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1130. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1131. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_ENABLING!!!");
  1132. }
  1133. }
  1134. }
  1135. } catch (RuntimeException re) {
  1136. LogUtil.errorLogInfo("", TAG, re);
  1137. }
  1138. catch (Exception e) {
  1139. Log.e(TAG, "[Exception] checkDongHoSetting()");
  1140. LogUtil.errorLogInfo("", TAG, e);
  1141. }
  1142. }
  1143. public void registerSubScreen() {
  1144. try {
  1145. if (Common.eGUIType == Common.GUI_TYPE.METRO) {
  1146. if (MetroUI_SUB_GroupScreen == null && SubScreenLayout_01 != null ) MetroUI_SUB_GroupScreen = new METROUI_SUB_GROUP(getContext() , SubScreenLayout_01, mWallPadAPI);
  1147. }
  1148. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) {
  1149. if (MetroUI_SUB_GroupScreen == null && SubScreenLayout_01 != null ) MetroUI_SUB_GroupScreen = new METROUI_SUB_GROUP(getContext() , SubScreenLayout_01, mWallPadAPI);
  1150. }
  1151. else {
  1152. if (mIconInfoTable.getCnt() > 0) {
  1153. if (SUB_01Screen == null && SubScreenLayout_01 != null ) SUB_01Screen = new SUB_01(getContext() , SubScreenLayout_01, mWallPadAPI);
  1154. }
  1155. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) {
  1156. if (SUB_02Screen == null && SubScreenLayout_02 != null ) SUB_02Screen = new SUB_02(getContext() , SubScreenLayout_02, mWallPadAPI);
  1157. }
  1158. if (bEasyModeUsage) {
  1159. if (EasyUI_MainScreen == null && EasyMainScreenLayout != null ) EasyUI_MainScreen = new EASYUI_MAIN(getContext() , EasyMainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  1160. }
  1161. }
  1162. // restoreSystemVolume();
  1163. SCManager = new ScheduleManager();
  1164. } catch (RuntimeException re) {
  1165. LogUtil.errorLogInfo("", TAG, re);
  1166. }
  1167. catch (Exception e) {
  1168. Log.w(TAG, "[registerSubScreen] registerSubScreen()");
  1169. LogUtil.errorLogInfo("", TAG, e);
  1170. }
  1171. }
  1172. public void moveNextPage() {
  1173. try {
  1174. Log.d(TAG, "[moveNextPage] ===== START =====");
  1175. aniSlideIn = AnimationUtils.loadAnimation(getContext(), R.layout.appear_from_right);
  1176. aniSlideOut = AnimationUtils.loadAnimation(getContext(), R.layout.disappear_to_left);
  1177. mViewFlipper.setInAnimation(aniSlideIn);
  1178. mViewFlipper.setOutAnimation(aniSlideOut);
  1179. mViewFlipper.showNext();
  1180. } catch (RuntimeException re) {
  1181. LogUtil.errorLogInfo("", TAG, re);
  1182. }
  1183. catch (Exception e) {
  1184. Log.e(TAG, "[Exception] moveNextPage()");
  1185. LogUtil.errorLogInfo("", TAG, e);
  1186. }
  1187. }
  1188. public void movePreviousPage() {
  1189. try {
  1190. Log.d(TAG, "[movePreviousPage] ===== START =====");
  1191. aniSlideIn = AnimationUtils.loadAnimation(getContext(), R.layout.appear_from_left);
  1192. aniSlideOut = AnimationUtils.loadAnimation(getContext(), R.layout.disappear_to_right);
  1193. mViewFlipper.setInAnimation(aniSlideIn);
  1194. mViewFlipper.setOutAnimation(aniSlideOut);
  1195. mViewFlipper.showPrevious();
  1196. } catch (RuntimeException re) {
  1197. LogUtil.errorLogInfo("", TAG, re);
  1198. }
  1199. catch (Exception e) {
  1200. Log.e(TAG, "[Exception] moveNextPage()");
  1201. LogUtil.errorLogInfo("", TAG, e);
  1202. }
  1203. }
  1204. boolean bScreenCheck = false;
  1205. int nSubScreenTimeout = 20, SCREENTIMEOUT = 20;
  1206. public void checkMainPage() {
  1207. try {
  1208. if (!bScreenCheck) {
  1209. nSubScreenTimeout = SCREENTIMEOUT;
  1210. return;
  1211. }
  1212. int nViewFlipperIndex = mViewFlipper.getDisplayedChild();
  1213. if (nViewFlipperIndex != 0) {
  1214. if (nSubScreenTimeout > 0) {
  1215. nSubScreenTimeout--;
  1216. }
  1217. else {
  1218. nSubScreenTimeout = SCREENTIMEOUT;
  1219. mViewFlipper.setDisplayedChild(0);
  1220. }
  1221. Log.i(TAG, "[checkMainPage] nViewFlipperIndex [" + nViewFlipperIndex + "], nSubScreenTimeout [" + nSubScreenTimeout + "]");
  1222. }
  1223. else {
  1224. if (nSubScreenTimeout <= 0) {
  1225. nSubScreenTimeout = SCREENTIMEOUT;
  1226. Log.i(TAG, "[checkMainPage] nViewFlipperIndex [" + nViewFlipperIndex + "], nSubScreenTimeout [" + nSubScreenTimeout + "]");
  1227. }
  1228. }
  1229. } catch (RuntimeException re) {
  1230. LogUtil.errorLogInfo("", TAG, re);
  1231. }
  1232. catch (Exception e) {
  1233. Log.e(TAG, "[Exception] checkMainPage()");
  1234. LogUtil.errorLogInfo("", TAG, e);
  1235. }
  1236. }
  1237. String strWallPadMainPakageName = "kr.co.icontrols.wallpadmain";
  1238. private boolean isPackageTop(String strPackageName) {
  1239. try {
  1240. ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  1241. Log.i(TAG, "[isPackageTop] Build.VERSION.SDK_INT [" + Build.VERSION.SDK_INT + "]");
  1242. if (Build.VERSION.SDK_INT > 23) {
  1243. // Android 7
  1244. List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses();
  1245. for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) {
  1246. if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
  1247. for (String activeProcess : processInfo.pkgList) {
  1248. if (activeProcess.equals(strPackageName)) {
  1249. Log.i(TAG, "[isPackageTop] The top package is [" + strPackageName + "]");
  1250. return true;
  1251. }
  1252. }
  1253. }
  1254. }
  1255. }
  1256. else {
  1257. // Android 6
  1258. List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  1259. ComponentName componentInfo = taskInfo.get(0).topActivity;
  1260. if (componentInfo.getPackageName().equals(strPackageName)) {
  1261. Log.i(TAG, "[isPackageTop] The top package is [" + strPackageName + "]");
  1262. return true;
  1263. }
  1264. }
  1265. } catch (RuntimeException re) {
  1266. LogUtil.errorLogInfo("", TAG, re);
  1267. }
  1268. catch (Exception e) {
  1269. Log.e(TAG, "[Exception] isPackageTop(String strPackageName)");
  1270. LogUtil.errorLogInfo("", TAG, e);
  1271. }
  1272. return false;
  1273. }
  1274. // 부팅시에는 최초 DB에서 값을 읽어와서 변경하도록 한다.
  1275. private boolean m_SetBookMarkMainScreen = false;
  1276. private int m_CheckBookMarkReturnCount = 0 ;
  1277. private final int BOOKMARK_SCREEN_RETURN_CHECK_TIME = 30;
  1278. private boolean m_thisAcitivityRusume = false;
  1279. // 즐겨찾기 메인화면을 항상 고정해서 쓸것인지 설정하는 함수
  1280. public void SetBookMarkMainScreen(boolean Set)
  1281. {
  1282. m_SetBookMarkMainScreen = Set;
  1283. try
  1284. {
  1285. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  1286. if( wdb != null )
  1287. {
  1288. if( Set == true )
  1289. {
  1290. wdb.SetSelectedMainScreen( WallpadStatusData.MAIN_BOOKMARK_SCREEN);
  1291. }
  1292. else
  1293. {
  1294. wdb.SetSelectedMainScreen( WallpadStatusData.MAIN_DEFAULT_SCREEN);
  1295. }
  1296. wdb.closeDB();
  1297. }
  1298. }
  1299. catch (RuntimeException re) {
  1300. LogUtil.errorLogInfo("", TAG, re);
  1301. }
  1302. catch (Exception e )
  1303. {
  1304. LogUtil.errorLogInfo("", TAG, e);
  1305. }
  1306. }
  1307. public boolean CheckCurrentEnergyScreen()
  1308. {
  1309. int currentView = mViewFlipper.getDisplayedChild();
  1310. Log.d(TAG, "-------> currentView : " + currentView);
  1311. if( currentView == 1)
  1312. return true;
  1313. else
  1314. return false;
  1315. }
  1316. private int nTouchDownPosX = 0;
  1317. private int nTouchUpPosX = 0;
  1318. @Override
  1319. public boolean dispatchTouchEvent(MotionEvent ev) {
  1320. boolean bReturn = false;
  1321. //Log.d("Move" , "dispatchTouchEvent-----------1");
  1322. try {
  1323. if (ev.getAction() == MotionEvent.ACTION_DOWN) {
  1324. nTouchDownPosX = (int)ev.getX();
  1325. }
  1326. else if (ev.getAction() == MotionEvent.ACTION_UP) {
  1327. nTouchUpPosX = (int)ev.getX();
  1328. Log.d(TAG, "[dispatchTouchEvent] nTouchDownPosX [" + nTouchDownPosX + "], nTouchUpPosX [" + nTouchUpPosX + "]");
  1329. if (nTouchUpPosX < nTouchDownPosX - 50) {
  1330. moveNextPage();
  1331. setPageIndicator();
  1332. }
  1333. else if (nTouchUpPosX > nTouchDownPosX + 50) {
  1334. movePreviousPage();
  1335. setPageIndicator();
  1336. }
  1337. nTouchDownPosX = nTouchUpPosX;
  1338. }
  1339. } catch (RuntimeException re) {
  1340. LogUtil.errorLogInfo("", TAG, re);
  1341. }
  1342. catch (Exception e) {
  1343. Log.e(TAG, "[Exception] dispatchTouchEvent(MotionEvent ev)");
  1344. LogUtil.errorLogInfo("", TAG, e);
  1345. }
  1346. bReturn = super.dispatchTouchEvent(ev);
  1347. return bReturn;
  1348. }
  1349. private void setPageIndicator() {
  1350. try {
  1351. int nViewFlipperIndex = mViewFlipper.getDisplayedChild();
  1352. int nChildCnt = mViewFlipper.getChildCount();
  1353. Log.d(TAG, "[setPageIndicator] nViewFlipperIndex [" + nViewFlipperIndex + "], nChildCnt [" + nChildCnt + "]");
  1354. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  1355. Log.d(TAG, "[setPageIndicator] eGUIType == GUI_TYPE.STANDARD");
  1356. ImageView[] IMG_INDICATOR;
  1357. 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) };
  1358. else IMG_INDICATOR = new ImageView[] { (ImageView) findViewById(R.id.pageindex_main), (ImageView) findViewById(R.id.pageindex_sub1), (ImageView) findViewById(R.id.pageindex_sub2) };
  1359. for (int i = 0; i < nChildCnt; i++) {
  1360. if (i == nViewFlipperIndex) {
  1361. if (i == 0) IMG_INDICATOR[i].setSelected(true);
  1362. else IMG_INDICATOR[i].setSelected(true);
  1363. }
  1364. else {
  1365. if (i == 0) IMG_INDICATOR[i].setSelected(false);
  1366. else IMG_INDICATOR[i].setSelected(false);
  1367. }
  1368. }
  1369. }
  1370. // else if (eGUIType == GUI_TYPE.METRO) {
  1371. // ImageView[] IMG_INDICATOR = { (ImageView) findViewById(R.id.pageindex_sub1), (ImageView) findViewById(R.id.pageindex_sub2) };
  1372. // if (nViewFlipperIndex == 0) {
  1373. // for (int i = 0; i < nChildCnt; i++) {
  1374. // if (i != 0) IMG_INDICATOR[i - 1].setVisibility(View.INVISIBLE);
  1375. // }
  1376. // }
  1377. // else {
  1378. // for (int i = 0; i < nChildCnt; i++) {
  1379. // if (i != 0) {
  1380. // IMG_INDICATOR[i - 1].setVisibility(View.VISIBLE);
  1381. // if (i == nViewFlipperIndex) IMG_INDICATOR[i - 1].setSelected(true);
  1382. // else IMG_INDICATOR[i - 1].setSelected(false);
  1383. // }
  1384. // }
  1385. // }
  1386. // }
  1387. } catch (RuntimeException re) {
  1388. LogUtil.errorLogInfo("", TAG, re);
  1389. }
  1390. catch (Exception e) {
  1391. Log.e(TAG, "[Exception] setPageIndicator()");
  1392. LogUtil.errorLogInfo("", TAG, e);
  1393. }
  1394. }
  1395. /**
  1396. * (임시코드) WallPadAPI 초기생성시 Connect 에 시간이 걸리며, <br>
  1397. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  1398. * 본 딜레이 코드를 임시로 적용한다.
  1399. */
  1400. @SuppressLint("HandlerLeak")
  1401. protected Handler mWallPadApiCheckHandler = new Handler()
  1402. {
  1403. @SuppressLint("HandlerLeak")
  1404. @Override
  1405. public void handleMessage(Message msg)
  1406. {
  1407. if (msg.what == 0) {
  1408. if (mWallPadAPI != null) {
  1409. if (mWallPadAPI.Check_Connect()) mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10);
  1410. else mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  1411. }
  1412. }
  1413. else if (msg.what == 1) {
  1414. // 현산향
  1415. AutoIGALStatusReleaseSinario();
  1416. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1417. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1418. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1419. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  1420. mSdbAPI = mWallPadAPI.Get_SdbController();
  1421. if (mSdb_LivingRoomLightAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_Sdb_LivingRoomLightAPI Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1422. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_Sdb_LivingRoomLightAPI Success !");
  1423. if (mSdbAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_SdbController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1424. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_SdbController Success !");
  1425. // ChangeLEDButtonLevel();
  1426. }
  1427. else if (Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1428. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410) {
  1429. mIntLightAPI = mWallPadAPI.Get_IntLightController();
  1430. if (mIntLightAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_IntLightController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1431. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_IntLightController Success !");
  1432. // ChangeLEDButtonLevel();
  1433. }
  1434. else {
  1435. // 대외향
  1436. WallpadDeviceSet devDB = new WallpadDeviceSet( getApplicationContext() );
  1437. int[] retArray = devDB.Get_Light_info();
  1438. devDB.closeDB();
  1439. if (retArray!= null && retArray[0] == 1) {
  1440. if (retArray[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  1441. // 거실 스위치
  1442. m_LightCtrl = mWallPadAPI.Get_LightController();
  1443. if (m_LightCtrl == null) Log.d(TAG , "Get_LightController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1444. else Log.d(TAG , "Get_LightController Success !");
  1445. }
  1446. else {
  1447. // 멀티스위치
  1448. m_MultiSwitch = mWallPadAPI.Get_MultiSwitchController();
  1449. if (m_MultiSwitch == null) Log.d(TAG , "Get_MultiSwitchController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1450. else Log.d(TAG , "Get_MultiSwitchController Success !");
  1451. }
  1452. }
  1453. }
  1454. }
  1455. else if (msg.what == 10) {
  1456. // 부트업 실패시 5초 간격으로 보내도록 수정
  1457. Log.d(TAG , "NOTIFY_SENDBOOTUP_FAIL Retry!!!!");
  1458. Intent Newintent = new Intent();
  1459. Newintent.setAction(define.NOTIFY_ACNAME);
  1460. Newintent.putExtra(define.NOTIBR_KIND,Common.DEVICE_BOOTUP_RETRY);
  1461. sendBroadcast(Newintent);
  1462. }
  1463. }
  1464. };
  1465. private void ChangeLEDButtonLevel()
  1466. {
  1467. if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL )
  1468. {
  1469. try
  1470. {
  1471. String filename = "/sdcard/led_button_reset.txt";
  1472. File savefile = new File(filename);
  1473. Log.d(TAG, "8888888888888888888888 savefile : " + savefile.exists());
  1474. if(savefile.exists())
  1475. {
  1476. Log.d(TAG, "try file is exist... ");
  1477. if( mIntLightAPI != null)
  1478. {
  1479. int ret = mIntLightAPI.LedBrightCtrl((byte)0x01);
  1480. if( ret >= 0 )
  1481. {
  1482. WallpadStatusData wd = new WallpadStatusData( getApplicationContext());
  1483. wd.SetLEDButtonBrightnessLevel(1); // DB 저장이 실패하게 되면 초기값을 2로 셋팅하기 때문에 다시 한번 셋팅해준다.
  1484. int level = wd.GetLEDButtonBrightnessLevel();
  1485. wd.closeDB();
  1486. Log.d(TAG, "88888888 button brightness Level 1 == " + level);
  1487. WallpadStatusData wd1 = new WallpadStatusData( getApplicationContext());
  1488. wd1.SetLEDButtonBrightnessLevel(1);
  1489. level = wd1.GetLEDButtonBrightnessLevel();
  1490. wd1.closeDB();
  1491. FileDelete(savefile);//.delete();
  1492. // 생산 기술팀 요청사항
  1493. // LED 버튼 보디 교체로 레벨이 너무 밝아 디폴트값 변경을 요청함 ,,
  1494. Log.d(TAG, "8888888888888888888888 button brightness Level 1 == " + level);
  1495. }
  1496. }
  1497. }
  1498. }
  1499. catch (RuntimeException re) {
  1500. LogUtil.errorLogInfo("", TAG, re);
  1501. }
  1502. catch (Exception e )
  1503. {
  1504. LogUtil.errorLogInfo("", TAG, e);
  1505. }
  1506. }
  1507. }
  1508. private void AutoIGALStatusReleaseSinario()
  1509. {
  1510. // 에너지미터 설정에 따라 조명 상태 변경시 일괄소등 해제 처리 시나리오를 설정하도록 한다.
  1511. // 일괄소등 해제 시나리오 적용시...
  1512. try
  1513. {
  1514. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  1515. int setIparkEnergy = devset.Get_Energy_Devices_Info();
  1516. Log.d(TAG , "Get_IPark_Energy_Info bSet: setIparkEnergy : " + setIparkEnergy);
  1517. if( setIparkEnergy == 1 )
  1518. {
  1519. mWallPadAPI.SetAutoIGALStatusClear(true);
  1520. Log.d(TAG , "AutoIGALStatusReleaseSinario bSet: true");
  1521. }
  1522. devset.closeDB();
  1523. }
  1524. catch (RuntimeException re) {
  1525. LogUtil.errorLogInfo("", TAG, re);
  1526. }
  1527. catch (Exception e )
  1528. {
  1529. Log.e(TAG, e.toString());
  1530. LogUtil.errorLogInfo("", TAG, e);
  1531. }
  1532. }
  1533. /**
  1534. * onDestroy
  1535. */
  1536. @Override
  1537. protected void onDestroy() {
  1538. // 이걸 왜 넣었지?
  1539. setChangeScreen(mCurrentScreenId, true, false);
  1540. unregisterBroadcastReceiver();
  1541. super.setFinishTimerDestroy();
  1542. Log.i(TAG, "*************************************************************");
  1543. Log.i(TAG, "****************** [END - MainActivity] *******************");
  1544. Log.i(TAG, "*************************************************************");
  1545. super.onDestroy();
  1546. }
  1547. /**
  1548. * onResume
  1549. */
  1550. @Override
  1551. protected void onResume() {
  1552. super.onResume();
  1553. m_thisAcitivityRusume = true;
  1554. if (mWallPadAPI != null) {
  1555. if (mWallPadAPI.Check_Connect()) Log.w(TAG, "[onResume] mWallPadAPI.Check_Connect() = true!!!");
  1556. else Log.w(TAG, "[onResume] mWallPadAPI.Check_Connect() = false!!!");
  1557. mWallPadAPI.Resume();
  1558. }
  1559. //CallDataChecker();
  1560. try {
  1561. if (m_ModelHouseSleepModeRelease) {
  1562. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  1563. // pm.userActivity(1, true);
  1564. // pm.userActivity(2, true);1qn
  1565. // LCD 항상 ON
  1566. ((Activity)this.getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  1567. }
  1568. } catch (RuntimeException re) {
  1569. LogUtil.errorLogInfo("", TAG, re);
  1570. }
  1571. catch (Exception e) {
  1572. LogUtil.errorLogInfo("", TAG, e);
  1573. }
  1574. if (MAINStatus == MAIN_WAIT_SETIP) {
  1575. try {
  1576. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  1577. AddressSet addc = SetData.getAddressMGR();
  1578. SetData.closeDB();
  1579. Log.i("MAINSCREEN", "onResume MAIN_WAIT_SETIP "+addc.IPAddress);
  1580. if (addc.IPAddress!=null && !addc.IPAddress.equals("NONE")) {
  1581. Log.i("MAINSCREEN", "onResume Start Server");
  1582. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1583. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1584. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1585. Intent intent = new Intent(getApplicationContext(), iMapServer.class);
  1586. Log.w("MAINSCREEN", "Call Start iMapServer");
  1587. startService(intent);
  1588. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1589. String[] sitecode = devSet.GetSettingData("site_code");
  1590. try {
  1591. if (sitecode != null) {
  1592. Intent sipServiceLauncher = new Intent ("cm.sip.hns.SIPStun.StartService");
  1593. getApplicationContext().startService(sipServiceLauncher);
  1594. }
  1595. } catch (RuntimeException re) {
  1596. LogUtil.errorLogInfo("", TAG, re);
  1597. }
  1598. catch (Exception e) {
  1599. Common.DebugLog("SIP StartServerice Error!!!!!!!!!!!!!!");
  1600. }
  1601. devSet.closeDB();
  1602. MAINStatus = MAIN_NORMAL;
  1603. }
  1604. } catch (RuntimeException re) {
  1605. LogUtil.errorLogInfo("", TAG, re);
  1606. }
  1607. catch (Exception e ) {
  1608. LogUtil.errorLogInfo("", TAG, e);
  1609. }
  1610. }
  1611. //CheckMainScreen();
  1612. //refreshUserCtr();
  1613. //reloadData();
  1614. try {
  1615. WallPadInterface wpdifc = new WallPadInterface();
  1616. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1617. amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  1618. wpdifc.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1619. Intent intent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1620. getContext().sendBroadcast(intent);
  1621. mGetCallHistoryCheckHandler.sendEmptyMessageDelayed(0, 1000);
  1622. } catch (RuntimeException re) {
  1623. LogUtil.errorLogInfo("", TAG, re);
  1624. }
  1625. catch (Exception e) {
  1626. LogUtil.errorLogInfo("", TAG, e);
  1627. }
  1628. bScreenCheck = true;
  1629. DebugLogOutput("@@@@@@@@ [onResume] @@@@@@@@");
  1630. }
  1631. protected String getForegroundAPK() {
  1632. try {
  1633. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  1634. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  1635. ComponentName topActivity=taskInfo.get(0).topActivity;
  1636. String str=topActivity.getPackageName();
  1637. return str;
  1638. } catch (RuntimeException re) {
  1639. LogUtil.errorLogInfo("", TAG, re);
  1640. return " ";
  1641. }
  1642. catch (Exception e) {
  1643. LogUtil.errorLogInfo("", TAG, e);
  1644. return " ";
  1645. }
  1646. }
  1647. /**
  1648. * onPause
  1649. */
  1650. @Override
  1651. protected void onPause() {
  1652. m_thisAcitivityRusume = false;
  1653. if(mWallPadAPI != null) mWallPadAPI.Pause();
  1654. bScreenCheck = false;
  1655. DebugLogOutput("@@@@@@@@ [onPause] @@@@@@@@");
  1656. super.onPause();
  1657. }
  1658. /* ================================================================================================
  1659. * [BroadcastReceiver] Section
  1660. ================================================================================================ */
  1661. /**
  1662. * BroadcastReceiver.onReceive for [WpadActivity]
  1663. */
  1664. @Override
  1665. protected void onBrReceive(Intent intent) {
  1666. try {
  1667. String strAction = intent.getAction();
  1668. Log.i(TAG, "[onBrReceive] Action [" + strAction + "]");
  1669. if (strAction.equals(BR_CTRL_LIGHT_LIVINGROOM)) {
  1670. Log.d(TAG, "[onBrReceive] (BR) BR_CTRL_LIGHT_LIVINGROOM");
  1671. mLightInfo.nLightPresetNo = 0;
  1672. }
  1673. } catch (RuntimeException re) {
  1674. LogUtil.errorLogInfo("", TAG, re);
  1675. }
  1676. catch (Exception e) {
  1677. Log.e(TAG, "[Exception] onBrReceive(Intent intent)");
  1678. LogUtil.errorLogInfo("", TAG, e);
  1679. }
  1680. super.onBrReceive(intent);
  1681. }
  1682. /* ================================================================================================
  1683. * [Touch & Key Event] Section
  1684. ================================================================================================ */
  1685. /**
  1686. * TouchEvent for [WpadActivity]
  1687. */
  1688. @Override
  1689. protected void onTouchEvent(View v, MotionEvent event) {
  1690. super.onTouchEvent(v, event);
  1691. int TargetId = v.getId();
  1692. int MoveEvent = event.getAction();
  1693. Log.i(TAG, "[onTouchEvent] TargetId [" + TargetId + "], MoveEvent [" + MoveEvent + "]");
  1694. if (MoveEvent == MotionEvent.ACTION_UP) {
  1695. }
  1696. }
  1697. /**
  1698. * H/W Key Event
  1699. */
  1700. @Override
  1701. public boolean onKeyDown(int keyCode, KeyEvent event) {
  1702. Log.i(TAG, "[onKeyDown] keyCode : " + keyCode + ", Action : " + event.getAction());
  1703. // sendKeyEventBR(keyCode);
  1704. return super.onKeyDown(keyCode, event);
  1705. }
  1706. @Override
  1707. public boolean onKeyUp(int keyCode, KeyEvent event) {
  1708. // TODO Auto-generated method stub
  1709. Log.i(TAG, "[onKeyUp] keyCode : " + keyCode + ", Action : " + event.getAction());
  1710. return super.onKeyUp(keyCode, event);
  1711. }
  1712. @Override
  1713. public boolean onKeyLongPress(int keyCode, KeyEvent event) {
  1714. // TODO Auto-generated method stub
  1715. DebugLogOutput("onKeyLongPress - " + " / keyCode : " + keyCode + " / Action : " + event.getAction());
  1716. return super.onKeyLongPress(keyCode, event);
  1717. }
  1718. /* ================================================================================================
  1719. * [Popup Activity] Section
  1720. ================================================================================================ */
  1721. /**
  1722. * Popup Activity 를 시작시킨다.
  1723. *
  1724. * @param ScreenId - 팝업시작시 Screen ID_OLD
  1725. * @return (boolean) true : 성공, false : 실패
  1726. */
  1727. public boolean StartPopup(int ScreenId){
  1728. try {
  1729. if (ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED <= ScreenId && ScreenId <= ID.POPUPS.POPUP_POSTRECEIVED) { // 알림 팝업에 한하여
  1730. if (Common.bWallPadCallLive) {
  1731. Log.w(TAG, "[StartPopup] StartPopup denied!!! === WallPadCall is running!! ScreenId [" + ScreenId + "]");
  1732. return false; // 통화 앱이 실행되어 있는 경우, 팝업 출력 안함
  1733. }
  1734. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  1735. int AlarmStatus = WsDB.GetAlarmStatus();
  1736. WsDB.closeDB();
  1737. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1738. Log.w(TAG, "[StartPopup] StartPopup denied!!! === AlarmStatus [" + AlarmStatus + "]");
  1739. return false; // 방범모드 실행중인 경우, 팝업 출력 안함
  1740. }
  1741. }
  1742. if (getPopupActivityRun()) {
  1743. if (ScreenId == ID.POPUPS.POPUP_NOTICESTRANGER) return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId);
  1744. else return false;
  1745. }
  1746. else {
  1747. setPopupActivityRun(true);
  1748. Intent intent = new Intent(mContext, PopupActivity.class);
  1749. intent.putExtra("ScreenId", ScreenId);
  1750. overridePendingTransition(0, 0);
  1751. startActivityForResult(intent, 0);
  1752. return true;
  1753. }
  1754. } catch (RuntimeException re) {
  1755. LogUtil.errorLogInfo("", TAG, re);
  1756. return false;
  1757. }
  1758. catch (Exception e) {
  1759. Log.e(TAG, "[Exception] StartPopup(int ScreenId)");
  1760. LogUtil.errorLogInfo("", TAG, e);
  1761. return false;
  1762. }
  1763. }
  1764. /**
  1765. * Popup Activity 를 시작시킨다. (시작시 Intent Type 데이터를 전달한다)
  1766. *
  1767. * @param ScreenId - 팝업시작시 Screen ID_OLD
  1768. * @param data - 전달할 데이터
  1769. * @return (boolean) true : 성공, false : 실패
  1770. */
  1771. public boolean StartPopup(int ScreenId, Intent data) {
  1772. try {
  1773. if (ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED <= ScreenId && ScreenId <= ID.POPUPS.POPUP_POSTRECEIVED) { // 알림 팝업에 한하여
  1774. if (Common.bWallPadCallLive) {
  1775. Log.w(TAG, "[StartPopup] StartPopup denied!!! === WallPadCall is running!! ScreenId [" + ScreenId + "]");
  1776. return false; // 통화 앱이 실행되어 있는 경우, 팝업 출력 안함
  1777. }
  1778. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  1779. int AlarmStatus = WsDB.GetAlarmStatus();
  1780. WsDB.closeDB();
  1781. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1782. Log.w(TAG, "[StartPopup] StartPopup denied!!! === AlarmStatus [" + AlarmStatus + "]");
  1783. return false; // 방범모드 실행중인 경우, 팝업 출력 안함
  1784. }
  1785. }
  1786. if (getPopupActivityRun()) {
  1787. if (ScreenId == ID.POPUPS.POPUP_NOTICESTRANGER) return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId);
  1788. else return false;
  1789. }
  1790. else {
  1791. setPopupActivityRun(true);
  1792. Intent intent = new Intent(mContext, PopupActivity.class);
  1793. intent.putExtra("ScreenId", ScreenId);
  1794. intent.putExtra("PopupScreenDataIntent", data);
  1795. overridePendingTransition(0, 0);
  1796. startActivityForResult(intent, 0);
  1797. return true;
  1798. }
  1799. } catch (RuntimeException re) {
  1800. LogUtil.errorLogInfo("", TAG, re);
  1801. return false;
  1802. }
  1803. catch (Exception e) {
  1804. Log.e(TAG, "[Exception] StartPopup(int ScreenId, Intent data)");
  1805. LogUtil.errorLogInfo("", TAG, e);
  1806. return false;
  1807. }
  1808. }
  1809. /**
  1810. * Activity Result Reception
  1811. */
  1812. @Override
  1813. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  1814. super.onActivityResult(requestCode, resultCode, data);
  1815. try {
  1816. Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@");
  1817. // int screenId = data.getIntExtra("SCREENS", -1);
  1818. // Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@ screenId : " + screenId );
  1819. //if( mViewFlipper)
  1820. if (requestCode == UNINSTALL_REQUEST_CODE) {
  1821. if (resultCode == RESULT_OK) {
  1822. Log.w(TAG, "[onActivityResult] user accepted the uninstall");
  1823. } else if (resultCode == RESULT_CANCELED) {
  1824. Log.w(TAG, "[onActivityResult] user canceled the uninstall");
  1825. } else if (resultCode == RESULT_FIRST_USER) {
  1826. Log.w(TAG, "[onActivityResult] failed to uninstall");
  1827. }
  1828. }
  1829. else {
  1830. if (data != null) {
  1831. int nSenderScreenID = data.getIntExtra(Common.BR_SENDER_SCREEN, -1);
  1832. int nReceiveScreenID = data.getIntExtra(Common.BR_RECEIVE_SCREEN, -1);
  1833. int nCallSubMenuScreen = data.getIntExtra(Common.CALL_SUBMAIN_SCREEN, -1);
  1834. if (nCallSubMenuScreen > 0) {
  1835. CallSubMenuScreen(nCallSubMenuScreen);
  1836. }
  1837. else {
  1838. Log.d(TAG, "[onActivityResult] nSenderScreenID : " + nSenderScreenID + " , nReceiveScreenID : " + nReceiveScreenID );
  1839. if (nSenderScreenID == ID.POPUPS.POPUP_DELETESHORTCUT) {
  1840. if (nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  1841. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  1842. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  1843. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  1844. MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  1845. return;
  1846. }
  1847. else if (nReceiveScreenID == ID.SCREENS.SCREEN_HYOSUNGUI_MAIN_HN) {
  1848. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  1849. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  1850. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  1851. Hyosung_HN_MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  1852. return;
  1853. }
  1854. else if (nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_MAIN) {
  1855. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  1856. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  1857. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  1858. MetroUI_MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  1859. return;
  1860. }
  1861. }
  1862. else if (nSenderScreenID == ID.POPUPS.POPUP_ADDSHORTCUT) {
  1863. if (nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  1864. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  1865. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  1866. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  1867. MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  1868. return;
  1869. }
  1870. else if (nReceiveScreenID == ID.SCREENS.SCREEN_HYOSUNGUI_MAIN_HN) {
  1871. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  1872. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  1873. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  1874. Hyosung_HN_MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  1875. return;
  1876. }
  1877. else if (nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_MAIN) {
  1878. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  1879. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  1880. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  1881. MetroUI_MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  1882. return;
  1883. }
  1884. }
  1885. else if (nSenderScreenID == ID.POPUPS.POPUP_CONFIGUREPRESET && nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  1886. String strLivinglightPresetInfo = data.getStringExtra(Common.BR_LIVINGLIGHT_PRESET_INFO);
  1887. Log.d(TAG, "[onActivityResult] strLivinglightPresetInfo [" + strLivinglightPresetInfo + "]");
  1888. savePresetValue(strLivinglightPresetInfo);
  1889. return;
  1890. }
  1891. else if ((ID.POPUPS.POPUP_GROUP_CTRL <= nSenderScreenID && nSenderScreenID <= ID.POPUPS.POPUP_GROUP_SETTING) && nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_GROUP) {
  1892. boolean bRun = data.getBooleanExtra(Common.BR_RUN_WIDGET, false);
  1893. int nIconID = data.getIntExtra(Common.BR_RUN_WIDGET_ID, 0);
  1894. Log.d(TAG, "[onPopupResult] bRun [" + bRun + "], nIconID [" + nIconID + "]") ;
  1895. if (bRun) runIcon(nIconID);
  1896. }
  1897. }
  1898. }
  1899. if (resultCode == RESULT_OK) {
  1900. // // 팝업을 종료하고 다른 팝업을 띄울경우가 있다.
  1901. // int screenIdCode = data.getExtras().getInt("CHANGE_POPUP" );
  1902. // int popupKind = data.getExtras().getInt("POPUP_KIND");
  1903. //
  1904. // Log.d(TAG, "@@@ CHANGE_POPUP : " + screenIdCode + " , popupKind : " +popupKind);
  1905. // if( screenIdCode > 0 )
  1906. // {
  1907. // setPopupActivityRun(false);
  1908. // Intent intent = new Intent();
  1909. // intent.putExtra("POPUP_KIND", popupKind );
  1910. // StartPopup(screenIdCode , intent);
  1911. // }
  1912. }
  1913. }
  1914. }
  1915. catch (RuntimeException re) {
  1916. LogUtil.errorLogInfo("", TAG, re);
  1917. }
  1918. catch (Exception e )
  1919. {
  1920. Log.e(TAG, e.toString());
  1921. LogUtil.errorLogInfo("", TAG, e);
  1922. }
  1923. }
  1924. /* ================================================================================================
  1925. * [Info Activity] Section
  1926. ================================================================================================ */
  1927. public static ManualActivity mManualActivity;
  1928. /**
  1929. * Info Activity를 시작시킨다.
  1930. *
  1931. * @param screenId - 매뉴얼 시작시 Screen ID_OLD
  1932. * @return (boolean) true : 성공, false : 실패
  1933. */
  1934. public boolean startManualPopup(int screenId) {
  1935. Log.d(TAG, "[startManualPopup] ScreenId [" + screenId +"], mCurrentInfoScreenId [" + mCurrentInfoScreenId + "]" );
  1936. if (getInfoActivityRun() == true) {
  1937. mCurrentInfoScreenId = screenId;
  1938. return ((WpadActivity)(ManualActivity.getContext())).ChangeScreen(screenId);
  1939. } else {
  1940. if (mCurrentInfoScreenId == screenId) return false;
  1941. mCurrentInfoScreenId = screenId;
  1942. setInfoActivityRun(true);
  1943. Intent intent = new Intent(mContext, ManualActivity.class);
  1944. intent.putExtra("ScreenId", screenId);
  1945. overridePendingTransition(0, 0);
  1946. startActivityForResult(intent, 0);
  1947. return true;
  1948. }
  1949. }
  1950. public static void resetCurrentInfoScreenID() {
  1951. try {
  1952. mCurrentInfoScreenId = -1;
  1953. } catch (RuntimeException re) {
  1954. LogUtil.errorLogInfo("", TAG, re);
  1955. }
  1956. catch (Exception e) {
  1957. Log.e(TAG, "[Exception] resetCurrentInfoScreenID()");
  1958. LogUtil.errorLogInfo("", TAG, e);
  1959. }
  1960. }
  1961. /**
  1962. * 매뉴얼 버튼 사용 유무
  1963. *
  1964. * @return boolean 타입 - true:사용, false:미사용
  1965. */
  1966. public boolean GetManualUse() {
  1967. WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
  1968. String[] DBinfo = devSet.GetSettingData("매뉴얼");
  1969. devSet.closeDB();
  1970. if (DBinfo != null) {
  1971. if (DBinfo[1].indexOf("사용함") > 0) {
  1972. Log.d(TAG, "[GetManualUse] Use Manual");
  1973. return true;
  1974. }
  1975. else {
  1976. // 미사용
  1977. Log.d(TAG, "[GetManualUse] Not Use Manual");
  1978. return false;
  1979. }
  1980. }
  1981. else {
  1982. //미사용
  1983. return false;
  1984. }
  1985. }
  1986. /* ================================================================================================
  1987. * [Screen] Section
  1988. ================================================================================================ */
  1989. /**
  1990. * Screen 에서 Screen 변경을 요청할 경우 호출된다.<br>
  1991. * Override 사용하여 Screen 변경을 처리한다.<br>
  1992. *
  1993. * @param nScreenId - 변경할 Screen ID_OLD
  1994. * @return (boolean) true : 성공, false : 실패
  1995. */
  1996. @Override
  1997. protected boolean onChangeScreen(int nScreenId) {
  1998. super.onChangeScreen(nScreenId);
  1999. return setChangeScreen(nScreenId, false, false);
  2000. }
  2001. /**
  2002. * Screen 등록자<br>
  2003. * MainScreenLayout 에 현재 Screen 을 삭제하고, 새로운 Screen 을 등록시킨다.
  2004. *
  2005. * @param nScreenId - 변경할 Screen ID_OLD
  2006. * @param OnlyRemove - 현재 Screen 을 삭제만 할 경우 (onDestroy 에서 사용)
  2007. * @return (boolean) true : 성공, false : 실패
  2008. */
  2009. private boolean setChangeScreen(int nScreenId, boolean OnlyRemove, boolean setAnimation) {
  2010. DebugLogOutput("setChangeScreen - " + "CurrentSelectDeviceId : " + mCurrentScreenId + " / NextLayoutId : " + nScreenId + " / OnlyRemove : " + OnlyRemove);
  2011. // 1. 현재 Layout 삭제
  2012. boolean remove = false;
  2013. if (mCurrentScreenId > 0) {
  2014. remove = true;
  2015. MainScreenLayout.removeAllViews();
  2016. super.setCurrentScreen(null);
  2017. }
  2018. if (OnlyRemove) return true;
  2019. mCurrentScreenId = nScreenId;
  2020. // 2. 새로운 Layout 표시
  2021. try {
  2022. switch (nScreenId) {
  2023. case ID.SCREENS.SCREEN_MAIN:
  2024. MainScreen = new MAIN(getContext(), MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  2025. super.setCurrentScreen(MainScreen);
  2026. break;
  2027. case ID.SCREENS.SCREEN_SUB_01:
  2028. SUB_01Screen = new SUB_01(getContext(), MainScreenLayout, mWallPadAPI);
  2029. super.setCurrentScreen(SUB_01Screen);
  2030. break;
  2031. case ID.SCREENS.SCREEN_SUB_02:
  2032. SUB_02Screen = new SUB_02(getContext(), MainScreenLayout, mWallPadAPI);
  2033. super.setCurrentScreen(SUB_02Screen);
  2034. break;
  2035. case ID.SCREENS.SCREEN_METROUI_MAIN:
  2036. MetroUI_MainScreen = new METROUI_MAIN(getContext(), MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  2037. super.setCurrentScreen(MetroUI_MainScreen);
  2038. break;
  2039. case ID.SCREENS.SCREEN_METROUI_SUB_01:
  2040. MetroUI_SUB_01Screen = new METROUI_SUB_01(getContext(), MainScreenLayout, mWallPadAPI);
  2041. super.setCurrentScreen(MetroUI_SUB_01Screen);
  2042. break;
  2043. case ID.SCREENS.SCREEN_METROUI_SUB_02:
  2044. MetroUI_SUB_02Screen = new METROUI_SUB_02(getContext(), MainScreenLayout, mWallPadAPI);
  2045. super.setCurrentScreen(MetroUI_SUB_02Screen);
  2046. break;
  2047. default:
  2048. Log.e(TAG, "[Error] setChangeScreen - nScreenId Not found!!! (" + mCurrentScreenId + ")");
  2049. mCurrentScreenId = -1;
  2050. return false;
  2051. }
  2052. } catch (RuntimeException re) {
  2053. LogUtil.errorLogInfo("", TAG, re);
  2054. return false;
  2055. }
  2056. catch (Exception e) {
  2057. Log.e(TAG, "[ExceptionError] - setChangeScreen->Screen Create : " + e);
  2058. return false;
  2059. }
  2060. return true;
  2061. }
  2062. /////////////////////////////////////////////////////////////////////////////////
  2063. private void runDeviceService() {
  2064. try {
  2065. Log.i(TAG, "[runDeviceService] ===== START =====");
  2066. /* 2018.01.30 속초 아이파크 RF현관카메라 연동으로 인하여 수정
  2067. // 우선 제어기기 연동 기능이 없음
  2068. if( Version.getModelType() == Version.MODEL_TYPE.IHN_750 )
  2069. return;
  2070. */
  2071. if (!getIsSubWallpad()) {
  2072. ActivityManager mActivityManager = (ActivityManager)getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  2073. List<ActivityManager.RunningAppProcessInfo> RunningAppList = mActivityManager.getRunningAppProcesses();
  2074. Common.DebugLog("[runDeviceService] -----> RunningAppProcessInfo : " + RunningAppList.size() + " +++ Version : " + this.getAppVersion());
  2075. for (int i = 0; i < RunningAppList.size(); i++) {
  2076. ActivityManager.RunningAppProcessInfo RunningAppListInfo = RunningAppList.get(i);
  2077. Common.DebugLog("[runDeviceService] -----> RunningAppListInfo.processName : " + RunningAppListInfo.processName);
  2078. if (RunningAppListInfo.processName.equals("com.artncore.deviceservice")) {
  2079. Log.w(TAG, "[runDeviceService] DevService is already running");
  2080. return;
  2081. }
  2082. }
  2083. Log.i(TAG, "[runDeviceService] Start DevService!!");
  2084. Intent mIntent = new Intent("wallpaddevservice.ServiceMain");
  2085. startService(mIntent);
  2086. }
  2087. else {
  2088. //여기서 직접 연동이 있는지 확인이 필요
  2089. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  2090. int[] naSubWallPadLight = mWallpadDeviceSet.GetSubWpdDirect_Light();
  2091. mWallpadDeviceSet.closeDB();
  2092. if(naSubWallPadLight!=null && naSubWallPadLight.length == 2 && naSubWallPadLight[1] == WallpadDeviceSet.SUBWPD_CTR_DIRECT)
  2093. {
  2094. ActivityManager mActivityManager = (ActivityManager)getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  2095. List<ActivityManager.RunningAppProcessInfo> RunningAppList = mActivityManager.getRunningAppProcesses();
  2096. Common.DebugLog("[runDeviceService] -----> RunningAppProcessInfo : " + RunningAppList.size() + " +++ Version : " + this.getAppVersion());
  2097. for (int i = 0; i < RunningAppList.size(); i++) {
  2098. ActivityManager.RunningAppProcessInfo RunningAppListInfo = RunningAppList.get(i);
  2099. Common.DebugLog("[runDeviceService] -----> RunningAppListInfo.processName : " + RunningAppListInfo.processName);
  2100. if (RunningAppListInfo.processName.equals("com.artncore.deviceservice")) {
  2101. Log.w(TAG, "[runDeviceService] DevService is already running");
  2102. return;
  2103. }
  2104. }
  2105. Log.i(TAG, "[runDeviceService] Start DevService!!");
  2106. Intent mIntent = new Intent("wallpaddevservice.ServiceMain");
  2107. startService(mIntent);
  2108. }
  2109. else {
  2110. Log.w(TAG, "[runDeviceService] This wallpad is sub-wallpad. not need DevService!!!");
  2111. }
  2112. }
  2113. } catch (RuntimeException re) {
  2114. LogUtil.errorLogInfo("", TAG, re);
  2115. }
  2116. catch (Exception e) {
  2117. Log.e(TAG, "[Exception] runDeviceService()");
  2118. LogUtil.errorLogInfo("", TAG, e);
  2119. }
  2120. }
  2121. // 통신으로 들어오는 비상버튼 스킵하기 위한 딜레이 체크 변수
  2122. private long EmerCommDelayTime = 0;
  2123. public static String WALLPAD_ALERT = "WALLPAD_ALERT";
  2124. BroadcastReceiver mWallPadAlertBR = new BroadcastReceiver() {
  2125. @Override
  2126. public void onReceive(Context context, Intent intent) {
  2127. Log.i(TAG, "[mWallPadAlertBR] Receive alert BR");
  2128. String strAction = intent.getAction();
  2129. Log.d(TAG, "[mWallPadAlertBR] strAction [" + strAction + "]");
  2130. if (strAction.equalsIgnoreCase(WALLPAD_ALERT)) {
  2131. int kind = intent.getIntExtra("KIND",0);
  2132. Log.i(TAG, "[mWallPadAlertBR] " + String.format("Receive alert BR [%d][tag:%s]", kind,String.valueOf(Alert_App_On)));
  2133. // 제주 아이파크 스위트현장의 비상발생 증상을 디버깅하기 위한 코드 (JEFF, 2019.09.26)
  2134. // if (kind == 4) {
  2135. // try {
  2136. // byte hFrom = intent.getByteExtra("FROM", (byte) 0xFF);
  2137. // if (hFrom != (byte) 0xFF) {
  2138. // if (hFrom % 10 == 3) {
  2139. // Log.w(TAG, "[mWallPadAlertBR] Emergency from BathPhone!!!");
  2140. // int nDstPort = 10000;
  2141. // sendAlarmOperationToMainServer("10.0.1.1", nDstPort, EMER_STATE.FIRE, EMER_DETAIL_INFO.EMERGENCY_COMM);
  2142. // return;
  2143. // }
  2144. // }
  2145. // } catch (RuntimeException re) {
  2146. // LogUtil.errorLogInfo("", TAG, re);
  2147. // }
  2148. // catch (Exception e) {
  2149. // Log.e(TAG, "[Exception] mWallPadAlertBR - 1");
  2150. // e.printStackTrace();
  2151. // }
  2152. // }
  2153. if (kind == 30) Alert_App_On = true;
  2154. else if (kind == 40) Alert_App_On = false;
  2155. else {
  2156. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2157. int alarmState = wdb.GetAlarmStatus();
  2158. wdb.closeDB();
  2159. if (alarmState == WallpadStatusData.ALARM_ARISE || alarmState == WallpadStatusData.ALARM_STOP) {
  2160. // 알람화면이 현재 실행중이면 스킵
  2161. Log.d(TAG, "Skip BR ==> Current Alarm state : "+ alarmState );
  2162. return;
  2163. }
  2164. if (kind == 4 && ( Math.abs(System.currentTimeMillis()-EmerCommDelayTime) < 1000)) {
  2165. // 통신 비상알람의 경우 중복으로 날라오는 경우가 있어서 필터링
  2166. Log.d(TAG, "Skip BR ==> deleayTime :" + String.valueOf( Math.abs(System.currentTimeMillis()-EmerCommDelayTime)));
  2167. return;
  2168. }
  2169. EmerCommDelayTime = System.currentTimeMillis();
  2170. SendAppFinishReqBR();
  2171. Log.i(TAG, "[mWallPadAlertBR] before Call Alert App");
  2172. int base = 7000;
  2173. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41, base+51};
  2174. int Menu_Start_Id = base+21;
  2175. int Menu_Start_Option = 1;
  2176. String Cause = "none";
  2177. if (kind == 1) Cause = "gas";
  2178. else if (kind == 2) Cause = "fire";
  2179. else if (kind == 4) Cause = "emergency_Comm";
  2180. else if (kind == 5) {
  2181. Cause = "heating_Leak";
  2182. Menu_Start_Id = base + 51;
  2183. }
  2184. else {
  2185. Cause = "unknown(" + kind + ")";
  2186. }
  2187. Intent newintent = new Intent(Intent.ACTION_MAIN);
  2188. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2189. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  2190. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2191. newintent.putExtra("MENU_DETAIL_INFO", Cause);
  2192. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2193. newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  2194. startActivity(newintent);
  2195. }
  2196. }
  2197. }
  2198. };
  2199. private void sendAlarmOperationToMainServer(String DstIP, int DstPort, EMER_STATE alarm_mode, EMER_DETAIL_INFO cause) {
  2200. Log.d(TAG, "[sendAlarmOperationToMainServer] DstIP [" + DstIP + "], DstPort [" + DstPort + "], alarm_mode [" + EMER_STATE.GetXMLData(alarm_mode) + "], cause [" + EMER_DETAIL_INFO.GetXMLData(cause) + "]");
  2201. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  2202. AddressSet addc = wdb.getAddressMGR(); //DB에서 동호 정보 받아옴
  2203. wdb.closeDB();
  2204. final iMAPAlarmOperation imapAlarmOperation = new iMAPAlarmOperation(getContext() , addc);
  2205. imapAlarmOperation.SetServerIPcfg(DstIP, DstPort);
  2206. imapAlarmOperation.DoWork(alarm_mode, cause);
  2207. imapAlarmOperation.SetRetCtr(new RetProci(){
  2208. @Override
  2209. public void ProcSuccess() {
  2210. // TODO Auto-generated method stub
  2211. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcSuccess()");
  2212. String result = imapAlarmOperation.GetAttributeVal(0, "result");
  2213. Log.i(TAG, "[sendAlarmOperationToMainServer] result [" + result +"]");
  2214. if (result.equalsIgnoreCase("ok")) {
  2215. Log.i(TAG, "[sendAlarmOperationToMainServer] result [" + result +"]");
  2216. }
  2217. }
  2218. @Override
  2219. public void ProcError() {
  2220. // TODO Auto-generated method stub
  2221. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcError() -> " + APIErrorCode.GetLogPrefix());
  2222. }
  2223. @Override
  2224. public void ProcDoing() {
  2225. // TODO Auto-generated method stub
  2226. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcDoing()");
  2227. }
  2228. });
  2229. }
  2230. private String getMainVersion() {
  2231. return this.getAppVersion();
  2232. }
  2233. private int m_LiveImapServer = 0;
  2234. private int m_LiveMainActivity = 0;
  2235. private boolean m_IPActivity = false;
  2236. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  2237. @Override
  2238. public void onReceive(Context context, Intent intent) {
  2239. String strAction = intent.getAction();
  2240. int item = 0;
  2241. Log.i(TAG, "[mWallPadNotifyBR] strAction [" + strAction + "]");
  2242. if (strAction.equals(define.NOTIFY_ACNAME)) {
  2243. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND,0);
  2244. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACNAME -> kind : " + kind);
  2245. switch (kind) {
  2246. case define.NOTIFY_GET_ELEC_CHARGE:
  2247. String strState = intent.getStringExtra("sCharging_Status");
  2248. String strCarNum = intent.getStringExtra("sCar_Num");
  2249. if (strState.equals("start")) {
  2250. try {
  2251. WallpadStatusData SetData = new WallpadStatusData(getContext());
  2252. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2253. SetData.closeDB();
  2254. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  2255. } catch (RuntimeException re) {
  2256. LogUtil.errorLogInfo("", TAG, re);
  2257. }
  2258. catch (Exception e) {
  2259. LogUtil.errorLogInfo("", TAG, e);
  2260. }
  2261. // 충전시작
  2262. Intent data = new Intent();
  2263. data.putExtra("CarNum", strCarNum); // KEY : MENU_ID_LIST
  2264. data.putExtra("Msg", "충전을 시작합니다.");
  2265. mIOInterface.ctrlLcdWakeUp();
  2266. StartPopup(ID.POPUPS.POPUP_CHARGINGELECTRICVEHICLE, data);
  2267. }
  2268. else if (strState.equals("stop")) {
  2269. try {
  2270. WallpadStatusData SetData = new WallpadStatusData(getContext());
  2271. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2272. SetData.closeDB();
  2273. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  2274. } catch (RuntimeException re) {
  2275. LogUtil.errorLogInfo("", TAG, re);
  2276. }
  2277. catch (Exception e) {
  2278. LogUtil.errorLogInfo("", TAG, e);
  2279. }
  2280. // 충전 종료
  2281. Intent data = new Intent();
  2282. data.putExtra("CarNum", strCarNum); // KEY : MENU_ID_LIST
  2283. data.putExtra("Msg", "충전이 종료되었습니다.");
  2284. mIOInterface.ctrlLcdWakeUp();
  2285. StartPopup(ID.POPUPS.POPUP_CHARGINGELECTRICVEHICLE, data);
  2286. }
  2287. break;
  2288. case define.NOTIFY_INTERLAYTER_NOISE_ALARM:
  2289. if (checkInterFloorNoiseFuncUsage()) {
  2290. mIOInterface.ctrlLcdWakeUp();
  2291. StartPopup(ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED);
  2292. }
  2293. break;
  2294. case define.NOTIFY_INTERLAYTER_SENSOR_STATUS_CHANGE :
  2295. if (checkInterFloorNoiseFuncUsage() && checkInterFloorNoiseError()) {
  2296. mIOInterface.ctrlLcdWakeUp();
  2297. StartPopup(ID.POPUPS.POPUP_INTERFLOORNOISEERROR);
  2298. }
  2299. break;
  2300. case define.NOTIFY_AUTOPICTURE_FINISH:
  2301. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_AUTOPICTURE_FINISH");
  2302. // 전자액자 종료 BR 수신시 LCD ON Flag 제거
  2303. ctrlLCDOnOff(false);
  2304. break;
  2305. case define.NOTIFY_ALARM_CHANGE:
  2306. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_ALARM_CHANGE");
  2307. // WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2308. // int nAlarmStatus = SetData.GetAlarmStatus();
  2309. // SetData.closeDB();
  2310. //
  2311. // Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus = " + nAlarmStatus);
  2312. // if (nAlarmStatus == WallpadStatusData.GUARD_IN) {
  2313. // mSound.PlayMent(SND.mode.INMODE_SETTING);
  2314. // }
  2315. // else if (nAlarmStatus == WallpadStatusData.GUARD_OUT) {
  2316. // mSound.PlayMent(SND.mode.OUTMODE_SETTING);
  2317. // }
  2318. // else if (nAlarmStatus == WallpadStatusData.ALARM_NONE) {
  2319. // mSound.PlayMent(SND.mode.NORMALMODE_COMEBACK);
  2320. // }
  2321. break;
  2322. case define.NOTIFY_PLAYMENT:
  2323. int sndidx = intent.getIntExtra(define.NOTIBR_CONTENT,0);
  2324. Sound().PlayMent(sndidx);
  2325. case define.NOTIFY_DEVICE_INIT_COMPLETION:
  2326. Log.i(TAG, "[mWallPadNotifyBR] NOTIFY_DEVICE_INIT_COMPLETION: bLCDKeeperUsage [" + bLCDKeeperUsage +"]");
  2327. if (bLCDKeeperUsage) registerLCDKeeper();
  2328. break;
  2329. default:
  2330. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  2331. break;
  2332. }
  2333. }
  2334. else if (strAction.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  2335. Log.d(TAG, "[mWallPadNotifyBR] Common.BR_ACK_WALLPADCALL_LIVE");
  2336. return;
  2337. }
  2338. else if (strAction.equals(define.DRIVER_VENTIL_BR)) {
  2339. Log.d(TAG, "[mWallPadNotifyBR] define.DRIVER_VENTIL_BR");
  2340. return;
  2341. }
  2342. else if (strAction.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  2343. try {
  2344. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND,0);
  2345. Log.d(TAG, "[mWallPadNotifyBR] ACNAME_MAIN_NOTI -> kind : " + kind);
  2346. switch (kind) {
  2347. case Common.BR_MAIN_NOTI.ARRIVED_CAR:
  2348. StartPopup(ID.POPUPS.POPUP_VEHICLEARRIVED, intent);
  2349. // StartPopup(ID_OLD.SCREENS.ArrivedCarPopupScreen);
  2350. break;
  2351. case Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL:
  2352. StartPopup(ID.POPUPS.POPUP_PARCELRECEIVED);
  2353. // StartPopup(ID_OLD.SCREENS.DeliveryBox);
  2354. break;
  2355. case Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR:
  2356. StartPopup(ID.POPUPS.POPUP_SMARTKEYEMERGENCY, intent);
  2357. // StartPopup(ID_OLD.SCREENS.SmartKeyAlarmPopupScreen, intent);
  2358. break;
  2359. case Common.BR_MAIN_NOTI.UI_BANDLOCATION_ALARM:
  2360. ctrlLCDOnOff(true);
  2361. int nCardNum = intent.getIntExtra(Common.BR_MAIN_NOTI.CARD_NUM,0);
  2362. Intent mIntent = new Intent();
  2363. mIntent.putExtra(Common.BR_MAIN_NOTI.CARD_NUM, nCardNum);
  2364. StartPopup(ID.POPUPS.POPUP_BANDLOCATIONALARM, mIntent);
  2365. break;
  2366. case Common.BR_MAIN_NOTI.UI_UPDATE_POST:
  2367. ctrlLCDOnOff(true);
  2368. StartPopup(ID.POPUPS.POPUP_POSTRECEIVED);
  2369. break;
  2370. case Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER:
  2371. // 알람 상태 확인
  2372. int doorCamType = intent.getIntExtra("DOORCAM_TYPE", -1);
  2373. Intent data = new Intent();
  2374. data.putExtra("DOORCAM_TYPE", doorCamType);
  2375. mIOInterface.ctrlLcdWakeUp();
  2376. // StartPopup(ID.POPUPS.POPUP_NOTICESTRANGER, data); // 시나리오 변경: 거동수상자 알림 팝업 삭제 (바로 녹화 시작)
  2377. WallpadStatusData SetData = new WallpadStatusData(mContext);
  2378. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2379. SetData.closeDB();
  2380. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  2381. // 메인 앱으로 BR 전송
  2382. Intent notiIntent = new Intent();
  2383. notiIntent.setAction(define.NOTIFY_ACNAME);
  2384. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ACCEPT_RECORD_STRANGER);
  2385. mContext.sendBroadcast(notiIntent);
  2386. break;
  2387. case Common.BR_MAIN_NOTI.ACCEPT_RECORDING:
  2388. int nEmerState = intent.getIntExtra("EMERGENCY_STATE", -1);
  2389. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Door_Record, nEmerState);
  2390. break;
  2391. default:
  2392. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  2393. break;
  2394. }
  2395. } catch (RuntimeException re) {
  2396. LogUtil.errorLogInfo("", TAG, re);
  2397. }
  2398. catch (Exception e) {
  2399. e.toString();
  2400. }
  2401. return;
  2402. }
  2403. else if(strAction.equals(BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER )) {
  2404. int kind = intent.getIntExtra(BR_MAIN_LIVE_CHECKER.KIND,0);
  2405. Log.d(TAG, "[mWallPadNotifyBR] BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER -> kind : " + kind + ", m_LiveImapServer [" + m_LiveImapServer + "], m_LiveMainActivity [" + m_LiveMainActivity + "]");
  2406. if (kind == BR_MAIN_LIVE_CHECKER.IMAP_SERVER) {
  2407. Log.d(TAG, "[mWallPadNotifyBR] received Imap Server Live !");
  2408. m_LiveImapServer++;
  2409. }
  2410. else if( kind == BR_MAIN_LIVE_CHECKER.MAIN_ACTIVITY) {
  2411. Log.d(TAG, "[mWallPadNotifyBR] received Main Activity Live !");
  2412. m_LiveMainActivity++;
  2413. if (m_IPActivity == false) {
  2414. Log.d(TAG, "[mWallPadNotifyBR] IP is not set");
  2415. m_LiveImapServer++;
  2416. }
  2417. }
  2418. Log.d(TAG, "[mWallPadNotifyBR] m_LiveImapServer [" + m_LiveImapServer + "], m_LiveMainActivity [" + m_LiveMainActivity +"]");
  2419. return;
  2420. }
  2421. int kind = intent.getIntExtra("KIND",0);
  2422. Log.d(TAG, "MainActivity mWallPadNotifyBR Receive Notify BR "+kind+" "/*+electr.isActive()*/);
  2423. switch (kind) {
  2424. case define.NOTIFY_ELE_MOVE:
  2425. // if (electr!= null /*&& electr.isActive()*/)
  2426. // {
  2427. // Log.i("MAINSCREEN", "Receive NOTIFY_ELE_MOVE");
  2428. // electr.updateUI(intent.getStringExtra("FLOOR"), intent.getByteExtra("UPDOWN",(byte)-1));
  2429. // }
  2430. break;
  2431. case define.NOTIFY_ELE_ARRIVAL_UP:
  2432. Log.i("AIDLTEST", "Receive NOTIFY_ELE_ARRIVAL_UP");
  2433. Sound().Play(SND.elevator.UP_ARRIVED);
  2434. break;
  2435. case define.NOTIFY_ELE_ARRIVAL_DOWN:
  2436. try {
  2437. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  2438. int eleinfo = devset.Get_Elevator_Info();
  2439. devset.closeDB();
  2440. if (WallpadDeviceSet.ELEVATOR_SIMPLE == eleinfo) Sound().Play(SND.elevator.ORG_ARRIVED);
  2441. else if (WallpadDeviceSet.ELEVATOR_FLOOR == eleinfo) Sound().Play(SND.elevator.DN_ARRIVED);
  2442. } catch (RuntimeException re) {
  2443. LogUtil.errorLogInfo("", TAG, re);
  2444. }
  2445. catch (Exception e) {
  2446. LogUtil.errorLogInfo("", TAG, e);
  2447. }
  2448. break;
  2449. case define.NOTIFY_UPDATE_START:
  2450. try {
  2451. String updateFile = intent.getStringExtra("PATH");
  2452. Log.i("WALLPADAPI","Call Update App :" + updateFile);
  2453. if (updateFile==null) return;
  2454. ComponentName cn = new ComponentName("com.telechips.android.systemupdater","com.telechips.android.systemupdater.SystemUpdate");
  2455. Intent Uintent = new Intent(Intent.ACTION_MAIN);
  2456. Uintent.addCategory(Intent.CATEGORY_LAUNCHER);
  2457. Uintent.putExtra("updatefile",updateFile);
  2458. Uintent.setComponent(cn);
  2459. startActivity(Uintent);
  2460. } catch (RuntimeException re) {
  2461. LogUtil.errorLogInfo("", TAG, re);
  2462. }
  2463. catch (Exception e) {
  2464. LogUtil.errorLogInfo("", TAG, e);
  2465. }
  2466. break;
  2467. case define.NOTIFY_DEVSERVICE_START:
  2468. mWallPadAPI = new WallPadAPI(getApplicationContext());
  2469. break;
  2470. case define.NOTIFY_DEVICECONNECTED:
  2471. //DevLockCtr.ReleaseLock(define.DEVICE_LOCK_SVC_INIT);
  2472. break;
  2473. case define.NOTIFY_SENDBOOTUP_FAIL:
  2474. // 부트업 실패시 5초 간격으로 다시 시도하도록 수정.
  2475. mWallPadApiCheckHandler.sendEmptyMessageDelayed(10, 10000);
  2476. break;
  2477. case define.NOTIFY_IMAPSERVER_START:
  2478. case Common.DEVICE_BOOTUP_RETRY:
  2479. Log.i(TAG, "Try Send Boot up MSG kind : " + kind );
  2480. bootupretryCNT++;
  2481. if (bootupretryCNT > MAX_BOOTUP_RETRY_COUNT) break;
  2482. try {
  2483. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2484. if (SetData != null) {
  2485. // AnC 기존 코드는 네트워크 연결이 안된경우 DB Close를 50회를 안 하도록 되어있어서 수정함.
  2486. String strServerIP = SetData.GetServerIP();
  2487. int nServerPort = SetData.GetServerPort();
  2488. String svrVersion = SetData.GetServerVer();
  2489. Log.d(TAG, "DB Server Version : " + svrVersion );
  2490. if (svrVersion == null) svrVersion = "1.0";
  2491. //설정정보 버전 가져오기
  2492. StringBuilder result = new StringBuilder();
  2493. result.append(SetData.GetSettingVer());
  2494. SetData.closeDB();
  2495. String Setting_Version = result.toString();
  2496. Log.i(TAG, "Setting's Version :"+Setting_Version);
  2497. boolean mNewDanjiServer = false;
  2498. try {
  2499. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2500. //mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2501. int danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  2502. if(danjiserverType == 1)
  2503. {
  2504. mNewDanjiServer = false;
  2505. }
  2506. else if(danjiserverType == 2)
  2507. {
  2508. mNewDanjiServer = true;
  2509. }
  2510. else
  2511. {
  2512. mNewDanjiServer = true;
  2513. }
  2514. wallpadDeviceSet.closeDB();
  2515. } catch (RuntimeException re) {
  2516. LogUtil.errorLogInfo("", TAG, re);
  2517. mNewDanjiServer = false;
  2518. }
  2519. catch (Exception e) {
  2520. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2521. LogUtil.errorLogInfo("", TAG, e);
  2522. mNewDanjiServer = false;
  2523. }
  2524. if (mNewDanjiServer == true) {
  2525. // DB 값하고 , 신형단지서버 사용 설정이 동일 하다면 DB값을 전달한다.
  2526. // 나중에 2.X 이상 버전이 갱신될 경우를 위해서
  2527. }
  2528. else {
  2529. svrVersion = "1.0";
  2530. }
  2531. //Main App 버전정보 가져오기
  2532. WallPadiMAPNotifyAPI notify = new WallPadiMAPNotifyAPI(getApplicationContext());
  2533. notify.SetSocketWaitCount(3000);
  2534. notify.SetServerIPcfg(strServerIP, nServerPort);
  2535. notify.Send_Device_BootUP(getMainVersion(), Setting_Version , svrVersion );
  2536. }
  2537. } catch (RuntimeException re) {
  2538. LogUtil.errorLogInfo("", TAG, re);
  2539. Intent Newintent = new Intent();
  2540. Newintent.setAction(define.NOTIFY_ACNAME);
  2541. Newintent.putExtra(define.NOTIBR_KIND,define.NOTIFY_SENDBOOTUP_FAIL);
  2542. sendBroadcast(Newintent);
  2543. }
  2544. catch (Exception e) {
  2545. LogUtil.errorLogInfo("", TAG, e);
  2546. Intent Newintent = new Intent();
  2547. Newintent.setAction(define.NOTIFY_ACNAME);
  2548. Newintent.putExtra(define.NOTIBR_KIND,define.NOTIFY_SENDBOOTUP_FAIL);
  2549. sendBroadcast(Newintent);
  2550. }
  2551. break;
  2552. case define.NOTIFY_SUBDEVCALLBUSY:
  2553. /*
  2554. callbtn = (Button)findViewById(R.id.Callbtn);
  2555. callbtn.setBackgroundResource(R.drawable.but_call_on);
  2556. MAIN_CALL_LOCK = true;
  2557. */
  2558. break;
  2559. case define.NOTIFY_SUBDEVCALLEND:
  2560. /*
  2561. callbtn = (Button)findViewById(R.id.Callbtn);
  2562. callbtn.setBackgroundResource(R.drawable.but_call);
  2563. MAIN_CALL_LOCK = false;
  2564. */
  2565. break;
  2566. case define.NOTIFY_UPDATECALLDATA:
  2567. try{
  2568. String[] UpdateCallData = intent.getStringExtra(define.NOTIBR_CONTENT).split(define.DEVCTR_CMD_SPLITER);
  2569. Log.i(APIErrorCode.GetLogPrefix(),"Receive NOTIFY_UPDATECALLDATA "+UpdateCallData[0]+";"+UpdateCallData[1]);
  2570. int IncallCnt = 0;
  2571. int VisitorCNT = 0;
  2572. try {
  2573. IncallCnt = Integer.parseInt(UpdateCallData[0]);
  2574. VisitorCNT = Integer.parseInt(UpdateCallData[1]);
  2575. } catch (RuntimeException re) {
  2576. LogUtil.errorLogInfo("", TAG, re);
  2577. }
  2578. catch (Exception e) {
  2579. LogUtil.errorLogInfo("", TAG, e);
  2580. }
  2581. } catch (RuntimeException re) {
  2582. LogUtil.errorLogInfo("", TAG, re);
  2583. }
  2584. catch (Exception e) {
  2585. LogUtil.errorLogInfo("", TAG, e);
  2586. }
  2587. break;
  2588. case define.NOTIFY_UPDATENOTICE:
  2589. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATENOTICE ");
  2590. try {
  2591. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2592. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2593. SetData.closeDB();
  2594. if (soundOut) {
  2595. Sound().PlayMent(SND.effect.EFFECT1);
  2596. }
  2597. mIOInterface.ctrlLcdWakeUp();
  2598. } catch (RuntimeException re) {
  2599. LogUtil.errorLogInfo("", TAG, re);
  2600. }
  2601. catch (Exception e) { LogUtil.errorLogInfo("", TAG, e);
  2602. }
  2603. break;
  2604. case define.NOTIFY_UPDATEPARCEL:
  2605. try {
  2606. String type = intent.getStringExtra(define.NOTIBR_CONTENT);
  2607. int itemcnt = intent.getIntExtra("ITEM",-1);
  2608. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2609. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2610. if (itemcnt !=-1) SetData.SetParcelCNT(itemcnt);
  2611. SetData.closeDB();
  2612. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPARCEL itemcnt : " + itemcnt);
  2613. // if (soundOut) {
  2614. // if (type.equals("parcel_in")) {
  2615. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2616. // pm.userActivity(1, true);
  2617. // Sound().PlayMent(SND.mode.BOX_ARRIVED);
  2618. // }
  2619. // }
  2620. Log.d(TAG, "Send BR --> Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL");
  2621. Intent Newintent = new Intent();
  2622. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2623. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL);
  2624. getApplicationContext().sendBroadcast(Newintent);
  2625. //NoticeIconOnoff(true);
  2626. } catch (RuntimeException re) {
  2627. LogUtil.errorLogInfo("", TAG, re);
  2628. }
  2629. catch (Exception e) {
  2630. LogUtil.errorLogInfo("", TAG, e);
  2631. }
  2632. // if (type.equals("parcel_in"))
  2633. // {
  2634. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2635. // pm.userActivity(1, true);
  2636. // PlayNotiSound(WpadSound.SND.mode.BOX_ARRIVED);
  2637. // }
  2638. //
  2639. // if (itemcnt!=-1){
  2640. // if (itemcnt > 0)
  2641. // ParcelIconOnoff(true);
  2642. // else
  2643. // ParcelIconOnoff(false);
  2644. // WallpadStatusData ParData = new WallpadStatusData(getApplicationContext());
  2645. // ParData.SetParcelCNT(itemcnt);
  2646. // ParData.closeDB();
  2647. // if (ParcelMGR!=null) ParcelMGR.updateParcel();
  2648. // }
  2649. break;
  2650. case define.NOTIFY_UPDATEPOST:
  2651. try {
  2652. int nItemCnt = intent.getIntExtra("ITEM",-1);
  2653. Log.d(TAG, "[UI_UPDATE_POST] nItemCnt [" + nItemCnt + "]");
  2654. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2655. if (nItemCnt != -1) SetData.SetPostCNT(nItemCnt);
  2656. SetData.closeDB();
  2657. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPOST nItemCnt : " + nItemCnt);
  2658. Log.d(TAG, "Send BR --> Common.BR_MAIN_NOTI.UI_UPDATE_POST");
  2659. Intent Newintent = new Intent();
  2660. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2661. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.UI_UPDATE_POST);
  2662. getApplicationContext().sendBroadcast(Newintent);
  2663. } catch (RuntimeException re) {
  2664. LogUtil.errorLogInfo("", TAG, re);
  2665. }
  2666. catch (Exception e) {
  2667. Log.e(TAG, "[Exception] mWallPadNotifyBR.onReceive()");
  2668. LogUtil.errorLogInfo("", TAG, e);
  2669. }
  2670. break;
  2671. case define.NOTIFY_UPDATEPARKING:
  2672. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPARKING ");
  2673. /*
  2674. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  2675. List<String[]> parkList = parkdb.GetParkInfo();
  2676. if(parkList != null)
  2677. {
  2678. for(int j= 0; j<parkList.size(); j++)
  2679. {
  2680. for(int i = 0; i<4; i++)
  2681. {
  2682. Common.DebugLog("parkList.get("+j+")["+i+"]:"+ parkList.get(j)[i]);
  2683. }
  2684. }
  2685. }
  2686. parkdb.closeDB();
  2687. */
  2688. break;
  2689. case define.NOTIFY_DEVICEREBOOT:
  2690. try {
  2691. //[Model]
  2692. // if (Version.getPlatformType() == Version.PLATFORM_TYPE.A20) {
  2693. // // A20
  2694. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  2695. // pm.userActivity(8, true);
  2696. // }
  2697. // else if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  2698. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  2699. // V40
  2700. V40IOInterface mV40IOInterface = new V40IOInterface();
  2701. mV40IOInterface.setV40Reboot(5);
  2702. }
  2703. else {
  2704. // TCC8935
  2705. SendAppFinishReqBR();
  2706. ComponentName cnA = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  2707. intent = new Intent(Intent.ACTION_MAIN);
  2708. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  2709. intent.putExtra("updatesystem", "no");
  2710. intent.putExtra("updateapp", " no ");
  2711. intent.putExtra("rebootcmd", "reboot");
  2712. intent.setComponent(cnA);
  2713. startActivity(intent);
  2714. }
  2715. } catch (RuntimeException re) {
  2716. LogUtil.errorLogInfo("", TAG, re);
  2717. }
  2718. catch (Exception e) {
  2719. LogUtil.errorLogInfo("", TAG, e);
  2720. }
  2721. break;
  2722. case define.NOTIFY_DEVICEDEEPSLEEP:
  2723. try {
  2724. Log.d(TAG, "[mWallPadAlertBR] NOTIFY_DEVICEDEEPSLEEP");
  2725. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  2726. String[] getstate = sdb.GetSystemUpdateStatus();
  2727. for (int i = 0; i < getstate.length; i++) {
  2728. Log.d(TAG, "[mWallPadAlertBR] getstate[" + i + "] = " + getstate[i]);
  2729. }
  2730. if (getstate[0].equalsIgnoreCase("SET")) {
  2731. sdb.SetSystemUpdate(null, null);
  2732. sdb.SetUpgradeState(true);
  2733. ComponentName cnn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  2734. intent = new Intent(Intent.ACTION_MAIN);
  2735. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2736. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  2737. intent.putExtra("updatesystem", getstate[1]);
  2738. intent.putExtra("updateapp", getstate[2]);
  2739. intent.setComponent(cnn);
  2740. Log.e("MAINSCREEN","Call Upgrade Request BSP : "+getstate[1]+" APP : "+getstate[2]);
  2741. startActivity(intent);
  2742. }
  2743. sdb.closeDB();
  2744. } catch (RuntimeException re) {
  2745. LogUtil.errorLogInfo("", TAG, re);
  2746. }
  2747. catch (Exception e) {
  2748. LogUtil.errorLogInfo("", TAG, e);
  2749. }
  2750. break;
  2751. case define.NOTIFY_SYSTEMTIMESETTED:
  2752. try {
  2753. Common.DebugLog("MainActivity ---------- > define.NOTIFY_SYSTEMTIMESETTED");
  2754. Calendar caldata = new GregorianCalendar();
  2755. // refreshdate(caldata);
  2756. // refreshclock(caldata);
  2757. if (SYSTEM_TIME_SET == false) {
  2758. SYSTEM_TIME_SET = true;
  2759. if (SCManager != null) {
  2760. if (SCManager.isSetted != true) SCManager.refreshSchedule();
  2761. }
  2762. }
  2763. } catch (RuntimeException re) {
  2764. LogUtil.errorLogInfo("", TAG, re);
  2765. }
  2766. catch (Exception e) {
  2767. LogUtil.errorLogInfo("", TAG, e);
  2768. }
  2769. break;
  2770. case define.NOTIFY_SCHEDULEUPDATED:
  2771. // item = intent.getIntExtra("ITEM",0);
  2772. // if (item == ScheduleManager.SCHEDULE_TYPE_SCHEDULER && SYSTEM_TIME_SET)
  2773. // SCManager.refreshSchedulerData();
  2774. // else if (item == ScheduleManager.SCHEDULE_TYPE_SYSRESET && SYSTEM_TIME_SET)
  2775. // SCManager.refreshsysreset();
  2776. // else if (item == ScheduleManager.SCHEDULE_TYPE_MORNINGCALL && SYSTEM_TIME_SET)
  2777. // SCManager.refreshMorningCall();
  2778. // break;
  2779. case define.NOTIFY_ALARMSTAUSCHANGED:
  2780. try {
  2781. item = intent.getIntExtra("ITEM",0);
  2782. if (item == WallpadStatusData.GUARD_OUT) {
  2783. int base = 8000;
  2784. int [] Menu_Id_List = { base+11};
  2785. int Menu_Start_Id = base+11;
  2786. int Menu_Start_Option = -1;
  2787. Intent iintent = new Intent(Intent.ACTION_MAIN);
  2788. iintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2789. iintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  2790. iintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2791. iintent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun","kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  2792. startActivity(iintent);
  2793. }
  2794. else if (item == WallpadStatusData.GUARD_IN) {
  2795. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  2796. // Button callBtn = (Button)findViewById(R.id.GuardBtn);
  2797. // callBtn.setBackgroundResource((SettData.GetAlarmStatus() == WallpadStatusData.GUARD_IN)?R.drawable.but_guard_on:R.drawable.but_guard);
  2798. SettData.closeDB();
  2799. }
  2800. } catch (RuntimeException re) {
  2801. LogUtil.errorLogInfo("", TAG, re);
  2802. }
  2803. catch (Exception e) {
  2804. LogUtil.errorLogInfo("", TAG, e);
  2805. }
  2806. break;
  2807. case define.NOTIFY_ENERGYUPDATE:
  2808. try
  2809. {
  2810. Calendar caldata = new GregorianCalendar();
  2811. String[] getData = intent.getStringExtra(define.NOTIBR_CONTENT).split(define.DEVCTR_CMD_SPLITER);
  2812. String checkDate = String.format("%04d%02d%02d",caldata.get(Calendar.YEAR),caldata.get(Calendar.MONTH)+1,caldata.get(Calendar.DAY_OF_MONTH));
  2813. WallpadStatusData energyData = new WallpadStatusData(getApplicationContext());
  2814. energyData.SetEnergyData(intent.getStringExtra(define.NOTIBR_CONTENT));
  2815. energyData.SetEnergyCheckDate(checkDate);
  2816. energyData.closeDB();
  2817. //if (NeedCheckEnergy)
  2818. // CheckEnergyUsage(getData);
  2819. // if (EnergyMGR!=null)
  2820. // EnergyMGR.UpdateData(getData);
  2821. }
  2822. catch (RuntimeException re) {
  2823. LogUtil.errorLogInfo("", TAG, re);
  2824. }
  2825. catch (Exception e )
  2826. {
  2827. LogUtil.errorLogInfo("", TAG, e);
  2828. }
  2829. break;
  2830. case define.NOTIFY_STARTEFRAME:
  2831. try
  2832. {
  2833. Log.w("MAINSCREEN"," Receive NOTIFY_STARTEFRAME Start StartAutoPictureAPP ");
  2834. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  2835. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar()))
  2836. {
  2837. if (!SettData.StartAutoPictureAPP())
  2838. {
  2839. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2840. // pm.userActivity(3, true);
  2841. }
  2842. }
  2843. else
  2844. {
  2845. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2846. // pm.userActivity(3, true);
  2847. }
  2848. SettData.closeDB();
  2849. }
  2850. catch (RuntimeException re) {
  2851. LogUtil.errorLogInfo("", TAG, re);
  2852. }
  2853. catch (Exception e )
  2854. {
  2855. LogUtil.errorLogInfo("", TAG, e);
  2856. }
  2857. break;
  2858. case define.NOTIFY_ADDDEVICELOCK:
  2859. Log.w("MAINSCREEN"," Receive NOTIFY_ADDDEVICELOCK Start ");
  2860. //DevLockCtr.AddLock(intent.getIntExtra(define.NOTIBR_CONTENT, 0));
  2861. break;
  2862. case define.NOTIFY_RELEASEDEVICELOCK:
  2863. Log.w("MAINSCREEN"," Receive NOTIFY_RELEASEDEVICELOCK Start ");
  2864. //DevLockCtr.ReleaseLock(intent.getIntExtra(define.NOTIBR_CONTENT, 0));
  2865. break;
  2866. case define.NOTIFY_PLAYMENT:
  2867. {
  2868. int sndidx = intent.getIntExtra(define.NOTIBR_CONTENT,0);
  2869. Sound().PlayMent(sndidx);
  2870. if (sndidx == WpadSound.SND.elevator.CALL) {
  2871. byte floorInfo = intent.getByteExtra(define.NOTIBR_FLOOR,(byte)0);
  2872. Log.e("MANUAL_MAIN", " PLAY MENT Get Ele Call : "+floorInfo);
  2873. }
  2874. }
  2875. break;
  2876. case define.NOTIFY_ENERGY_DATA:
  2877. {
  2878. try
  2879. {
  2880. Log.w("MAINSCREEN"," Receive NOTIFY_ENERGY DATA Start ");
  2881. //에너지 데이터 개수 - 3종 또는 5종
  2882. EnergyAlramPopupMgr.m_EnergyInfoCount = intent.getIntExtra(Common.ENERGY_INTENT_ENERGY_COUNT, -1);
  2883. Log.w("MAINSCREEN"," ENERGY_INTENT_ENERGY_COUNT :"+ EnergyAlramPopupMgr.m_EnergyInfoCount);
  2884. //에너지 단지서버에서 받아온 시간
  2885. EnergyAlramPopupMgr.m_ReceiveYear = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_YEAR, -1);
  2886. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_YEAR :"+ EnergyAlramPopupMgr.m_ReceiveYear);
  2887. EnergyAlramPopupMgr.m_ReceiveMonth = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_MONTH, -1);
  2888. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_MONTH :"+ EnergyAlramPopupMgr.m_ReceiveMonth);
  2889. EnergyAlramPopupMgr.m_ReceiveDay = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_DAY, -1);
  2890. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_DAY :"+ EnergyAlramPopupMgr.m_ReceiveDay );
  2891. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_HOUR :"+ intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_HOUR, -1));
  2892. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_MINUTE :"+ intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_MINUTE, -1));
  2893. //전기 에너지 정보
  2894. String Vaule = "";
  2895. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_ELECTRIC);
  2896. if( Vaule != null && Vaule.length() > 0 )
  2897. EnergyAlramPopupMgr.m_Elec_UseValue = Double.parseDouble(Vaule);
  2898. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC);
  2899. if( Vaule != null && Vaule.length() > 0 )
  2900. EnergyAlramPopupMgr.m_Elec_GoalValue = Double.parseDouble(Vaule);
  2901. //수도 에너지 정보
  2902. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_WATER);
  2903. if( Vaule != null && Vaule.length() > 0 )
  2904. EnergyAlramPopupMgr.m_Water_UseValue = Double.parseDouble(Vaule);
  2905. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_WATER);
  2906. if( Vaule != null && Vaule.length() > 0 )
  2907. EnergyAlramPopupMgr.m_Water_GoalValue = Double.parseDouble(Vaule);
  2908. //가스 에너지 정보
  2909. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_GAS);
  2910. if( Vaule != null && Vaule.length() > 0 )
  2911. EnergyAlramPopupMgr.m_Gas_UseValue = Double.parseDouble(Vaule);
  2912. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_GAS);
  2913. if( Vaule != null && Vaule.length() > 0 )
  2914. EnergyAlramPopupMgr.m_Gas_GoalValue = Double.parseDouble(Vaule);
  2915. //온수 에너지 정보
  2916. if( EnergyAlramPopupMgr.m_EnergyInfoCount >= 5 )
  2917. {
  2918. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_HOTWATER);
  2919. if( Vaule != null && Vaule.length() > 0 )
  2920. EnergyAlramPopupMgr.m_HotWater_UseValue = Double.parseDouble(Vaule);
  2921. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_HOTWATER);
  2922. if( Vaule != null && Vaule.length() > 0 )
  2923. EnergyAlramPopupMgr.m_HotWater_GoalValue = Double.parseDouble(Vaule);
  2924. //난방 에너지 정보
  2925. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_HEATING);
  2926. if( Vaule != null && Vaule.length() > 0 )
  2927. EnergyAlramPopupMgr.m_Heating_UseValue = Double.parseDouble(Vaule);
  2928. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_HEATING);
  2929. if( Vaule != null && Vaule.length() > 0 )
  2930. EnergyAlramPopupMgr.m_Heating_GoalValue = Double.parseDouble(Vaule);
  2931. }
  2932. }
  2933. catch (RuntimeException re) {
  2934. LogUtil.errorLogInfo("", TAG, re);
  2935. }
  2936. catch (Exception e )
  2937. {
  2938. LogUtil.errorLogInfo("", TAG, e);
  2939. }
  2940. }
  2941. break;
  2942. case define.NOTIFY_GET_CAR_PARKING:
  2943. try
  2944. {
  2945. if(bUseofNot_ParkingInfo == true)
  2946. {
  2947. bSetMSG_GetParkingInfo = true;
  2948. LoadParkingDataFromServer();
  2949. }
  2950. else
  2951. {
  2952. DebugLogOutput("bUseofNot_ParkingInfo == false");
  2953. }
  2954. }
  2955. catch (RuntimeException re) {
  2956. LogUtil.errorLogInfo("", TAG, re);
  2957. }
  2958. catch (Exception e )
  2959. {
  2960. LogUtil.errorLogInfo("", TAG, e);
  2961. }
  2962. break;
  2963. case define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER:
  2964. String tempFromWhere = intent.getStringExtra("FromWhere");
  2965. if(tempFromWhere == null)
  2966. {
  2967. ResultGetIntent = true;
  2968. }
  2969. String tempElect_target = intent.getStringExtra("elect_target");
  2970. if(tempElect_target != null)
  2971. {
  2972. elect_target = tempElect_target;
  2973. }
  2974. String tempElect_used = intent.getStringExtra("elect_used");
  2975. if(tempElect_used != null)
  2976. {
  2977. elect_used = tempElect_used;
  2978. }
  2979. String tempElect_info = intent.getStringExtra("elect_info");
  2980. if(tempElect_info != null)
  2981. {
  2982. elect_info = tempElect_info;
  2983. }
  2984. String tempWater_target = intent.getStringExtra("water_target");
  2985. if(tempWater_target != null)
  2986. {
  2987. water_target = tempWater_target;
  2988. }
  2989. String tempWater_used = intent.getStringExtra("water_used");
  2990. if(tempWater_used != null)
  2991. {
  2992. water_used = tempWater_used;
  2993. }
  2994. String tempWater_info = intent.getStringExtra("water_info");
  2995. if(tempWater_info != null)
  2996. {
  2997. water_info = tempWater_info;
  2998. }
  2999. String tempGas_target = intent.getStringExtra("gas_target");
  3000. if(tempGas_target != null)
  3001. {
  3002. gas_target = tempGas_target;
  3003. }
  3004. String tempGas_used = intent.getStringExtra("gas_used");
  3005. if(tempGas_used != null)
  3006. {
  3007. gas_used = tempGas_used;
  3008. }
  3009. String tempGas_info = intent.getStringExtra("gas_info");
  3010. if(tempGas_info != null)
  3011. {
  3012. gas_info = tempGas_info;
  3013. }
  3014. String tempHotwater_target = intent.getStringExtra("hotwater_target");
  3015. if(tempHotwater_target != null)
  3016. {
  3017. hotwater_target = tempHotwater_target;
  3018. }
  3019. String tempHotwater_used = intent.getStringExtra("hotwater_used");
  3020. if(tempHotwater_used != null)
  3021. {
  3022. hotwater_used = tempHotwater_used;
  3023. }
  3024. String tempHotwater_info = intent.getStringExtra("hotwater_info");
  3025. if(tempHotwater_info != null)
  3026. {
  3027. hotwater_info = tempHotwater_info;
  3028. }
  3029. String tempHeating_target = intent.getStringExtra("heating_target");
  3030. if(tempHeating_target != null)
  3031. {
  3032. heating_target = tempHeating_target;
  3033. }
  3034. String tempHeating_used = intent.getStringExtra("heating_used");
  3035. if(tempHeating_used != null)
  3036. {
  3037. heating_used = tempHeating_used;
  3038. }
  3039. String tempHeatin_info = intent.getStringExtra("heating_info");
  3040. if(tempHeatin_info != null)
  3041. {
  3042. heating_info = tempHeatin_info;
  3043. }
  3044. break;
  3045. }
  3046. }
  3047. };
  3048. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3049. private void ctrlLCDOnOff(boolean bOn) {
  3050. try {
  3051. if (bOn) {
  3052. PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  3053. Log.d(TAG, "[ctrlLCDOnOff] Screen On: " + pm.isScreenOn());
  3054. if (getCompareBSPVersion()) {
  3055. if (!checkLCDOnByCMD()) {
  3056. Log.d(TAG, "[ctrlLCDOnOff] V40Interface LcdWakeUp Call!!");
  3057. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  3058. }
  3059. }
  3060. else {
  3061. if (!pm.isScreenOn()) {
  3062. Log.d(TAG, "[ctrlLCDOnOff] V40Interface LcdWakeUp Call!!");
  3063. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  3064. }
  3065. }
  3066. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3067. } else
  3068. getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3069. } catch (RuntimeException re) {
  3070. LogUtil.errorLogInfo("", TAG, re);
  3071. }
  3072. catch (Exception e) {
  3073. Log.e(TAG, "[Exception] ctrlLCDOnOff(boolean bOn)");
  3074. LogUtil.errorLogInfo("", TAG, e);
  3075. }
  3076. }
  3077. protected void refreshUserCtr() {
  3078. Intent intent = new Intent();
  3079. intent.setAction(define.DRIVER_LIGHT_BR);
  3080. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_LIGHT_BR);
  3081. sendBroadcast(intent);
  3082. intent = new Intent();
  3083. intent.setAction(define.DRIVER_BATCHLIGHT_BR);
  3084. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_BATCHLIGHT_BR);
  3085. sendBroadcast(intent);
  3086. intent = new Intent();
  3087. intent.setAction(define.DRIVER_VENTIL_BR);
  3088. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_VENTIL_BR);
  3089. sendBroadcast(intent);
  3090. // intent = new Intent();
  3091. // intent.setAction(HEATERBR);
  3092. // Log.i("HIGH","StatusChanged BR Send "+HEATERBR);
  3093. // sendBroadcast(intent);
  3094. }
  3095. private void Check_Upgrade_File() {
  3096. try {
  3097. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3098. String[] getstate = sdb.GetSystemUpdateStatus();
  3099. if (getstate[0].equalsIgnoreCase("SET")) {
  3100. for (int i = 1; i < 3; i++) {
  3101. if (!getstate[i].equals("no")) {
  3102. String filePath = "/sdcard/"+getstate[i];
  3103. File updradef = new File(filePath);
  3104. if (updradef.exists()) FileDelete(updradef);//.delete();
  3105. }
  3106. }
  3107. sdb.SetSystemUpdate(null, null);
  3108. }
  3109. sdb.closeDB();
  3110. } catch (RuntimeException re) {
  3111. LogUtil.errorLogInfo("", TAG, re);
  3112. }
  3113. catch (Exception e) {
  3114. Log.e(TAG, "[Exception] Check_Upgrade_File()");
  3115. LogUtil.errorLogInfo("", TAG, e);
  3116. }
  3117. }
  3118. protected void SendAppFinishReqBR() {
  3119. try {
  3120. Log.e("MANUAL_MAIN", "Send Finish BR");
  3121. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  3122. // pm.userActivity(1, true);
  3123. // LCD Always ON
  3124. getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3125. Intent notiIntent = new Intent();
  3126. notiIntent.setAction(define.BR_APP_FINISH);
  3127. getApplicationContext().sendBroadcast(notiIntent);
  3128. } catch (RuntimeException re) {
  3129. LogUtil.errorLogInfo("", TAG, re);
  3130. }
  3131. catch (Exception e) {
  3132. Log.e(TAG, "[Exception] SendAppFinishReqBR()");
  3133. LogUtil.errorLogInfo("", TAG, e);
  3134. }
  3135. }
  3136. private void registerBroadcastReceiver() {
  3137. try {
  3138. IntentFilter mIntentFilter = new IntentFilter();
  3139. mIntentFilter.addAction("WALLPAD_ALERT");
  3140. registerReceiver(mWallPadAlertBR, mIntentFilter);
  3141. mIntentFilter = new IntentFilter();
  3142. mIntentFilter.addAction("WALLPAD_NOTIFY");
  3143. mIntentFilter.addAction(define.DRIVER_VENTIL_BR);
  3144. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI); // ACC 꺼와 구분되는 Noti 추가
  3145. mIntentFilter.addAction(BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER);
  3146. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  3147. registerReceiver(mWallPadNotifyBR, mIntentFilter);
  3148. registerMainActivityBR();
  3149. } catch (RuntimeException re) {
  3150. LogUtil.errorLogInfo("", TAG, re);
  3151. }
  3152. catch (Exception e) {
  3153. Log.e(TAG, "[Exception] registerBroadcastReceiver()");
  3154. LogUtil.errorLogInfo("", TAG, e);
  3155. }
  3156. }
  3157. private void unregisterBroadcastReceiver() {
  3158. try {
  3159. unregisterReceiver(mWallPadAlertBR);
  3160. unregisterReceiver(mWallPadNotifyBR);
  3161. unregisterReceiver(MainActivityBroadcastReceiver);
  3162. } catch (RuntimeException re) {
  3163. LogUtil.errorLogInfo("", TAG, re);
  3164. }
  3165. catch (Exception e) {
  3166. Log.e(TAG, "[Exception] unregisterBroadcastReceiver()");
  3167. LogUtil.errorLogInfo("", TAG, e);
  3168. }
  3169. }
  3170. private void MainScrLog(String msg) {
  3171. Log.e("MAINSCREEN",APIErrorCode.GetLogPrefix()+msg);
  3172. }
  3173. protected void CheckEnv() {
  3174. try {
  3175. File dnDIC = new File(BESTIN_LOCATION);
  3176. if (!dnDIC.exists()) dnDIC.mkdir();
  3177. dnDIC = new File(ALBUM_PICTURE_LOCATION);
  3178. if (!dnDIC.exists()) dnDIC.mkdir();
  3179. } catch (RuntimeException re) {
  3180. LogUtil.errorLogInfo("", TAG, re);
  3181. }
  3182. catch (Exception e) {
  3183. Log.e(TAG, "[Exception] CheckEnv()");
  3184. LogUtil.errorLogInfo("", TAG, e);
  3185. }
  3186. }
  3187. public void FileCopy(String Target, String Source) {
  3188. FileInputStream input = null;
  3189. FileOutputStream output = null;
  3190. try {
  3191. input = new FileInputStream(Source);
  3192. long size = input.available();
  3193. byte buff[] = new byte[(int)size];
  3194. input.read(buff);
  3195. output = new FileOutputStream(Target);
  3196. output.write(buff);
  3197. output.flush();
  3198. } catch (RuntimeException re) {
  3199. LogUtil.errorLogInfo("", TAG, re);
  3200. }
  3201. catch (Exception e ) {
  3202. Log.e(TAG, "[Exception] FileCopy(String Target, String Source)");
  3203. LogUtil.errorLogInfo("", TAG, e);
  3204. }
  3205. finally {
  3206. if(input!=null) {
  3207. try {
  3208. input.close( );
  3209. } catch (IOException e) {
  3210. LogUtil.errorLogInfo("", TAG, e);
  3211. }
  3212. }
  3213. input = null;
  3214. if(output!=null) {
  3215. try {
  3216. output.close();
  3217. } catch (IOException e) {
  3218. LogUtil.errorLogInfo("", TAG, e);
  3219. }
  3220. }
  3221. output = null;
  3222. }
  3223. }
  3224. public void checkEventNotifications() {
  3225. try {
  3226. Log.d(TAG,"[checkEventNotifications] ========== START ==========)");
  3227. // 스마트우편함, 전기차충전 연동 여부 확인
  3228. int nRetElecVehicle = -1;
  3229. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this.getContext());
  3230. bSmartPostUsage = mWallpadDeviceSet.Get_SmartPostUse();
  3231. nRetElecVehicle = mWallpadDeviceSet.GetDeviceSetted("전기차충전");
  3232. mWallpadDeviceSet.closeDB();
  3233. if (nRetElecVehicle == WallpadDeviceSet.DEV_DATA_ENABLE) bElecVehicleUsage = true;
  3234. else bElecVehicleUsage = false;
  3235. Log.d(TAG, "[checkEventNotifications] bSmartPostUsage [" + bSmartPostUsage + "], nRetElecVehicle [" + nRetElecVehicle + "], bElecVehicleUsage [" + bElecVehicleUsage + "]");
  3236. // 부재중 통화
  3237. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3238. try {
  3239. nMissedCallCnt = mWallpadCallHistoryData.RowCallHistoryCountData();
  3240. } catch (RuntimeException re) {
  3241. LogUtil.errorLogInfo("", TAG, re);
  3242. }
  3243. catch (Exception e) {
  3244. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadCallHistoryData");
  3245. LogUtil.errorLogInfo("", TAG, e);
  3246. }
  3247. mWallpadCallHistoryData.closeDB();
  3248. // 방문자 사진
  3249. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3250. try {
  3251. nVisitorPicCnt = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3252. } catch (RuntimeException re) {
  3253. LogUtil.errorLogInfo("", TAG, re);
  3254. }
  3255. catch (Exception e) {
  3256. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadVisitorPicData_A20");
  3257. LogUtil.errorLogInfo("", TAG, e);
  3258. }
  3259. mWallpadVisitorPicData_A20.closeDB();
  3260. // 공지사항, 택배, 스마트 우편
  3261. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  3262. try {
  3263. nNoticeCnt = mWallpadStatusData.GetNoticeCNT();
  3264. nParcelCnt = mWallpadStatusData.GetParcelCNT();
  3265. nPostCnt = mWallpadStatusData.GetPostCNT();
  3266. } catch (RuntimeException re) {
  3267. LogUtil.errorLogInfo("", TAG, re);
  3268. }
  3269. catch (Exception e) {
  3270. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadStatusData");
  3271. LogUtil.errorLogInfo("", TAG, e);
  3272. }
  3273. mWallpadStatusData.closeDB();
  3274. if (0 > nMissedCallCnt) {
  3275. Log.w(TAG,"[checkEventNotifications] out of range!! nMissedCallCnt [" + nMissedCallCnt + "]");
  3276. nMissedCallCnt = 0;
  3277. }
  3278. if (0 > nVisitorPicCnt) {
  3279. Log.w(TAG,"[checkEventNotifications] out of range!! nVisitorPicCnt [" + nVisitorPicCnt + "]");
  3280. nVisitorPicCnt = 0;
  3281. }
  3282. if (0 > nNoticeCnt) {
  3283. Log.w(TAG,"[checkEventNotifications] out of range!! nNoticeCnt [" + nNoticeCnt + "]");
  3284. nNoticeCnt = 0;
  3285. }
  3286. if (0 > nParcelCnt) {
  3287. Log.w(TAG,"[checkEventNotifications] out of range!! nParcelCnt [" + nParcelCnt + "]");
  3288. nParcelCnt = 0;
  3289. }
  3290. if (0 > nPostCnt) {
  3291. Log.w(TAG,"[checkEventNotifications] out of range!! nPostCnt [" + nPostCnt + "]");
  3292. nPostCnt = 0;
  3293. }
  3294. if (0 > nElecVehicleChangingCnt) {
  3295. Log.w(TAG,"[checkEventNotifications] out of range!! nElecVehicleChangingCnt [" + nElecVehicleChangingCnt + "]");
  3296. nElecVehicleChangingCnt = 0;
  3297. }
  3298. if (!bSmartPostUsage) {
  3299. Log.w(TAG,"[checkEventNotifications] bSmartPostUsage is not supported!! -> bSmartPostUsage [" + bSmartPostUsage + "]");
  3300. nPostCnt = 0;
  3301. }
  3302. if (!bElecVehicleUsage) {
  3303. Log.w(TAG,"[checkEventNotifications] bElecVehicleUsage is not supported!! -> bElecVehicleUsage [" + bElecVehicleUsage + "]");
  3304. nElecVehicleChangingCnt = 0;
  3305. }
  3306. Log.d(TAG,"[checkEventNotifications] nMissedCallCnt [" + nMissedCallCnt + "], nVisitorPicCnt [" + nVisitorPicCnt + "], nNoticeCnt [" + nNoticeCnt + "], nParcelCnt [" + nParcelCnt + "], nPostCnt [" + nPostCnt + "], nElecVehicleChangingCnt [" + nElecVehicleChangingCnt + "]");
  3307. sendEventNotiBR(nMissedCallCnt, nVisitorPicCnt, nNoticeCnt, nParcelCnt, nPostCnt, nElecVehicleChangingCnt);
  3308. Send_NotiSmartSwitch(MainActivity.nNoticeCnt, MainActivity.nParcelCnt, MainActivity.nVisitorPicCnt);
  3309. } catch (RuntimeException re) {
  3310. LogUtil.errorLogInfo("", TAG, re);
  3311. }
  3312. catch (Exception e) {
  3313. Log.e(TAG, "[Exception] checkEventNotifications()");
  3314. LogUtil.errorLogInfo("", TAG, e);
  3315. }
  3316. }
  3317. public String getEventNotificationInfo() {
  3318. try {
  3319. Log.d(TAG,"[getEventNotificationInfo] ========== START ==========)");
  3320. // 부재중 통화, 방문자 사진, 공지사항, 택배
  3321. int nMissedCallCnt = 0, nVisitorPicCnt = 0, nNoticeCnt = 0, nParcelCnt = 0, nPostCnt = 0;
  3322. // 부재중 통화
  3323. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3324. try {
  3325. nMissedCallCnt = mWallpadCallHistoryData.RowCallHistoryCountData();
  3326. } catch (RuntimeException re) {
  3327. LogUtil.errorLogInfo("", TAG, re);
  3328. }
  3329. catch (Exception e) {
  3330. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadCallHistoryData");
  3331. LogUtil.errorLogInfo("", TAG, e);
  3332. }
  3333. mWallpadCallHistoryData.closeDB();
  3334. // 방문자 사진
  3335. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3336. try {
  3337. nVisitorPicCnt = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3338. } catch (RuntimeException re) {
  3339. LogUtil.errorLogInfo("", TAG, re);
  3340. }
  3341. catch (Exception e) {
  3342. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadVisitorPicData_A20");
  3343. LogUtil.errorLogInfo("", TAG, e);
  3344. }
  3345. mWallpadVisitorPicData_A20.closeDB();
  3346. // 공지사항, 택배
  3347. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  3348. try {
  3349. nNoticeCnt = mWallpadStatusData.GetNoticeCNT();
  3350. nParcelCnt = mWallpadStatusData.GetParcelCNT();
  3351. nPostCnt = mWallpadStatusData.GetPostCNT();
  3352. } catch (RuntimeException re) {
  3353. LogUtil.errorLogInfo("", TAG, re);
  3354. }
  3355. catch (Exception e) {
  3356. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadStatusData");
  3357. LogUtil.errorLogInfo("", TAG, e);
  3358. }
  3359. mWallpadStatusData.closeDB();
  3360. if (0 > nMissedCallCnt) {
  3361. Log.w(TAG,"[getEventNotificationInfo] out of range!! nMissedCallCnt [" + nMissedCallCnt + "]");
  3362. nMissedCallCnt = 0;
  3363. }
  3364. if (0 > nVisitorPicCnt) {
  3365. Log.w(TAG,"[getEventNotificationInfo] out of range!! nVisitorPicCnt [" + nVisitorPicCnt + "]");
  3366. nVisitorPicCnt = 0;
  3367. }
  3368. if (0 > nNoticeCnt) {
  3369. Log.w(TAG,"[getEventNotificationInfo] out of range!! nNoticeCnt [" + nNoticeCnt + "]");
  3370. nNoticeCnt = 0;
  3371. }
  3372. if (0 > nParcelCnt) {
  3373. Log.w(TAG,"[getEventNotificationInfo] out of range!! nParcelCnt [" + nParcelCnt + "]");
  3374. nParcelCnt = 0;
  3375. }
  3376. if (0 > nPostCnt) {
  3377. Log.w(TAG,"[getEventNotificationInfo] out of range!! nPostCnt [" + nPostCnt + "]");
  3378. nPostCnt = 0;
  3379. }
  3380. Log.d(TAG,"[getEventNotificationInfo] nMissedCallCnt [" + nMissedCallCnt + "], nVisitorPicCnt [" + nVisitorPicCnt + "], nNoticeCnt [" + nNoticeCnt + "], nParcelCnt [" + nParcelCnt + "], nPostCnt [" + nPostCnt + "]");
  3381. if (bSmartPostUsage) return nMissedCallCnt + define.DEVCTR_CMD_SPLITER + nVisitorPicCnt + define.DEVCTR_CMD_SPLITER + nNoticeCnt + define.DEVCTR_CMD_SPLITER + nParcelCnt + define.DEVCTR_CMD_SPLITER + nPostCnt;
  3382. else return nMissedCallCnt + define.DEVCTR_CMD_SPLITER + nVisitorPicCnt + define.DEVCTR_CMD_SPLITER + nNoticeCnt + define.DEVCTR_CMD_SPLITER + nParcelCnt;
  3383. } catch (RuntimeException re) {
  3384. LogUtil.errorLogInfo("", TAG, re);
  3385. return null;
  3386. }
  3387. catch (Exception e) {
  3388. Log.e(TAG, "[Exception] getEventNotificationInfo()");
  3389. LogUtil.errorLogInfo("", TAG, e);
  3390. return null;
  3391. }
  3392. }
  3393. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel) {
  3394. try {
  3395. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "]");
  3396. 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);
  3397. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3398. Intent mIntent = new Intent();
  3399. mIntent.setAction(define.NOTIFY_ACNAME);
  3400. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3401. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3402. getApplicationContext().sendBroadcast(mIntent);
  3403. } catch (RuntimeException re) {
  3404. LogUtil.errorLogInfo("", TAG, re);
  3405. }
  3406. catch (Exception e) {
  3407. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel)");
  3408. LogUtil.errorLogInfo("", TAG, e);
  3409. }
  3410. }
  3411. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post) {
  3412. try {
  3413. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "], post [" + post + "]");
  3414. 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);
  3415. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3416. Intent mIntent = new Intent();
  3417. mIntent.setAction(define.NOTIFY_ACNAME);
  3418. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3419. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3420. getApplicationContext().sendBroadcast(mIntent);
  3421. } catch (RuntimeException re) {
  3422. LogUtil.errorLogInfo("", TAG, re);
  3423. }
  3424. catch (Exception e) {
  3425. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post)");
  3426. LogUtil.errorLogInfo("", TAG, e);
  3427. }
  3428. }
  3429. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post, int elecvehiclecharging) {
  3430. try {
  3431. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "], post [" + post + "], elecvehiclecharging [" + elecvehiclecharging +"]");
  3432. String strResult = String.valueOf(missedcall) + define.DEVCTR_CMD_SPLITER + String.valueOf(visitorpic) + define.DEVCTR_CMD_SPLITER + String.valueOf(notice)
  3433. + define.DEVCTR_CMD_SPLITER + String.valueOf(parcel) + define.DEVCTR_CMD_SPLITER + String.valueOf(post) + define.DEVCTR_CMD_SPLITER + String.valueOf(elecvehiclecharging);
  3434. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3435. Intent mIntent = new Intent();
  3436. mIntent.setAction(define.NOTIFY_ACNAME);
  3437. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3438. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3439. getApplicationContext().sendBroadcast(mIntent);
  3440. } catch (RuntimeException re) {
  3441. LogUtil.errorLogInfo("", TAG, re);
  3442. }
  3443. catch (Exception e) {
  3444. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post, int elecvehiclecharging)");
  3445. LogUtil.errorLogInfo("", TAG, e);
  3446. }
  3447. }
  3448. private void CheckCallData_CalledCountAndVisitorCount() {
  3449. try {
  3450. int Vcount = 0;
  3451. int Ccount = 0;
  3452. try {
  3453. //DB정보 읽어서 처리
  3454. Log.d(TAG,"CheckCallData_CalledCountAndVisitorCount Start");
  3455. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3456. int TempCcount = mWallpadCallHistoryData.RowCallHistoryCountData();
  3457. mWallpadCallHistoryData.closeDB();
  3458. Log.d(TAG,"RowCallHistoryCountData() :" + TempCcount);
  3459. if (TempCcount != -999) {
  3460. Ccount = TempCcount;
  3461. }
  3462. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3463. int TempVcount = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3464. mWallpadVisitorPicData_A20.closeDB();
  3465. Log.d(TAG,"RowVisitorPictureCountData() :" + TempVcount);
  3466. if (TempVcount != -999) {
  3467. Vcount = TempVcount;
  3468. }
  3469. } catch (RuntimeException re) {
  3470. LogUtil.errorLogInfo("", TAG, re);
  3471. }
  3472. catch (Exception e) {
  3473. LogUtil.errorLogInfo("", TAG, e);
  3474. }
  3475. Log.d(TAG," Call Count Check Receive Ccount :" + Ccount + " , Photo Count : " + Vcount );
  3476. String Retdata = String.valueOf(Ccount)+define.DEVCTR_CMD_SPLITER+String.valueOf(Vcount);
  3477. Intent intent = new Intent();
  3478. intent.setAction(define.NOTIFY_ACNAME);
  3479. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3480. intent.putExtra(define.NOTIBR_CONTENT, Retdata);
  3481. getApplicationContext().sendBroadcast(intent);
  3482. } catch (RuntimeException re) {
  3483. LogUtil.errorLogInfo("", TAG, re);
  3484. }
  3485. catch (Exception e) {
  3486. Log.e(TAG, "[Exception] CheckCallData_CalledCountAndVisitorCount()");
  3487. LogUtil.errorLogInfo("", TAG, e);
  3488. }
  3489. }
  3490. class ScheduleManager {
  3491. public static final int SCHEDULE_TYPE_GETINFO = 5000;
  3492. public static final int SCHEDULE_TYPE_MORNINGCALL = 5001;
  3493. public static final int SCHEDULE_TYPE_SCHEDULER = 5002;
  3494. public static final int SCHEDULE_TYPE_SYSRESET = 5003;
  3495. public static final int SCHEDULE_TYPE_NONE = 5004;
  3496. public boolean isSetted = false;
  3497. List<TimeScheduleUnit> SchedulerData = new ArrayList<TimeScheduleUnit>();
  3498. List<TimeScheduleUnit> GeneralData = new ArrayList<TimeScheduleUnit>();
  3499. public ScheduleManager() {
  3500. }
  3501. public class TimeScheduleUnit {
  3502. int type;
  3503. Calendar TimeSet;
  3504. String message;
  3505. TimeScheduleUnit(int sctype, Calendar target) {
  3506. type = sctype;
  3507. TimeSet = target;
  3508. }
  3509. TimeScheduleUnit(int sctype, Calendar target, String msg) {
  3510. Log.i("MAINSCREEN","TimeScheduleUnit Create "+sctype+" : MSG : "+msg);
  3511. type = sctype;
  3512. TimeSet = target;
  3513. message = msg;
  3514. }
  3515. public boolean isOver() {
  3516. Calendar cal_now = new GregorianCalendar();
  3517. if (cal_now.after(TimeSet)) {
  3518. return true;
  3519. }
  3520. return false;
  3521. }
  3522. }
  3523. private void CheckSysResetData() {
  3524. try {
  3525. Calendar today = new GregorianCalendar();
  3526. Log.i("MAINSCREEN","CheckSysResetData Schedule");
  3527. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3528. String[] ResetData = WsDB.GetResetSchedule();
  3529. if (!ResetData[0].equals("NONE")) {
  3530. int type = Integer.parseInt(ResetData[0]);
  3531. Log.i("MAINSCREEN","CheckSysResetData Schedule check typr : "+type + " Week : "+today.get(Calendar.DAY_OF_WEEK)+" Set Week : "+ResetData[1]);
  3532. if ((type == WallpadStatusData.RESET_MONTH && today.get(Calendar.DAY_OF_MONTH)+1 == Integer.parseInt(ResetData[1])) ||
  3533. (type == WallpadStatusData.RESET_WEEK && today.get(Calendar.DAY_OF_WEEK) == (Integer.parseInt(ResetData[1]))+1) )
  3534. {
  3535. if (today.get(Calendar.HOUR_OF_DAY) == Integer.parseInt(ResetData[2]) && today.get(Calendar.MINUTE) < 2) {
  3536. SendAppFinishReqBR();
  3537. ComponentName cn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  3538. Intent intent = new Intent(Intent.ACTION_MAIN);
  3539. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  3540. intent.putExtra("updatesystem", "no");
  3541. intent.putExtra("updateapp", " no ");
  3542. intent.putExtra("rebootcmd", "reboot");
  3543. intent.setComponent(cn);
  3544. startActivity(intent);
  3545. }
  3546. }
  3547. }
  3548. WsDB.closeDB();
  3549. } catch (RuntimeException re) {
  3550. LogUtil.errorLogInfo("", TAG, re);
  3551. }
  3552. catch (Exception e) {
  3553. Log.e(TAG, "[Exception] CheckSysResetData()");
  3554. LogUtil.errorLogInfo("", TAG, e);
  3555. }
  3556. }
  3557. private boolean checkMorningCall() {
  3558. try {
  3559. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3560. int AlarmStatus = WsDB.GetAlarmStatus();
  3561. if (AlarmStatus != WallpadStatusData.ALARM_NONE && AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.ALARM_STOP) {
  3562. WsDB.closeDB();
  3563. return false;
  3564. }
  3565. Calendar today = new GregorianCalendar();
  3566. int MCStatus = WsDB.GetMorningCallStatus();
  3567. Log.i(TAG,"[checkMorningCall] GetMorningCallStatus : "+MCStatus);
  3568. if (MCStatus==WallpadStatusData.MORNINGCALL_ON) {
  3569. int MCPer = WsDB.GetMorningCallPeriod();
  3570. Log.i(TAG,"[checkMorningCall] GetMorningCallPeriod : "+MCPer);
  3571. int TodatofWeek = today.get(Calendar.DAY_OF_WEEK);
  3572. if ((MCPer == WallpadStatusData.MORNINGCALL_EWORKDAY && TodatofWeek != Calendar.SUNDAY) ||
  3573. (MCPer == WallpadStatusData.MORNINGCALL_WORKDAY && TodatofWeek!=Calendar.SUNDAY && TodatofWeek != Calendar.SATURDAY) ||
  3574. (MCPer == WallpadStatusData.MORNINGCALL_ONCE || MCPer == WallpadStatusData.MORNINGCALL_EVERYDAY )) {
  3575. Log.i(TAG,"[checkMorningCall] "+today.get(Calendar.HOUR_OF_DAY)+";"+WsDB.MorningHour + " -- " +today.get(Calendar.MINUTE)+":"+WsDB.MorningMin);
  3576. if (today.get(Calendar.HOUR_OF_DAY) == WsDB.MorningHour && today.get(Calendar.MINUTE) == WsDB.MorningMin) {
  3577. SendAppFinishReqBR();
  3578. mIOInterface.ctrlLcdWakeUp();
  3579. StartPopup(ID.POPUPS.POPUP_MORNINGCALL);
  3580. int[] MC_Doing = WsDB.GetMorningCallReserve();
  3581. if (MC_Doing != null && MC_Doing.length > 0) {
  3582. for (int k=0;k<MC_Doing.length;k++) {
  3583. switch (MC_Doing[k]) {
  3584. case WallpadStatusData.MCALLR_VENTIL_ON:
  3585. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  3586. break;
  3587. case WallpadStatusData.MCALLR_LIGHT_ON:
  3588. //에너지 미터인 경우 안방 조명을 켜도록 하고
  3589. //에너지 미터가 안 달린 경우 거실 조명을 켜도록 한다
  3590. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  3591. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3592. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3593. // 안방조명에 1번 조명만 제어하도록 한다
  3594. // 모닝콜이 울리면 일괄소등시나리오에 의해 일괄소등이 해제가 되겠네 ? 음.....이건 아닌데
  3595. // 모닝콜이 울리는 동안만 켜고 끄자 일괄소등 시나리오를 해제할까나? 그러면 팝업 화면에서 제어처리를?
  3596. Log.d(TAG, "[checkMorningCall] mSdbAPI Room 2 - Lamp 1 On");
  3597. if (mSdbAPI != null) {
  3598. int nResult = mSdbAPI.SetLightOnOff((byte) 0x01, (byte) 0x00, true);
  3599. Log.d(TAG, "[checkMorningCall] mSdbAPI nResult = " + nResult);
  3600. }
  3601. }
  3602. else if (Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  3603. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410) {
  3604. Log.d(TAG, "[checkMorningCall] mIntLightAPI Living Room - Lamp 1 On");
  3605. if (mIntLightAPI != null) {
  3606. int nResult = mIntLightAPI.LightControl((byte) 0x01, true);
  3607. Log.d(TAG, "[checkMorningCall] mIntLightAPI nResult = " + nResult);
  3608. }
  3609. }
  3610. else {
  3611. // 대외향 구분하여 처리
  3612. WallpadDeviceSet devDB = new WallpadDeviceSet( getApplicationContext() );
  3613. int[] retArray = devDB.Get_Light_info();
  3614. devDB.closeDB();
  3615. if (retArray!= null && retArray[0] == 1) {
  3616. if (retArray[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  3617. // 거실 스위치
  3618. if (m_LightCtrl != null) {
  3619. m_LightCtrl.Refresh(false);
  3620. m_LightCtrl.SetLightOnOff((byte)0x01, true);
  3621. }
  3622. }
  3623. else {
  3624. // 멀티 스위치
  3625. if (m_MultiSwitch != null) {
  3626. m_MultiSwitch.Refresh((byte)0x00, false);
  3627. if (m_MultiSwitch.data.DeviceCnt > 1) {
  3628. m_MultiSwitch.SetLightOnOff((byte)0x01 ,(byte)0x00 , true);
  3629. }
  3630. else if(m_MultiSwitch.data.DeviceCnt == 1) {
  3631. m_MultiSwitch.SetLightOnOff((byte)0x00 ,(byte)0x00 , true);
  3632. }
  3633. }
  3634. }
  3635. }
  3636. }
  3637. break;
  3638. case WallpadStatusData.MCALLR_CURTAIN_OPEN: //fill lather
  3639. break;
  3640. }
  3641. }
  3642. }
  3643. if (MCPer == WallpadStatusData.MORNINGCALL_ONCE) {
  3644. // Button morning = (Button)findViewById(R.id.top_alarm);
  3645. // morning.setVisibility(View.INVISIBLE);
  3646. WsDB.SetMorningCall(WallpadStatusData.MORNINGCALL_OFF, WsDB.MorningHour, WsDB.MorningMin);
  3647. }
  3648. }
  3649. }
  3650. }
  3651. WsDB.closeDB();
  3652. } catch (RuntimeException re) {
  3653. LogUtil.errorLogInfo("", TAG, re);
  3654. }
  3655. catch (Exception e) {
  3656. LogUtil.errorLogInfo("", TAG, e);
  3657. }
  3658. return false;
  3659. }
  3660. private void scheduleCheck()
  3661. {
  3662. try
  3663. {
  3664. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++");
  3665. Log.d("scheduleCheck", "Enter scheduleCheck "+GeneralData.size()+" : "+SchedulerData.size());
  3666. checkMorningCall();
  3667. if (GeneralData.size() > 0)
  3668. {
  3669. for (int i = 0;i < GeneralData.size(); i++)
  3670. {
  3671. TimeScheduleUnit scUnit = GeneralData.get(i);
  3672. if (scUnit.isOver())
  3673. {
  3674. switch (scUnit.type)
  3675. {
  3676. case SCHEDULE_TYPE_SYSRESET:
  3677. GeneralData.remove(scUnit);
  3678. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++ SCHEDULE_TYPE_SYSRESET");
  3679. SendAppFinishReqBR();
  3680. ComponentName cn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  3681. Intent intent = new Intent(Intent.ACTION_MAIN);
  3682. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  3683. intent.putExtra("updatesystem", "no");
  3684. intent.putExtra("updateapp", "no");
  3685. intent.putExtra("rebootcmd", "reboot");
  3686. intent.setComponent(cn);
  3687. startActivity(intent);
  3688. break;
  3689. case SCHEDULE_TYPE_GETINFO:
  3690. GeneralData.remove(scUnit);
  3691. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++ SCHEDULE_TYPE_GETINFO");
  3692. WallPadiMAPNotifyAPI notifyAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  3693. notifyAPI.ReqGetSet();
  3694. break;
  3695. }
  3696. }
  3697. }
  3698. Log.d("scheduleCheck", "after scheduleCheck "+GeneralData.size() );
  3699. }
  3700. }
  3701. catch (RuntimeException re) {
  3702. LogUtil.errorLogInfo("", TAG, re);
  3703. }
  3704. catch (Exception e)
  3705. {
  3706. LogUtil.errorLogInfo("", TAG, e);
  3707. }
  3708. }
  3709. public void doSchedule(String mess, int cnt)
  3710. {
  3711. // SendAppFinishReqBR();
  3712. // Intent intent = new Intent(getApplicationContext(), schedulepopup.class);
  3713. // String SendMSG = mess;
  3714. // if (cnt > 1) SendMSG+=(" 외 "+cnt+"건을 알려드립니다.");
  3715. // intent.putExtra("MESSAGE", SendMSG);
  3716. // Log.i("MAINSCREEN","Call Schedule POPUP");
  3717. // startActivity(intent);
  3718. }
  3719. public void refreshSchedulerData()
  3720. {
  3721. try
  3722. {
  3723. SchedulerData.clear();
  3724. WallpadScheduleData schedata = new WallpadScheduleData(getApplicationContext());
  3725. List<WallpadScheduleData.ScheduleData> scheduledata = schedata.GetTodaySchedule();
  3726. Log.i("MAINSCREEN","refreshSchedulerData "+scheduledata.size());
  3727. for(int i=0;i<scheduledata.size();i++)
  3728. {
  3729. WallpadScheduleData.ScheduleData ScUnit = scheduledata.get(i);
  3730. int hour;
  3731. int min;
  3732. Log.i("MAINSCREEN","refreshSchedulerData "+ScUnit.inqatype+" : "+ScUnit.inqhour+" : ");
  3733. if (ScUnit.inqatype.equals("no")) continue;
  3734. else if (ScUnit.inqatype.equals("intime")||ScUnit.inqatype.equals("day"))
  3735. {
  3736. hour = ScUnit.inqhour;
  3737. min = 0;
  3738. }
  3739. else if (ScUnit.inqatype.equals("hour"))
  3740. {
  3741. hour = ScUnit.inqhour-1;
  3742. if (hour < 0) continue;
  3743. min = 0;
  3744. }
  3745. else if (ScUnit.inqatype.equals("min"))
  3746. {
  3747. hour = ScUnit.inqhour-1;
  3748. if (hour < 0) continue;
  3749. min = 50;
  3750. }
  3751. else
  3752. continue;
  3753. Calendar today = new GregorianCalendar();
  3754. int MoonM = 0;
  3755. int MoonD = 0;
  3756. try
  3757. {
  3758. String Moon = schedata.GetLunarDate(String.format("%04d%02d%02d", today.get(Calendar.YEAR),today.get(Calendar.MONTH)+1,today.get(Calendar.DAY_OF_MONTH) ));
  3759. if(Moon!=null)
  3760. {
  3761. MoonM = Integer.parseInt(Moon.substring(4, 6));
  3762. MoonD = Integer.parseInt(Moon.substring(6, 8));
  3763. Log.i("MAINSCREEN", " Get Lunar Date "+Moon+" : "+MoonM+"/"+MoonD);
  3764. }
  3765. }
  3766. catch (RuntimeException re) {
  3767. LogUtil.errorLogInfo("", TAG, re);
  3768. }
  3769. catch (Exception e)
  3770. {
  3771. LogUtil.errorLogInfo("", TAG, e);
  3772. MoonM = 0;
  3773. MoonD = 0;
  3774. }
  3775. today.set(Calendar.HOUR_OF_DAY, hour);
  3776. today.set(Calendar.MINUTE, min);
  3777. 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;
  3778. Log.i("MAINSCREEN","refreshSchedulerData add "+ScUnit.inqatype+" : "+ScUnit.inqhour+" : "+Mesg);
  3779. TimeScheduleUnit newUnit = new TimeScheduleUnit(SCHEDULE_TYPE_SCHEDULER, today, Mesg);
  3780. isSetted = true;
  3781. SchedulerData.add(newUnit);
  3782. }
  3783. schedata.closeDB();
  3784. }
  3785. catch (RuntimeException re) {
  3786. LogUtil.errorLogInfo("", TAG, re);
  3787. }
  3788. catch (Exception e)
  3789. {
  3790. LogUtil.errorLogInfo("", TAG, e);
  3791. }
  3792. }
  3793. public void refreshMorningCall()
  3794. {
  3795. try
  3796. {
  3797. for (int i = 0; i < GeneralData.size(); i++)
  3798. {
  3799. TimeScheduleUnit scUnit = SchedulerData.get(i);
  3800. if (scUnit.type == SCHEDULE_TYPE_MORNINGCALL)
  3801. {
  3802. SchedulerData.remove(i);
  3803. break;
  3804. }
  3805. }
  3806. SetMorningCallData();
  3807. }
  3808. catch (RuntimeException re) {
  3809. LogUtil.errorLogInfo("", TAG, re);
  3810. }
  3811. catch (Exception e)
  3812. {
  3813. LogUtil.errorLogInfo("", TAG, e);
  3814. }
  3815. }
  3816. private void SetMorningCallData()
  3817. {
  3818. try
  3819. {
  3820. Log.i("MAINSCREEN","SetMorningCallData Schedule");
  3821. Calendar today = new GregorianCalendar();
  3822. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3823. int MCStatus = WsDB.GetMorningCallStatus();
  3824. if (MCStatus==WallpadStatusData.MORNINGCALL_ON)
  3825. {
  3826. int MCPer = WsDB.GetMorningCallPeriod();
  3827. int TodatofWeek = today.get(Calendar.DAY_OF_WEEK);
  3828. if ((MCPer == WallpadStatusData.MORNINGCALL_EWORKDAY && TodatofWeek != Calendar.SUNDAY) &&
  3829. (MCPer == WallpadStatusData.MORNINGCALL_WORKDAY && TodatofWeek!=Calendar.SUNDAY && TodatofWeek != Calendar.SATURDAY) &&
  3830. (MCPer == WallpadStatusData.MORNINGCALL_ONCE || MCPer == WallpadStatusData.MORNINGCALL_EVERYDAY ))
  3831. {
  3832. today.set(Calendar.HOUR_OF_DAY, WsDB.MorningHour);
  3833. today.set(Calendar.MINUTE, WsDB.MorningMin);
  3834. today.set(Calendar.SECOND, 0);
  3835. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_MORNINGCALL, today);
  3836. if (!scUnit.isOver())
  3837. {
  3838. isSetted = true;
  3839. // Button morning = (Button)findViewById(R.id.top_alarm);
  3840. // morning.setVisibility(View.VISIBLE);
  3841. GeneralData.add(scUnit);
  3842. }
  3843. else
  3844. {
  3845. // Button morning = (Button)findViewById(R.id.top_alarm);
  3846. // morning.setVisibility(View.INVISIBLE);
  3847. }
  3848. }
  3849. }
  3850. WsDB.closeDB();
  3851. }
  3852. catch (RuntimeException re) {
  3853. LogUtil.errorLogInfo("", TAG, re);
  3854. }
  3855. catch (Exception e)
  3856. {
  3857. LogUtil.errorLogInfo("", TAG, e);
  3858. }
  3859. }
  3860. public void refreshsysreset()
  3861. {
  3862. try
  3863. {
  3864. Log.i("MAINSCREEN","refreshsysreset Schedule");
  3865. for (int i = 0; i < GeneralData.size(); i++)
  3866. {
  3867. TimeScheduleUnit scUnit = SchedulerData.get(i);
  3868. if (scUnit.type == SCHEDULE_TYPE_SYSRESET)
  3869. {
  3870. SchedulerData.remove(i);
  3871. break;
  3872. }
  3873. }
  3874. SetSysResetData();
  3875. }
  3876. catch (RuntimeException re) {
  3877. LogUtil.errorLogInfo("", TAG, re);
  3878. }
  3879. catch (Exception e)
  3880. {
  3881. LogUtil.errorLogInfo("", TAG, e);
  3882. }
  3883. }
  3884. private void SetSysResetData()
  3885. {
  3886. try
  3887. {
  3888. Calendar today = new GregorianCalendar();
  3889. Log.i("MAINSCREEN","SetSysResetData Schedule");
  3890. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3891. String[] ResetData = WsDB.GetResetSchedule();
  3892. if (!ResetData[0].equals("NONE"))
  3893. {
  3894. int type = Integer.parseInt(ResetData[0]);
  3895. if ((type == WallpadStatusData.RESET_MONTH && today.get(Calendar.DAY_OF_MONTH) == Integer.parseInt(ResetData[1])) ||
  3896. (type == WallpadStatusData.RESET_WEEK && today.get(Calendar.DAY_OF_WEEK) == Integer.parseInt(ResetData[1])) )
  3897. {
  3898. Log.i("MAINSCREEN","SetSysResetData Setted");
  3899. today.set(Calendar.HOUR_OF_DAY, Integer.parseInt(ResetData[2]));
  3900. today.set(Calendar.MINUTE, 0);
  3901. today.set(Calendar.SECOND, 0);
  3902. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_SYSRESET, today);
  3903. if (!scUnit.isOver())
  3904. {
  3905. isSetted = true;
  3906. GeneralData.add(scUnit);
  3907. }
  3908. }
  3909. }
  3910. WsDB.closeDB();
  3911. }
  3912. catch (RuntimeException re) {
  3913. LogUtil.errorLogInfo("", TAG, re);
  3914. }
  3915. catch (Exception e)
  3916. {
  3917. LogUtil.errorLogInfo("", TAG, e);
  3918. }
  3919. }
  3920. public void refreshSchedule()
  3921. {
  3922. try
  3923. {
  3924. Log.i("MAINSCREEN","Refresh Schedule");
  3925. GeneralData.clear();
  3926. Calendar today = new GregorianCalendar();
  3927. // 하루에 한번 가져오는 걸로 변경함
  3928. //if (today.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY)
  3929. {
  3930. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  3931. AddressSet addc = SetData.getAddressMGR();
  3932. SetData.closeDB();
  3933. int dong = Integer.parseInt(addc.Dong);
  3934. int ho = 101;
  3935. if(addc.UseOrNotRentHouse == true)
  3936. {
  3937. ho = addc.Ho_Integer;
  3938. }
  3939. else
  3940. {
  3941. ho = Integer.parseInt(addc.Ho);
  3942. }
  3943. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  3944. int hour;
  3945. int min;
  3946. int sec;
  3947. if (interval/3600 > 0)
  3948. {
  3949. hour = 3+interval/3600;
  3950. interval=interval%3600;
  3951. }
  3952. else hour = 3;
  3953. if (interval/60 > 0)
  3954. {
  3955. min = interval/60;
  3956. sec = interval%60;
  3957. }
  3958. else
  3959. {
  3960. min = 0;
  3961. sec = interval;
  3962. }
  3963. today.set(Calendar.HOUR_OF_DAY, hour);
  3964. today.set(Calendar.MINUTE, min);
  3965. today.set(Calendar.SECOND, sec);
  3966. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_GETINFO, today);
  3967. if (!scUnit.isOver())
  3968. GeneralData.add(scUnit);
  3969. }
  3970. SetMorningCallData();
  3971. SetSysResetData();
  3972. refreshSchedulerData();
  3973. }
  3974. catch (RuntimeException re) {
  3975. LogUtil.errorLogInfo("", TAG, re);
  3976. }
  3977. catch (Exception e)
  3978. {
  3979. LogUtil.errorLogInfo("", TAG, e);
  3980. }
  3981. }
  3982. }
  3983. class runCallServices extends Thread {
  3984. public runCallServices() {
  3985. super();
  3986. }
  3987. public void run() {
  3988. try {
  3989. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  3990. if (getIsSubWallpad()) {
  3991. Log.w(TAG, "[runCallServices.run()] ############### This wallpad is set as a sub-wallpad ###############");
  3992. Intent SubWallpadServiceLauncher = new Intent ("kr.co.icontrols.callengine.subwallpad.SubWallPadSerialManager.StartService");
  3993. getApplicationContext().startService(SubWallpadServiceLauncher);
  3994. }
  3995. else {
  3996. Log.w(TAG, "[runCallServices.run()] ############### This wallpad is set as a main-wallpad ###############");
  3997. // SIP/Subphone 서비스 실행
  3998. Intent SIPServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  3999. getApplicationContext().startService(SIPServiceLauncher);
  4000. Intent SubPhoneServiceLauncher = new Intent ("kr.co.icontrols.callengine.subphone.SubPhoneSerialManager.StartService");
  4001. getApplicationContext().startService(SubPhoneServiceLauncher);
  4002. if (GetRemoteCallUseInfo()) {
  4003. Intent remoteCallServiceLauncher = new Intent ("kr.co.icontrols.callengine.remotecall.RemoteCallManager.StartService");
  4004. getApplicationContext().startService(remoteCallServiceLauncher);
  4005. }
  4006. }
  4007. }
  4008. else {
  4009. int nModelType = Version.getModelType();
  4010. if (nModelType == MODEL_TYPE.IHN_750) {
  4011. // SIP 서비스만 실행
  4012. Intent sipServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  4013. getApplicationContext().startService(sipServiceLauncher);
  4014. }
  4015. else {
  4016. // SIP/PSTN/Subphone 서비스 실행
  4017. Intent sipServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  4018. getApplicationContext().startService(sipServiceLauncher);
  4019. Intent PSTNServiceLauncher = new Intent ("kr.co.icontrols.callengine.pstn.PSTNSerialManager.StartService");
  4020. getApplicationContext().startService(PSTNServiceLauncher);
  4021. Intent SubPhoneServiceLauncher = new Intent ("kr.co.icontrols.callengine.subphone.SubPhoneSerialManager.StartService");
  4022. getApplicationContext().startService(SubPhoneServiceLauncher);
  4023. }
  4024. }
  4025. } catch (RuntimeException re) {
  4026. LogUtil.errorLogInfo("", TAG, re);
  4027. }
  4028. catch (Exception e) {
  4029. Log.e(TAG, "[Exception] runCallServices().run()");
  4030. LogUtil.errorLogInfo("", TAG, e);
  4031. }
  4032. }
  4033. }
  4034. // 방문객원격통화 솔루션 사용여부 판별
  4035. private boolean GetRemoteCallUseInfo() {
  4036. try {
  4037. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  4038. if (mWallpadDeviceSet != null) {
  4039. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  4040. if (astrRemoteCall != null) {
  4041. if (astrRemoteCall[1].contains("사용함"))
  4042. return true;
  4043. } else {
  4044. Log.d(TAG, "[GetRemoteCallUseInfo] astrRemoteCall is null!!");
  4045. }
  4046. }
  4047. mWallpadDeviceSet.closeDB();
  4048. } catch (RuntimeException re) {
  4049. LogUtil.errorLogInfo("", TAG, re);
  4050. }
  4051. catch (Exception e) {
  4052. Log.e(TAG, "[Exception] GetRemoteCallUseInfo()");
  4053. LogUtil.errorLogInfo("", TAG, e);
  4054. }
  4055. return false;
  4056. }
  4057. int UNINSTALL_REQUEST_CODE = 1;
  4058. private void uninstallAnCCallApp(String strAPK) {
  4059. try {
  4060. Log.w(TAG, "[uninstallAnCCallApp] strAPK [" + strAPK + "]");
  4061. if (checkAppInstalled(strAPK)) {
  4062. // Intent mIntent = new Intent(Intent.ACTION_DELETE);
  4063. Intent mIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
  4064. mIntent.setData(Uri.parse("package:" + strAPK));
  4065. mIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
  4066. startActivityForResult(mIntent, UNINSTALL_REQUEST_CODE);
  4067. }
  4068. else {
  4069. Log.w(TAG, "[uninstallAnCCallApp] Not installed [" + strAPK + "]");
  4070. }
  4071. } catch (RuntimeException re) {
  4072. LogUtil.errorLogInfo("", TAG, re);
  4073. }
  4074. catch (Exception e) {;
  4075. Log.e(TAG, "[Exception] uninstallAnCCallApp()");
  4076. LogUtil.errorLogInfo("", TAG, e);
  4077. }
  4078. }
  4079. private boolean checkAppInstalled(String strAPK) {
  4080. try {
  4081. PackageManager mPackageManager = getPackageManager();
  4082. try {
  4083. mPackageManager.getPackageInfo(strAPK, PackageManager.GET_ACTIVITIES);
  4084. return true;
  4085. } catch (PackageManager.NameNotFoundException pne) {
  4086. Log.w(TAG, "[checkAppInstalled] No Package [" + strAPK + "]");
  4087. }
  4088. return false;
  4089. } catch (RuntimeException re) {
  4090. LogUtil.errorLogInfo("", TAG, re);
  4091. return false;
  4092. }
  4093. catch (Exception e) {
  4094. Log.e(TAG, "[Exception] checkAppInstalled(String strAPK)");
  4095. LogUtil.errorLogInfo("", TAG, e);
  4096. return false;
  4097. }
  4098. }
  4099. private boolean MainSubScreenLoadingComplite = false;
  4100. public boolean getMainSubScreenLoadingComplite() {
  4101. return MainSubScreenLoadingComplite;
  4102. }
  4103. /**
  4104. * 설치된 모든 어플의 이름/버전정보 Version DB에 저장하는 쓰레드. <br>
  4105. * main Activity 생성 시 최초 1회 실행 후 die
  4106. */
  4107. class getInstalledPackageInfo extends Thread {
  4108. @Override
  4109. public void run() {
  4110. super.run();
  4111. try {
  4112. Log.d(TAG, "[getInstalledPackageInfo] Started getting installed package infomation");
  4113. ArrayList<PackageVersionInfo> PackageVersionInfos = new ArrayList<PackageVersionInfo>();
  4114. List<PackageInfo> PackageInfoList = getPackageManager().getInstalledPackages(PackageManager.PERMISSION_GRANTED);
  4115. while (true) {
  4116. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages start!!");
  4117. try {
  4118. for (PackageInfo pack : PackageInfoList) {
  4119. Log.d(TAG, "# PackageName : " + pack.packageName);
  4120. Log.d(TAG, "# VersionName : " + pack.versionName);
  4121. if ((pack.packageName.contains("icontrols")) || (pack.packageName.contains("artncore")) || (pack.packageName.contains("dadam"))) {
  4122. PackageVersionInfos.add(new PackageVersionInfo(pack.packageName, pack.versionName));
  4123. }
  4124. }
  4125. } catch (RuntimeException re) {
  4126. LogUtil.errorLogInfo("", TAG, re);
  4127. break;
  4128. }
  4129. catch (Exception e) {
  4130. LogUtil.errorLogInfo("", TAG, e);
  4131. break;
  4132. }
  4133. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages end!!");
  4134. break;
  4135. }
  4136. Log.d(TAG, "[getInstalledPackageInfo.run()] Save installed packages start!!");
  4137. wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  4138. if (PackageVersionInfos != null) {
  4139. for (int i = 0; i < PackageVersionInfos.size(); i++) {
  4140. WallpadDBMGR.UpdateVersionData(PackageVersionInfos.get(i).getPackageName(), PackageVersionInfos.get(i).getPackageVersion());
  4141. }
  4142. }
  4143. WallpadDBMGR.closeDB();
  4144. Log.d(TAG, "[getInstalledPackageInfo.run()] Save installed packages end!!");
  4145. try {
  4146. Thread.sleep(1500);
  4147. } catch (RuntimeException re) {
  4148. LogUtil.errorLogInfo("", TAG, re);
  4149. }
  4150. catch (Exception e) {
  4151. LogUtil.errorLogInfo("", TAG, e);
  4152. }
  4153. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  4154. try {
  4155. Thread.sleep(1000);
  4156. } catch (RuntimeException re) {
  4157. LogUtil.errorLogInfo("", TAG, re);
  4158. }
  4159. catch (Exception e) {
  4160. LogUtil.errorLogInfo("", TAG, e);
  4161. }
  4162. }
  4163. runOnUiThread(new Runnable() {
  4164. @Override
  4165. public void run() {
  4166. registerSubScreen();
  4167. }
  4168. });
  4169. try
  4170. {
  4171. WallpadScheduleData schedb = new WallpadScheduleData(getApplicationContext());
  4172. boolean bLunarTableExist = schedb.CheckLunarTable();
  4173. schedb.closeDB();
  4174. if (!bLunarTableExist) {
  4175. try {
  4176. Log.d(TAG, "DB File Copy Start");
  4177. copyDataBase(wallpaddbmgr.dblocation + "/" + wallpaddbmgr.Schedule_LunaDB);
  4178. Log.d(TAG, "DB File Copy End");
  4179. } catch (IOException e) {
  4180. LogUtil.errorLogInfo("", TAG, e);
  4181. }
  4182. }
  4183. } catch (RuntimeException re) {
  4184. LogUtil.errorLogInfo("", TAG, re);
  4185. }
  4186. catch (Exception e) {
  4187. LogUtil.errorLogInfo("", TAG, e);
  4188. }
  4189. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) checkDongHoSetting();
  4190. checkDongHoSetting();
  4191. if (Common.GetElevatorSampleMode(getApplicationContext())) {
  4192. int retCount = EnergyAlramPopupMgr.get_WallPadRebootingCount( getApplicationContext()) + 1;
  4193. EnergyAlramPopupMgr.set_WallPadRebootingCount(getApplicationContext(), retCount);
  4194. Log.d(TAG, "################################# rebooting Count : " + retCount );
  4195. }
  4196. // 하드웨어 키 샘플 모드 동작 여부 설정
  4197. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  4198. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  4199. sdata.closeDB();
  4200. WallPadInterface wpdifc = new WallPadInterface();
  4201. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  4202. wpdifc.DoControl(WallPadInterface.IOCTL_KEY_ONOFF_SET, 0);
  4203. CheckEnv();
  4204. }
  4205. catch (RuntimeException re) {
  4206. LogUtil.errorLogInfo("", TAG, re);
  4207. }
  4208. catch (Exception e)
  4209. {
  4210. LogUtil.errorLogInfo("", TAG, e);
  4211. }
  4212. try {Thread.sleep(5000);}
  4213. catch (RuntimeException re) {
  4214. LogUtil.errorLogInfo("", TAG, re);
  4215. MainSubScreenLoadingComplite = true;
  4216. }
  4217. catch (Exception e){LogUtil.errorLogInfo("", TAG, e);}
  4218. MainSubScreenLoadingComplite = true;
  4219. }
  4220. }
  4221. public static String DB_WALLPAD_WIDGET_INIT = "DB_WALLPAD_WIDGET_INIT";
  4222. public void set_WallPadWidgetInit(Context context) {
  4223. try {
  4224. wallpaddbmgr mgr = new wallpaddbmgr(context);
  4225. boolean bRet = mgr.UpdateWallPADData(DB_WALLPAD_WIDGET_INIT, String.valueOf(1));
  4226. if (bRet == false ) {
  4227. Log.d(TAG, "----- DB_WALLPAD_WIDGET_INIT insert ==> false ");
  4228. mgr.insertWallPADDB(DB_WALLPAD_WIDGET_INIT, "1");
  4229. }
  4230. mgr.closeDB();
  4231. } catch (RuntimeException re) {
  4232. LogUtil.errorLogInfo("", TAG, re);
  4233. }
  4234. catch (Exception e) {
  4235. LogUtil.errorLogInfo("", TAG, e);
  4236. }
  4237. }
  4238. public int get_WallPadWidgetInit(Context context) {
  4239. int ret = 0;
  4240. try {
  4241. wallpaddbmgr mgr = new wallpaddbmgr(context);
  4242. String strRet = mgr.GetWallPADData(DB_WALLPAD_WIDGET_INIT);
  4243. if (strRet == null) {
  4244. Log.d(TAG, "----- get_WallPadRebootingCount strRet == null && insert ==> false ");
  4245. mgr.insertWallPADDB(DB_WALLPAD_WIDGET_INIT, "0");
  4246. return 0;
  4247. }
  4248. ret = Integer.parseInt(strRet);
  4249. mgr.closeDB();
  4250. } catch (RuntimeException re) {
  4251. LogUtil.errorLogInfo("", TAG, re);
  4252. }
  4253. catch (Exception e) {
  4254. LogUtil.errorLogInfo("", TAG, e);
  4255. }
  4256. return ret;
  4257. }
  4258. /**
  4259. * 스케줄 관련 처리 핸들러 추가
  4260. * 모닝콜, 일정관리, 엘리베이터 호출상태, 에너지 사용량 확인
  4261. * 현재는 사용하지 않음. checkTimeTasks()로 대체
  4262. */
  4263. private int nDay, nHour, nMin;
  4264. Handler Checker = new Handler() {
  4265. public void handleMessage(Message msg) {
  4266. super.handleMessage(msg);
  4267. Calendar cal = new GregorianCalendar();
  4268. if (cal.get(Calendar.DAY_OF_MONTH) != nDay) {
  4269. // 날짜가 바뀌었을때...
  4270. nDay = cal.get(Calendar.DAY_OF_MONTH);
  4271. Log.d(TAG , "-----------------day change repeat");
  4272. if (SCManager != null) {
  4273. if (SYSTEM_TIME_SET)SCManager.refreshSchedule();
  4274. }
  4275. //
  4276. // Intent intent = new Intent();
  4277. // intent.setAction(define.NOTIFY_ACNAME);
  4278. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DAYCHANGED);
  4279. // getApplicationContext().sendBroadcast(intent);
  4280. //에너지사용량 알림 초기화
  4281. ClearEnergyUsage();
  4282. Log.d(TAG , "cal.get(Calendar.YEAR) :" + cal.get(Calendar.YEAR) );
  4283. if ((bUseofNot_ZeroEnergyHouseInfo == true) && (cal.get(Calendar.YEAR) > 2016) && (SYSTEM_TIME_SET == true)) {
  4284. //어제 시간 재입력
  4285. Log.d(TAG , "/**********************************************/");
  4286. Log.d(TAG , "GetZeroEnergyHouseInfo_RandomCheckHandler(true);");
  4287. Log.d(TAG , "/**********************************************/");
  4288. DayofLastSecond = StringUtil.GetDayofLastSecondTimeString(cal); //하루전 날짜의 마지막 시간 입력
  4289. Log.d(TAG , "DayofLastSecond : "+ DayofLastSecond);
  4290. }
  4291. }
  4292. if (cal.get(Calendar.HOUR_OF_DAY) != nHour) {
  4293. nHour = cal.get(Calendar.HOUR_OF_DAY);
  4294. DoScheduleHourUnit(cal);
  4295. }
  4296. if (cal.get(Calendar.MINUTE) != nMin) {
  4297. nMin = cal.get(Calendar.MINUTE);
  4298. /**
  4299. * A20월패드 BSP는 전자액자 실행을 시키지 않기때문에 main app에서 전자액자 실행 여부 확인하여
  4300. * 실행시킴
  4301. * **/
  4302. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A20) {
  4303. Log.i(TAG, "[Checker handler] ========== JEFF 1 ========== m_LiveMainActivity : " + m_LiveMainActivity);
  4304. if (m_LiveMainActivity > 0) {
  4305. String LCD_Sleep_Status = null;
  4306. Runtime runtime = Runtime.getRuntime();
  4307. Process process;
  4308. try {
  4309. String cmd = "getprop persist.sys.display.lcdoff";
  4310. process = runtime.exec(cmd);
  4311. BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
  4312. String line;
  4313. while ((line = br.readLine()) != null) {
  4314. LCD_Sleep_Status = line;
  4315. }
  4316. } catch (RuntimeException re) {
  4317. LogUtil.errorLogInfo("", TAG, re);
  4318. }
  4319. catch (Exception e) {
  4320. e.fillInStackTrace();
  4321. Log.e("Process Manager", "Unable to execute top command");
  4322. }
  4323. if (LCD_Sleep_Status != null) {
  4324. Log.d(TAG, "The LCD_Sleep_Status : " + LCD_Sleep_Status);
  4325. if (LCD_Sleep_Status.equals("1") == true) {
  4326. // LCD 꺼져있음
  4327. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4328. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4329. if (SettData.StartAutoPictureAPP() == true) {
  4330. Log.d(TAG, "StartAutoPictureAPP is true");
  4331. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  4332. // pm.userActivity(2, true);
  4333. // LCD backlight normal
  4334. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4335. Log.d(TAG, "PowerManager will be set");
  4336. }
  4337. else {
  4338. Log.d(TAG, "StartAutoPictureAPP is false");
  4339. }
  4340. }
  4341. else {
  4342. Log.d(TAG, "DecideAutoPictureAppStartOrNot is false");
  4343. }
  4344. SettData.closeDB();
  4345. }
  4346. }
  4347. else {
  4348. Log.e(TAG, "The LCD_Sleep_Status is null");
  4349. }
  4350. }
  4351. }
  4352. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  4353. Log.i(TAG, "[Checker handler] ========== JEFF 2 ========== m_LiveMainActivity : " + m_LiveMainActivity);
  4354. if (m_LiveMainActivity > 0) {
  4355. boolean bisScreenOn = false;
  4356. if (getCompareBSPVersion()) {
  4357. bisScreenOn = checkLCDOnByCMD();
  4358. }
  4359. else {
  4360. PowerManager mPowerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
  4361. bisScreenOn = mPowerManager.isScreenOn();
  4362. }
  4363. Log.i(TAG, "[Checker handler] bisScreenOn : " + bisScreenOn);
  4364. if (!bisScreenOn) {
  4365. if (getBlackoutStatus()) {
  4366. Log.i(TAG, "[Checker handler] getBlackoutStatus is true!!!");
  4367. sendBlackoutScreenRunBR();
  4368. }
  4369. else {
  4370. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4371. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4372. if (SettData.StartAutoPictureAPP() == true) {
  4373. Log.d(TAG, "StartAutoPictureAPP is true");
  4374. mIOInterface.ctrlLcdWakeUp();
  4375. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4376. Log.d(TAG, "PowerManager will be set");
  4377. }
  4378. else {
  4379. Log.d(TAG, "StartAutoPictureAPP is false");
  4380. }
  4381. }
  4382. else {
  4383. Log.d(TAG, "DecideAutoPictureAppStartOrNot is false");
  4384. }
  4385. SettData.closeDB();
  4386. }
  4387. }
  4388. }
  4389. }
  4390. if ((nMin == 50) || (nMin == 0)) {
  4391. try {
  4392. checkScheduleReminder();
  4393. } catch (RuntimeException re) {
  4394. LogUtil.errorLogInfo("", TAG, re);
  4395. }
  4396. catch (Exception e) {
  4397. LogUtil.errorLogInfo("", TAG, e);
  4398. }
  4399. // 스케줄 일정 알람 팝업을 띄우도록 한다.
  4400. // Intent intent = new Intent(getApplicationContext(), schedulepopup.class);
  4401. // String SendMSG = doSchedule.get(0).inqmsg;
  4402. // if (doSchedule.size() > 1) SendMSG+=(" 외 "+doSchedule.size()+"건을 알려드립니다.");
  4403. // intent.putExtra("MESSAGE", SendMSG);
  4404. //
  4405. // startActivity(intent);
  4406. }
  4407. if (SCManager != null) SCManager.scheduleCheck();
  4408. //CheckElevator();
  4409. if (MAX_BOOTUP_RETRY_COUNT < bootupretryCNT && SYSTEM_TIME_SET == false) {
  4410. try {
  4411. WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4412. iMAPMethod.ReqGetSet();
  4413. } catch (RuntimeException re) {
  4414. LogUtil.errorLogInfo("", TAG, re);
  4415. }
  4416. catch (Exception e) {
  4417. LogUtil.errorLogInfo("", TAG, e);
  4418. }
  4419. }
  4420. // 중복.... 이게 왜 있는겨....
  4421. // if ( cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY && SYSTEM_TIME_SET && cal.get(Calendar.DAY_OF_MONTH)!=LastTimeSync)
  4422. // {
  4423. // Calendar checktime = GetTimeSyncTime();
  4424. // if (checktime != null)
  4425. // {
  4426. // if (cal.after(checktime))
  4427. // {
  4428. // LastTimeSync = cal.get(Calendar.DAY_OF_MONTH);
  4429. // WallpadStatusData wpd = new WallpadStatusData(getApplicationContext());
  4430. // wpd.SetLastTimeSyncDate(LastTimeSync);
  4431. // wpd.closeDB();
  4432. // WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4433. // iMAPMethod.ReqGetSet();
  4434. // }
  4435. // }
  4436. // }
  4437. //주차정보 관련 20분 마다 얻어오기
  4438. if (bUseofNot_ParkingInfo == true) {
  4439. cGetParkingMin++;
  4440. //테스트
  4441. /*
  4442. bSetMSG_GetParkingInfo = true;
  4443. LoadParkingDataFromServer();
  4444. */
  4445. if (cGetParkingMin >= 20) {
  4446. // 20분으로 고정
  4447. cGetParkingMin = 0;
  4448. //아이콘트롤스 일때도 처리하지 않도록 수정필요
  4449. //넥스파인 경우는 협의후 처리
  4450. switch (nParkingSystemType) {
  4451. case Common.PARKING_SYSTEM_ICONTROLS:
  4452. case Common.PARKING_SYSTEM_NEXPA:
  4453. case Common.PARKING_SYSTEM_UPIS:
  4454. case Common.PARKING_SYSTEM_IES_100:
  4455. break;
  4456. case Common.PARKING_SYSTEM_BASIC:
  4457. case Common.PARKING_SYSTEM_ETC:
  4458. GetParkingInfo_RandomCheckHandler(); //주차 정보 얻어오기
  4459. break;
  4460. default:
  4461. break;
  4462. }
  4463. }
  4464. }
  4465. // 필요없는 코드 삭제 ( yskim 2015.03.31 )
  4466. // String checkDate = String.format("%04d%02d%02d",cal.get(Calendar.YEAR),cal.get(Calendar.MONTH)+1,cal.get(Calendar.DAY_OF_MONTH));
  4467. // WallpadStatusData energyData = new WallpadStatusData(getApplicationContext());
  4468. // String EnergyCheckData = energyData.GetEnergyCheckDate();
  4469. // energyData.closeDB();
  4470. // if (SYSTEM_TIME_SET)
  4471. // {
  4472. // Calendar checktime = GetEnergyDataLoadingTime();
  4473. // if (!checkDate.equals(EnergyCheckData))
  4474. // {
  4475. // if (checktime != null)
  4476. // {
  4477. //
  4478. // if (cal.after(checktime))
  4479. // {
  4480. // WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4481. // iMAPMethod.GetEnergyUsage();
  4482. // WallPadiMAPNotifyAPI iMAPMethod2 = new WallPadiMAPNotifyAPI(getApplicationContext());
  4483. // iMAPMethod2.GetEnergyUsageMonth();
  4484. // }
  4485. // }
  4486. // }
  4487. // }
  4488. }
  4489. // checkMainPage();
  4490. Checker.sendEmptyMessageDelayed(0, 1000);
  4491. }
  4492. };
  4493. /**
  4494. * JEFF, 2019.12.25
  4495. * 매 1초마다 실행되면서 스케쥴 확인하여 각 기능을 동작시킨다 (시간업데이트, 전자액자 등)
  4496. */
  4497. Handler handlerEverySecond = new Handler() {
  4498. public void handleMessage(Message msg) {
  4499. super.handleMessage(msg);
  4500. checkTimeTasks();
  4501. handlerEverySecond.sendEmptyMessageDelayed(0, 1000);
  4502. }
  4503. };
  4504. private void checkTimeTasks() {
  4505. try {
  4506. // Log.d(TAG , "[checkTimeTasks] ===== START =====");
  4507. Calendar cal = new GregorianCalendar();
  4508. if (cal.get(Calendar.DAY_OF_MONTH) != nDay) {
  4509. // 날짜 변경시
  4510. Log.d(TAG , "[checkTimeTasks] day changed!!");
  4511. nDay = cal.get(Calendar.DAY_OF_MONTH);
  4512. if (SCManager != null) {
  4513. if (SYSTEM_TIME_SET) SCManager.refreshSchedule();
  4514. }
  4515. else {
  4516. Log.w(TAG , "[checkTimeTasks] SYSTEM_TIME_SET is null!!");
  4517. }
  4518. // 모바일연동 서비스로 원격검침 데이터를 전송
  4519. // getTelemeteringDataOnRandomTime();
  4520. // // 에너지사용량 알림 초기화
  4521. // ClearEnergyUsage();
  4522. Log.d(TAG , "[checkTimeTasks] Calendar.YEAR = " + cal.get(Calendar.YEAR) );
  4523. if ((bUseofNot_ZeroEnergyHouseInfo == true) && (cal.get(Calendar.YEAR) > 2016) && (SYSTEM_TIME_SET == true)) {
  4524. //어제 시간 재입력
  4525. Log.i(TAG , "[checkTimeTasks] GetZeroEnergyHouseInfo_RandomCheckHandler(true);");
  4526. DayofLastSecond = StringUtil.GetDayofLastSecondTimeString(cal); //하루전 날짜의 마지막 시간 입력
  4527. Log.d(TAG , "[checkTimeTasks] DayofLastSecond : "+ DayofLastSecond);
  4528. }
  4529. }
  4530. if (cal.get(Calendar.HOUR_OF_DAY) != nHour) {
  4531. nHour = cal.get(Calendar.HOUR_OF_DAY);
  4532. // 원격검침 데이터를 서버로부터 가져와 관련 기능모듈에 알린다.
  4533. getTelemeteringDataOnRandomTime();
  4534. DoScheduleHourUnit(cal);
  4535. }
  4536. if (getBlackoutStatus()) {
  4537. Log.i(TAG, "[checkTimeTasks] getBlackoutStatus is true!!!");
  4538. sendBlackoutScreenRunBR();
  4539. }
  4540. if (cal.get(Calendar.MINUTE) != nMin) {
  4541. nMin = cal.get(Calendar.MINUTE);
  4542. /**
  4543. * main app에서 전자액자 실행 여부 확인하여 실행시킴
  4544. * **/
  4545. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  4546. Log.i(TAG, "[checkTimeTasks] m_LiveMainActivity : " + m_LiveMainActivity);
  4547. if (m_LiveMainActivity > 0) {
  4548. boolean bScreenOn = false;
  4549. if (getCompareBSPVersion()) {
  4550. bScreenOn = checkLCDOnByCMD();
  4551. }
  4552. else {
  4553. PowerManager mPowerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
  4554. bScreenOn = mPowerManager.isScreenOn();
  4555. }
  4556. Log.i(TAG, "[checkTimeTasks] bScreenOn : " + bScreenOn);
  4557. if (!bScreenOn && !getBlackoutStatus()) {
  4558. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4559. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4560. if (SettData.StartAutoPictureAPP() == true) {
  4561. Log.d(TAG, "[checkTimeTasks] StartAutoPictureAPP() is true");
  4562. mIOInterface.ctrlLcdWakeUp();
  4563. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4564. Log.d(TAG, "[checkTimeTasks] PowerManager will be set");
  4565. }
  4566. else {
  4567. Log.d(TAG, "[checkTimeTasks] StartAutoPictureAPP() is false");
  4568. }
  4569. }
  4570. else {
  4571. Log.d(TAG, "[checkTimeTasks] DecideAutoPictureAppStartOrNot(...) is false");
  4572. }
  4573. SettData.closeDB();
  4574. }
  4575. }
  4576. }
  4577. if ((nMin == 50) || (nMin == 0)) {
  4578. try {
  4579. checkScheduleReminder();
  4580. } catch (RuntimeException re) {
  4581. LogUtil.errorLogInfo("", TAG, re);
  4582. }
  4583. catch (Exception e) {
  4584. LogUtil.errorLogInfo("", TAG, e);
  4585. }
  4586. }
  4587. if (SCManager != null) SCManager.scheduleCheck();
  4588. if (MAX_BOOTUP_RETRY_COUNT < bootupretryCNT && SYSTEM_TIME_SET == false) {
  4589. try {
  4590. WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4591. iMAPMethod.ReqGetSet();
  4592. } catch (RuntimeException re) {
  4593. LogUtil.errorLogInfo("", TAG, re);
  4594. }
  4595. catch (Exception e) {
  4596. LogUtil.errorLogInfo("", TAG, e);
  4597. }
  4598. }
  4599. //주차정보 관련 20분 마다 얻어오기
  4600. if (bUseofNot_ParkingInfo == true) {
  4601. cGetParkingMin++;
  4602. //테스트
  4603. /*
  4604. bSetMSG_GetParkingInfo = true;
  4605. LoadParkingDataFromServer();
  4606. */
  4607. if (cGetParkingMin >= 20) {
  4608. // 20분으로 고정
  4609. cGetParkingMin = 0;
  4610. //아이콘트롤스 일때도 처리하지 않도록 수정필요
  4611. //넥스파인 경우는 협의후 처리
  4612. switch(nParkingSystemType) {
  4613. case Common.PARKING_SYSTEM_ICONTROLS:
  4614. case Common.PARKING_SYSTEM_NEXPA:
  4615. case Common.PARKING_SYSTEM_UPIS:
  4616. case Common.PARKING_SYSTEM_IES_100:
  4617. break;
  4618. case Common.PARKING_SYSTEM_BASIC:
  4619. case Common.PARKING_SYSTEM_ETC:
  4620. GetParkingInfo_RandomCheckHandler(); //주차 정보 얻어오기
  4621. break;
  4622. default:
  4623. break;
  4624. }
  4625. }
  4626. }
  4627. }
  4628. } catch (RuntimeException re) {
  4629. LogUtil.errorLogInfo("", TAG, re);
  4630. }
  4631. catch (Exception e) {
  4632. Log.e(TAG, "[Exception] checkTimeTasks()");
  4633. LogUtil.errorLogInfo("", TAG, e);
  4634. }
  4635. }
  4636. /**
  4637. * 일정 알림 팝업창 생성하는 함수<br>
  4638. * 김용성 과장님 이곳에서 팝업창 생성해주시기 바랍니다.
  4639. * @param popup_msg 팝업창에 띄울 메시지.
  4640. * **/
  4641. private void MakePopup_Schedule(String popup_msg) {
  4642. try {
  4643. Log.e(TAG, "[MakePopup_Schedule] popup_msg [" + popup_msg + "]");
  4644. DebugLogOutput("===================================");
  4645. DebugLogOutput(popup_msg);
  4646. DebugLogOutput("===================================");
  4647. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  4648. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  4649. boolean soundOut = mWallpadStatusData.GetSoundOutputOfEventAlarm();
  4650. mWallpadStatusData.closeDB();
  4651. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 1 ==========");
  4652. if (AlarmStatus != WallpadStatusData.ALARM_ARISE && AlarmStatus != WallpadStatusData.GUARD_OUT && AlarmStatus != WallpadStatusData.GUARD_OUT_WAIT) {
  4653. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 2 ==========");
  4654. if (!Common.bWallPadCallLive) {
  4655. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 3 ==========");
  4656. Common.SendAppFinishReqBR(getApplicationContext());
  4657. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  4658. Log.d(TAG, "[MakePopup_Schedule] Screen On: " + mPowerManager.isScreenOn());
  4659. if (getCompareBSPVersion()) {
  4660. if (!checkLCDOnByCMD()) {
  4661. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  4662. }
  4663. }
  4664. else {
  4665. if (!mPowerManager.isScreenOn()) {
  4666. Log.d(TAG, "[MakePopup_Schedule] V40Interface LcdWakeUp Call!!");
  4667. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  4668. }
  4669. }
  4670. ((MainActivity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4671. // 알람 소리를 내준다.
  4672. if (soundOut) {
  4673. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 4 ==========");
  4674. Sound().Play(SND.effect.EFFECT1);
  4675. }
  4676. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 5 ==========");
  4677. EnergyAlramPopupMgr.SchedulePopupMsg = popup_msg;
  4678. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 6 ==========");
  4679. StartPopup(ID.POPUPS.POPUP_SCHEDULENOTIFICATION);
  4680. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 7 ==========");
  4681. }
  4682. }
  4683. } catch (RuntimeException re) {
  4684. LogUtil.errorLogInfo("", TAG, re);
  4685. }
  4686. catch (Exception e) {
  4687. Log.e(TAG, "[Exception] MakePopup_Schedule(String popup_msg)");
  4688. LogUtil.errorLogInfo("", TAG, e);
  4689. }
  4690. }
  4691. /**
  4692. * 일정 알림 시간 비교!
  4693. * **/
  4694. private void checkScheduleReminder() {
  4695. try {
  4696. Calendar ScheduleCal = Calendar.getInstance();
  4697. Log.i(TAG, "[checkScheduleReminder] ScheduleCal: " + ScheduleCal.getTime());
  4698. WallpadScheduleData SCData = new WallpadScheduleData(getApplicationContext());
  4699. // List<WallpadScheduleData.ScheduleData> scheduleDataDB = SCData.NewGetScheduleDataForMainActivity(ScheduleCal.get(Calendar.YEAR), ScheduleCal.get(Calendar.MONTH) + 1, ScheduleCal.get(Calendar.DAY_OF_MONTH));
  4700. List<WallpadScheduleData.ScheduleData> scheduleDataDB = SCData.getScheduledInfoforMainActivity();
  4701. SCData.closeDB();
  4702. if (scheduleDataDB != null) {
  4703. Log.i(TAG, "scheduleDataDB.size() [" + scheduleDataDB.size() + "]");
  4704. for (int i = 0; i < scheduleDataDB.size(); i++) {
  4705. DebugLogOutput("[checkScheduleReminder] ===================================");
  4706. DebugLogOutput("[checkScheduleReminder] index [" + i + "], year [" + scheduleDataDB.get(i).inqyear + "], month [" + scheduleDataDB.get(i).inqmonth + "], day [" + scheduleDataDB.get(i).inqday + "], hour [" + scheduleDataDB.get(i).inqhour + "]");
  4707. DebugLogOutput("[checkScheduleReminder] msg [" + scheduleDataDB.get(i).inqmsg + "], seq [" + scheduleDataDB.get(i).seqnum + "]");
  4708. /**
  4709. * inqttype: 음력여부 - {"moon", "sun"}
  4710. * inqctype: 주기 - no:없음 or month:매월주기 or year:매년주기
  4711. * inqatype: 알림 - {"no","intime","min","hour","day"} := {안울림, 정각, 10분전, 1시간전, 하루전}
  4712. * inqitype: 행사 - {"birth","memorial","appoint","trip","first","wedding","tax","meeting","car","ancestor"} := {생일,기념일,약속,여행,돌,결혼,공과금,차량점검,제사}
  4713. */
  4714. DebugLogOutput("[checkScheduleReminder] lunar [" + scheduleDataDB.get(i).inqttype + "], cycle [" + scheduleDataDB.get(i).inqctype + "], remindtime [" + scheduleDataDB.get(i).inqatype + "], event [" + scheduleDataDB.get(i).inqitype + "]");
  4715. DebugLogOutput("[checkScheduleReminder] ===================================\n");
  4716. Calendar alarmCalendar = Calendar.getInstance();
  4717. if(scheduleDataDB.get(i).inqatype.equalsIgnoreCase("no") == true) {
  4718. //알림 사용하지 않음.
  4719. Log.i(TAG, "[checkScheduleReminder] ========== alarm off ==========");
  4720. }
  4721. else {
  4722. Log.i(TAG, "[checkScheduleReminder] ========== alarm on ==========");
  4723. if (scheduleDataDB.get(i).inqctype.equalsIgnoreCase("month")) {
  4724. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month ==========");
  4725. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  4726. //정각인 경우
  4727. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> intime ==========");
  4728. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4729. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4730. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4731. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4732. AlarmScheduleCount++;
  4733. if (bAlarmScheduleString == false) {
  4734. bAlarmScheduleString = true;
  4735. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4736. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4737. }
  4738. else {
  4739. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4740. }
  4741. }
  4742. }
  4743. }
  4744. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("min")) {
  4745. //10분 전
  4746. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 10 min before ==========");
  4747. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4748. alarmCalendar.add(Calendar.MINUTE, -10);
  4749. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4750. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4751. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4752. AlarmScheduleCount++;
  4753. if (bAlarmScheduleString == false) {
  4754. bAlarmScheduleString = true;
  4755. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4756. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4757. }
  4758. else {
  4759. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4760. }
  4761. }
  4762. }
  4763. }
  4764. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("hour")) {
  4765. //1시간 전
  4766. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 1 hour before ==========");
  4767. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4768. alarmCalendar.add(Calendar.HOUR_OF_DAY, -1);
  4769. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4770. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4771. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4772. AlarmScheduleCount++;
  4773. if (bAlarmScheduleString == false) {
  4774. bAlarmScheduleString = true;
  4775. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4776. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4777. }
  4778. else {
  4779. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4780. }
  4781. }
  4782. }
  4783. }
  4784. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  4785. //하루전
  4786. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 1 day before ==========");
  4787. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4788. alarmCalendar.add(Calendar.DATE, -1);
  4789. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  4790. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  4791. // 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));
  4792. // 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));
  4793. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  4794. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4795. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4796. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4797. AlarmScheduleCount++;
  4798. if (bAlarmScheduleString == false) {
  4799. bAlarmScheduleString = true;
  4800. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4801. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4802. }
  4803. else {
  4804. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4805. }
  4806. }
  4807. }
  4808. }
  4809. }
  4810. else if (scheduleDataDB.get(i).inqctype.equalsIgnoreCase("year")) {
  4811. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year ==========");
  4812. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  4813. //정각인 경우
  4814. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> intime ==========");
  4815. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4816. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4817. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4818. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4819. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4820. AlarmScheduleCount++;
  4821. if (bAlarmScheduleString == false) {
  4822. bAlarmScheduleString = true;
  4823. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4824. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4825. }
  4826. else {
  4827. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4828. }
  4829. }
  4830. }
  4831. }
  4832. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("min")) {
  4833. //10분 전
  4834. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 10 min before ==========");
  4835. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4836. alarmCalendar.add(Calendar.MINUTE, -10);
  4837. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4838. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4839. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4840. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4841. {
  4842. AlarmScheduleCount++;
  4843. if (bAlarmScheduleString == false) {
  4844. bAlarmScheduleString = true;
  4845. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4846. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4847. }
  4848. else {
  4849. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4850. }
  4851. }
  4852. }
  4853. }
  4854. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("hour")) {
  4855. //1시간 전
  4856. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 1 hour before ==========");
  4857. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4858. alarmCalendar.add(Calendar.HOUR_OF_DAY, -1);
  4859. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4860. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4861. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4862. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4863. {
  4864. AlarmScheduleCount++;
  4865. if (bAlarmScheduleString == false) {
  4866. bAlarmScheduleString = true;
  4867. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4868. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4869. }
  4870. else {
  4871. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4872. }
  4873. }
  4874. }
  4875. }
  4876. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  4877. //하루전
  4878. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 1 day before ==========");
  4879. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4880. alarmCalendar.add(Calendar.DATE, -1);
  4881. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  4882. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  4883. // 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));
  4884. // 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));
  4885. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  4886. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4887. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4888. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4889. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4890. {
  4891. AlarmScheduleCount++;
  4892. if (bAlarmScheduleString == false) {
  4893. bAlarmScheduleString = true;
  4894. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4895. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4896. }
  4897. else {
  4898. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4899. }
  4900. }
  4901. }
  4902. }
  4903. }
  4904. else {
  4905. //반복 없는경우
  4906. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat ==========");
  4907. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  4908. //정각인 경우
  4909. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> intime ==========");
  4910. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4911. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  4912. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4913. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4914. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4915. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4916. {
  4917. AlarmScheduleCount++;
  4918. if (bAlarmScheduleString == false) {
  4919. bAlarmScheduleString = true;
  4920. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4921. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4922. }
  4923. else {
  4924. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4925. }
  4926. }
  4927. }
  4928. }
  4929. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("min")) {
  4930. //10분 전
  4931. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 10 min before ==========");
  4932. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4933. alarmCalendar.add(Calendar.MINUTE, -10);
  4934. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  4935. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4936. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4937. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4938. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4939. {
  4940. AlarmScheduleCount++;
  4941. if (bAlarmScheduleString == false) {
  4942. bAlarmScheduleString = true;
  4943. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4944. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4945. }
  4946. else {
  4947. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4948. }
  4949. }
  4950. }
  4951. }
  4952. else if(scheduleDataDB.get(i).inqatype.equalsIgnoreCase("hour")) {
  4953. //1시간 전
  4954. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 1 hour before ==========");
  4955. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4956. alarmCalendar.add(Calendar.HOUR_OF_DAY, -1);
  4957. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  4958. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4959. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4960. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4961. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4962. {
  4963. AlarmScheduleCount++;
  4964. if (bAlarmScheduleString == false) {
  4965. bAlarmScheduleString = true;
  4966. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4967. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4968. }
  4969. else {
  4970. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4971. }
  4972. }
  4973. }
  4974. }
  4975. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  4976. //하루전
  4977. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 1 day before ==========");
  4978. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4979. alarmCalendar.add(Calendar.DATE, -1);
  4980. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  4981. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  4982. // 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));
  4983. // 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));
  4984. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  4985. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  4986. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4987. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4988. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4989. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4990. {
  4991. AlarmScheduleCount++;
  4992. if (bAlarmScheduleString == false) {
  4993. bAlarmScheduleString = true;
  4994. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4995. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4996. }
  4997. else {
  4998. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4999. }
  5000. }
  5001. }
  5002. }
  5003. else {
  5004. Log.w(TAG, "[checkScheduleReminder] Unsupported alarm type!! -> " + scheduleDataDB.get(i).inqatype);
  5005. }
  5006. }
  5007. }
  5008. }
  5009. Log.i(TAG, "[checkScheduleReminder] bAlarmScheduleString [" + bAlarmScheduleString + "], AlarmScheduleCount [" + AlarmScheduleCount + "]");
  5010. if (bAlarmScheduleString == true) {
  5011. if(AlarmScheduleCount == 1) {
  5012. //일정이 1개인 경우
  5013. AlarmScheduleString += " 일정이 있습니다.\r\n확인 하시겠습니까?";
  5014. }
  5015. else {
  5016. //일정이 1개보다 많은 경우
  5017. AlarmScheduleString += " 일정 외 "+(AlarmScheduleCount-1)+"건이 있습니다.\r\n확인 하시겠습니까?";
  5018. }
  5019. AlarmScheduleCount = 0;
  5020. bAlarmScheduleString = false;
  5021. MakePopup_Schedule(AlarmScheduleString);
  5022. }
  5023. }
  5024. else {
  5025. Log.w(TAG, "[checkScheduleReminder] scheduleDataDB is null!!");
  5026. }
  5027. } catch (RuntimeException re) {
  5028. LogUtil.errorLogInfo("", TAG, re);
  5029. }
  5030. catch (Exception e) {
  5031. Log.e(TAG, "[Exception] checkScheduleReminder(Calendar cal)");
  5032. LogUtil.errorLogInfo("", TAG, e);
  5033. }
  5034. }
  5035. // 프로토콜에 정의된 일정표 이벤트 종류를 변환하여 반환한다.
  5036. private String getScheduleEventType(String strEvent) {
  5037. try {
  5038. Log.i(TAG, "[getScheduleEventType] strEvent [" + strEvent + "]");
  5039. if (strEvent.equalsIgnoreCase("birth")) return "생일";
  5040. else if (strEvent.equalsIgnoreCase("memorial")) return "기념일";
  5041. else if (strEvent.equalsIgnoreCase("appoint")) return "약속";
  5042. else if (strEvent.equalsIgnoreCase("trip")) return "여행";
  5043. else if (strEvent.equalsIgnoreCase("first")) return "돌";
  5044. else if (strEvent.equalsIgnoreCase("wedding")) return "결혼";
  5045. else if (strEvent.equalsIgnoreCase("tax")) return "공과금";
  5046. else if (strEvent.equalsIgnoreCase("meeting")) return "모임";
  5047. else if (strEvent.equalsIgnoreCase("car")) return "생일";
  5048. else if (strEvent.equalsIgnoreCase("ancestor")) return "제사";
  5049. else return "알수없음";
  5050. } catch (RuntimeException re) {
  5051. LogUtil.errorLogInfo("", TAG, re);
  5052. return "알수없음";
  5053. }
  5054. catch (Exception e) {
  5055. Log.e(TAG, "[Exception] getScheduleEventType(String strEvent)");
  5056. LogUtil.errorLogInfo("", TAG, e);
  5057. return "알수없음";
  5058. }
  5059. }
  5060. private void getParkedVehicleLocationSysInfo() {
  5061. try {
  5062. DebugLogOutput("getParkedVehicleLocationSysInfo Init");
  5063. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  5064. String[] ParkingDB = devSet.GetSettingData("주차확인");
  5065. devSet.closeDB();
  5066. if (ParkingDB!=null) {
  5067. try {
  5068. String devInfo = ParkingDB[1];
  5069. devInfo = devInfo.replace('(', '_');
  5070. devInfo = devInfo.replace(':', '_');
  5071. devInfo = devInfo.replace(')', '_');
  5072. String[] ParkingInfo = devInfo.split("_");
  5073. //ParkingInfo[3] -> 사용여부 <사용함 / else>
  5074. //ParkingInfo[5] -> 종류 <기본 / 아이콘트롤스 / NEXPA / UPIS / ETC / 비상벨 / else>
  5075. //ParkingInfo[7] -> IP정보
  5076. //ParkingInfo[8] -> 포트번호
  5077. if (ParkingInfo[3].equalsIgnoreCase("사용함") == true) {
  5078. bUseofNot_ParkingInfo = true;
  5079. }
  5080. if (ParkingInfo[5].equalsIgnoreCase("기본") == true) {
  5081. nParkingSystemType = Common.PARKING_SYSTEM_BASIC;
  5082. }
  5083. else if (ParkingInfo[5].equalsIgnoreCase("아이콘트롤스") == true) {
  5084. nParkingSystemType = Common.PARKING_SYSTEM_ICONTROLS;
  5085. }
  5086. else if (ParkingInfo[5].equalsIgnoreCase("넥스파") == true) {
  5087. nParkingSystemType = Common.PARKING_SYSTEM_NEXPA;
  5088. }
  5089. else if (ParkingInfo[5].equalsIgnoreCase("NEXPA") == true) {
  5090. nParkingSystemType = Common.PARKING_SYSTEM_NEXPA;
  5091. }
  5092. else if (ParkingInfo[5].equalsIgnoreCase("UPIS") == true) {
  5093. nParkingSystemType = Common.PARKING_SYSTEM_UPIS;
  5094. }
  5095. else if (ParkingInfo[5].equalsIgnoreCase("ETC") == true) {
  5096. nParkingSystemType = Common.PARKING_SYSTEM_ETC;
  5097. }
  5098. else if (ParkingInfo[5].equalsIgnoreCase("비상벨") == true) {
  5099. nParkingSystemType = Common.PARKING_SYSTEM_IES_100;
  5100. }
  5101. else if (ParkingInfo[5].equalsIgnoreCase("다람정보") == true) {
  5102. nParkingSystemType = Common.PARKING_SYSTEM_DARAM;
  5103. }
  5104. ParkingServerIP = ParkingInfo[7];
  5105. ParkingServerPort = Integer.parseInt(ParkingInfo[8]);
  5106. DebugLogOutput("[getParkedVehicleLocationSysInfo] bUseofNot_ParkingInfo [" + bUseofNot_ParkingInfo + ", nParkingSystemType ["+ nParkingSystemType + "]");
  5107. DebugLogOutput("[getParkedVehicleLocationSysInfo] ParkingServerIP ["+ParkingServerIP + "], ParkingServerPort [" + ParkingServerPort + "]");
  5108. } catch (RuntimeException re) {
  5109. LogUtil.errorLogInfo("", TAG, re);
  5110. bUseofNot_ParkingInfo = false;
  5111. }
  5112. catch (Exception e) {
  5113. LogUtil.errorLogInfo("", TAG, e);
  5114. bUseofNot_ParkingInfo = false;
  5115. }
  5116. }
  5117. else {
  5118. bUseofNot_ParkingInfo = false;
  5119. DebugLogOutput("[getParkedVehicleLocationSysInfo] bUseofNot_ParkingInfo ["+bUseofNot_ParkingInfo + "]");
  5120. }
  5121. } catch (RuntimeException re) {
  5122. LogUtil.errorLogInfo("", TAG, re);
  5123. }
  5124. catch (Exception e) {
  5125. LogUtil.errorLogInfo("", TAG, e);
  5126. }
  5127. }
  5128. //20분 마다 한번씩 호출되는 주차관련 함수!
  5129. private void GetParkingInfo_RandomCheckHandler() {
  5130. int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  5131. if (DelayTime < 1) {
  5132. return;
  5133. }
  5134. DebugLogOutput("[GetParkingInfo] DelayTime : "+ DelayTime);
  5135. bSetMSG_GetParkingInfo = true;
  5136. mGetParkInfoRandomCheckHandler.sendEmptyMessageDelayed(0, 1000 * DelayTime);
  5137. }
  5138. private Handler mGetParkInfoRandomCheckHandler = new Handler()
  5139. {
  5140. @Override
  5141. public void handleMessage(Message msg)
  5142. {
  5143. if (msg.what == 0) {
  5144. DebugLogOutput("[GetParkingInfo] mGetParkInfoRandomCheckHandler() will be called");
  5145. //얻어오기
  5146. LoadParkingDataFromServer();
  5147. }
  5148. }
  5149. };
  5150. /**
  5151. * @description 주차정보 서버로부터 얻어오기<br>
  5152. * 호출 시에는 bSetMSG_GetParkingInfo = true 하고 호출해야함.
  5153. * **/
  5154. private void LoadParkingDataFromServer() {
  5155. try {
  5156. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5157. final AddressSet addc = SetData.getAddressMGR();
  5158. SetData.closeDB();
  5159. if (bSetMSG_GetParkingInfo == false) {
  5160. return;
  5161. }
  5162. if ((nParkingSystemType == Common.PARKING_SYSTEM_BASIC)
  5163. || (nParkingSystemType == Common.PARKING_SYSTEM_ICONTROLS)
  5164. || (nParkingSystemType == Common.PARKING_SYSTEM_NEXPA)
  5165. || (nParkingSystemType == Common.PARKING_SYSTEM_IES_100))
  5166. {
  5167. iMAPcarParking = new iMAPCarParking(mContext, true);
  5168. iMAPcarParking.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5169. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5170. DebugLogOutput("iMAPcarParking.DoWork()");
  5171. iMAPcarParking.DoWork();
  5172. iMAPcarParking.SetRetCtr(new RetProci(){
  5173. @Override
  5174. public void ProcSuccess() {
  5175. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5176. try {
  5177. iMAPcarParking.SetItem("home_info");
  5178. int home_info_count = Integer.parseInt(iMAPcarParking.GetAttributeVal(0, "count"));
  5179. int park_info_count = iMAPcarParking.SetItem("park_info");
  5180. if (home_info_count != park_info_count) {
  5181. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5182. cGetParkingMin = 0;
  5183. bSetMSG_GetParkingInfo = false;
  5184. return;
  5185. }
  5186. if (park_info_count == 0) {
  5187. DebugLogOutput("park_info_count :" + park_info_count);
  5188. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5189. parkdb.DeleteAllParkInfo();
  5190. parkdb.closeDB();
  5191. cGetParkingMin = 0;
  5192. bSetMSG_GetParkingInfo = false;
  5193. /*
  5194. parkdb = new WallpadParkInfo(getApplicationContext());
  5195. int countRow = parkdb.RowCountCarParking();
  5196. parkdb.closeDB();
  5197. DebugLogOutput("countRow :" + countRow);
  5198. */
  5199. Intent intent = new Intent();
  5200. intent.setAction(define.NOTIFY_ACNAME);
  5201. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5202. getApplicationContext().sendBroadcast(intent);
  5203. return;
  5204. }
  5205. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5206. parkdb.DeleteAllParkInfo();
  5207. parkdb.closeDB();
  5208. for (int i = 0; i < park_info_count; i++) {
  5209. if ((addc.Dong.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "ho")))) {
  5210. parkdb = new WallpadParkInfo(getApplicationContext());
  5211. parkdb.InputParkInfo(
  5212. iMAPcarParking.GetAttributeVal(i, "index"),
  5213. iMAPcarParking.GetAttributeVal(i, "dong"),
  5214. iMAPcarParking.GetAttributeVal(i, "ho"),
  5215. iMAPcarParking.GetAttributeVal(i, "card_num"),
  5216. iMAPcarParking.GetAttributeVal(i, "uid"),
  5217. iMAPcarParking.GetAttributeVal(i, "sn"),
  5218. iMAPcarParking.GetAttributeVal(i, "card_type"),
  5219. iMAPcarParking.GetAttributeVal(i, "time"),
  5220. iMAPcarParking.GetAttributeVal(i, "location_text"),
  5221. iMAPcarParking.GetAttributeVal(i, "location_map"),
  5222. iMAPcarParking.GetAttributeVal(i, "vehicle_info"),
  5223. iMAPcarParking.GetAttributeVal(i, "ftp_path"),
  5224. iMAPcarParking.GetAttributeVal(i, "ftp_info"),
  5225. iMAPcarParking.GetAttributeVal(i, "message"));
  5226. parkdb.closeDB();
  5227. }
  5228. }
  5229. //테스트
  5230. parkdb = new WallpadParkInfo(getApplicationContext());
  5231. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5232. parkdb.closeDB();
  5233. if (carParkingData != null) {
  5234. for (int j = 0; j < carParkingData.length; j++) {
  5235. DebugLogOutput(carParkingData[j].ToDebugString());
  5236. }
  5237. }
  5238. //테스트
  5239. Intent intent = new Intent();
  5240. intent.setAction(define.NOTIFY_ACNAME);
  5241. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5242. getApplicationContext().sendBroadcast(intent);
  5243. } catch (RuntimeException re) {
  5244. LogUtil.errorLogInfo("", TAG, re);
  5245. cGetParkingMin = 0;
  5246. bSetMSG_GetParkingInfo = false;
  5247. }
  5248. catch (Exception e) {
  5249. cGetParkingMin = 0;
  5250. bSetMSG_GetParkingInfo = false;
  5251. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5252. LogUtil.errorLogInfo("", TAG, e);
  5253. }
  5254. cGetParkingMin = 0;
  5255. bSetMSG_GetParkingInfo = false;
  5256. }
  5257. @Override
  5258. public void ProcError() {
  5259. cGetParkingMin = 0;
  5260. bSetMSG_GetParkingInfo = false;
  5261. DebugLogOutput("Load EMData From Server - ProcError");
  5262. }
  5263. @Override
  5264. public void ProcDoing() {
  5265. }
  5266. });
  5267. }
  5268. else if (nParkingSystemType == Common.PARKING_SYSTEM_DARAM) {
  5269. iMAPcarParking = new iMAPCarParking(mContext, false);
  5270. iMAPcarParking.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5271. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5272. DebugLogOutput("iMAPcarParking.DoWork()");
  5273. iMAPcarParking.DoWork();
  5274. iMAPcarParking.SetRetCtr(new RetProci(){
  5275. @Override
  5276. public void ProcSuccess() {
  5277. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5278. try {
  5279. iMAPcarParking.SetItem("home_info");
  5280. int home_info_count = Integer.parseInt(iMAPcarParking.GetAttributeVal(0, "count"));
  5281. int park_info_count = iMAPcarParking.SetItem("park_info");
  5282. if (home_info_count != park_info_count) {
  5283. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5284. cGetParkingMin = 0;
  5285. bSetMSG_GetParkingInfo = false;
  5286. return;
  5287. }
  5288. if (park_info_count == 0) {
  5289. DebugLogOutput("park_info_count :" + park_info_count);
  5290. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5291. parkdb.DeleteAllParkInfo();
  5292. parkdb.closeDB();
  5293. cGetParkingMin = 0;
  5294. bSetMSG_GetParkingInfo = false;
  5295. /*
  5296. parkdb = new WallpadParkInfo(getApplicationContext());
  5297. int countRow = parkdb.RowCountCarParking();
  5298. parkdb.closeDB();
  5299. DebugLogOutput("countRow :" + countRow);
  5300. */
  5301. Intent intent = new Intent();
  5302. intent.setAction(define.NOTIFY_ACNAME);
  5303. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5304. getApplicationContext().sendBroadcast(intent);
  5305. return;
  5306. }
  5307. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5308. parkdb.DeleteAllParkInfo();
  5309. parkdb.closeDB();
  5310. for (int i = 0; i < park_info_count; i++) {
  5311. if ((addc.Dong.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "ho")))) {
  5312. parkdb = new WallpadParkInfo(getApplicationContext());
  5313. parkdb.InputParkInfo(
  5314. iMAPcarParking.GetAttributeVal(i, "index"),
  5315. iMAPcarParking.GetAttributeVal(i, "dong"),
  5316. iMAPcarParking.GetAttributeVal(i, "ho"),
  5317. iMAPcarParking.GetAttributeVal(i, "card_num"),
  5318. iMAPcarParking.GetAttributeVal(i, "uid"),
  5319. iMAPcarParking.GetAttributeVal(i, "sn"),
  5320. iMAPcarParking.GetAttributeVal(i, "card_type"),
  5321. iMAPcarParking.GetAttributeVal(i, "time"),
  5322. iMAPcarParking.GetAttributeVal(i, "location_text"),
  5323. iMAPcarParking.GetAttributeVal(i, "location_map"),
  5324. iMAPcarParking.GetAttributeVal(i, "vehicle_info"),
  5325. iMAPcarParking.GetAttributeVal(i, "ftp_path"),
  5326. iMAPcarParking.GetAttributeVal(i, "ftp_info"),
  5327. iMAPcarParking.GetAttributeVal(i, "message"));
  5328. parkdb.closeDB();
  5329. }
  5330. }
  5331. //테스트
  5332. parkdb = new WallpadParkInfo(getApplicationContext());
  5333. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5334. parkdb.closeDB();
  5335. if (carParkingData != null) {
  5336. for (int j = 0; j < carParkingData.length; j++) {
  5337. DebugLogOutput(carParkingData[j].ToDebugString());
  5338. }
  5339. }
  5340. //테스트
  5341. Intent intent = new Intent();
  5342. intent.setAction(define.NOTIFY_ACNAME);
  5343. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5344. getApplicationContext().sendBroadcast(intent);
  5345. } catch (RuntimeException re) {
  5346. LogUtil.errorLogInfo("", TAG, re);
  5347. cGetParkingMin = 0;
  5348. bSetMSG_GetParkingInfo = false;
  5349. }
  5350. catch (Exception e) {
  5351. cGetParkingMin = 0;
  5352. bSetMSG_GetParkingInfo = false;
  5353. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5354. LogUtil.errorLogInfo("", TAG, e);
  5355. }
  5356. cGetParkingMin = 0;
  5357. bSetMSG_GetParkingInfo = false;
  5358. }
  5359. @Override
  5360. public void ProcError() {
  5361. cGetParkingMin = 0;
  5362. bSetMSG_GetParkingInfo = false;
  5363. DebugLogOutput("Load EMData From Server - ProcError");
  5364. }
  5365. @Override
  5366. public void ProcDoing() {
  5367. }
  5368. });
  5369. }
  5370. else if (nParkingSystemType == Common.PARKING_SYSTEM_UPIS) {
  5371. iMapcarParking_UPIS = new iMAPCarParking_UPIS(mContext, false);
  5372. iMapcarParking_UPIS.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5373. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5374. DebugLogOutput("iMapcarParking_UPIS.DoWork()");
  5375. iMapcarParking_UPIS.DoWork();
  5376. iMapcarParking_UPIS.SetRetCtr(new RetProci(){
  5377. @Override
  5378. public void ProcSuccess() {
  5379. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5380. try {
  5381. iMapcarParking_UPIS.SetItem("home_info");
  5382. int home_info_count = Integer.parseInt(iMapcarParking_UPIS.GetAttributeVal(0, "count"));
  5383. int park_info_count = iMapcarParking_UPIS.SetItem("park_info");
  5384. if (home_info_count != park_info_count) {
  5385. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5386. cGetParkingMin = 0;
  5387. bSetMSG_GetParkingInfo = false;
  5388. return;
  5389. }
  5390. if (park_info_count == 0) {
  5391. DebugLogOutput("park_info_count :" + park_info_count);
  5392. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5393. parkdb.DeleteAllParkInfo();
  5394. parkdb.closeDB();
  5395. cGetParkingMin = 0;
  5396. bSetMSG_GetParkingInfo = false;
  5397. /*
  5398. parkdb = new WallpadParkInfo(getApplicationContext());
  5399. int countRow = parkdb.RowCountCarParking();
  5400. parkdb.closeDB();
  5401. DebugLogOutput("countRow :" + countRow);
  5402. */
  5403. Intent intent = new Intent();
  5404. intent.setAction(define.NOTIFY_ACNAME);
  5405. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5406. getApplicationContext().sendBroadcast(intent);
  5407. return;
  5408. }
  5409. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5410. parkdb.DeleteAllParkInfo();
  5411. parkdb.closeDB();
  5412. for (int i = 0; i < park_info_count; i++) {
  5413. if ((addc.Dong.equalsIgnoreCase(iMapcarParking_UPIS.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMapcarParking_UPIS.GetAttributeVal(i, "ho")))) {
  5414. parkdb = new WallpadParkInfo(getApplicationContext());
  5415. parkdb.InputParkInfo(
  5416. iMapcarParking_UPIS.GetAttributeVal(i, "index"),
  5417. iMapcarParking_UPIS.GetAttributeVal(i, "dong"),
  5418. iMapcarParking_UPIS.GetAttributeVal(i, "ho"),
  5419. "null",
  5420. iMapcarParking_UPIS.GetAttributeVal(i, "uid"),
  5421. iMapcarParking_UPIS.GetAttributeVal(i, "sn"),
  5422. iMapcarParking_UPIS.GetAttributeVal(i, "card_type"),
  5423. iMapcarParking_UPIS.GetAttributeVal(i, "time"),
  5424. iMapcarParking_UPIS.GetAttributeVal(i, "location_2"),
  5425. iMapcarParking_UPIS.GetAttributeVal(i, "location_1"),
  5426. iMapcarParking_UPIS.GetAttributeVal(i, "car_info"),
  5427. "null",
  5428. "null",
  5429. iMapcarParking_UPIS.GetAttributeVal(i, "message"));
  5430. parkdb.closeDB();
  5431. }
  5432. }
  5433. //테스트
  5434. parkdb = new WallpadParkInfo(getApplicationContext());
  5435. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5436. parkdb.closeDB();
  5437. if (carParkingData != null) {
  5438. for (int j = 0; j < carParkingData.length; j++) {
  5439. DebugLogOutput(carParkingData[j].ToDebugString());
  5440. }
  5441. }
  5442. Intent intent = new Intent();
  5443. intent.setAction(define.NOTIFY_ACNAME);
  5444. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5445. getApplicationContext().sendBroadcast(intent);
  5446. } catch (RuntimeException re) {
  5447. LogUtil.errorLogInfo("", TAG, re);
  5448. cGetParkingMin = 0;
  5449. bSetMSG_GetParkingInfo = false;
  5450. }
  5451. catch (Exception e) {
  5452. cGetParkingMin = 0;
  5453. bSetMSG_GetParkingInfo = false;
  5454. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5455. LogUtil.errorLogInfo("", TAG, e);
  5456. }
  5457. cGetParkingMin = 0;
  5458. bSetMSG_GetParkingInfo = false;
  5459. }
  5460. @Override
  5461. public void ProcError() {
  5462. cGetParkingMin = 0;
  5463. bSetMSG_GetParkingInfo = false;
  5464. DebugLogOutput("Load EMData From Server - ProcError");
  5465. }
  5466. @Override
  5467. public void ProcDoing() {
  5468. }
  5469. });
  5470. }
  5471. } catch (RuntimeException re) {
  5472. LogUtil.errorLogInfo("", TAG, re);
  5473. }
  5474. catch (Exception e) {
  5475. Log.e(TAG, "[Exception] LoadParkingDataFromServer()");
  5476. LogUtil.errorLogInfo("", TAG, e);
  5477. }
  5478. }
  5479. // 한시간에 한번식 호출되는 함수임
  5480. private void DoScheduleHourUnit(Calendar cal) {
  5481. nHour = cal.get(Calendar.HOUR_OF_DAY);
  5482. // 매시 7시부터 매시간 정각에 계속해서 알려준다. 사용자가 확인하기 전까지...
  5483. // 사용자가 확인하게 되면 알림을 중지한다.
  5484. // 목표값 팝업 알림에 필요한 DB 정보
  5485. // 각각의 항목에 대한 초기화, 근접알림 발생, 근접알림 확인, 초과 알림 발생 , 초과알림 확인 5단계 구분 필요
  5486. // 달이 넘어가게 되면 초괴하 한다.
  5487. try {
  5488. if (nHour == GetEnergyAlarmTime()) {
  5489. if (GetEnergyAlarm() == true) {
  5490. if (bUseofNot_EnergyServer == true) {
  5491. if (ResultGetIntent == true) {
  5492. ResultGetIntent = false;
  5493. Intent intent = new Intent();
  5494. intent.setAction(define.NOTIFY_ACNAME);
  5495. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_MAIN_ACTIVIVY);
  5496. intent.putExtra("elect_target", elect_target);
  5497. intent.putExtra("elect_used", elect_used);
  5498. intent.putExtra("elect_info", elect_info);
  5499. intent.putExtra("water_target", water_target);
  5500. intent.putExtra("water_used", water_used);
  5501. intent.putExtra("water_info", water_info);
  5502. intent.putExtra("gas_target", gas_target);
  5503. intent.putExtra("gas_used", gas_used);
  5504. intent.putExtra("gas_info", gas_info);
  5505. intent.putExtra("heating_target", heating_target);
  5506. intent.putExtra("heating_used", heating_used);
  5507. intent.putExtra("heating_info", heating_info);
  5508. intent.putExtra("hotwater_target", hotwater_target);
  5509. intent.putExtra("hotwater_used", hotwater_used);
  5510. intent.putExtra("hotwater_info", hotwater_info);
  5511. sendBroadcast(intent);
  5512. }
  5513. }
  5514. else {
  5515. CheckEnergyUsage();
  5516. }
  5517. }
  5518. }
  5519. } catch (RuntimeException re) {
  5520. LogUtil.errorLogInfo("", TAG, re);
  5521. }
  5522. catch (Exception e) {
  5523. LogUtil.errorLogInfo("", TAG, e);
  5524. }
  5525. if (SCManager != null ) SCManager.CheckSysResetData();
  5526. }
  5527. static boolean NeedCheckEnergy = false;
  5528. //에너지 사용량 확인
  5529. public void CheckEnergyUsage() {
  5530. Log.d(TAG, "***********************************************");
  5531. Log.d(TAG, "[CheckEnergyUsage] CheckEnergyUsage Function in");
  5532. Log.d(TAG, "***********************************************");
  5533. try {
  5534. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5535. int alarmstate = SetData.GetAlarmStatus();
  5536. SetData.closeDB();
  5537. if (alarmstate == WallpadStatusData.ALARM_ARISE || alarmstate == WallpadStatusData.GUARD_OUT)
  5538. return;
  5539. String strNear = "";
  5540. String strOver = "";
  5541. if (EnergyAlramPopupMgr.m_Elec_UseValue > 0 && EnergyAlramPopupMgr.m_Elec_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP)) {
  5542. if (EnergyAlramPopupMgr.m_Elec_UseValue >= EnergyAlramPopupMgr.m_Elec_GoalValue) {
  5543. strOver += "전기 ";
  5544. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP);
  5545. }
  5546. else {
  5547. double nNearValue = EnergyAlramPopupMgr.m_Elec_GoalValue * 0.9;
  5548. if (EnergyAlramPopupMgr.m_Elec_UseValue > nNearValue) {
  5549. strNear += "전기 ";
  5550. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP);
  5551. }
  5552. }
  5553. }
  5554. if (EnergyAlramPopupMgr.m_Water_UseValue > 0 && EnergyAlramPopupMgr.m_Water_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP)) {
  5555. if (EnergyAlramPopupMgr.m_Water_UseValue >= EnergyAlramPopupMgr.m_Water_GoalValue) {
  5556. strOver += "수도 ";
  5557. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP);
  5558. }
  5559. else {
  5560. double nNearValue = EnergyAlramPopupMgr.m_Water_GoalValue * 0.9;
  5561. if (EnergyAlramPopupMgr.m_Water_UseValue > nNearValue) {
  5562. strNear += "수도 ";
  5563. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP);
  5564. }
  5565. }
  5566. }
  5567. if (EnergyAlramPopupMgr.m_Gas_UseValue > 0 && EnergyAlramPopupMgr.m_Gas_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP)) {
  5568. if (EnergyAlramPopupMgr.m_Gas_UseValue >= EnergyAlramPopupMgr.m_Gas_GoalValue) {
  5569. strOver += "가스 ";
  5570. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP);
  5571. }
  5572. else {
  5573. double nNearValue = EnergyAlramPopupMgr.m_Gas_GoalValue * 0.9;
  5574. if (EnergyAlramPopupMgr.m_Gas_UseValue > nNearValue) {
  5575. strNear += "가스 ";
  5576. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP);
  5577. }
  5578. }
  5579. }
  5580. if (EnergyAlramPopupMgr.m_HotWater_UseValue > 0 && EnergyAlramPopupMgr.m_HotWater_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP)) {
  5581. if (EnergyAlramPopupMgr.m_HotWater_UseValue >= EnergyAlramPopupMgr.m_HotWater_GoalValue) {
  5582. strOver += "온수 ";
  5583. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP);
  5584. }
  5585. else {
  5586. double nNearValue = EnergyAlramPopupMgr.m_HotWater_GoalValue * 0.9;
  5587. if (EnergyAlramPopupMgr.m_HotWater_UseValue > nNearValue) {
  5588. strNear += "온수 ";
  5589. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP);
  5590. }
  5591. }
  5592. }
  5593. if (EnergyAlramPopupMgr.m_Heating_UseValue > 0 && EnergyAlramPopupMgr.m_Heating_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP)) {
  5594. if (EnergyAlramPopupMgr.m_Heating_UseValue >= EnergyAlramPopupMgr.m_Heating_GoalValue) {
  5595. strOver += "난방 ";
  5596. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP);
  5597. }
  5598. else {
  5599. double nNearValue = EnergyAlramPopupMgr.m_Heating_GoalValue * 0.9;
  5600. if (EnergyAlramPopupMgr.m_Heating_UseValue > nNearValue) {
  5601. strNear += "난방 ";
  5602. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP);
  5603. }
  5604. }
  5605. }
  5606. if (strNear.length() > 8) EnergyAlramPopupMgr.PopupMsg01 = strNear + "사용량이\n목표값에 가까워지고 있습니다.\n확인 하시겠습니까?";
  5607. else if (0 < strNear.length() && strNear.length() <= 8) EnergyAlramPopupMgr.PopupMsg01 = strNear + "사용량이 목표값에 가까워지고 있습니다.\n확인 하시겠습니까?";
  5608. else EnergyAlramPopupMgr.PopupMsg01 = "";
  5609. if (strOver.length() > 10) {
  5610. EnergyAlramPopupMgr.PopupMsg02 = strOver + "사용량이\n목표값을 초과하였습니다.\n확인 하시겠습니까?";
  5611. }
  5612. else if (0 < strOver.length() && strOver.length() <= 10) {
  5613. EnergyAlramPopupMgr.PopupMsg02 = strOver + "사용량이 목표값을 초과하였습니다.\n확인 하시겠습니까?";
  5614. }
  5615. else if(strOver.length() < 0){
  5616. EnergyAlramPopupMgr.PopupMsg02 = "";
  5617. }
  5618. if (EnergyAlramPopupMgr.PopupMsg01.length() > 0 || EnergyAlramPopupMgr.PopupMsg02.length() > 0) {
  5619. mIOInterface.ctrlLcdWakeUp();
  5620. StartPopup(ID.POPUPS.POPUP_ENERGYUSAGEALERT);
  5621. }
  5622. } catch (RuntimeException re) {
  5623. LogUtil.errorLogInfo("", TAG, re);
  5624. }
  5625. catch (Exception e) {
  5626. Log.e(TAG, "[Exception] CheckEnergyUsage()");
  5627. LogUtil.errorLogInfo("", TAG, e);
  5628. }
  5629. }
  5630. //시간 동기화를 위한 getinfo 실행 시간을 구함
  5631. protected Calendar GetTimeSyncTime()
  5632. {
  5633. Calendar retTime = new GregorianCalendar();
  5634. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5635. AddressSet addc = SetData.getAddressMGR();
  5636. SetData.closeDB();
  5637. try {
  5638. int dong = Integer.parseInt(addc.Dong);
  5639. int ho = 101;
  5640. if(addc.UseOrNotRentHouse == true)
  5641. {
  5642. ho = addc.Ho_Integer;
  5643. }
  5644. else
  5645. {
  5646. ho = Integer.parseInt(addc.Ho);
  5647. }
  5648. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  5649. int hour;
  5650. int min;
  5651. int sec;
  5652. if (interval/3600 > 0)
  5653. {
  5654. hour = 3+interval/3600;
  5655. interval=interval%3600;
  5656. }
  5657. else hour = 6;
  5658. if (interval/60 > 0)
  5659. {
  5660. min = interval/60;
  5661. sec = interval%60;
  5662. }
  5663. else
  5664. {
  5665. min = 0;
  5666. sec = interval;
  5667. }
  5668. retTime.set(Calendar.HOUR_OF_DAY, hour);
  5669. retTime.set(Calendar.MINUTE, min);
  5670. retTime.set(Calendar.SECOND, sec);
  5671. }
  5672. catch (RuntimeException re) {
  5673. LogUtil.errorLogInfo("", TAG, re);
  5674. return null;
  5675. }
  5676. catch (Exception e)
  5677. {
  5678. LogUtil.errorLogInfo("", TAG, e);
  5679. return null;
  5680. }
  5681. return retTime;
  5682. }
  5683. //에너지 사용량 확인을 위한 데이터 로딩 시간을 가져옴
  5684. protected Calendar GetEnergyDataLoadingTime()
  5685. {
  5686. Calendar retTime = new GregorianCalendar();
  5687. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5688. AddressSet addc = SetData.getAddressMGR();
  5689. SetData.closeDB();
  5690. try {
  5691. int dong = Integer.parseInt(addc.Dong);
  5692. int ho = 201;
  5693. if(addc.UseOrNotRentHouse == true)
  5694. {
  5695. ho = addc.Ho_Integer;
  5696. }
  5697. else
  5698. {
  5699. ho = Integer.parseInt(addc.Ho);
  5700. }
  5701. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  5702. int hour;
  5703. int min;
  5704. int sec;
  5705. if (interval/3600 > 0)
  5706. {
  5707. hour = 6+interval/3600;
  5708. interval=interval%3600;
  5709. }
  5710. else hour = 6;
  5711. if (interval/60 > 0)
  5712. {
  5713. min = interval/60;
  5714. sec = interval%60;
  5715. }
  5716. else
  5717. {
  5718. min = 0;
  5719. sec = interval;
  5720. }
  5721. retTime.set(Calendar.HOUR_OF_DAY, hour);
  5722. retTime.set(Calendar.MINUTE, min);
  5723. retTime.set(Calendar.SECOND, sec);
  5724. }
  5725. catch (RuntimeException re) {
  5726. LogUtil.errorLogInfo("", TAG, re);
  5727. return null;
  5728. }
  5729. catch (Exception e)
  5730. {
  5731. LogUtil.errorLogInfo("", TAG, e);
  5732. return null;
  5733. }
  5734. return retTime;
  5735. }
  5736. private void setNetworkAddr(int secNum, int thirdNum, int forthNum) {
  5737. try
  5738. {
  5739. String IPAddress = String.format("10.%d.%d.%d", secNum, thirdNum, forthNum);
  5740. String gateWayIPAddress = String.format("10.%d.%d.%d", secNum, Common.DEFAULT_GATEWAY_IP_THIRD, Common.DEFAULT_GATEWAY_IP_FORTH);
  5741. String MacAddr = String.format("00:0A:%02x:%02x:%02x:00", secNum, thirdNum, forthNum);
  5742. String serverIP = Common.DEFAULT_SERVER_IP;
  5743. int serverPort = Common.DEFAULT_SERVER_PORT;
  5744. String managePCIP = Common.DEFAULT_MANAGER_PC_IP;
  5745. int managePCPort = Common.DEFAULT_MANAGER_PC_PORT;
  5746. wallpaddbmgr dbmgr = new wallpaddbmgr(this);
  5747. AddressSet addc = dbmgr.getAddressMGR();
  5748. String mDong = String.format("%d%02d", 1, secNum);
  5749. String mHo = String.format("%d%02d", thirdNum, forthNum);
  5750. addc.setAddress(mDong, mHo);
  5751. addc.setIPAddress(IPAddress);
  5752. dbmgr.closeDB();
  5753. WallpadStatusData wallpadStatusData = new WallpadStatusData(this);
  5754. wallpadStatusData.SetServerIP(serverIP, serverPort);
  5755. wallpadStatusData.SetManagePC(managePCIP, managePCPort);
  5756. wallpadStatusData.closeDB();
  5757. EthernetDevInfo info = new EthernetDevInfo();
  5758. info.setIfName("eth0");
  5759. info.setConnectMode(EthernetDevInfo.ETH_CONN_MODE_MANUAL);
  5760. info.setIpAddress(IPAddress);
  5761. info.setRouteAddr(gateWayIPAddress);
  5762. info.setDnsAddr(Common.DNS_IP);
  5763. info.setNetMask(Common.SUBNET_MASK);
  5764. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  5765. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  5766. mEthManager.UpdateEthDevInfo(info);
  5767. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  5768. WallPadInterface wallPadInterface = new WallPadInterface();;
  5769. wallPadInterface.setMacAddr(MacAddr);
  5770. Log.d("MANAGERSETTING", " IP : "+IPAddress+" Mac : "+ MacAddr);
  5771. writeMacAddress(MacAddr);
  5772. }
  5773. catch (RuntimeException re) {
  5774. LogUtil.errorLogInfo("", TAG, re);
  5775. }
  5776. catch (Exception e)
  5777. {
  5778. LogUtil.errorLogInfo("", TAG, e);
  5779. }
  5780. }
  5781. private final String NETWORK_SETTING = "network_setting";
  5782. private final String MAC_ADDRESS_FILE_PATH = Common.CONTENTS_ROOT + NETWORK_SETTING + ".inc";
  5783. private boolean writeMacAddress(String MacAddr) {
  5784. boolean ret = false;
  5785. String read = null;
  5786. BufferedWriter bufferWriter = null;
  5787. try {
  5788. FileOutputStream fos = new FileOutputStream(MAC_ADDRESS_FILE_PATH, false);
  5789. OutputStreamWriter osr = new OutputStreamWriter(fos, "UTF-8");
  5790. bufferWriter = new BufferedWriter(osr, 1024);
  5791. if ((bufferWriter != null) && (MacAddr != null)) {
  5792. bufferWriter.write(MacAddr, 0, MacAddr.length());
  5793. bufferWriter.newLine();
  5794. bufferWriter.flush();
  5795. ret = true;
  5796. }
  5797. } catch (RuntimeException re) {
  5798. LogUtil.errorLogInfo("", TAG, re);
  5799. }
  5800. catch (Exception e) {
  5801. LogUtil.errorLogInfo("", TAG, e);
  5802. } finally {
  5803. try {
  5804. if (bufferWriter != null) {
  5805. bufferWriter.close();
  5806. }
  5807. } catch (RuntimeException re) {
  5808. LogUtil.errorLogInfo("", TAG, re);
  5809. }
  5810. catch (Exception e) {
  5811. LogUtil.errorLogInfo("", TAG, e);
  5812. }
  5813. }
  5814. Log.d(TAG, "writeMacAddress() path : " + MAC_ADDRESS_FILE_PATH
  5815. + ", MacAddr : " + MacAddr
  5816. + ", ret : " + ret
  5817. );
  5818. return ret;
  5819. }
  5820. private void GetElectricCarInfo() {
  5821. try {
  5822. Log.d(TAG, "[GetElectricCarInfo] ===== START =====");
  5823. int retInt = -1;
  5824. WallpadDeviceSet mWallpadDeviceSet = null;
  5825. mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  5826. retInt = mWallpadDeviceSet.GetDeviceSetted("전기차충전");
  5827. mWallpadDeviceSet.closeDB();
  5828. Log.d(TAG, "[GetElectricCarInfo] retInt = " + retInt);
  5829. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  5830. Log.i(TAG, "[GetElectricCarInfo] Electronic car changing enabled!!");
  5831. GetElectricCarInfo_RandomCheckHandler();
  5832. }
  5833. else Log.i(TAG, "[GetElectricCarInfo] Electronic car changing disabled!!");
  5834. } catch (RuntimeException re) {
  5835. LogUtil.errorLogInfo("", TAG, re);
  5836. }
  5837. catch (Exception e) {
  5838. Log.e(TAG, "[Exception] GetElectricCarInfo()");
  5839. LogUtil.errorLogInfo("", TAG, e);
  5840. }
  5841. }
  5842. private void GetElectricCarInfo_RandomCheckHandler() {
  5843. try {
  5844. Log.d(TAG, "[GetElectricCarInfo_RandomCheckHandler] ===== START =====");
  5845. int nDelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  5846. Log.d(TAG, "[GetElectricCarInfo_RandomCheckHandler] nDelayTime : "+ nDelayTime);
  5847. if (nDelayTime < 1) {
  5848. Log.w(TAG, "[GetElectricCarInfo_RandomCheckHandler] DelayTime error!! -> nDelayTime = " + nDelayTime);
  5849. return;
  5850. }
  5851. mGetElecricCarRandomCheckHandler.sendEmptyMessageDelayed(0, 1000 * nDelayTime);
  5852. } catch (RuntimeException re) {
  5853. LogUtil.errorLogInfo("", TAG, re);
  5854. }
  5855. catch (Exception e) {
  5856. Log.e(TAG, "[Exception] GetElectricCarInfo_RandomCheckHandler()");
  5857. LogUtil.errorLogInfo("", TAG, e);
  5858. }
  5859. }
  5860. private Handler mGetElecricCarRandomCheckHandler = new Handler()
  5861. {
  5862. @Override
  5863. public void handleMessage(Message msg)
  5864. {
  5865. if (msg.what == 0) {
  5866. Log.i(TAG, "[GetElectricCarInfo] mGetElecricCarRandomCheckHandler() will be called!!");
  5867. //얻어오기
  5868. imapElecCarChargingInfo = new iMAPElecCarChargingInfo(getApplicationContext());
  5869. LoadElectricCarDataFromServer();
  5870. }
  5871. }
  5872. };
  5873. void LoadElectricCarDataFromServer() {
  5874. DebugLogOutput("LoadElectricCarDataFromServer");
  5875. imapElecCarChargingInfo.DoWork();
  5876. imapElecCarChargingInfo.SetRetCtr(new RetProci() {
  5877. @Override
  5878. public void ProcSuccess() {
  5879. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcSuccess");
  5880. try {
  5881. int SetItemResult = imapElecCarChargingInfo.SetItem("charging_cnt");
  5882. if(SetItemResult != 1) {
  5883. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - SetItemResult : "+ SetItemResult);
  5884. nElecVehicleChangingCnt = 0;
  5885. return;
  5886. }
  5887. String sChargingCount = imapElecCarChargingInfo.GetItemVal(0);
  5888. int intChargingCount = Integer.parseInt(sChargingCount);
  5889. if (intChargingCount < 1) {
  5890. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - intChargingCount : "+ intChargingCount);
  5891. nElecVehicleChangingCnt = 0;
  5892. return;
  5893. }
  5894. SetItemResult = imapElecCarChargingInfo.SetItem("charger_info");
  5895. if (SetItemResult != intChargingCount) {
  5896. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - SetItemResult : "+ SetItemResult);
  5897. nElecVehicleChangingCnt = 0;
  5898. return;
  5899. }
  5900. if (intChargingCount > 0) {
  5901. nElecVehicleChangingCnt = intChargingCount;
  5902. Intent intent = new Intent();
  5903. intent.setAction(define.NOTIFY_ACNAME);
  5904. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  5905. intent.putExtra("sCard_Num", imapElecCarChargingInfo.GetAttributeVal(0, "card_num"));
  5906. intent.putExtra("sCar_Num", imapElecCarChargingInfo.GetAttributeVal(0, "car_num"));
  5907. intent.putExtra("sCharger_Num", imapElecCarChargingInfo.GetAttributeVal(0, "charger_num"));
  5908. intent.putExtra("sCharger_Loc", imapElecCarChargingInfo.GetAttributeVal(0, "charger_loc"));
  5909. intent.putExtra("sCharging_Status", "charging");
  5910. intent.putExtra("sCharger_sort", imapElecCarChargingInfo.GetAttributeVal(0, "charger_sort"));
  5911. intent.putExtra("sCharging_Ratio", imapElecCarChargingInfo.GetAttributeVal(0, "charging_ratio"));
  5912. intent.putExtra("sStart_Time", imapElecCarChargingInfo.GetAttributeVal(0, "start_time"));
  5913. intent.putExtra("sRemain_Time", imapElecCarChargingInfo.GetAttributeVal(0, "remain_time"));
  5914. intent.putExtra("sMessage", imapElecCarChargingInfo.GetAttributeVal(0, "c_msg"));
  5915. getApplicationContext().sendBroadcast(intent);
  5916. }
  5917. } catch (RuntimeException re) {
  5918. LogUtil.errorLogInfo("", TAG, re);
  5919. }
  5920. catch (Exception e) {
  5921. Log.e(TAG, "[Exception] LoadElectricCarDataFromServer() -> ProcSuccess");
  5922. LogUtil.errorLogInfo("", TAG, e);
  5923. }
  5924. }
  5925. @Override
  5926. public void ProcError()
  5927. {
  5928. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcError");
  5929. }
  5930. @Override
  5931. public void ProcDoing()
  5932. {
  5933. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcDoing");
  5934. }
  5935. });
  5936. }
  5937. /**
  5938. * 대외향 Call 버튼 점멸 및 On Off 처리
  5939. */
  5940. @SuppressLint("HandlerLeak")
  5941. protected Handler mLedFlickerHandler = new Handler()
  5942. {
  5943. boolean Flicker = false;
  5944. @SuppressLint("HandlerLeak")
  5945. @Override
  5946. public void handleMessage(Message msg)
  5947. {
  5948. if(msg.what == 0) // 콜 수신시 또는 발신시 ...
  5949. {
  5950. // 점멸 시작 CallButton LED On
  5951. Flicker = true;
  5952. mLedFlickerHandler.sendEmptyMessageDelayed(1, 500);
  5953. WallPadInterface wpdifc = new WallPadInterface();
  5954. wpdifc.callLEDControll(true);
  5955. }
  5956. else if(msg.what == 1)
  5957. {
  5958. mLedFlickerHandler.sendEmptyMessageDelayed(0, 500);
  5959. WallPadInterface wpdifc = new WallPadInterface();
  5960. wpdifc.callLEDControll(false);
  5961. }
  5962. else if(msg.what == 2) // 통화중
  5963. {
  5964. Flicker = false;
  5965. }
  5966. else if(msg.what == 4) // 통화종료
  5967. {
  5968. Flicker = false;
  5969. }
  5970. }
  5971. };
  5972. public void GetEnergyServerInfo()
  5973. {
  5974. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  5975. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  5976. devSet.closeDB();
  5977. if (MetringDB != null)
  5978. {
  5979. try
  5980. {
  5981. String devInfo = MetringDB[1];
  5982. devInfo = devInfo.replace('(', '_');
  5983. devInfo = devInfo.replace(':', '_');
  5984. devInfo = devInfo.replace(')', '_');
  5985. String[] MetringInfo = devInfo.split("_");
  5986. // MetringInfo[1] -> 회로수
  5987. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  5988. // MetringInfo[4] -> IP
  5989. // MetringInfo[5] -> IP정보
  5990. // MetringInfo[6] -> 검침일사용자설정
  5991. // MetringInfo[7] -> 사용함 또는 사용안함
  5992. if(MetringInfo[3].equals("사용함") == true)
  5993. {
  5994. bUseofNot_EnergyServer = true;
  5995. }
  5996. }
  5997. catch (RuntimeException re) {
  5998. LogUtil.errorLogInfo("", TAG, re);
  5999. }
  6000. catch (Exception e)
  6001. {
  6002. LogUtil.errorLogInfo("", TAG, e);
  6003. }
  6004. }
  6005. else
  6006. {
  6007. }
  6008. Log.d(TAG, "[bUseofNot_EnergyServer] bUseofNot_EnergyServer :"+bUseofNot_EnergyServer);
  6009. }
  6010. /**
  6011. * 카카오 사용 여부 체크
  6012. * @return
  6013. */
  6014. public boolean getKakaoHomeCheck()
  6015. {
  6016. boolean result = false;
  6017. WallpadDeviceSet mWallpadDeviceSet = null;
  6018. mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6019. try {
  6020. result = mWallpadDeviceSet.Get_KakaoUse();
  6021. }
  6022. catch (SQLException e)
  6023. {
  6024. LogUtil.errorLogInfo("", TAG, e);
  6025. }
  6026. return result;
  6027. }
  6028. /**
  6029. * 사용자 설정(카카오를 볼것인지 아닌지를 설정)
  6030. * @return
  6031. */
  6032. public boolean getShowKakaoCheck()
  6033. {
  6034. boolean result = false;
  6035. WallpadDeviceSet mWallpadDeviceSet = null;
  6036. mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6037. try {
  6038. result = mWallpadDeviceSet.Get_KakaoShow();
  6039. }
  6040. catch (SQLException e)
  6041. {
  6042. LogUtil.errorLogInfo("", TAG, e);
  6043. }
  6044. return result;
  6045. }
  6046. public boolean GetEnergyAlarm()
  6047. {
  6048. boolean ret = false;
  6049. WallpadStatusData DBMGR = null;
  6050. DBMGR = new WallpadStatusData(getContext());
  6051. if( DBMGR != null )
  6052. {
  6053. try
  6054. {
  6055. ret = DBMGR.GetRemoteMetering_Alarm();
  6056. }
  6057. catch (RuntimeException re) {
  6058. LogUtil.errorLogInfo("", TAG, re);
  6059. ret = false;
  6060. DBMGR.insertWallPADDB(WallpadStatusData.REMOTE_METERING_ALARM_USE, WallpadStatusData.REMOTE_METERING_ALARM_USE_DEFAULT);
  6061. }
  6062. catch (Exception e)
  6063. {
  6064. LogUtil.errorLogInfo("", TAG, e);
  6065. ret = false;
  6066. DBMGR.insertWallPADDB(WallpadStatusData.REMOTE_METERING_ALARM_USE, WallpadStatusData.REMOTE_METERING_ALARM_USE_DEFAULT);
  6067. }
  6068. DBMGR.closeDB();
  6069. }
  6070. bUseofNot_EnergyAlarm = ret;
  6071. Log.d(TAG, "[bUseofNot_EnergyAlarm] bUseofNot_EnergyAlarm :"+bUseofNot_EnergyAlarm);
  6072. return ret;
  6073. }
  6074. /**
  6075. * @description
  6076. * 에너지 사용량 알림 시간 얻어오기
  6077. * @return int Hour시간 값
  6078. */
  6079. public int GetEnergyAlarmTime()
  6080. {
  6081. int ret = 12;
  6082. WallpadStatusData DBMGR = null;
  6083. DBMGR = new WallpadStatusData(getContext());
  6084. try
  6085. {
  6086. ret = DBMGR.GetRemoteMetering_AlarmTime();
  6087. }
  6088. catch (RuntimeException re) {
  6089. LogUtil.errorLogInfo("", TAG, re);
  6090. }
  6091. catch (Exception e)
  6092. {
  6093. LogUtil.errorLogInfo("", TAG, e);
  6094. }
  6095. DBMGR.closeDB();
  6096. Log.d(TAG, "[GetEnergyAlarmTime] GetEnergyAlarmTime :"+ret);
  6097. return ret;
  6098. }
  6099. public void ClearEnergyUsage()
  6100. {
  6101. ResultGetIntent = false;
  6102. elect_target = "Error";
  6103. elect_used = "Error";
  6104. elect_info = "Error";
  6105. water_target = "Error";
  6106. water_used = "Error";
  6107. water_info = "Error";
  6108. gas_target = "Error";
  6109. gas_used = "Error";
  6110. gas_info = "Error";
  6111. hotwater_target = "Error";
  6112. hotwater_used = "Error";
  6113. hotwater_info = "Error";
  6114. heating_target = "Error";
  6115. heating_used = "Error";
  6116. heating_info = "Error";
  6117. }
  6118. // 신규 통화어플 실행을 위한 코드 (JEFF, 2016.05.23)
  6119. // 통화주체를 다루는 enum
  6120. public enum CALLOWNER {
  6121. NONE,
  6122. WALLPAD,
  6123. MOBILE,
  6124. SUB_WALLPAD,
  6125. KITCHEN_TV,
  6126. BATH_PHONE,
  6127. BATH_TV,
  6128. UNIVERSAL_DEVICE,
  6129. ERROR;
  6130. }
  6131. public enum CALLEVENTTYPE {
  6132. RECEIVE_CALL, // 호출 수신 (호출 수신)
  6133. TRYING_CALL, // 호출 시도중 (호출 발신)
  6134. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  6135. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  6136. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  6137. CONNECT_CALL, // 통화 시작
  6138. TERMINATE_CALL, // 통화 종료
  6139. CANCEL_CALL, // 호출 취소
  6140. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  6141. REJECT_CALL, // 호출수신 거절
  6142. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  6143. FORWARD_CALL, // 착신전환 설정
  6144. CALLERID, // Caller ID_OLD
  6145. TIMEOUT_1STCALL, // 1st Call Timeout
  6146. TIMEOUT_2NDCALL, // 2nd Call Timeout
  6147. TIMEOUT_3RDCALL, // 3rd Call Timeout
  6148. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  6149. DOOR_OPEN, // 문열림 설정
  6150. DETECT_STRANGER, // 거동수상자 발생
  6151. NONE;
  6152. }
  6153. public enum CALLTYPE {
  6154. NONE,
  6155. FRONT,
  6156. RESIDENCE,
  6157. LOBBY,
  6158. GUARD,
  6159. PSTN,
  6160. IHUB,
  6161. HISTORY_CALL,
  6162. HISTORY_VISITORPIC,
  6163. FRONT_RECORD, // 현관_영상녹화
  6164. FRONT_TAKEPIC, // 현관_사진촬영
  6165. ERROR,
  6166. }
  6167. public static class CALLTRIGGER {
  6168. public static String CALLOWNER = "CALLOWNER";
  6169. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  6170. public static String CALLTYPE = "CALLTYPE";
  6171. public enum SOURCE {
  6172. USER,
  6173. CALL_RECEIVE,
  6174. SUBPHONE
  6175. }
  6176. public enum TYPE {
  6177. MENU,
  6178. FRONT,
  6179. LOBBY,
  6180. GUARD,
  6181. RESIDENCE,
  6182. PSTN
  6183. }
  6184. }
  6185. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  6186. public void runWallPadCallAPKByUX(int nScreen) {
  6187. try {
  6188. Log.i(TAG, "[runWallPadCallAPKByUX] nScreen [" + nScreen + "]");
  6189. CALLOWNER eCallOwner = CALLOWNER.NONE;
  6190. CALLEVENTTYPE eEventType = CALLEVENTTYPE.NONE;
  6191. CALLTYPE eCallType = CALLTYPE.GUARD;
  6192. if (nScreen == ID.LINKEDSCREEN.SubCall.Door) {
  6193. if (getIsSubWallpad()) eCallOwner = CALLOWNER.SUB_WALLPAD;
  6194. else eCallOwner = CALLOWNER.WALLPAD;
  6195. eEventType = CALLEVENTTYPE.REQUEST_FRONT_MONITORING;
  6196. eCallType = CALLTYPE.FRONT;
  6197. }
  6198. else if (nScreen == ID.LINKEDSCREEN.SubCall.Door_Record) {
  6199. eCallType = CALLTYPE.FRONT;
  6200. eEventType = CALLEVENTTYPE.DETECT_STRANGER;
  6201. }
  6202. else if (nScreen == ID.LINKEDSCREEN.SubCall.Lobby) eCallType = CALLTYPE.LOBBY;
  6203. else if (nScreen == ID.LINKEDSCREEN.SubCall.Guard) eCallType = CALLTYPE.GUARD;
  6204. else if (nScreen == ID.LINKEDSCREEN.SubCall.Neighboor) eCallType = CALLTYPE.RESIDENCE;
  6205. else if (nScreen == ID.LINKEDSCREEN.SubCall.Pstn) eCallType = CALLTYPE.PSTN;
  6206. else if (nScreen == ID.LINKEDSCREEN.SubCall.CallList) eCallType = CALLTYPE.HISTORY_CALL;
  6207. else if (nScreen == ID.LINKEDSCREEN.SubCall.Visitor) eCallType = CALLTYPE.HISTORY_VISITORPIC;
  6208. else {
  6209. Log.w(TAG, "[runWallPadCallAPKByUX] NOT Supported nScreen!! [" + nScreen + "]");
  6210. }
  6211. Log.i(TAG, "[runWallPadCallAPKByUX] eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6212. if (getIsSubWallpad()) {
  6213. // 서브월패드는 국선 기능을 제공하지 않는다.
  6214. if (eCallType != CALLTYPE.PSTN) runCallMainActivity(eCallOwner, eEventType, eCallType);
  6215. }
  6216. else {
  6217. runCallMainActivity(eCallOwner, eEventType, eCallType);
  6218. }
  6219. } catch (RuntimeException re) {
  6220. LogUtil.errorLogInfo("", TAG, re);
  6221. }
  6222. catch (Exception e) {
  6223. Log.e(TAG, "[Exception] runWallPadCallAPKByUX(int nScreen)");
  6224. LogUtil.errorLogInfo("", TAG, e);
  6225. }
  6226. }
  6227. public void runWallPadCallAPKByUX(int nScreen, int nEmerState) {
  6228. try {
  6229. Log.i(TAG, "[runWallPadCallAPKByUX] nScreen [" + nScreen + "], nEmerState [" + nEmerState + "]");
  6230. CALLOWNER eCallOwner = CALLOWNER.NONE;
  6231. CALLEVENTTYPE eEventType = CALLEVENTTYPE.NONE;
  6232. CALLTYPE eCallType = CALLTYPE.GUARD;
  6233. if (nScreen == ID.LINKEDSCREEN.SubCall.Door) {
  6234. if (getIsSubWallpad()) eCallOwner = CALLOWNER.SUB_WALLPAD;
  6235. else eCallOwner = CALLOWNER.WALLPAD;
  6236. eEventType = CALLEVENTTYPE.REQUEST_FRONT_MONITORING;
  6237. eCallType = CALLTYPE.FRONT;
  6238. }
  6239. else if (nScreen == ID.LINKEDSCREEN.SubCall.Door_Record) {
  6240. eCallType = CALLTYPE.FRONT;
  6241. eEventType = CALLEVENTTYPE.DETECT_STRANGER;
  6242. }
  6243. else if (nScreen == ID.LINKEDSCREEN.SubCall.Lobby) eCallType = CALLTYPE.LOBBY;
  6244. else if (nScreen == ID.LINKEDSCREEN.SubCall.Guard) eCallType = CALLTYPE.GUARD;
  6245. else if (nScreen == ID.LINKEDSCREEN.SubCall.Neighboor) eCallType = CALLTYPE.RESIDENCE;
  6246. else if (nScreen == ID.LINKEDSCREEN.SubCall.Pstn) eCallType = CALLTYPE.PSTN;
  6247. else if (nScreen == ID.LINKEDSCREEN.SubCall.CallList) eCallType = CALLTYPE.HISTORY_CALL;
  6248. else if (nScreen == ID.LINKEDSCREEN.SubCall.Visitor) eCallType = CALLTYPE.HISTORY_VISITORPIC;
  6249. else {
  6250. Log.w(TAG, "[runWallPadCallAPKByUX] NOT Supported nScreen!! [" + nScreen + "]");
  6251. }
  6252. Log.i(TAG, "[runWallPadCallAPKByUX] eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6253. if (getIsSubWallpad()) {
  6254. // 서브월패드는 국선 기능을 제공하지 않는다.
  6255. if (eCallType != CALLTYPE.PSTN) runCallMainActivity(eCallOwner, eEventType, eCallType, nEmerState);
  6256. }
  6257. else {
  6258. runCallMainActivity(eCallOwner, eEventType, eCallType, nEmerState);
  6259. }
  6260. } catch (RuntimeException re) {
  6261. LogUtil.errorLogInfo("", TAG, re);
  6262. }
  6263. catch (Exception e) {
  6264. Log.e(TAG, "[Exception] runWallPadCallAPKByUX(int nScreen, int nEmerState)");
  6265. LogUtil.errorLogInfo("", TAG, e);
  6266. }
  6267. }
  6268. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  6269. try {
  6270. Log.i(TAG, "[runCallMainActivity] Common.bWallPadCallLive [" + Common.bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6271. if (!Common.bWallPadCallLive) {
  6272. // 통화어플을 실행시킨다.
  6273. sendLCDBacklightStatus(true);
  6274. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  6275. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6276. // mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  6277. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  6278. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  6279. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  6280. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6281. mIntent.setComponent(mComponentName);
  6282. startActivity(mIntent);
  6283. }
  6284. else {
  6285. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  6286. }
  6287. } catch (RuntimeException re) {
  6288. LogUtil.errorLogInfo("", TAG, re);
  6289. }
  6290. catch (Exception e) {
  6291. Log.e(TAG, "[Exception] runCallMainActivity()");
  6292. LogUtil.errorLogInfo("", TAG, e);
  6293. }
  6294. }
  6295. /**
  6296. * Edited by jeff (2020.06.22)
  6297. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  6298. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  6299. * @param bOn
  6300. */
  6301. private void sendLCDBacklightStatus(boolean bOn) {
  6302. try {
  6303. Log.d(TAG,"[sendLCDBacklightStatus] bOn [" + bOn + "]");
  6304. Intent mIntent = new Intent();
  6305. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  6306. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  6307. getApplicationContext().sendBroadcast(mIntent);
  6308. } catch (RuntimeException re) {
  6309. LogUtil.errorLogInfo("", TAG, re);
  6310. }
  6311. catch (Exception e) {
  6312. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  6313. LogUtil.errorLogInfo("", TAG, e);
  6314. }
  6315. }
  6316. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nEmerState) {
  6317. try {
  6318. Log.i(TAG, "[runCallMainActivity] Common.bWallPadCallLive [" + Common.bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "], nEmerState [" + nEmerState + "]");
  6319. if (!Common.bWallPadCallLive) {
  6320. // 통화어플을 실행시킨다.
  6321. sendLCDBacklightStatus(true);
  6322. if (eEventType == CALLEVENTTYPE.DETECT_STRANGER) {
  6323. if (nEmerState >= 0) {
  6324. if (nEmerState != WallpadStatusData.GUARD_OUT)
  6325. Common.SendAppFinishReqBR(getApplicationContext());
  6326. }
  6327. }
  6328. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  6329. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6330. // mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  6331. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  6332. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  6333. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  6334. mIntent.putExtra("EMERGENCY_STATE", nEmerState);
  6335. if (nEmerState != WallpadStatusData.GUARD_OUT) Common.SendAppFinishReqBR(getApplicationContext());
  6336. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6337. mIntent.setComponent(mComponentName);
  6338. startActivity(mIntent);
  6339. }
  6340. else {
  6341. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  6342. }
  6343. } catch (RuntimeException re) {
  6344. LogUtil.errorLogInfo("", TAG, re);
  6345. }
  6346. catch (Exception e) {
  6347. Log.e(TAG, "[Exception] runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nEmerState)");
  6348. LogUtil.errorLogInfo("", TAG, e);
  6349. }
  6350. }
  6351. private String getTopActivity() {
  6352. try {
  6353. ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  6354. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  6355. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  6356. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  6357. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  6358. return mComponentName.getPackageName();
  6359. } catch (RuntimeException re) {
  6360. LogUtil.errorLogInfo("", TAG, re);
  6361. return null;
  6362. }
  6363. catch (Exception e) {
  6364. Log.e(TAG, "[Exception] getTopActivity()");
  6365. LogUtil.errorLogInfo("", TAG, e);
  6366. return null;
  6367. }
  6368. }
  6369. /**
  6370. * 월패드에 설치된 APP들의 패키지 명 및 버전을 저장하는 클래스
  6371. * **/
  6372. class PackageVersionInfo {
  6373. protected String strPackageName;
  6374. protected String strPackageVersion;
  6375. public PackageVersionInfo(String strName, String strVersion) {
  6376. strPackageName = strName;
  6377. strPackageVersion = strVersion;
  6378. }
  6379. public String getPackageName() {
  6380. return strPackageName;
  6381. }
  6382. public String getPackageVersion() {
  6383. return strPackageVersion;
  6384. }
  6385. }
  6386. /**
  6387. * 통화 타임아웃 DB정보 초기화 (무조건 사용함으로 변경)
  6388. * **/
  6389. public void setCallAppTimeoutAsDefault() {
  6390. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6391. try {
  6392. mWallpadDeviceSet.Set_CallAppCallTimeout(true);
  6393. mWallpadDeviceSet.closeDB();
  6394. } catch (RuntimeException re) {
  6395. LogUtil.errorLogInfo("", TAG, re);
  6396. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6397. }
  6398. catch (Exception e) {
  6399. Log.e(TAG, "[Exception] setCallAppTimeoutAsDefault()");
  6400. LogUtil.errorLogInfo("", TAG, e);
  6401. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6402. }
  6403. }
  6404. /**
  6405. * 동호 설정 화면 나오게 처리
  6406. * **/
  6407. private void startManagerSettingSetAddress() {
  6408. try {
  6409. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6410. MAINStatus = MAIN_WAIT_SETIP;
  6411. mIntent.setComponent(new ComponentName("com.artncore.managersetting", "com.artncore.managersetting.ui.activities.SetAddress"));
  6412. mIntent.putExtra("KIND", "SOLO");
  6413. startActivity(mIntent);
  6414. } catch (RuntimeException re) {
  6415. LogUtil.errorLogInfo("", TAG, re);
  6416. }
  6417. catch (Exception e) {
  6418. Log.e(TAG, "[Exception] startManagerSettingSetAddress()");
  6419. LogUtil.errorLogInfo("", TAG, e);
  6420. }
  6421. }
  6422. private Handler mGetCallHistoryCheckHandler = new Handler() {
  6423. @Override
  6424. public void handleMessage(Message msg) {
  6425. if (msg.what == 0) {
  6426. // CheckCallData_CalledCountAndVisitorCount();
  6427. checkEventNotifications();
  6428. }
  6429. }
  6430. };
  6431. /**
  6432. * 음력 데이터를 raw resource에서 wallpaddata폴더 밑으로 복사한다.
  6433. * **/
  6434. private void copyDataBase(String OutputDBPath) throws IOException {
  6435. // Open your local db as the input stream
  6436. //InputStream myInput = this.getAssets().open("luna_db.db");
  6437. InputStream myInput = getResources().openRawResource(R.raw.luna_db);
  6438. // Path to the just created empty db
  6439. String outFileName = OutputDBPath;
  6440. // Open the empty db as the output stream
  6441. OutputStream myOutput = new FileOutputStream(outFileName);
  6442. try {
  6443. // transfer bytes from the inputfile to the outputfile
  6444. byte[] buffer = new byte[1024];
  6445. int length;
  6446. while ((length = myInput.read(buffer)) > 0)
  6447. {
  6448. myOutput.write(buffer, 0, length);
  6449. }
  6450. // Close the streams
  6451. myOutput.flush();
  6452. }
  6453. catch (RuntimeException re) {
  6454. LogUtil.errorLogInfo("", TAG, re);
  6455. }
  6456. catch (Exception e)
  6457. {
  6458. LogUtil.errorLogInfo("", TAG, e);
  6459. }
  6460. finally {
  6461. if(myOutput!=null)
  6462. myOutput.close();
  6463. myOutput = null;
  6464. if(myInput!=null)
  6465. myInput.close();
  6466. myInput = null;
  6467. }
  6468. }
  6469. @SuppressLint("HandlerLeak")
  6470. protected Handler mLCD_SleepHandler = new Handler()
  6471. {
  6472. @SuppressLint("HandlerLeak")
  6473. @Override
  6474. public void handleMessage(Message msg)
  6475. {
  6476. if (msg.what == 0) {
  6477. try {
  6478. if (m_ModelHouseSleepModeRelease == true) {
  6479. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  6480. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  6481. }
  6482. else {
  6483. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  6484. }
  6485. Log.i(TAG, "[SAMPLE SLEEP MODE] Never Sleep Run ~~~");
  6486. }
  6487. } catch (RuntimeException re) {
  6488. LogUtil.errorLogInfo("", TAG, re);
  6489. }
  6490. catch (Exception e) {
  6491. LogUtil.errorLogInfo("", TAG, e);
  6492. }
  6493. }
  6494. }
  6495. };
  6496. public void runIcon(int nIconID) {
  6497. try {
  6498. Log.d(TAG, "[runIcon] nIconID [" + nIconID + "]");
  6499. if (nIconID == ID.ICONS.MENUS.MAIN_ELEVATOR.getID()) {
  6500. // DB를 체크해서 층표시이면 팝업을 띄우고 아니면 바로 호출하도록 한다
  6501. String strElevShortEnabled = Common.getSubDevListItem(this.getContext() ,Common.SETTING_ITEM_SUB_DEVICE_ELEVATOR);
  6502. if(strElevShortEnabled!=null)
  6503. {
  6504. Log.d(TAG, "[runIcon] strElevShortEnabled [" + strElevShortEnabled + "]");
  6505. if (strElevShortEnabled.contains("사용함") && strElevShortEnabled.contains("기본")) {
  6506. Sound().Play(SND.effect.TOUCH_LATCHED);
  6507. Intent intent = new Intent(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  6508. intent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN);
  6509. getContext().sendBroadcast(intent);
  6510. }
  6511. else {
  6512. ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.ElevatorPopupScreen);
  6513. }
  6514. }
  6515. }
  6516. else if (nIconID == ID.ICONS.MENUS.MAIN_LIGHTS_OUT.getID()) {
  6517. ((MainActivity)(getContext())).StartPopup(ID.POPUPS.POPUP_COLLECTIVELIGHTCTRL);
  6518. }
  6519. else if (nIconID == ID.ICONS.MENUS.MAIN_CALRENDAR.getID()) {
  6520. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.TimeSetting);
  6521. }
  6522. else if (nIconID == ID.ICONS.MENUS.MAIN_WEATHER.getID()) {
  6523. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Weather);
  6524. }
  6525. else if (nIconID == ID.ICONS.MENUS.TALK_FRONT.getID()) {
  6526. // Common.command_iGW200( this.getContext(), Common.IGW200_DOOR_MONITERING );
  6527. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Door);
  6528. }
  6529. else if (nIconID == ID.ICONS.MENUS.TALK_LOBBY.getID()) {
  6530. // 로비는 수신시에만 출력되는 화면이므로 해당코드 없음
  6531. }
  6532. else if (nIconID == ID.ICONS.MENUS.TALK_NEIGHBOR.getID()) {
  6533. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Neighboor);
  6534. }
  6535. else if (nIconID == ID.ICONS.MENUS.TALK_GUARD.getID()) {
  6536. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Guard);
  6537. }
  6538. else if (nIconID == ID.ICONS.MENUS.TALK_PHONE.getID()) {
  6539. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Pstn);
  6540. }
  6541. else if (nIconID == ID.ICONS.MENUS.TALK_CALLHISTORY.getID()) {
  6542. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.CallList);
  6543. }
  6544. else if (nIconID == ID.ICONS.MENUS.TALK_VISITORPIC.getID()) {
  6545. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Visitor);
  6546. }
  6547. else if (nIconID == ID.ICONS.MENUS.CTRL_LIGHT.getID()) {
  6548. // 모델별 설정에 따라 구분하여 호출하는 기능 추가해야함
  6549. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  6550. int[] naLightEnable = mWallpadDeviceSet.Get_Light_info(); // 조명설정 확인
  6551. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6552. // for (int i = 0; i < naLightEnable.length; i++) Log.i(TAG, "[runIcon] naLightEnable[" + i + "] = " + naLightEnable[i]);
  6553. //기본형
  6554. if (naLightEnable[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_NORMAL) {
  6555. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDCLivingNEach_Lamp);
  6556. }
  6557. //기본형 + 에너지미터
  6558. else if(naLightEnable[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_ADD_BATCHLIGHT_MULTISWITCH) {
  6559. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDCLivingNEnergyMeter_Lamp);
  6560. }
  6561. else {
  6562. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDC_EachLamp);
  6563. }
  6564. }
  6565. else if (nIconID == ID.ICONS.MENUS.CTRL_HEATING.getID()) {
  6566. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Heating_V1);
  6567. }
  6568. //커튼 추가(전동커튼)
  6569. else if (nIconID == ID.ICONS.MENUS.CTRL_CURTAIN.getID()) {
  6570. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Curtain);
  6571. }
  6572. else if (nIconID == ID.ICONS.MENUS.CTRL_GAS.getID()) {
  6573. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Gas);
  6574. }
  6575. else if (nIconID == ID.ICONS.MENUS.CTRL_DOORLOCK.getID()) {
  6576. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.DoorLockWL);
  6577. }
  6578. else if (nIconID == ID.ICONS.MENUS.CTRL_VENT.getID()) {
  6579. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.ChangAir_Normal);
  6580. }
  6581. else if (nIconID == ID.ICONS.MENUS.CTRL_OUTLET.getID()) {
  6582. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  6583. int[] naLightEnable = mWallpadDeviceSet.Get_Light_info(); // 조명설정 확인
  6584. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6585. if (naLightEnable[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_ADD_BATCHLIGHT_MULTISWITCH) {
  6586. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDCLivingNEach_Concent);
  6587. }
  6588. else {
  6589. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Concent);
  6590. }
  6591. }
  6592. else if (nIconID == ID.ICONS.MENUS.CTRL_LIVINGLIGHT.getID()) {
  6593. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDC_LivingLamp);
  6594. }
  6595. else if (nIconID == ID.ICONS.MENUS.CTRL_AIRQUALTY.getID()) {
  6596. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.AirQualty);
  6597. }
  6598. else if (nIconID == ID.ICONS.MENUS.CTRL_ELECCOOKTOP.getID()) {
  6599. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.ElecCooktop);
  6600. }
  6601. else if (nIconID == ID.ICONS.MENUS.CTRL_COOKTOPOUTLET.getID()) {
  6602. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.CooktopOutlet);
  6603. }
  6604. else if (nIconID == ID.ICONS.MENUS.CTRL_SYSTEMAIRCON.getID()) {
  6605. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.SystemAircon);
  6606. }
  6607. else if (nIconID == ID.ICONS.MENUS.ADD_NOTICE.getID()) {
  6608. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Notice);
  6609. }
  6610. else if (nIconID == ID.ICONS.MENUS.ADD_WEATHER.getID()) {
  6611. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Weather);
  6612. }
  6613. else if (nIconID == ID.ICONS.MENUS.ADD_MEMO.getID()) {
  6614. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Memo);
  6615. }
  6616. else if (nIconID == ID.ICONS.MENUS.ADD_E_FRAME.getID()) {
  6617. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.AutoPicture);
  6618. }
  6619. else if (nIconID == ID.ICONS.MENUS.ADD_SCHEDULE.getID()) {
  6620. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Schedule);
  6621. }
  6622. else if (nIconID == ID.ICONS.MENUS.ADD_CCTV.getID()) {
  6623. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Cctv);
  6624. }
  6625. else if (nIconID == ID.ICONS.MENUS.ADD_PARKING.getID()) {
  6626. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Parking);
  6627. }
  6628. else if (nIconID == ID.ICONS.MENUS.ADD_PARKINGLIST.getID()) {
  6629. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.ParkingList);
  6630. }
  6631. else if (nIconID == ID.ICONS.MENUS.ADD_ELECTRICCAR.getID()) {
  6632. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.ElecCar);
  6633. }
  6634. else if (nIconID == ID.ICONS.MENUS.ADD_INTERLAYERNOISE.getID()) {
  6635. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.InterlayerNoiseHistory);
  6636. }
  6637. else if (nIconID == ID.ICONS.MENUS.ADD_VISITEDVEHICLEREGI.getID()) {
  6638. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.VisitedVehicleRegi);
  6639. }
  6640. else if (nIconID == ID.ICONS.MENUS.ADD_BANDLOCATION.getID()) {
  6641. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.BandLocation);
  6642. }
  6643. else if (nIconID == ID.ICONS.MENUS.ADD_GUARDINGSTREETLAMP.getID()) {
  6644. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.GuardingStreetLamp);
  6645. }
  6646. else if (nIconID == ID.ICONS.MENUS.SECURITY_SETARMED.getID()) {
  6647. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.SecurityMain);
  6648. }
  6649. else if (nIconID == ID.ICONS.MENUS.SECURITY_DEVICELINK.getID()) {
  6650. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.LinkDeviceSet);
  6651. }
  6652. else if (nIconID == ID.ICONS.MENUS.SECURITY_DEVICELINKSLEEP.getID()) {
  6653. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.lnkBedDeviceSet);
  6654. }
  6655. else if (nIconID == ID.ICONS.MENUS.SECURITY_ACCESSHISTORY.getID()) {
  6656. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.AccessHistoryDoor);
  6657. }
  6658. else if (nIconID == ID.ICONS.MENUS.SECURITY_VISITORVIDEO.getID()) {
  6659. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.VisitorVideo);
  6660. }
  6661. //에너지
  6662. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTPANEL.getID()) {
  6663. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartPanel);
  6664. }
  6665. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTLIGHT.getID()) {
  6666. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartLight);
  6667. }
  6668. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTOUTLET.getID()) {
  6669. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartOutlet);
  6670. }
  6671. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYMETER.getID()) {
  6672. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.IEnergy);
  6673. }
  6674. else if (nIconID == ID.ICONS.MENUS.ENERGY_REMOTEMETER.getID()) {
  6675. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.RemoteMeter);
  6676. }
  6677. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYCONSUMPTION.getID()) {
  6678. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.EnergyMgr);
  6679. }
  6680. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYCOSTTABLE.getID()) {
  6681. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.CostTable);
  6682. }
  6683. else if (nIconID == ID.ICONS.MENUS.SETTING_CONFIG.getID()) {
  6684. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.Configuration);
  6685. }
  6686. else if (nIconID == ID.ICONS.MENUS.SETTING_CLREANSCREEN.getID()) {
  6687. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.CleanLcd);
  6688. }
  6689. else if (nIconID == ID.ICONS.MENUS.SETTING_PWCHANGE.getID()) {
  6690. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.PassWordChange);
  6691. }
  6692. else if (nIconID == ID.ICONS.MENUS.SETTING_MORNINGCALL.getID()) {
  6693. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.MoningCall);
  6694. }
  6695. else if (nIconID == ID.ICONS.MENUS.SETTING_SMARTKEY.getID()) {
  6696. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.SmartKey);
  6697. }
  6698. else if (nIconID == ID.ICONS.MENUS.SETTING_SMARTBAND.getID()) {
  6699. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.SmartBand);
  6700. }
  6701. else if (nIconID == ID.ICONS.MENUS.SETTING_ACCESSCARD.getID()) {
  6702. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.RfCard);
  6703. }
  6704. else if (nIconID == ID.ICONS.MENUS.SETTING_CALENDAR.getID()) {
  6705. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.TimeSetting);
  6706. }
  6707. else if (nIconID == ID.ICONS.MENUS.SETTING_REMOTECALLUSER.getID()) {
  6708. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.RemoteCallUser);
  6709. }
  6710. else if (nIconID == ID.ICONS.MENUS.SETTING_REMOTECTRL.getID()) {
  6711. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.MobileDeviceReg);
  6712. }
  6713. else if (nIconID == ID.ICONS.MENUS.SETTING_OCCUPANCYSENSOR.getID()) {
  6714. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.OccupancySensorConfig);
  6715. }
  6716. else {
  6717. Log.w(TAG, "[runShortcut] nIconID is not supported!! [" + nIconID + "]");
  6718. }
  6719. } catch (RuntimeException re) {
  6720. LogUtil.errorLogInfo("", TAG, re);
  6721. }
  6722. catch (Exception e) {
  6723. Log.e(TAG, "[Exception] runShortcut(int nIconID)");
  6724. LogUtil.errorLogInfo("", TAG, e);
  6725. }
  6726. }
  6727. public void runSecurityAPK(int nScreenID) {
  6728. try {
  6729. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  6730. int nSecurityMode = wdb.GetAlarmStatus();
  6731. wdb.closeDB();
  6732. Log.w(TAG, "[runSecurityAPK] nSecurityMode [" + nSecurityMode + "]");
  6733. if (nSecurityMode == WallpadStatusData.GUARD_IN) {
  6734. // 팝업 띄워서 재택모드 해제 유도
  6735. StartPopup(ID.POPUPS.POPUP_RELEASEINMODE);
  6736. // ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.SecurityReleasePopupScreen);
  6737. }
  6738. else if (nSecurityMode == WallpadStatusData.OUT_MODE) {
  6739. // 팝업 띄워서 외출모드 해제 유도
  6740. StartPopup(ID.POPUPS.POPUP_RELEASEOUTMODE);
  6741. // ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.OutModeReleasePopupScreen);
  6742. }
  6743. else if (nSecurityMode == WallpadStatusData.ALARM_STOP) {
  6744. // 알람 화면을 띄우도록 한다.
  6745. runEmergencyAPK(this, getAlarmType(), 2 , "모름");
  6746. }
  6747. else {
  6748. m_CallSubMenuScreen.callStartSecurityAPK(nScreenID);
  6749. }
  6750. } catch (RuntimeException re) {
  6751. LogUtil.errorLogInfo("", TAG, re);
  6752. }
  6753. catch (Exception e) {
  6754. Log.e(TAG, "[Exception] runSecurityAPK(int nScreenID)");
  6755. LogUtil.errorLogInfo("", TAG, e);
  6756. }
  6757. }
  6758. public void runEmergencyAPK(Context context, int nScreenID, int startOption, String detailInfo) {
  6759. try {
  6760. // DB 체크 해서 띄우 도록 한다.
  6761. int [] m_EmerMenuList = new int[4];
  6762. m_EmerMenuList[0] = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  6763. m_EmerMenuList[1] = ID.LINKEDSCREEN.SubEmergency.FIRE_ALARM;
  6764. m_EmerMenuList[2] = ID.LINKEDSCREEN.SubEmergency.BREAKIN_ALARM;
  6765. m_EmerMenuList[3] = ID.LINKEDSCREEN.SubEmergency.LADDER_ALARM;
  6766. Intent intent = new Intent(Intent.ACTION_MAIN);
  6767. intent.putExtra(Common.MENU_ID_LIST, m_EmerMenuList); // KEY : MENU_ID_LIST
  6768. intent.putExtra(Common.MENU_START_ID, nScreenID); // KEY : MENU_START_ID
  6769. intent.putExtra(Common.MENU_START_OPTION, startOption); // KEY : MENU_START_OPTION
  6770. intent.putExtra(Common.MENU_DETAIL_INFO, detailInfo);
  6771. intent.setComponent(new ComponentName(Common.EMER_ALARM_APK, Common.EMER_ALARM_APK + Common.MAIN_ACTIVITY ));
  6772. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6773. context.startActivity(intent);
  6774. } catch (RuntimeException re) {
  6775. LogUtil.errorLogInfo("", TAG, re);
  6776. }
  6777. catch (Exception e) {
  6778. Log.e(TAG, "[Exception] runEmergencyAPK(Context context, int nScreenID, int startOption, String detailInfo)");
  6779. LogUtil.errorLogInfo("", TAG, e);
  6780. }
  6781. }
  6782. public int getAlarmType() {
  6783. WallpadStatusData SetData = new WallpadStatusData(this.getContext());
  6784. int alarmtype = SetData.GetAlarmType();
  6785. SetData.closeDB();
  6786. int Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  6787. switch (alarmtype) {
  6788. case WallpadStatusData.ALARM_ALERT:
  6789. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.FIRE_ALARM;
  6790. break;
  6791. case WallpadStatusData.ALARM_EMM:
  6792. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  6793. break;
  6794. case WallpadStatusData.ALARM_EVAC:
  6795. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.LADDER_ALARM;
  6796. break;
  6797. case WallpadStatusData.ALARM_INVADE:
  6798. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.BREAKIN_ALARM;
  6799. break;
  6800. }
  6801. return Menu_Start_Option;
  6802. }
  6803. public void runGoogleLauncher() {
  6804. try {
  6805. ComponentName mComponentName = new ComponentName("com.android.launcher3", "com.android.launcher3.Launcher");
  6806. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6807. mIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  6808. mIntent.setComponent(mComponentName);
  6809. startActivity(mIntent);
  6810. } catch (RuntimeException re) {
  6811. LogUtil.errorLogInfo("", TAG, re);
  6812. }
  6813. catch (Exception e) {
  6814. Log.e(TAG, "[Exception] runGoogleLauncher()");
  6815. LogUtil.errorLogInfo("", TAG, e);
  6816. }
  6817. }
  6818. public void setCallAppRunning(boolean bRunning) {
  6819. try {
  6820. Log.i(TAG, "[setCallAppRunning] bRunning [" + bRunning + "]");
  6821. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  6822. DBMGR.SetCallAPKStatus(bRunning);
  6823. DBMGR.closeDB();
  6824. } catch (RuntimeException re) {
  6825. LogUtil.errorLogInfo("", TAG, re);
  6826. }
  6827. catch (Exception e) {
  6828. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  6829. LogUtil.errorLogInfo("", TAG, e);
  6830. }
  6831. }
  6832. private void registerMainActivityBR() {
  6833. try {
  6834. IntentFilter filter = new IntentFilter();
  6835. filter.addAction(Common.BR_REQUEST_APK_RUN);
  6836. filter.addAction(ACTION_TIME_TICK);
  6837. filter.addAction(Common.BR_PLAY_SOUND);
  6838. filter.addAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  6839. filter.addAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  6840. mContext.registerReceiver(MainActivityBroadcastReceiver, filter);
  6841. } catch (RuntimeException re) {
  6842. LogUtil.errorLogInfo("", TAG, re);
  6843. }
  6844. catch (Exception e) {
  6845. Log.e(TAG, "[Exception] registerMainActivityBR()");
  6846. LogUtil.errorLogInfo("", TAG, e);
  6847. }
  6848. }
  6849. String strAPKType = "APKType";
  6850. String strMenuType = "MenuType";
  6851. String strSoundID = "SoundID";
  6852. BroadcastReceiver MainActivityBroadcastReceiver = new BroadcastReceiver() {
  6853. @Override
  6854. public void onReceive(Context context, Intent intent) {
  6855. try {
  6856. if (((MainActivity)(getContext())).getMainSubScreenLoadingComplite() == false)
  6857. return;
  6858. String strActionName = intent.getAction();
  6859. Log.d(TAG,"[MainActivityBroadcastReceiver] strActionName [" + strActionName + "]");
  6860. if (strActionName.equals(Common.BR_REQUEST_APK_RUN)) {
  6861. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) BR_REQUEST_APK_RUN");
  6862. int nAPKType = intent.getIntExtra(strAPKType,0);
  6863. int nMenuType = intent.getIntExtra(strMenuType,0);
  6864. int nCardNum = intent.getIntExtra(Common.BR_MAIN_NOTI.CARD_NUM, 0);
  6865. Log.d(TAG, "[MainActivityBroadcastReceiver] nAPKType [" + nAPKType + "], nMenuType [" + nMenuType + "], nCardNum [" + nCardNum + "]");
  6866. if (nAPKType == ID.LINKEDSCREEN.SubCall.BASE) {
  6867. m_CallSubMenuScreen.callStartCallAPK(nMenuType);
  6868. }
  6869. else if (nAPKType == ID.LINKEDSCREEN.SubMenuAddService.BASE) {
  6870. m_CallSubMenuScreen.callStartAddServiceAPK(nMenuType, nCardNum);
  6871. }
  6872. }
  6873. else if (strActionName.equals(ACTION_TIME_TICK)) {
  6874. // checkTimeTasks();
  6875. if (bLCDKeeperUsage) ctrlLCDKeeper();
  6876. }
  6877. else if (strActionName.equals(Common.BR_PLAY_SOUND)) {
  6878. int nSoundID = intent.getIntExtra(strSoundID,0);
  6879. Sound().Play(nSoundID);
  6880. }
  6881. else if (strActionName.equals(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON)) {
  6882. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) NOTIFY_ACNAME_LCD_BACKLIGHT_ON: bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  6883. if (bLCDKeeperUsage) {
  6884. bLCDBacklightPower = true;
  6885. ctrlLCDKeeper();
  6886. }
  6887. }
  6888. else if (strActionName.equals(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF)) {
  6889. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) NOTIFY_ACNAME_LCD_BACKLIGHT_OFF: bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  6890. if (bLCDKeeperUsage) {
  6891. bLCDBacklightPower = false;
  6892. ctrlLCDKeeper();
  6893. }
  6894. }
  6895. else {
  6896. Log.w(TAG,"[MainActivityBroadcastReceiver] Not supported strActionName [" + strActionName + "]");
  6897. }
  6898. } catch (RuntimeException re) {
  6899. LogUtil.errorLogInfo("", TAG, re);
  6900. }
  6901. catch (Exception e) {
  6902. Log.e(TAG, "[Exception] MainActivityBroadcastReceiver()");
  6903. LogUtil.errorLogInfo("", TAG, e);
  6904. }
  6905. }
  6906. };
  6907. public Common.GUI_TYPE checkGUIType(Context context) {
  6908. try {
  6909. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(context);
  6910. String strGUIType = mWallpadDeviceSet.GetMainGUISelect();
  6911. mWallpadDeviceSet.closeDB();
  6912. if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_DEFAULT)) return Common.GUI_TYPE.STANDARD;
  6913. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_METRO)) return Common.GUI_TYPE.METRO;
  6914. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_HYOSUNG)) return Common.GUI_TYPE.HYOSUNG;
  6915. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_HIMCHAN)) return Common.GUI_TYPE.HIMCHAN;
  6916. else return Common.GUI_TYPE.STANDARD;
  6917. } catch (RuntimeException re) {
  6918. LogUtil.errorLogInfo("", TAG, re);
  6919. return Common.GUI_TYPE.STANDARD;
  6920. }
  6921. catch (Exception e) {
  6922. Log.e(TAG, "[Exception] checkGUIType(Context context)");
  6923. LogUtil.errorLogInfo("", TAG, e);
  6924. return Common.GUI_TYPE.STANDARD;
  6925. }
  6926. }
  6927. public void finishActivity() {
  6928. try {
  6929. Log.i(TAG, "[finishActivity]");
  6930. super.finish();
  6931. } catch (RuntimeException re) {
  6932. LogUtil.errorLogInfo("", TAG, re);
  6933. }
  6934. catch (Exception e) {
  6935. Log.e(TAG, "[Exception] finishActivity()");
  6936. LogUtil.errorLogInfo("", TAG, e);
  6937. }
  6938. }
  6939. // MainActivity Handler
  6940. public final class HANDLERMSG {
  6941. public final static int CHECK_FLIPPER_MAINSCREEN_ID = 100;
  6942. public final static int CHECK_WALLPAD_CAMERA_INIT = 200;
  6943. public final static int CHECK_WALLPAD_CAMERA_REMOVE = 300;
  6944. public final static int CHECK_WALLPAD_CAMERA_RESET = 400;
  6945. public final static int CHECK_WALLPAD_CAMERA_CHECK = 500;
  6946. public final static int FINISH_ACTIVITY = 999;
  6947. }
  6948. public Handler MainHandler = new Handler(Looper.getMainLooper()) {
  6949. public void handleMessage(Message msg) {
  6950. Log.d(TAG, "[MainHandler] MainHandler : what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
  6951. switch (msg.what) {
  6952. case HANDLERMSG.CHECK_FLIPPER_MAINSCREEN_ID:
  6953. // checkMainPage();
  6954. break;
  6955. case HANDLERMSG.CHECK_WALLPAD_CAMERA_INIT:
  6956. if (getWallPadCameraUsage()) {
  6957. initMyVideoSurfaceLayout();
  6958. sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_REMOVE, 0, 0, 3000); // 월패드 카메라 영상을 띄우고 5초뒤에 없앤다.
  6959. }
  6960. break;
  6961. case HANDLERMSG.CHECK_WALLPAD_CAMERA_REMOVE:
  6962. if (getWallPadCameraUsage()) removeMyVideoSurfaceLayout();
  6963. break;
  6964. case HANDLERMSG.CHECK_WALLPAD_CAMERA_RESET:
  6965. if (getWallPadCameraUsage()) resetCameraService();
  6966. break;
  6967. case HANDLERMSG.CHECK_WALLPAD_CAMERA_CHECK:
  6968. checkCameraLoading();
  6969. break;
  6970. case HANDLERMSG.FINISH_ACTIVITY:
  6971. finishActivity();
  6972. break;
  6973. default:
  6974. Log.d(TAG, "MainHandler : " + msg.what);
  6975. break;
  6976. }
  6977. }
  6978. };
  6979. public void sendHandlerMsg(int what, int arg1, int arg2) {
  6980. try {
  6981. Log.i(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
  6982. Message HandleMsg = MainHandler.obtainMessage();
  6983. HandleMsg.what = what;
  6984. HandleMsg.arg1 = arg1;
  6985. HandleMsg.arg2 = arg2;
  6986. MainHandler.sendMessage(HandleMsg);
  6987. } catch (RuntimeException re) {
  6988. LogUtil.errorLogInfo("", TAG, re);
  6989. }
  6990. catch (Exception e) {
  6991. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  6992. LogUtil.errorLogInfo("", TAG, e);
  6993. }
  6994. }
  6995. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, long delay) {
  6996. try {
  6997. Log.i(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
  6998. Message HandleMsg = MainHandler.obtainMessage();
  6999. HandleMsg.what = what;
  7000. HandleMsg.arg1 = arg1;
  7001. HandleMsg.arg2 = arg2;
  7002. MainHandler.sendMessageDelayed(HandleMsg, delay);
  7003. } catch (RuntimeException re) {
  7004. LogUtil.errorLogInfo("", TAG, re);
  7005. }
  7006. catch (Exception e) {
  7007. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  7008. LogUtil.errorLogInfo("", TAG, e);
  7009. }
  7010. }
  7011. private boolean savePresetValue(String strPresetValues) {
  7012. try {
  7013. Log.i(TAG, "[savePresetValue] strPresetValues [" + strPresetValues + "]");
  7014. String[] strParse_01 = strPresetValues.split("/");
  7015. int presetid = Integer.parseInt(strParse_01[0]);
  7016. String[] strParse_02 = strParse_01[1].split(":");
  7017. String onoff = strParse_02[0];
  7018. int dim = Integer.parseInt(strParse_02[1]);
  7019. int color = Integer.parseInt(strParse_02[2]);
  7020. WallpadStatusData mWallpadStatusData = new WallpadStatusData(mContext);
  7021. boolean result = mWallpadStatusData.setLivinglightModeCtrlUnitValues(presetid, 0, "on", dim, color);
  7022. mWallpadStatusData.closeDB();
  7023. Log.d(TAG, "[savePresetValue] result [" + result + "], onoff [" + onoff + "], dim [" + dim + "], color [" + color + "]");
  7024. if (result) {
  7025. mLightInfo.mPreset[presetid].mLights[0].ONOFF = onoff;
  7026. mLightInfo.mPreset[presetid].mLights[0].DIM = dim;
  7027. mLightInfo.mPreset[presetid].mLights[0].COLOR = color;
  7028. 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 + "]");
  7029. return true;
  7030. }
  7031. else {
  7032. Log.w(TAG,"[savePresetValue] Fail to save light preset values!!");
  7033. return false;
  7034. }
  7035. } catch (RuntimeException re) {
  7036. LogUtil.errorLogInfo("", TAG, re);
  7037. return false;
  7038. }
  7039. catch (Exception e) {
  7040. Log.e(TAG, "[Exception] savePresetValue(String strPresetValues)");
  7041. LogUtil.errorLogInfo("", TAG, e);
  7042. return false;
  7043. }
  7044. }
  7045. private void initProximitySensor() {
  7046. try {
  7047. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  7048. int nProximitySensorLevel = mWallpadStatusData.GetCloseSensorValue();
  7049. mWallpadStatusData.closeDB();
  7050. Log.i(TAG, "[initProximitySensor] nProximitySensorLevel = " + nProximitySensorLevel);
  7051. if (nProximitySensorLevel < 0 || 5 < nProximitySensorLevel) {
  7052. Log.w(TAG, "[initProximitySensor] nProximitySensorLevel is out of range!!");
  7053. nProximitySensorLevel = 5;
  7054. }
  7055. int nResult = mIOInterface.setProximitySensorLevel(nProximitySensorLevel * 3);
  7056. Log.i(TAG, "[initProximitySensor] nResult = " + nResult);
  7057. } catch (RuntimeException re) {
  7058. LogUtil.errorLogInfo("", TAG, re);
  7059. }
  7060. catch (Exception e) {
  7061. Log.e(TAG, "[Exception] initProximitySensor()");
  7062. LogUtil.errorLogInfo("", TAG, e);
  7063. }
  7064. }
  7065. private boolean checkInterFloorNoiseError() {
  7066. try {
  7067. WallpadStatusData wsd = new WallpadStatusData(getContext());
  7068. String stSensorStatus = wsd.Get_InterlayerSensor_Status();
  7069. wsd.closeDB();
  7070. // 센서 정상 : false, 센서 이상 : true
  7071. Log.i(TAG, "[checkInterFloorNoiseError] stSensorStatus : " + stSensorStatus);
  7072. if (stSensorStatus.equalsIgnoreCase(define.INTERLAYER_NOISE_STATUS_NORMAL)) return false;
  7073. else return true;
  7074. } catch (RuntimeException re) {
  7075. LogUtil.errorLogInfo("", TAG, re);
  7076. return false;
  7077. }
  7078. catch (Exception e) {
  7079. Log.e(TAG, "[Exception] checkInterFloorNoiseError()");
  7080. LogUtil.errorLogInfo("", TAG, e);
  7081. return false;
  7082. }
  7083. }
  7084. private boolean checkInterFloorNoiseFuncUsage() {
  7085. try {
  7086. WallpadStatusData wsd = new WallpadStatusData(getContext());
  7087. boolean bUsage = wsd.GetNoisePopupUse();
  7088. wsd.closeDB();
  7089. return bUsage;
  7090. } catch (RuntimeException re) {
  7091. LogUtil.errorLogInfo("", TAG, re);
  7092. return false;
  7093. }
  7094. catch (Exception e) {
  7095. Log.e(TAG, "[Exception] checkInterFloorNoiseFuncUsage()");
  7096. LogUtil.errorLogInfo("", TAG, e);
  7097. return false;
  7098. }
  7099. }
  7100. /**
  7101. * 현관호출 or 전화호출시 사용되는 keycode - Broadcast 을 송신한다.
  7102. *
  7103. * @param nKeyCode - (int) 송신할 keycode
  7104. * @return (int) - >=0 : 성공, <0 : 실패
  7105. */
  7106. private int sendKeyEventBR(int nKeyCode) {
  7107. try {
  7108. Log.i(TAG, "[sendKeyEventBR] nKeyCode [" + nKeyCode +"] -> EVENT_DEVICE_CONTROL");
  7109. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  7110. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  7111. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  7112. intent.putExtra("keycode",nKeyCode);
  7113. sendBroadcast(intent);
  7114. } catch (RuntimeException re) {
  7115. LogUtil.errorLogInfo("", TAG, re);
  7116. return -100;
  7117. }
  7118. catch (Exception e) {
  7119. Log.e(TAG, "[Exception] sendKeyEventBR(int nKeyCode) [" + nKeyCode + "]");
  7120. LogUtil.errorLogInfo("", TAG, e);
  7121. return -100;
  7122. }
  7123. return 0;
  7124. }
  7125. // 카카오 연동 관련
  7126. public static boolean bKakaoiEnable = false;
  7127. /**
  7128. * 이진규
  7129. * kakaohome 서비스 사용 유무 판단
  7130. */
  7131. protected boolean bKakaoHomeEnable = false;
  7132. // run Kakao i floating button 실행
  7133. private void startKakaoiFloatingBTN() {
  7134. try {
  7135. Log.i(TAG, "[startKakaoiFloatingBTN] ========== Run Kakao i floating button ==========");
  7136. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadglobalbutton", "kr.co.icontrols.wallpadglobalbutton.MainActivity");
  7137. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  7138. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  7139. mIntent.setComponent(mComponentName);
  7140. startActivity(mIntent);
  7141. } catch (RuntimeException re) {
  7142. LogUtil.errorLogInfo("", TAG, re);
  7143. }
  7144. catch (Exception e) {
  7145. Log.e(TAG, "[Exception] startKakaoiFloatingBTN()");
  7146. LogUtil.errorLogInfo("", TAG, e);
  7147. }
  7148. }
  7149. public void Send_NotiSmartSwitch(int nNoticeCnt, int nParcelCnt, int nVisitorPicCnt)
  7150. {
  7151. try
  7152. {
  7153. Intent intentBR = new Intent();
  7154. intentBR.setAction(define.DRIVER_ISD_NOTIINFO);
  7155. //if( m_NoticeCNT > 0 || m_ParcelCNT > 0 || m_InCallCNT > 0 || m_VisitorCNT > 0 )
  7156. {
  7157. // 아이콘 활성화
  7158. if( nNoticeCnt > 0 )
  7159. {
  7160. Log.d(TAG, "LOG : NOTICE CNT INCREASED ++");
  7161. intentBR.putExtra(define.NOTIBR_ISD_NOTICECNT, nNoticeCnt);
  7162. Log.d(TAG, "NoticeCNT BroadCast Added");
  7163. }
  7164. else
  7165. {
  7166. intentBR.putExtra(define.NOTIBR_ISD_NOTICECNT, 0);
  7167. Log.d(TAG, "NoticeCNT ZERO Added");
  7168. }
  7169. if( nParcelCnt > 0 )
  7170. {
  7171. Log.d(TAG, "LOG : Parcel CNT INCREASED ++");
  7172. intentBR.putExtra(define.NOTIBR_ISD_PARCELCNT, nParcelCnt);
  7173. Log.d(TAG, "ParcelCNT BroadCast Added");
  7174. }
  7175. else
  7176. {
  7177. intentBR.putExtra(define.NOTIBR_ISD_PARCELCNT, 0);
  7178. Log.d(TAG, "ParcelCNT ZERO Added");
  7179. }
  7180. if( nVisitorPicCnt > 0 )
  7181. {
  7182. Log.d(TAG, "LOG : VISITOR CNT INCREASED ++");
  7183. intentBR.putExtra(define.NOTIBR_ISD_VISITORCNT, nVisitorPicCnt);
  7184. Log.d(TAG, "VisitorCNT BroadCast Added");
  7185. }
  7186. else
  7187. {
  7188. intentBR.putExtra(define.NOTIBR_ISD_VISITORCNT, nVisitorPicCnt);
  7189. Log.d(TAG, "VisitorCNT ZERO Added");
  7190. }
  7191. // 알림정보 intent BroadCast
  7192. getContext().sendBroadcast(intentBR);
  7193. }
  7194. }
  7195. catch (RuntimeException re) {
  7196. LogUtil.errorLogInfo("", TAG, re);
  7197. }
  7198. catch (Exception e)
  7199. {
  7200. Log.e(TAG, e.toString());
  7201. LogUtil.errorLogInfo("", TAG, e);
  7202. }
  7203. }
  7204. // private void startKakaoiVoiceAgent() {
  7205. // try {
  7206. // Log.i(TAG, "[startKakaoiVoiceAgent] ========== Start Kakao i Voice Agent ==========");
  7207. // Intent mIntent = new Intent("com.kakao.i.agent.START_SERVICE").setPackage("com.kakao.i.test.sandbox");
  7208. // ContextCompat.startForegroundService(this, mIntent);
  7209. // } catch (RuntimeException re) {
  7210. // LogUtil.errorLogInfo("", TAG, re);
  7211. // }
  7212. // catch (Exception e) {
  7213. // Log.e(TAG, "[Exception] startKakaoiVoiceAgent()");
  7214. // e.printStackTrace();
  7215. // }
  7216. // }
  7217. //
  7218. // private void enableKakaoiVoiceAgent() {
  7219. // try {
  7220. // Log.i(TAG, "[enableKakaoiVoiceAgent] ========== Enable Kakao i Voice Agent ==========");
  7221. // Intent mIntent = new Intent("com.kakao.i.agent.ENABLE_KAKAO_I").setPackage("com.kakao.i.test.sandbox");
  7222. // ContextCompat.startForegroundService(this, mIntent);
  7223. // } catch (RuntimeException re) {
  7224. // LogUtil.errorLogInfo("", TAG, re);
  7225. // }
  7226. // catch (Exception e) {
  7227. // Log.e(TAG, "[Exception] enableKakaoiVoiceAgent()");
  7228. // e.printStackTrace();
  7229. // }
  7230. // }
  7231. //
  7232. // private void diableKakaoiVoiceAgent() {
  7233. // try {
  7234. // Log.i(TAG, "[diableKakaoiVoiceAgent] ========== Disable Kakao i Voice Agent ==========");
  7235. // Intent mIntent = new Intent("com.kakao.i.agent.DISABLE_KAKAO_I").setPackage("com.kakao.i.test.sandbox");
  7236. // ContextCompat.startForegroundService(this, mIntent);
  7237. // } catch (RuntimeException re) {
  7238. // LogUtil.errorLogInfo("", TAG, re);
  7239. // }
  7240. // catch (Exception e) {
  7241. // Log.e(TAG, "[Exception] diableKakaoiVoiceAgent()");
  7242. // e.printStackTrace();
  7243. // }
  7244. // }
  7245. /**
  7246. * JEFF, 2019.08.06
  7247. * 동탄현장 월패드 죽는 이슈 원인 분석을 위한 월패드 App 삭제 코드
  7248. * 메인App만 남기고 모두 삭제
  7249. */
  7250. UninstallAPKs mUninstallAPKs = new UninstallAPKs();
  7251. class UninstallAPKs extends Thread {
  7252. @Override
  7253. public void run() {
  7254. super.run();
  7255. try {
  7256. Log.d(TAG, "[UninstallAPKs.run()] Started getting installed package infomation");
  7257. ArrayList<PackageVersionInfo> PackageVersionInfos = new ArrayList<PackageVersionInfo>();
  7258. List<PackageInfo> PackageInfoList = getPackageManager().getInstalledPackages(PackageManager.PERMISSION_GRANTED);
  7259. while (true) {
  7260. Log.d(TAG, "[UninstallAPKs.run()] Get installed packages start!!");
  7261. try {
  7262. for (PackageInfo pack : PackageInfoList) {
  7263. // Log.d(TAG, "[UninstallAPKs.run()] Package Name [" + pack.packageName + "]");
  7264. // Log.d(TAG, "[UninstallAPKs.run()] Version Name [" + pack.versionName + "]");
  7265. if ((pack.packageName.contains("icontrols")) || (pack.packageName.contains("artncore"))) {
  7266. PackageVersionInfos.add(new PackageVersionInfo(pack.packageName, pack.versionName));
  7267. }
  7268. }
  7269. } catch (RuntimeException re) {
  7270. LogUtil.errorLogInfo("", TAG, re);
  7271. break;
  7272. } catch (Exception e) {
  7273. LogUtil.errorLogInfo("", TAG, e);
  7274. break;
  7275. }
  7276. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages end!!");
  7277. break;
  7278. }
  7279. for (int i = 0; i < PackageVersionInfos.size(); i++) {
  7280. Log.d(TAG, "[UninstallAPKs.run()] Package Name [" + PackageVersionInfos.get(i).getPackageName() + "]");
  7281. Log.d(TAG, "[UninstallAPKs.run()] Version Name [" + PackageVersionInfos.get(i).strPackageVersion + "]");
  7282. uninstallWallPadApp(PackageVersionInfos.get(i).getPackageName());
  7283. try {
  7284. Thread.sleep(5000);
  7285. } catch (RuntimeException re) {
  7286. LogUtil.errorLogInfo("", TAG, re);
  7287. } catch (Exception e) {
  7288. LogUtil.errorLogInfo("", TAG, e);
  7289. }
  7290. }
  7291. } catch (RuntimeException re) {
  7292. LogUtil.errorLogInfo("", TAG, re);
  7293. } catch (Exception e) {
  7294. Log.e(TAG, "[Exception] UninstallAPKs.run()");
  7295. LogUtil.errorLogInfo("", TAG, e);
  7296. }
  7297. // try {Thread.sleep(5000);}catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
  7298. }
  7299. }
  7300. private void uninstallWallPadApp(String strAPK) {
  7301. try {
  7302. Log.w(TAG, "[uninstallWallPadApp] strAPK [" + strAPK + "]");
  7303. if (checkAppInstalled(strAPK)) {
  7304. // Intent mIntent = new Intent(Intent.ACTION_DELETE);
  7305. Intent mIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
  7306. mIntent.setData(Uri.parse("package:" + strAPK));
  7307. mIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
  7308. startActivityForResult(mIntent, UNINSTALL_REQUEST_CODE);
  7309. }
  7310. else {
  7311. Log.w(TAG, "[uninstallWallPadApp] Not installed [" + strAPK + "]");
  7312. }
  7313. } catch (RuntimeException re) {
  7314. LogUtil.errorLogInfo("", TAG, re);
  7315. }
  7316. catch (Exception e) {;
  7317. Log.e(TAG, "[Exception] uninstallWallPadApp()");
  7318. LogUtil.errorLogInfo("", TAG, e);
  7319. }
  7320. }
  7321. iMAPRemotemeter miMAPRemotemeter;
  7322. boolean mEMS_Enable;
  7323. int nEnergyTypeCnt;
  7324. private boolean mCostInfo_Enable = false;
  7325. private Calendar nowCal, HourCal, DateCal, MonthCal, YearCal, EnergyDataGetCal;
  7326. int CalendarYear;
  7327. int CalendarMonth;
  7328. int CalendarDate;
  7329. int ShowNowEnergyIndex = 0;
  7330. String[] ShowListEnergyType_String = {
  7331. "전기",
  7332. "수도",
  7333. "가스",
  7334. "온수",
  7335. "난방",
  7336. "탄소"
  7337. };
  7338. // 원격검침 월사용량 데이터 클래스
  7339. MonthTableClass monthTableClass[] = new MonthTableClass[6];
  7340. class MonthTableClass {
  7341. private String Use;
  7342. private String SamePyungUse;
  7343. private String Rank;
  7344. private String Goal;
  7345. private String Price;
  7346. public MonthTableClass (String Use, String SamePyungUse, String Rank, String Goal) {
  7347. this.Use = Use;
  7348. this.SamePyungUse = SamePyungUse;
  7349. this.Rank = Rank;
  7350. this.Goal = Goal;
  7351. }
  7352. public String getUse(){return Use;}
  7353. public String getSamePyungUse(){return SamePyungUse;}
  7354. public String getRank(){return Rank;}
  7355. public String getGoal(){return Goal;}
  7356. public String getPrice(){return Price;}
  7357. }
  7358. public void GetMeteringCount()
  7359. {
  7360. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  7361. String[] MetringDB = devSet.GetSettingData("원격검침");
  7362. devSet.closeDB();
  7363. if (MetringDB != null)
  7364. {
  7365. try
  7366. {
  7367. String devInfo = MetringDB[1];
  7368. devInfo = devInfo.replace('(', '_');
  7369. devInfo = devInfo.replace(':', '_');
  7370. devInfo = devInfo.replace(')', '_');
  7371. String[] MetringInfo = devInfo.split("_");
  7372. // MetringInfo[1] -> 회로수
  7373. // MetringInfo[5] -> EMS 사용여부 사용함 or 사용안함
  7374. if ((Integer.parseInt(MetringInfo[1]) == 2) || (Integer.parseInt(MetringInfo[1]) == 3) || (Integer.parseInt(MetringInfo[1]) == 5) || (Integer.parseInt(MetringInfo[1]) == 6))
  7375. {
  7376. nEnergyTypeCnt = Integer.parseInt(MetringInfo[1]);
  7377. }
  7378. else
  7379. {
  7380. nEnergyTypeCnt = 5;
  7381. }
  7382. if (MetringInfo[5].equals("사용함"))
  7383. {
  7384. mEMS_Enable = true;
  7385. }
  7386. else
  7387. {
  7388. mEMS_Enable = false;
  7389. }
  7390. if(MetringInfo[7].equals("사용함"))
  7391. {
  7392. mCostInfo_Enable = true;
  7393. }
  7394. else
  7395. {
  7396. mCostInfo_Enable = false;
  7397. }
  7398. }
  7399. catch (RuntimeException re) {
  7400. LogUtil.errorLogInfo("", TAG, re);
  7401. nEnergyTypeCnt = 5;
  7402. mEMS_Enable = true;
  7403. }
  7404. catch (Exception e)
  7405. {
  7406. LogUtil.errorLogInfo("", TAG, e);
  7407. nEnergyTypeCnt = 5;
  7408. mEMS_Enable = true;
  7409. }
  7410. }
  7411. else
  7412. {
  7413. nEnergyTypeCnt = 5;
  7414. mEMS_Enable = true;
  7415. }
  7416. }
  7417. /**
  7418. * @description
  7419. * 서버로 부터 데이터를 받아와 분석하고 표현하는 함수<br>
  7420. * @param
  7421. * InputType 0 당월, 1 일별<br>
  7422. * @param
  7423. * //year - 연도<br>
  7424. * @param
  7425. * //month - 월<br>
  7426. * @param
  7427. * //energy - 0 전기, 1 수도, 2 가스, 3 온수, 4 열량, 5 탄소<br>
  7428. */
  7429. private void LoadRemotemeterDataFromServer(int InputType, int Year, int Month, int Energy, final boolean bSendToMobile) {
  7430. final int inputType = InputType;
  7431. final int year = Year;
  7432. final int month = (Month+1);
  7433. try {
  7434. Log.i(TAG, "[LoadRemotemeterDataFromServer] InputType [" + InputType + "], Year [" + Year + "], Month [" + Month + "], Energy [" + Energy + "], bSendToMobile [" + bSendToMobile + "]");
  7435. Log.i(TAG, "[LoadRemotemeterDataFromServer] inputType [" + inputType + "], year [" + year + "], month [" + month + "]");
  7436. miMAPRemotemeter = new iMAPRemotemeter(getApplicationContext());
  7437. switch(inputType) {
  7438. case 0: //당월
  7439. miMAPRemotemeter.DoWork(true, true, true, true, true, true, true, mEMS_Enable, year, month);
  7440. break;
  7441. case 1: //일별
  7442. miMAPRemotemeter.DoWork(false, true, true, true, true, true, false, false, year, month);
  7443. break;
  7444. default:
  7445. break;
  7446. }
  7447. boolean isUseEMS = true;
  7448. WallpadDeviceSet wds = new WallpadDeviceSet(getContext());
  7449. isUseEMS = wds.GetEMSProtocolUse();
  7450. wds.closeDB();
  7451. if(isUseEMS)
  7452. {
  7453. miMAPRemotemeter.SetRetCtr(new RetProci() {
  7454. @Override
  7455. public void ProcSuccess() {
  7456. String TempString = null;
  7457. // DB
  7458. WallpadStatusData StatusDBMGR = null;
  7459. try {
  7460. StatusDBMGR = new WallpadStatusData(getApplicationContext());
  7461. Log.i(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] inputType [" + inputType + "]");
  7462. boolean result = false;
  7463. switch (inputType) {
  7464. case 0: // 당월
  7465. EnergyDataGetCal = Calendar.getInstance();
  7466. int NumberOfValuelist = miMAPRemotemeter.SetItem("valuelist");
  7467. if (NumberOfValuelist != 0) {
  7468. for (int i = 0; i < NumberOfValuelist; i++) {
  7469. //DebugLogOutput("NumberOfValuelist " + Integer.toString(NumberOfValuelist));
  7470. //DebugLogOutput("GetAttributeVal(i, month) " + imapRemotemeter.GetAttributeVal(i, "month"));
  7471. //DebugLogOutput("CalendarMonth " + (CalendarMonth + 1));
  7472. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == (CalendarMonth + 1)) && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == (CalendarYear))) {
  7473. result = true;
  7474. int Temp_mNumberOfEnergy = nEnergyTypeCnt;
  7475. if (Temp_mNumberOfEnergy == 2) {
  7476. Temp_mNumberOfEnergy = 3;
  7477. }
  7478. for (int j = 0; j < Temp_mNumberOfEnergy; j++) {
  7479. switch (j) {
  7480. case 0:
  7481. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7482. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  7483. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000") == true) {
  7484. monthTableClass[j].Use = "0";
  7485. }
  7486. else {
  7487. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  7488. }
  7489. }
  7490. if (miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize") != null) {
  7491. if (miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize").equals("null") == true) {
  7492. monthTableClass[j].SamePyungUse = "0";
  7493. }
  7494. else {
  7495. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize");
  7496. }
  7497. }
  7498. if ((miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7499. if (miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize").equals("null") == true) {
  7500. TempString = "- / ";
  7501. }
  7502. else {
  7503. TempString = miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize") + " / ";
  7504. }
  7505. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7506. TempString = TempString + "-";
  7507. }
  7508. else {
  7509. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7510. }
  7511. monthTableClass[j].Rank = TempString;
  7512. }
  7513. //가격정보
  7514. if (mCostInfo_Enable == true) {
  7515. if (miMAPRemotemeter.GetAttributeVal(i, "elect_price") != null) {
  7516. if (miMAPRemotemeter.GetAttributeVal(i, "elect_price").equals("null") == true) {
  7517. monthTableClass[j].Price = "";
  7518. }
  7519. else {
  7520. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "elect_price");
  7521. }
  7522. }
  7523. }
  7524. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7525. //DebugLogOutput("전기");
  7526. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7527. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7528. break;
  7529. case 1:
  7530. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7531. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  7532. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  7533. monthTableClass[j].Use = "0";
  7534. }
  7535. else {
  7536. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  7537. }
  7538. }
  7539. if (miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize") != null) {
  7540. if (miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize").equals("null") == true) {
  7541. monthTableClass[j].SamePyungUse = "0";
  7542. }
  7543. else {
  7544. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize");
  7545. }
  7546. }
  7547. if ((miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7548. if (miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize").equals("null") == true) {
  7549. TempString = "- / ";
  7550. }
  7551. else {
  7552. TempString = miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize") + " / ";
  7553. }
  7554. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7555. TempString = TempString + "-";
  7556. }
  7557. else {
  7558. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7559. }
  7560. monthTableClass[j].Rank = TempString;
  7561. }
  7562. //가격정보
  7563. if (mCostInfo_Enable == true) {
  7564. if (miMAPRemotemeter.GetAttributeVal(i, "water_price") != null) {
  7565. if (miMAPRemotemeter.GetAttributeVal(i, "water_price").equals("null") == true) {
  7566. monthTableClass[j].Price = "";
  7567. }
  7568. else {
  7569. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "water_price");
  7570. }
  7571. }
  7572. }
  7573. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7574. //DebugLogOutput("수도");
  7575. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7576. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7577. break;
  7578. case 2:
  7579. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7580. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  7581. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  7582. monthTableClass[j].Use = "0";
  7583. }
  7584. else {
  7585. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  7586. }
  7587. }
  7588. if (miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize") != null) {
  7589. if (miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize").equals("null") == true) {
  7590. monthTableClass[j].SamePyungUse = "0";
  7591. }
  7592. else {
  7593. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize");
  7594. }
  7595. }
  7596. if ((miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7597. if (miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize").equals("null") == true) {
  7598. TempString = "- / ";
  7599. }
  7600. else {
  7601. TempString = miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize") + " / ";
  7602. }
  7603. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7604. TempString = TempString + "-";
  7605. }
  7606. else {
  7607. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7608. }
  7609. monthTableClass[j].Rank = TempString;
  7610. }
  7611. //가격정보
  7612. if (mCostInfo_Enable == true) {
  7613. if (miMAPRemotemeter.GetAttributeVal(i, "gas_price") != null) {
  7614. if (miMAPRemotemeter.GetAttributeVal(i, "gas_price").equals("null") == true) {
  7615. monthTableClass[j].Price = "";
  7616. }
  7617. else {
  7618. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "gas_price");
  7619. }
  7620. }
  7621. }
  7622. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7623. //DebugLogOutput("가스");
  7624. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7625. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7626. break;
  7627. case 3:
  7628. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7629. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  7630. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  7631. monthTableClass[j].Use = "0";
  7632. }
  7633. else {
  7634. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  7635. }
  7636. }
  7637. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize") != null) {
  7638. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize").equals("null") == true) {
  7639. monthTableClass[j].SamePyungUse = "0";
  7640. }
  7641. else {
  7642. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize");
  7643. }
  7644. }
  7645. if ((miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7646. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize").equals("null") == true) {
  7647. TempString = "- / ";
  7648. }
  7649. else {
  7650. TempString = miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize") + " / ";
  7651. }
  7652. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7653. TempString = TempString + "-";
  7654. }
  7655. else {
  7656. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7657. }
  7658. monthTableClass[j].Rank = TempString;
  7659. }
  7660. //가격정보
  7661. if (mCostInfo_Enable == true) {
  7662. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_price") != null) {
  7663. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_price").equals("null") == true) {
  7664. monthTableClass[j].Price = "";
  7665. }
  7666. else {
  7667. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "hotwater_price");
  7668. }
  7669. }
  7670. }
  7671. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7672. //DebugLogOutput("온수");
  7673. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7674. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7675. break;
  7676. case 4:
  7677. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7678. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  7679. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  7680. monthTableClass[j].Use = "0";
  7681. }
  7682. else {
  7683. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  7684. }
  7685. }
  7686. if (miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize") != null) {
  7687. if (miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize").equals("null") == true) {
  7688. monthTableClass[j].SamePyungUse = "0";
  7689. }
  7690. else {
  7691. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize");
  7692. }
  7693. }
  7694. if ((miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7695. if (miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize").equals("null") == true) {
  7696. TempString = "- / ";
  7697. }
  7698. else {
  7699. TempString = miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize") + " / ";
  7700. }
  7701. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7702. TempString = TempString + "-";
  7703. }
  7704. else {
  7705. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7706. }
  7707. monthTableClass[j].Rank = TempString;
  7708. }
  7709. //가격정보
  7710. if (mCostInfo_Enable == true) {
  7711. if (miMAPRemotemeter.GetAttributeVal(i, "energy_price") != null) {
  7712. if (miMAPRemotemeter.GetAttributeVal(i, "energy_price").equals("null") == true) {
  7713. monthTableClass[j].Price = "";
  7714. }
  7715. else {
  7716. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "energy_price");
  7717. }
  7718. }
  7719. }
  7720. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7721. //DebugLogOutput("열량");
  7722. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7723. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7724. break;
  7725. case 5:
  7726. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7727. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_used") != null) {
  7728. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_used").equals("1000000") == true) {
  7729. monthTableClass[j].Use = "0";
  7730. }
  7731. else {
  7732. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "carbon_used");
  7733. }
  7734. }
  7735. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize") != null) {
  7736. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize").equals("null") == true) {
  7737. monthTableClass[j].SamePyungUse = "0";
  7738. }
  7739. else {
  7740. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize");
  7741. }
  7742. }
  7743. if ((miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7744. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize").equals("null") == true) {
  7745. TempString = "- / ";
  7746. }
  7747. else {
  7748. TempString = miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize") + " / ";
  7749. }
  7750. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7751. TempString = TempString + "-";
  7752. }
  7753. else {
  7754. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7755. }
  7756. monthTableClass[j].Rank = TempString;
  7757. }
  7758. //가격정보
  7759. if (mCostInfo_Enable == true) {
  7760. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_price") != null) {
  7761. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_price").equals("null") == true) {
  7762. monthTableClass[j].Price = "";
  7763. }
  7764. else {
  7765. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "carbon_price");
  7766. }
  7767. }
  7768. }
  7769. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7770. //DebugLogOutput("탄소");
  7771. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7772. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7773. break;
  7774. default:
  7775. break;
  7776. }
  7777. }
  7778. }
  7779. }
  7780. if (result) {
  7781. if (1 < nEnergyTypeCnt && nEnergyTypeCnt < 6) {
  7782. Intent intent = new Intent();
  7783. intent.setAction(define.NOTIFY_ACNAME);
  7784. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  7785. intent.putExtra("FromWhere", "IcEnergyMgrScreen");
  7786. if (nEnergyTypeCnt == 2) {
  7787. elect_target = monthTableClass[0].Goal;
  7788. elect_used = monthTableClass[0].Use;
  7789. water_target = monthTableClass[1].Goal;
  7790. water_used = monthTableClass[1].Use;
  7791. }
  7792. else if (nEnergyTypeCnt == 3) {
  7793. elect_target = monthTableClass[0].Goal;
  7794. elect_used = monthTableClass[0].Use;
  7795. water_target = monthTableClass[1].Goal;
  7796. water_used = monthTableClass[1].Use;
  7797. gas_target = monthTableClass[2].Goal;
  7798. gas_used = monthTableClass[2].Use;
  7799. }
  7800. else if (nEnergyTypeCnt == 4) {
  7801. elect_target = monthTableClass[0].Goal;
  7802. elect_used = monthTableClass[0].Use;
  7803. water_target = monthTableClass[1].Goal;
  7804. water_used = monthTableClass[1].Use;
  7805. hotwater_target = monthTableClass[2].Goal;
  7806. hotwater_used = monthTableClass[2].Use;
  7807. heating_target = monthTableClass[3].Goal;
  7808. heating_used = monthTableClass[3].Use;
  7809. }
  7810. else if (nEnergyTypeCnt == 5) {
  7811. elect_target = monthTableClass[0].Goal;
  7812. elect_used = monthTableClass[0].Use;
  7813. water_target = monthTableClass[1].Goal;
  7814. water_used = monthTableClass[1].Use;
  7815. gas_target = monthTableClass[2].Goal;
  7816. gas_used = monthTableClass[2].Use;
  7817. hotwater_target = monthTableClass[3].Goal;
  7818. hotwater_used = monthTableClass[3].Use;
  7819. heating_target = monthTableClass[4].Goal;
  7820. heating_used = monthTableClass[4].Use;
  7821. }
  7822. else {
  7823. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =1 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  7824. return;
  7825. }
  7826. getApplicationContext().sendBroadcast(intent);
  7827. if (bSendToMobile) sendRemotemeterDataToMobile();
  7828. }
  7829. else {
  7830. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =2 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  7831. }
  7832. return;
  7833. }
  7834. else {
  7835. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] result [" + result + "]");
  7836. }
  7837. }
  7838. break;
  7839. default:
  7840. break;
  7841. }
  7842. StatusDBMGR.closeDB();
  7843. } catch (RuntimeException re) {
  7844. if (StatusDBMGR != null) {
  7845. StatusDBMGR.closeDB();
  7846. }
  7847. LogUtil.errorLogInfo("", TAG, re);
  7848. }
  7849. catch (Exception e) {
  7850. if (StatusDBMGR != null) {
  7851. StatusDBMGR.closeDB();
  7852. }
  7853. LogUtil.errorLogInfo("", TAG, e);
  7854. }
  7855. }
  7856. @Override
  7857. public void ProcError() {
  7858. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcError] Error!!!");
  7859. }
  7860. @Override
  7861. public void ProcDoing() {
  7862. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcDoing] Processing!!!");
  7863. }
  7864. });
  7865. }
  7866. else {
  7867. miMAPRemotemeter.SetRetCtr(new RetProci() {
  7868. @Override
  7869. public void ProcSuccess() {
  7870. String TempString = null;
  7871. // DB
  7872. WallpadStatusData StatusDBMGR = null;
  7873. try {
  7874. StatusDBMGR = new WallpadStatusData(getApplicationContext());
  7875. Log.i(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] inputType [" + inputType + "]");
  7876. boolean result = false;
  7877. switch (inputType) {
  7878. case 0: // 당월
  7879. EnergyDataGetCal = Calendar.getInstance();
  7880. int NumberOfValuelist = miMAPRemotemeter.SetItem("valuelist");
  7881. if (NumberOfValuelist != 0) {
  7882. for (int i = 0; i < NumberOfValuelist; i++) {
  7883. //DebugLogOutput("NumberOfValuelist " + Integer.toString(NumberOfValuelist));
  7884. //DebugLogOutput("GetAttributeVal(i, month) " + imapRemotemeter.GetAttributeVal(i, "month"));
  7885. //DebugLogOutput("CalendarMonth " + (CalendarMonth + 1));
  7886. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == (CalendarMonth + 1)) && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == (CalendarYear))) {
  7887. result = true;
  7888. int Temp_mNumberOfEnergy = nEnergyTypeCnt;
  7889. if (Temp_mNumberOfEnergy == 2) {
  7890. Temp_mNumberOfEnergy = 3;
  7891. }
  7892. for (int j = 0; j < Temp_mNumberOfEnergy; j++) {
  7893. switch (j) {
  7894. case 0:
  7895. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7896. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  7897. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000") == true) {
  7898. monthTableClass[j].Use = "0";
  7899. }
  7900. else {
  7901. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  7902. }
  7903. }
  7904. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7905. //DebugLogOutput("전기");
  7906. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7907. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7908. break;
  7909. case 1:
  7910. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7911. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  7912. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  7913. monthTableClass[j].Use = "0";
  7914. }
  7915. else {
  7916. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  7917. }
  7918. }
  7919. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7920. //DebugLogOutput("수도");
  7921. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7922. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7923. break;
  7924. case 2:
  7925. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7926. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  7927. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  7928. monthTableClass[j].Use = "0";
  7929. }
  7930. else {
  7931. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  7932. }
  7933. }
  7934. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7935. //DebugLogOutput("가스");
  7936. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7937. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7938. break;
  7939. case 3:
  7940. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7941. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  7942. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  7943. monthTableClass[j].Use = "0";
  7944. }
  7945. else {
  7946. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  7947. }
  7948. }
  7949. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7950. //DebugLogOutput("온수");
  7951. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7952. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7953. break;
  7954. case 4:
  7955. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7956. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  7957. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  7958. monthTableClass[j].Use = "0";
  7959. }
  7960. else {
  7961. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  7962. }
  7963. }
  7964. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7965. //DebugLogOutput("열량");
  7966. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7967. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7968. break;
  7969. case 5:
  7970. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7971. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7972. //DebugLogOutput("탄소");
  7973. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7974. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7975. break;
  7976. default:
  7977. break;
  7978. }
  7979. }
  7980. }
  7981. }
  7982. if (result) {
  7983. if (1 < nEnergyTypeCnt && nEnergyTypeCnt < 6) {
  7984. Intent intent = new Intent();
  7985. intent.setAction(define.NOTIFY_ACNAME);
  7986. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  7987. intent.putExtra("FromWhere", "IcEnergyMgrScreen");
  7988. if (nEnergyTypeCnt == 2) {
  7989. elect_target = monthTableClass[0].Goal;
  7990. elect_used = monthTableClass[0].Use;
  7991. water_target = monthTableClass[1].Goal;
  7992. water_used = monthTableClass[1].Use;
  7993. }
  7994. else if (nEnergyTypeCnt == 3) {
  7995. elect_target = monthTableClass[0].Goal;
  7996. elect_used = monthTableClass[0].Use;
  7997. water_target = monthTableClass[1].Goal;
  7998. water_used = monthTableClass[1].Use;
  7999. gas_target = monthTableClass[2].Goal;
  8000. gas_used = monthTableClass[2].Use;
  8001. }
  8002. else if (nEnergyTypeCnt == 4) {
  8003. elect_target = monthTableClass[0].Goal;
  8004. elect_used = monthTableClass[0].Use;
  8005. water_target = monthTableClass[1].Goal;
  8006. water_used = monthTableClass[1].Use;
  8007. hotwater_target = monthTableClass[2].Goal;
  8008. hotwater_used = monthTableClass[2].Use;
  8009. heating_target = monthTableClass[3].Goal;
  8010. heating_used = monthTableClass[3].Use;
  8011. }
  8012. else if (nEnergyTypeCnt == 5) {
  8013. elect_target = monthTableClass[0].Goal;
  8014. elect_used = monthTableClass[0].Use;
  8015. water_target = monthTableClass[1].Goal;
  8016. water_used = monthTableClass[1].Use;
  8017. gas_target = monthTableClass[2].Goal;
  8018. gas_used = monthTableClass[2].Use;
  8019. hotwater_target = monthTableClass[3].Goal;
  8020. hotwater_used = monthTableClass[3].Use;
  8021. heating_target = monthTableClass[4].Goal;
  8022. heating_used = monthTableClass[4].Use;
  8023. }
  8024. else {
  8025. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =1 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  8026. return;
  8027. }
  8028. getApplicationContext().sendBroadcast(intent);
  8029. if (bSendToMobile) sendRemotemeterDataToMobile();
  8030. }
  8031. else {
  8032. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =2 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  8033. }
  8034. return;
  8035. }
  8036. else {
  8037. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] result [" + result + "]");
  8038. }
  8039. }
  8040. break;
  8041. default:
  8042. break;
  8043. }
  8044. StatusDBMGR.closeDB();
  8045. } catch (RuntimeException re) {
  8046. if (StatusDBMGR != null) {
  8047. StatusDBMGR.closeDB();
  8048. }
  8049. LogUtil.errorLogInfo("", TAG, re);
  8050. }
  8051. catch (Exception e) {
  8052. if (StatusDBMGR != null) {
  8053. StatusDBMGR.closeDB();
  8054. }
  8055. LogUtil.errorLogInfo("", TAG, e);
  8056. }
  8057. }
  8058. @Override
  8059. public void ProcError() {
  8060. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcError] Error!!!");
  8061. }
  8062. @Override
  8063. public void ProcDoing() {
  8064. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcDoing] Processing!!!");
  8065. }
  8066. });
  8067. }
  8068. } catch (RuntimeException re) {
  8069. LogUtil.errorLogInfo("", TAG, re);
  8070. }
  8071. catch (Exception e) {
  8072. Log.e(TAG, "[Exception] LoadRemotemeterDataFromServer(int InputType, int Year, int Month, int Energy)");
  8073. LogUtil.errorLogInfo("", TAG, e);
  8074. }
  8075. }
  8076. /**
  8077. * @description
  8078. * 서버로 부터 데이터를 받아와 분석하고 표현하는 함수<br>
  8079. * @param
  8080. * //year - 연도<br>
  8081. * @param
  8082. * //month - 월<br>
  8083. * @param
  8084. * //energy - 0 전기, 1 수도, 2 가스, 3 온수, 4 열량, 5 탄소<br>
  8085. */
  8086. private void getTelemeringDailyUsageData(final int nYear, final int nMonth, final int nDate) {
  8087. try {
  8088. Log.i(TAG, "[getTelemeringDailyUsageData] nYear [" + nYear + "], nMonth [" + nMonth + "], nDate [" + nDate + "]");
  8089. miMAPRemotemeter = new iMAPRemotemeter(getApplicationContext());
  8090. miMAPRemotemeter.DoWork(false, true, true, true, true, true, false, false, nYear, nMonth);
  8091. boolean isUseEMS = true;
  8092. WallpadDeviceSet wds = new WallpadDeviceSet(getContext());
  8093. isUseEMS = wds.GetEMSProtocolUse();
  8094. wds.closeDB();
  8095. if(isUseEMS)
  8096. {
  8097. miMAPRemotemeter.SetRetCtr(new RetProci() {
  8098. @Override
  8099. public void ProcSuccess() {
  8100. String strTempValue = null;
  8101. int nEnergyTypeCnt = 5;
  8102. try {
  8103. boolean bResult = false;
  8104. String strElecUsage = "", strGasUsage = "", strWaterUsage = "", strHotwaterUsage = "", strHeatingUsage = "";
  8105. int nDataCnt = miMAPRemotemeter.SetItem("valuelist");
  8106. if (nDataCnt != 0) {
  8107. Log.i(TAG, "[getTelemeringDailyData] nDataCnt [" + nDataCnt + "]");
  8108. for (int i = 0; i < nDataCnt; i++) {
  8109. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == nYear)
  8110. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == nMonth)
  8111. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "day")) == nDate)) {
  8112. bResult = true;
  8113. Log.i(TAG, "[getTelemeringDailyUsageData] Find!!! nYear [" + nYear + "], nMonth [" + nMonth + "], nDate [" + nDate + "]");
  8114. for (int j = 0; j < nEnergyTypeCnt; j++) {
  8115. if (j == 0) {
  8116. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  8117. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000")) {
  8118. strElecUsage = "0";
  8119. }
  8120. else {
  8121. strElecUsage = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  8122. }
  8123. }
  8124. }
  8125. else if (j == 1) {
  8126. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  8127. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  8128. strWaterUsage = "0";
  8129. }
  8130. else {
  8131. strWaterUsage = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  8132. }
  8133. }
  8134. }
  8135. else if (j == 2) {
  8136. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  8137. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  8138. strGasUsage = "0";
  8139. }
  8140. else {
  8141. strGasUsage = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  8142. }
  8143. }
  8144. }
  8145. else if (j == 3) {
  8146. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  8147. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  8148. strHotwaterUsage = "0";
  8149. }
  8150. else {
  8151. strHotwaterUsage = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  8152. }
  8153. }
  8154. }
  8155. else if (j == 4) {
  8156. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  8157. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  8158. strHeatingUsage = "0";
  8159. }
  8160. else {
  8161. strHeatingUsage = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  8162. }
  8163. }
  8164. }
  8165. }
  8166. }
  8167. }
  8168. if (bResult) {
  8169. Intent mIntent = new Intent();
  8170. mIntent.setAction(define.NOTIFY_ACNAME);
  8171. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_TELEMETERING_DAILY_USAGE);
  8172. mIntent.putExtra("elect_used", strElecUsage);
  8173. mIntent.putExtra("water_used", strWaterUsage);
  8174. mIntent.putExtra("gas_used", strGasUsage);
  8175. mIntent.putExtra("hotwater_used", strHotwaterUsage);
  8176. mIntent.putExtra("heating_used", strHeatingUsage);
  8177. getApplicationContext().sendBroadcast(mIntent);
  8178. }
  8179. else {
  8180. Log.w(TAG, "[getTelemeringDailyUsageData.ProcSuccess] bResult [" + bResult + "]");
  8181. }
  8182. }
  8183. } catch (RuntimeException re) {
  8184. LogUtil.errorLogInfo("", TAG, re);
  8185. }
  8186. catch (Exception e) {
  8187. Log.e(TAG, "[Exception] getTelemeringDailyData.ProcSuccess");
  8188. LogUtil.errorLogInfo("", TAG, e);
  8189. }
  8190. }
  8191. @Override
  8192. public void ProcError() {
  8193. Log.w(TAG, "[getTelemeringDailyData.ProcError] Error!!!");
  8194. }
  8195. @Override
  8196. public void ProcDoing() {
  8197. Log.w(TAG, "[getTelemeringDailyData.ProcDoing] Processing!!!");
  8198. }
  8199. });
  8200. }
  8201. else
  8202. {
  8203. miMAPRemotemeter.SetRetCtr(new RetProci() {
  8204. @Override
  8205. public void ProcSuccess() {
  8206. String strTempValue = null;
  8207. int nEnergyTypeCnt = 5;
  8208. try {
  8209. boolean bResult = false;
  8210. String strElecUsage = "", strGasUsage = "", strWaterUsage = "", strHotwaterUsage = "", strHeatingUsage = "";
  8211. int nDataCnt = miMAPRemotemeter.SetItem("valuelist");
  8212. if (nDataCnt != 0) {
  8213. Log.i(TAG, "[getTelemeringDailyData] nDataCnt [" + nDataCnt + "]");
  8214. for (int i = 0; i < nDataCnt; i++) {
  8215. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == nYear)
  8216. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == nMonth)
  8217. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "day")) == nDate)) {
  8218. bResult = true;
  8219. Log.i(TAG, "[getTelemeringDailyUsageData] Find!!! nYear [" + nYear + "], nMonth [" + nMonth + "], nDate [" + nDate + "]");
  8220. for (int j = 0; j < nEnergyTypeCnt; j++) {
  8221. if (j == 0) {
  8222. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  8223. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000")) {
  8224. strElecUsage = "0";
  8225. }
  8226. else {
  8227. strElecUsage = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  8228. }
  8229. }
  8230. }
  8231. else if (j == 1) {
  8232. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  8233. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  8234. strWaterUsage = "0";
  8235. }
  8236. else {
  8237. strWaterUsage = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  8238. }
  8239. }
  8240. }
  8241. else if (j == 2) {
  8242. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  8243. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  8244. strGasUsage = "0";
  8245. }
  8246. else {
  8247. strGasUsage = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  8248. }
  8249. }
  8250. }
  8251. else if (j == 3) {
  8252. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  8253. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  8254. strHotwaterUsage = "0";
  8255. }
  8256. else {
  8257. strHotwaterUsage = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  8258. }
  8259. }
  8260. }
  8261. else if (j == 4) {
  8262. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  8263. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  8264. strHeatingUsage = "0";
  8265. }
  8266. else {
  8267. strHeatingUsage = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  8268. }
  8269. }
  8270. }
  8271. }
  8272. }
  8273. }
  8274. if (bResult) {
  8275. Intent mIntent = new Intent();
  8276. mIntent.setAction(define.NOTIFY_ACNAME);
  8277. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_TELEMETERING_DAILY_USAGE);
  8278. mIntent.putExtra("elect_used", strElecUsage);
  8279. mIntent.putExtra("water_used", strWaterUsage);
  8280. mIntent.putExtra("gas_used", strGasUsage);
  8281. mIntent.putExtra("hotwater_used", strHotwaterUsage);
  8282. mIntent.putExtra("heating_used", strHeatingUsage);
  8283. getApplicationContext().sendBroadcast(mIntent);
  8284. }
  8285. else {
  8286. Log.w(TAG, "[getTelemeringDailyUsageData.ProcSuccess] bResult [" + bResult + "]");
  8287. }
  8288. }
  8289. } catch (RuntimeException re) {
  8290. LogUtil.errorLogInfo("", TAG, re);
  8291. }
  8292. catch (Exception e) {
  8293. Log.e(TAG, "[Exception] getTelemeringDailyData.ProcSuccess");
  8294. LogUtil.errorLogInfo("", TAG, e);
  8295. }
  8296. }
  8297. @Override
  8298. public void ProcError() {
  8299. Log.w(TAG, "[getTelemeringDailyData.ProcError] Error!!!");
  8300. }
  8301. @Override
  8302. public void ProcDoing() {
  8303. Log.w(TAG, "[getTelemeringDailyData.ProcDoing] Processing!!!");
  8304. }
  8305. });
  8306. }
  8307. } catch (RuntimeException re) {
  8308. LogUtil.errorLogInfo("", TAG, re);
  8309. }
  8310. catch (Exception e) {
  8311. Log.e(TAG, "[Exception] getTelemeringDailyData(int nYear, int nMonth)");
  8312. LogUtil.errorLogInfo("", TAG, e);
  8313. }
  8314. }
  8315. public void sendRemotemeterDataToMobile() {
  8316. try {
  8317. Log.i(TAG, "[sendRemotemeterDataToMobile] ========== START ==========");
  8318. Intent intent = new Intent();
  8319. intent.setAction(define.NOTIFY_ACNAME);
  8320. intent.putExtra("KIND", define.NOTIFY_ENERGY_DATA);
  8321. intent.putExtra(Common.ENERGY_INTENT_ENERGY_COUNT, nEnergyTypeCnt);
  8322. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_YEAR, EnergyDataGetCal.get(Calendar.YEAR));
  8323. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MONTH, (EnergyDataGetCal.get(Calendar.MONTH)+1));
  8324. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_DAY, EnergyDataGetCal.get(Calendar.DATE));
  8325. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_HOUR, EnergyDataGetCal.get(Calendar.HOUR_OF_DAY));
  8326. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MINUTE, EnergyDataGetCal.get(Calendar.MINUTE));
  8327. if (nEnergyTypeCnt == 2) {
  8328. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8329. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8330. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8331. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8332. }
  8333. else if (nEnergyTypeCnt == 3) {
  8334. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8335. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8336. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8337. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8338. intent.putExtra(Common.ENERGY_INTENT_USE_GAS, gas_used); //가스
  8339. intent.putExtra(Common.ENERGY_INTENT_GOAL_GAS, gas_target);
  8340. }
  8341. else if (nEnergyTypeCnt == 4) {
  8342. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8343. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8344. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8345. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8346. intent.putExtra(Common.ENERGY_INTENT_USE_HOTWATER, hotwater_used); //온수
  8347. intent.putExtra(Common.ENERGY_INTENT_GOAL_HOTWATER, hotwater_target);
  8348. intent.putExtra(Common.ENERGY_INTENT_USE_HEATING, heating_used); //열량
  8349. intent.putExtra(Common.ENERGY_INTENT_GOAL_HEATING, heating_target);
  8350. }
  8351. else if (nEnergyTypeCnt == 5) {
  8352. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8353. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8354. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8355. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8356. intent.putExtra(Common.ENERGY_INTENT_USE_GAS, gas_used); //가스
  8357. intent.putExtra(Common.ENERGY_INTENT_GOAL_GAS, gas_target);
  8358. intent.putExtra(Common.ENERGY_INTENT_USE_HOTWATER, hotwater_used); //온수
  8359. intent.putExtra(Common.ENERGY_INTENT_GOAL_HOTWATER, hotwater_target);
  8360. intent.putExtra(Common.ENERGY_INTENT_USE_HEATING, heating_used); //열량
  8361. intent.putExtra(Common.ENERGY_INTENT_GOAL_HEATING, heating_target);
  8362. }
  8363. getContext().sendBroadcast(intent);
  8364. Log.i(TAG, "[sendRemotemeterDataToMobile] Sent ENERGY_INTENT_ BR "+define.NOTIFY_ENERGY_DATA);
  8365. } catch (RuntimeException re) {
  8366. LogUtil.errorLogInfo("", TAG, re);
  8367. }
  8368. catch (Exception e) {
  8369. Log.e(TAG, "[Exception] sendRemotemeterDataToMobile()");
  8370. LogUtil.errorLogInfo("", TAG, e);
  8371. }
  8372. }
  8373. private void getTelemeteringDataOnRandomTime() {
  8374. try {
  8375. int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  8376. if (DelayTime < 1) {
  8377. return;
  8378. }
  8379. Log.i(TAG, "[getTelemeteringDataOnRandomTime] DelayTime : "+ DelayTime);
  8380. getTelemeteringDataHandler.sendEmptyMessageDelayed(0, 1000 * DelayTime);
  8381. } catch (RuntimeException re) {
  8382. LogUtil.errorLogInfo("", TAG, re);
  8383. return;
  8384. }
  8385. catch (Exception e) {
  8386. Log.e(TAG, "[Exception] getTelemeteringDataOnRandomTime()");
  8387. LogUtil.errorLogInfo("", TAG, e);
  8388. return;
  8389. }
  8390. }
  8391. @SuppressLint("HandlerLeak")
  8392. private Handler getTelemeteringDataHandler = new Handler() {
  8393. @SuppressLint("HandlerLeak")
  8394. @Override
  8395. public void handleMessage(Message msg) {
  8396. if (msg.what == 0) {
  8397. getRemoteMeterDataFromServer(true);
  8398. }
  8399. }
  8400. };
  8401. boolean bTelemeteringToISS = false;
  8402. private void checkISSEnergyType() {
  8403. try {
  8404. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplication());
  8405. int nEnergyKind = mWallpadDeviceSet.Get_SmartSwitchEnergy_Kind();
  8406. mWallpadDeviceSet.closeDB();
  8407. if (nEnergyKind == WallpadDeviceSet.SMARTSWITCH_ENERGY_REMOTE) bTelemeteringToISS = true;
  8408. else bTelemeteringToISS = false;
  8409. } catch (RuntimeException re) {
  8410. LogUtil.errorLogInfo("", TAG, re);
  8411. }
  8412. catch (Exception e) {
  8413. Log.e(TAG, "[Exception] checkISSEnergyType()");
  8414. LogUtil.errorLogInfo("", TAG, e);
  8415. }
  8416. }
  8417. public void getRemoteMeterDataFromServer(boolean bSendToMobile) {
  8418. try {
  8419. nowCal = Calendar.getInstance();
  8420. CalendarYear = nowCal.get(Calendar.YEAR);
  8421. CalendarMonth = nowCal.get(Calendar.MONTH);
  8422. CalendarDate = nowCal.get(Calendar.DATE);
  8423. GetMeteringCount();
  8424. LoadRemotemeterDataFromServer(0, CalendarYear, CalendarMonth, ShowNowEnergyIndex, bSendToMobile);
  8425. if (bTelemeteringToISS) getTelemeringDailyUsageData(CalendarYear, CalendarMonth + 1, CalendarDate);
  8426. } catch (RuntimeException re) {
  8427. LogUtil.errorLogInfo("", TAG, re);
  8428. }
  8429. catch (Exception e) {
  8430. Log.e(TAG, "[Exception] getRemoteMeterDataFromServer()");
  8431. LogUtil.errorLogInfo("", TAG, e);
  8432. }
  8433. }
  8434. private boolean getBlackoutStatus() {
  8435. try {
  8436. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  8437. return mSharedPreferences.getBoolean("status", false);
  8438. } catch (RuntimeException re) {
  8439. LogUtil.errorLogInfo("", TAG, re);
  8440. return false;
  8441. }
  8442. catch (Exception e) {
  8443. Log.e(TAG, "[Exception] getBlackoutStatus()");
  8444. LogUtil.errorLogInfo("", TAG, e);
  8445. return false;
  8446. }
  8447. }
  8448. private void sendBlackoutScreenRunBR() {
  8449. try {
  8450. Log.i(TAG, "[sendBlackoutScreenRunBR] ========== START ==========");
  8451. Intent mIntent = new Intent(Common.BR_BLACKOUT_SCREEN_RUN, null);
  8452. mContext.sendBroadcast(mIntent);
  8453. } catch (RuntimeException re) {
  8454. LogUtil.errorLogInfo("", TAG, re);
  8455. }
  8456. catch (Exception e) {
  8457. Log.e(TAG, "[Exception] sendBlackoutScreenRunBR()");
  8458. LogUtil.errorLogInfo("", TAG, e);
  8459. }
  8460. }
  8461. /**
  8462. * 월패드 타입 판별
  8463. * @return bResult
  8464. * false: 메인월패드
  8465. * true: 서브월패드
  8466. */
  8467. public boolean getIsSubWallpad() {
  8468. boolean bResult = false;
  8469. try {
  8470. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  8471. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  8472. mWallpadDeviceSet.closeDB();
  8473. if (DBinfo == null) bResult = false;
  8474. else {
  8475. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  8476. else bResult = false;
  8477. }
  8478. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  8479. return bResult;
  8480. } catch (RuntimeException re) {
  8481. LogUtil.errorLogInfo("", TAG, re);
  8482. return false;
  8483. }
  8484. catch (Exception e) {
  8485. Log.e(TAG, "[Exception] getIsSubWallpad()");
  8486. LogUtil.errorLogInfo("", TAG, e);
  8487. return false;
  8488. }
  8489. }
  8490. /**
  8491. * JEFF, 2020.01.14
  8492. * 월패드 카메라의 초기화를 위한 코드 삽입
  8493. * 월패드 카메라 preview 실행시, 최초 1회에 한하여 카메라 화면에 녹색이 보이는 증상을 해결하기 위함
  8494. */
  8495. /* ================================================================================================
  8496. * 내 영상
  8497. ================================================================================================ */
  8498. // SurfaceLayout 구성
  8499. RelativeLayout MyVideoLayout; // MoIP 카메라 영상
  8500. SurfaceHolder MyVideoHolder;
  8501. SurfaceView MyVideoSurface;
  8502. RelativeLayout SurfaceLayout; // 영상표시 화면
  8503. public Camera mMyCamera;
  8504. public void toggleMyVideo() {
  8505. try {
  8506. if (MyVideoLayout == null) {
  8507. Log.e(TAG, "[toggleMyVideo] Show My Video!!!");
  8508. initMyVideoSurfaceLayout();
  8509. }
  8510. else {
  8511. Log.e(TAG, "[toggleMyVideo] Remove My Video!!!");
  8512. removeMyVideoSurfaceLayout();
  8513. }
  8514. } catch (RuntimeException re) {
  8515. LogUtil.errorLogInfo("", TAG, re);
  8516. }
  8517. catch (Exception e) {
  8518. Log.e(TAG, "[Exception] toggleMyVideo()");
  8519. LogUtil.errorLogInfo("", TAG, e);
  8520. }
  8521. }
  8522. public void initMyVideoSurfaceLayout() {
  8523. try {
  8524. // LOG_INFO("[initMyVideoSurfaceLayout] MyVideoLayout = " + MyVideoLayout);
  8525. if (MyVideoLayout != null) {
  8526. MyVideoSurface.getHolder().removeCallback(MyVideoCallback);
  8527. MyVideoLayout.removeAllViews();
  8528. MyVideoLayout = null;
  8529. }
  8530. MyVideoLayout = new RelativeLayout(mContext);
  8531. WpadUtil.LayoutRegistration(SurfaceLayout, MyVideoLayout, 1024, 600, 0, 0, ID.MAINACTIVITY.LAYOUT.MYVIDEO);
  8532. MyVideoSurface = new SurfaceView(mContext);
  8533. MyVideoHolder = MyVideoSurface.getHolder();
  8534. WpadRelativeLayoutParams MyVideoParams = new WpadRelativeLayoutParams(320, 240);
  8535. // MyVideoParams.setMargins(10, 10, 0, 0); // 보이게
  8536. MyVideoParams.setMargins(1300, 112, 0, 0); // 안보이게
  8537. MyVideoLayout.addView(MyVideoSurface, MyVideoParams);
  8538. MyVideoSurface.getHolder().addCallback(MyVideoCallback);
  8539. MyVideoSurface.setZOrderOnTop(true);
  8540. } catch (RuntimeException re) {
  8541. LogUtil.errorLogInfo("", TAG, re);
  8542. }
  8543. catch (Exception e) {
  8544. Log.e(TAG, "[Exception] initMyVideoSurfaceLayout()");
  8545. LogUtil.errorLogInfo("", TAG, e);
  8546. }
  8547. }
  8548. public void removeMyVideoSurfaceLayout() {
  8549. try {
  8550. Log.i(TAG, "[removeMyVideoSurfaceLayout] MyVideoLayout = " + MyVideoLayout);
  8551. if (MyVideoLayout != null) {
  8552. MyVideoLayout.removeAllViews();
  8553. MyVideoLayout = null;
  8554. }
  8555. } catch (RuntimeException re) {
  8556. LogUtil.errorLogInfo("", TAG, re);
  8557. }
  8558. catch (Exception e) {
  8559. Log.e(TAG, "[Exception] removeRemoteVideoSurfaceLayout()");
  8560. LogUtil.errorLogInfo("", TAG, e);
  8561. }
  8562. }
  8563. private SurfaceHolder.Callback MyVideoCallback = new SurfaceHolder.Callback() {
  8564. @Override
  8565. public void surfaceCreated(SurfaceHolder holder) {
  8566. try {
  8567. Log.i(TAG, "[MyVideoCallback] surfaceCreated!!");
  8568. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8569. mIOInterface.ctrlWallPadCamPower(true);
  8570. mMyCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  8571. Camera.Parameters params = mMyCamera.getParameters();
  8572. params.setPictureSize(320, 240);
  8573. mMyCamera.setParameters(params);
  8574. mMyCamera.setPreviewDisplay(holder);
  8575. } else {
  8576. Log.w(TAG, "[MyVideoCallback] surfaceCreated!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8577. }
  8578. } catch (RuntimeException re) {
  8579. LogUtil.errorLogInfo("", TAG, re);
  8580. }
  8581. catch (Exception e) {
  8582. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceCreated(SurfaceHolder holder)");
  8583. LogUtil.errorLogInfo("", TAG, e);
  8584. }
  8585. }
  8586. @Override
  8587. public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
  8588. try {
  8589. Log.i(TAG, "[MyVideoCallback] surfaceChanged!!");
  8590. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8591. mMyCamera.startPreview();
  8592. } else {
  8593. Log.w(TAG, "[MyVideoCallback] surfaceChanged!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8594. }
  8595. } catch (RuntimeException re) {
  8596. LogUtil.errorLogInfo("", TAG, re);
  8597. }
  8598. catch (Exception e) {
  8599. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceChanged(SurfaceHolder holder, int format, int width, int height)");
  8600. LogUtil.errorLogInfo("", TAG, e);
  8601. // if (getWallPadCameraUsage()) sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_RESET, 0, 0, 3000); // 3초후 카메라 서비스를 재실행한다.
  8602. }
  8603. }
  8604. @Override
  8605. public void surfaceDestroyed(SurfaceHolder holder) {
  8606. try {
  8607. Log.i(TAG, "[MyVideoCallback] surfaceDestroyed!!");
  8608. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8609. mIOInterface.ctrlWallPadCamPower(false);
  8610. if (mMyCamera != null) {
  8611. mMyCamera.stopPreview();
  8612. mMyCamera.release();
  8613. mMyCamera = null;
  8614. }
  8615. } else {
  8616. Log.w(TAG, "[MyVideoCallback] surfaceDestroyed!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8617. }
  8618. } catch (RuntimeException re) {
  8619. LogUtil.errorLogInfo("", TAG, re);
  8620. }
  8621. catch (Exception e) {
  8622. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceDestroyed(SurfaceHolder holder)");
  8623. LogUtil.errorLogInfo("", TAG, e);
  8624. }
  8625. }
  8626. };
  8627. private boolean getWallPadCameraUsage() {
  8628. boolean bResult = false;
  8629. try {
  8630. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this.getContext());
  8631. int nResult = mWallpadDeviceSet.GetDeviceSetted("월패드카메라");
  8632. mWallpadDeviceSet.closeDB();
  8633. if (nResult == WallpadDeviceSet.DEV_DATA_ENABLE) bResult = true;
  8634. else bResult = false;
  8635. } catch (RuntimeException re) {
  8636. LogUtil.errorLogInfo("", TAG, re);
  8637. }
  8638. catch (Exception e) {
  8639. Log.e(TAG, "[Exception] getWallPadCameraUsage()");
  8640. LogUtil.errorLogInfo("", TAG, e);
  8641. }
  8642. Log.i(TAG, "[getWallPadCameraUsage] bResult [" + bResult + "]");
  8643. return bResult;
  8644. }
  8645. private void forceCtrlStrangerRecordingUserSettingDisable(boolean bEnable) {
  8646. try {
  8647. WallpadStatusData DBMGR = new WallpadStatusData(getContext());
  8648. DBMGR.SetStrangerRecordingOnOff(bEnable);
  8649. DBMGR.closeDB();
  8650. } catch (RuntimeException re) {
  8651. LogUtil.errorLogInfo("", TAG, re);
  8652. }
  8653. catch (Exception e) {
  8654. Log.e(TAG, "[Exception] forceCtrlStrangerRecordingUserSettingDisable(boolean bEnable)");
  8655. LogUtil.errorLogInfo("", TAG, e);
  8656. }
  8657. }
  8658. private void registerLCDKeeper() {
  8659. try {
  8660. Log.i(TAG, "[registerLCDKeeper] ===== START =====");
  8661. if (!bLCDKeeperUsage) {
  8662. Log.w(TAG, "[registerLCDKeeper] bLCDKeeperUsage is false!!!");
  8663. return;
  8664. }
  8665. if (Build.VERSION.SDK_INT < 24) {
  8666. Log.w(TAG, "[registerLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8667. return;
  8668. }
  8669. IMG_LCD_KEEPER = (ImageView) findViewById(R.id.view_lcdkeeper);
  8670. IMG_LCD_KEEPER.bringToFront();
  8671. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8672. Log.i(TAG, "[registerLCDKeeper] ===== END =====");
  8673. } catch (RuntimeException re) {
  8674. LogUtil.errorLogInfo("", TAG, re);
  8675. }
  8676. catch (Exception e) {
  8677. Log.e(TAG, "[Exception] registerLCDKeeper()");
  8678. LogUtil.errorLogInfo("", TAG, e);
  8679. }
  8680. }
  8681. int LCDKEEPER_MODE_NONE = 0; // 동작중 아님
  8682. int LCDKEEPER_MODE_RESTROE = 1; // 복구모드
  8683. int LCDKEEPER_MODE_PROTECT = 2; // 보호모드
  8684. boolean bLCDBacklightPower = true; // LCD backlight on/off 여부 (true: on, false: off)
  8685. int nLCDKeeperRunMode = LCDKEEPER_MODE_NONE; // LCD Keeper 동작 모드 (0: 동작중 아님, 1: 복구모드, 2: 예방모드)
  8686. private void runLCDKeeper(int nKeeperMode) {
  8687. try {
  8688. if (!bLCDKeeperUsage) {
  8689. Log.w(TAG, "[runLCDKeeper] bLCDKeeperUsage is false!!!");
  8690. return;
  8691. }
  8692. Log.i(TAG, "[runLCDKeeper] nKeeperMode [" + nKeeperMode +"], bLCDBacklightPower [" + bLCDBacklightPower +"]");
  8693. if (Build.VERSION.SDK_INT < 24) {
  8694. Log.w(TAG, "[runLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8695. return;
  8696. }
  8697. if (IMG_LCD_KEEPER == null) {
  8698. Log.w(TAG, "[runLCDKeeper] IMG_LCD_KEEPER is null!!");
  8699. return;
  8700. }
  8701. // check run mode
  8702. if (nLCDKeeperRunMode == nKeeperMode) {
  8703. // already run LCDKeeper!!
  8704. Log.w(TAG, "[runLCDKeeper] LCD Keeper mode is same -> Asis [" + nLCDKeeperRunMode + "], Tobe [" + nKeeperMode + "]");
  8705. return;
  8706. }
  8707. nLCDKeeperRunMode = nKeeperMode;
  8708. if (nKeeperMode == LCDKEEPER_MODE_NONE) {
  8709. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8710. }
  8711. else if (nKeeperMode == LCDKEEPER_MODE_RESTROE) {
  8712. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) {
  8713. Glide.with(this).asGif().load(R.drawable.lcd_restore_1280).diskCacheStrategy(DiskCacheStrategy.RESOURCE).into(IMG_LCD_KEEPER);
  8714. }
  8715. else {
  8716. Glide.with(this).asGif().load(R.drawable.lcd_restore_1024).diskCacheStrategy(DiskCacheStrategy.RESOURCE).into(IMG_LCD_KEEPER);
  8717. }
  8718. IMG_LCD_KEEPER.setVisibility(View.VISIBLE);
  8719. }
  8720. else if (nKeeperMode == LCDKEEPER_MODE_PROTECT) {
  8721. IMG_LCD_KEEPER.setImageBitmap(null);
  8722. IMG_LCD_KEEPER.setBackgroundColor(Color.BLACK);
  8723. IMG_LCD_KEEPER.setVisibility(View.VISIBLE);
  8724. }
  8725. else {
  8726. Log.w(TAG, "[runLCDKeeper] Not supported mode!! -> " + nKeeperMode);
  8727. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8728. }
  8729. } catch (RuntimeException re) {
  8730. LogUtil.errorLogInfo("", TAG, re);
  8731. }
  8732. catch (Exception e) {
  8733. Log.e(TAG, "[Exception] runLCDKeeper(int nKeeperMode)");
  8734. LogUtil.errorLogInfo("", TAG, e);
  8735. }
  8736. }
  8737. private void ctrlLCDKeeper() {
  8738. try {
  8739. if (!bLCDKeeperUsage) {
  8740. Log.w(TAG, "[ctrlLCDKeeper] bLCDKeeperUsage is false!!");
  8741. return;
  8742. }
  8743. if (Build.VERSION.SDK_INT < 24) {
  8744. Log.w(TAG, "[ctrlLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8745. return;
  8746. }
  8747. if (IMG_LCD_KEEPER == null) {
  8748. Log.w(TAG, "[ctrlLCDKeeper] IMG_LCD_KEEPER is null!!");
  8749. return;
  8750. }
  8751. Log.i(TAG, "[ctrlLCDKeeper] bLCDBacklightPower [" + bLCDBacklightPower +"]");
  8752. if (bLCDBacklightPower) {
  8753. // backlight on시 lcd keeper를 비활성화 한다.
  8754. runLCDKeeper(LCDKEEPER_MODE_NONE);
  8755. }
  8756. else {
  8757. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT) {
  8758. // LCD backlight off시, LCD protect 화면을 구동한다.
  8759. runLCDKeeper(LCDKEEPER_MODE_PROTECT);
  8760. }
  8761. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER) {
  8762. // LCD backlight off시, LCD restore 화면을 구동한다.
  8763. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8764. }
  8765. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) {
  8766. // 새벽 2:00 ~ 3:59까지 LCD restore 화면을 구동하고, 나머지 시간에는 LCD protect 화면을 구동한다.
  8767. // 화면에 스모그 또는 미러 글라스 적용이 아닌 경우에는 LCD 보호모드(블랙)만 사용을 권장한다. (LCD RGBW rolling시 컬러가 화면에 비침)
  8768. Calendar LCDCal = Calendar.getInstance();
  8769. int nYear = LCDCal.get(Calendar.YEAR);
  8770. int nMonth = LCDCal.get(Calendar.MONTH) + 1;
  8771. int nDay = LCDCal.get(Calendar.DAY_OF_MONTH);
  8772. int nHour = LCDCal.get(Calendar.HOUR_OF_DAY);
  8773. Log.i(TAG, "[ctrlLCDKeeper] nYear [" + nYear +"], nMonth [" + nMonth +"], nDay [" + nDay +"], nHour [" + nHour +"]");
  8774. if (3 >= nHour && nHour >= 2) {
  8775. // 새벽 2:00 ~ 3:59까지 LCD restore 화면을 구동한다.
  8776. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8777. }
  8778. else {
  8779. // 새벽 2:00 ~ 3:59 이외의 시간에는 LCD protect 화면을 구동한다.
  8780. if (nYear == 2020 && ((nMonth < 8 && nDay < 20) || (nMonth < 7))) {
  8781. // 단, 이미 증상이 발생한 현장의 LCD 복구를 위해 2020년 7월 19일까지는 protection 화면 대신 restore 화면을 구동한다.
  8782. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8783. }
  8784. else {
  8785. runLCDKeeper(LCDKEEPER_MODE_PROTECT);
  8786. }
  8787. }
  8788. }
  8789. }
  8790. } catch (RuntimeException re) {
  8791. LogUtil.errorLogInfo("", TAG, re);
  8792. }
  8793. catch (Exception e) {
  8794. Log.e(TAG, "[Exception] ctrlLCDKeeper()");
  8795. LogUtil.errorLogInfo("", TAG, e);
  8796. }
  8797. }
  8798. private boolean checkTranslucentGlassUsage() {
  8799. try {
  8800. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
  8801. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  8802. || Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I
  8803. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  8804. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410
  8805. || Version.getModelType() == MODEL_TYPE.IHN_T1010 || Version.getModelType() == MODEL_TYPE.IHN_T1010_I
  8806. || Version.getModelType() == MODEL_TYPE.IHN_1303_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  8807. return true;
  8808. }
  8809. else return false;
  8810. } catch (RuntimeException re) {
  8811. LogUtil.errorLogInfo("", TAG, re);
  8812. return false;
  8813. }
  8814. catch (Exception e) {
  8815. Log.e(TAG, "[Exception] checkTranslucentGlassUsage()");
  8816. LogUtil.errorLogInfo("", TAG, e);
  8817. return false;
  8818. }
  8819. }
  8820. /**
  8821. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  8822. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  8823. * Jeff, 2020.09.07
  8824. * @return true: LCD backlight On, false: LCD backlight Off
  8825. */
  8826. public boolean checkLCDOnByCMD() {
  8827. try {
  8828. Runtime mRuntime = Runtime.getRuntime();
  8829. Process mProcess;
  8830. String cmd = "getprop persist.sys.lcdcon";
  8831. mProcess = mRuntime.exec(cmd);
  8832. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  8833. String line;
  8834. String strResult = null;
  8835. while ((line = br.readLine()) != null) {
  8836. strResult = line;
  8837. }
  8838. if(strResult!=null)
  8839. {
  8840. if (strResult.equals("0")) {
  8841. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  8842. return true;
  8843. }
  8844. else if (strResult.equals("1")) {
  8845. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  8846. return false;
  8847. }
  8848. else {
  8849. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  8850. return false;
  8851. }
  8852. }
  8853. else return false;
  8854. } catch (RuntimeException re) {
  8855. LogUtil.errorLogInfo("", TAG, re);
  8856. return false;
  8857. }
  8858. catch (Exception e) {
  8859. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  8860. LogUtil.errorLogInfo("", TAG, e);
  8861. return false;
  8862. }
  8863. }
  8864. /**
  8865. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  8866. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  8867. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  8868. */
  8869. public boolean getCompareBSPVersion() {
  8870. try {
  8871. StringBuilder strBSPVersion = new StringBuilder();
  8872. StringBuffer sysInfoBuffer = new StringBuffer();
  8873. sysInfoBuffer.append(Build.DISPLAY);
  8874. strBSPVersion.append(sysInfoBuffer.toString());
  8875. String result = strBSPVersion.toString();
  8876. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  8877. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  8878. Date date = simpleDateFormat.parse(result);
  8879. Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
  8880. if (date.compareTo(standardDate) >= 0) {
  8881. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  8882. return true;
  8883. }
  8884. } catch (RuntimeException re) {
  8885. LogUtil.errorLogInfo("", TAG, re);
  8886. }
  8887. catch (Exception e) {
  8888. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  8889. LogUtil.errorLogInfo("", TAG, e);
  8890. }
  8891. return false;
  8892. }
  8893. /**
  8894. * 월패드 부팅시 카메라서비스 로딩이 실패하는 경우가 생겨 카메라 화면이 안나오는 경우 발생
  8895. * WallPadMain에서 부팅시 카메라를 확인하여 Exception이 발생하는 경우
  8896. * 카메라 서비스를 재실행한다.
  8897. * (Edited by jeff, 2020.09.08)
  8898. */
  8899. public void resetCameraService() {
  8900. try {
  8901. Log.e(TAG, "[resetCameraService] start!!");
  8902. Runtime mRuntime = Runtime.getRuntime();
  8903. String cmd = "setprop persist.sys.fakeactivitydel 1";
  8904. mRuntime.exec(cmd);
  8905. } catch (RuntimeException re) {
  8906. LogUtil.errorLogInfo("", TAG, re);
  8907. }
  8908. catch (Exception e) {
  8909. Log.e(TAG, "[Exception] resetCameraService()");
  8910. LogUtil.errorLogInfo("", TAG, e);
  8911. }
  8912. }
  8913. /**
  8914. * 월패드 부팅시 카메라서비스 로딩이 실패하는 경우가 발생하여
  8915. * 카메라서비스 정상동작 여부를 확인하기위한 함수를 정의한다.
  8916. * 카메라서비스 정상: 정상적으로 카메라가 open되며, camera object가 null이 아니면 카메라를 release한다.
  8917. * 카메라 서비스 비정상: 카메라 open시 Exception이 발생하며 resetCameraService() 함수를 실행하여 카메라서비스를 재실행한다.
  8918. * (Edited by jeff, 2020.09.08)
  8919. */
  8920. public void checkCameraLoading() {
  8921. try {
  8922. Camera checkCamera = Camera.open();
  8923. if (checkCamera != null) {
  8924. Log.e(TAG, "[checkCameraLoading] checkCamera is not null!!");
  8925. checkCamera.release();
  8926. }
  8927. else {
  8928. Log.e(TAG, "[checkCameraLoading] checkCamera is null!!");
  8929. resetCameraService();
  8930. }
  8931. } catch (RuntimeException re) {
  8932. LogUtil.errorLogInfo("", TAG, re);
  8933. resetCameraService();
  8934. }
  8935. catch (Exception e) {
  8936. Log.e(TAG, "[Exception] checkCameraLoading()");
  8937. LogUtil.errorLogInfo("", TAG, e);
  8938. resetCameraService();
  8939. }
  8940. }
  8941. private synchronized void FileDelete(File file)
  8942. {
  8943. if(file!=null && file.exists())
  8944. {
  8945. file.delete();
  8946. }
  8947. }
  8948. public static void ReDirectCall(String ip)
  8949. {
  8950. Intent Intent = new Intent();
  8951. Intent.setAction("CERES_CALL");
  8952. Intent.putExtra("REMOTEINFO", ip);
  8953. mContext_call.sendBroadcast(Intent);
  8954. }
  8955. }