MainActivity.java 469 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225
  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. //월패드 CallBr 관리하기 위한 List
  274. static public ArrayList<Intent> CallBrList;
  275. IconManager mIconManager;
  276. public IconInfoTable mIconInfoTable;
  277. public static int nShortcutCnt = 0;
  278. public static int nShortcutMax = 12;
  279. public static int nShortcutCnt_HS = 0;
  280. public static int nShortcutMax_HS = 9;
  281. public static int nShortcutCnt_Metro = 0;
  282. public static int nShortcutMax_Metro = 3;
  283. int nIconsOnSubScreen = 24;
  284. public static List<WallpadStatusData.WidgetItem> MainScreenShortcutList;
  285. public static List<WallpadStatusData.WidgetItem> HSScreenShortcutList;
  286. public static List<WallpadStatusData.WidgetItem> MetroScreenShortcutList;
  287. // 조명상태를 관리하기 위한 클래스
  288. public static class LightInfo {
  289. public class Preset {
  290. public class Lights {
  291. public String ONOFF = "none";
  292. public int DIM = 0;
  293. public int COLOR = 0;
  294. public Lights() {
  295. ONOFF = "none";
  296. DIM = 0;
  297. COLOR = 0;
  298. }
  299. }
  300. public Lights[] mLights;
  301. public Preset() {
  302. mLights = new Lights[9]; // 0번지는 프리셋별 그룹제어 설정값 (조명 1~8)
  303. for (int i = 0; i < mLights.length; i++) {
  304. mLights[i] = new Lights();
  305. }
  306. }
  307. }
  308. public Preset[] mPreset;
  309. public int nLightPresetNo;
  310. public LightInfo() {
  311. mPreset = new Preset[9]; // 0번지는 전체제어 설정값 (프리셋 1~8)
  312. for (int i = 0; i < mPreset.length; i++) {
  313. mPreset[i] = new Preset();
  314. }
  315. nLightPresetNo = 0;
  316. }
  317. }
  318. public static LightInfo mLightInfo;
  319. public String BR_CTRL_LIGHT_LIVINGROOM = "kr.co.icontrols.wallpadglobalscreen.BR_CTRL_LIGHT_LIVINGROOM";
  320. public static WpadSound mSound;
  321. public void getLivinglightPreset() {
  322. try {
  323. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  324. String[] strEntireValue = mWallpadStatusData.getLivinglightModeCtrlEntireValue();
  325. mWallpadStatusData.closeDB();
  326. Log.i(TAG, "[getLivinglightPreset] strEntireValue.length = " + strEntireValue.length);
  327. for (int i = 0; i < strEntireValue.length; i++) {
  328. Log.i(TAG, "[getLivinglightPreset] strEntireValue[" + i + "] = " + strEntireValue[i]);
  329. }
  330. } catch (RuntimeException re) {
  331. LogUtil.errorLogInfo("", TAG, re);
  332. }
  333. catch (Exception e) {
  334. Log.e(TAG, "[Exception] getLivinglightPreset()");
  335. LogUtil.errorLogInfo("", TAG, e);
  336. }
  337. }
  338. public void initLivinglightPreset() {
  339. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  340. try {
  341. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  342. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  343. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  344. Log.i(TAG, "[initLivinglightPreset] Initialize preset for IHN-D101");
  345. for (int i = 1; i < 5; i++) {
  346. String strPreset = mWallpadStatusData.getLivinglightModeCtrlUnitValues(i, 0);
  347. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  348. String[] strParse = strPreset.split(":");
  349. if (strParse[1].equalsIgnoreCase("0") || strParse[2].equalsIgnoreCase("0")) {
  350. if (i == 1) {
  351. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  352. mLightInfo.mPreset[i].mLights[0].DIM = 7;
  353. mLightInfo.mPreset[i].mLights[0].COLOR = 5;
  354. }
  355. else if (i == 2) {
  356. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  357. mLightInfo.mPreset[i].mLights[0].DIM = 3;
  358. mLightInfo.mPreset[i].mLights[0].COLOR = 2;
  359. }
  360. else if (i == 3) {
  361. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  362. mLightInfo.mPreset[i].mLights[0].DIM = 1;
  363. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  364. }
  365. mWallpadStatusData.setLivinglightModeCtrlUnitValues(i, 0, mLightInfo.mPreset[i].mLights[0].ONOFF, mLightInfo.mPreset[i].mLights[0].DIM, mLightInfo.mPreset[i].mLights[0].COLOR);
  366. }
  367. else {
  368. mLightInfo.mPreset[i].mLights[0].ONOFF = strParse[0];
  369. mLightInfo.mPreset[i].mLights[0].DIM = Integer.parseInt(strParse[1]);
  370. mLightInfo.mPreset[i].mLights[0].COLOR = Integer.parseInt(strParse[2]);
  371. }
  372. }
  373. }
  374. else if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I
  375. || Version.getModelType() == MODEL_TYPE.IHN_1010_I_2443
  376. ) {
  377. Log.i(TAG, "[initLivinglightPreset] Initialize preset for IHN-1010(-I)");
  378. if (getKCCDimmingCtrl()) {
  379. for (int i = 1; i < 5; i++) {
  380. String strPreset = mWallpadStatusData.getLivinglightModeCtrlUnitValues(i, 0);
  381. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  382. String[] strParse = strPreset.split(":");
  383. if (strParse[1].equalsIgnoreCase("0") || strParse[2].equalsIgnoreCase("0")) {
  384. if (i == 1) {
  385. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  386. mLightInfo.mPreset[i].mLights[0].DIM = 10;
  387. mLightInfo.mPreset[i].mLights[0].COLOR = 5;
  388. }
  389. else if (i == 2) {
  390. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  391. mLightInfo.mPreset[i].mLights[0].DIM = 7;
  392. mLightInfo.mPreset[i].mLights[0].COLOR = 2;
  393. }
  394. else if (i == 3) {
  395. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  396. mLightInfo.mPreset[i].mLights[0].DIM = 5;
  397. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  398. }
  399. else if (i == 4) {
  400. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  401. mLightInfo.mPreset[i].mLights[0].DIM = 2;
  402. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  403. }
  404. mWallpadStatusData.setLivinglightModeCtrlUnitValues(i, 0, mLightInfo.mPreset[i].mLights[0].ONOFF, mLightInfo.mPreset[i].mLights[0].DIM, mLightInfo.mPreset[i].mLights[0].COLOR);
  405. }
  406. else {
  407. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  408. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].ONOFF);
  409. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].DIM);
  410. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].COLOR);
  411. }
  412. }
  413. }
  414. }
  415. } catch (RuntimeException re) {
  416. LogUtil.errorLogInfo("", TAG, re);
  417. }
  418. catch (Exception e) {
  419. Log.e(TAG, "[Exception] initLivinglightPreset()");
  420. LogUtil.errorLogInfo("", TAG, e);
  421. }
  422. mWallpadStatusData.closeDB();
  423. }
  424. private boolean getKCCDimmingCtrl() {
  425. try {
  426. Log.i(TAG, "[getKCCDimmingCtrl] ========== START ==========");
  427. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  428. int nEnable = mWallpadDeviceSet.GetDeviceSetted("KCC디밍제어기");
  429. mWallpadDeviceSet.closeDB();
  430. Log.i(TAG, "[getKCCDimmingCtrl] nEnable [" + nEnable + "]");
  431. if (nEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
  432. Log.i(TAG, "[getKCCDimmingCtrl] Enabled");
  433. return true;
  434. }
  435. else {
  436. Log.i(TAG, "[getKCCDimmingCtrl] Disabled");
  437. return false;
  438. }
  439. } catch (RuntimeException re) {
  440. LogUtil.errorLogInfo("", TAG, re);
  441. return false;
  442. }
  443. catch (Exception e) {
  444. Log.e(TAG, "[Exception] setKCCDimmingCtrl()");
  445. LogUtil.errorLogInfo("", TAG, e);
  446. return false;
  447. }
  448. }
  449. private void initEscapeLadderDownSend() {
  450. try {
  451. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getContext());
  452. if(deviceSet!=null)
  453. {
  454. int ladderDownSend = deviceSet.getEscapeLadderDownSend();
  455. boolean ladderDownRecv = deviceSet.GetEscapeLadderDownRecv(); // 기존 '피난사다리입하수신' 설정정보 (더이상 사용하지 않음 2021.01.28)\
  456. Log.d(TAG, "[initEscapeLadderDownSend] ladderDownRecv [" + ladderDownRecv + "]");
  457. if (ladderDownRecv) {
  458. if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_NONE) {
  459. Log.d(TAG, "[initEscapeLadderDownSend] ===== first setting =====");
  460. deviceSet.setEscapeLadderDownSend(WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER); // 신규 /'피난사다리전송' 설정정보 '윗집'
  461. } else {
  462. Log.d(TAG, "[initEscapeLadderDownSend] ladderDownSend [" + ladderDownSend + "]");
  463. }
  464. }
  465. deviceSet.closeDB();
  466. }
  467. } catch (RuntimeException re) {
  468. LogUtil.errorLogInfo("", TAG, re);
  469. } catch (Exception e) {
  470. Log.e(TAG, "[Exception] initEscapeLadderDownSend()");
  471. LogUtil.errorLogInfo("", TAG, e);
  472. }
  473. }
  474. public void CallSubMenuScreen(int screenID) {
  475. if (screenID >= ID.LINKEDSCREEN.SubMenuAddService.Notice && screenID <= ID.LINKEDSCREEN.SubMenuAddService.ElecCar) m_CallSubMenuScreen.callStartAddServiceAPK(screenID);
  476. else if (screenID >= ID.LINKEDSCREEN.SubMenuEnergy.RealTimeCheckMeter && screenID <= ID.LINKEDSCREEN.SubMenuEnergy.IEnergy) m_CallSubMenuScreen.callStartEnergyAPK(screenID);
  477. }
  478. private void restoreSystemVolume() {
  479. try {
  480. String strCurrentTopPackage = getTopActivity();
  481. Log.i(TAG, "[restoreSystemVolume] strCurrentTopPackage = " + strCurrentTopPackage);
  482. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  483. int nSavedVolume = wdb.GetWallPadMasterVolume();
  484. wdb.closeDB();
  485. final AudioManager audioManager = (AudioManager)this.getContext().getSystemService(this.getContext().AUDIO_SERVICE);
  486. int nCurrentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
  487. audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume , 0);
  488. Log.i(TAG, "[restoreSystemVolume] #Before# nCurrentVolume = " + nCurrentVolume + ", #After# nSavedVolume = " + nSavedVolume);
  489. } catch (RuntimeException re) {
  490. LogUtil.errorLogInfo("", TAG, re);
  491. }
  492. catch (Exception e) {
  493. Log.e(TAG, "[Exception] restoreSystemVolume()");
  494. LogUtil.errorLogInfo("", TAG, e);
  495. }
  496. }
  497. // =================================================================================================
  498. // [[ Activity Life Cycle ]] region
  499. // =================================================================================================
  500. /**
  501. * Activity Constructors
  502. */
  503. @Override
  504. protected void onCreate(Bundle savedInstanceState) {
  505. super.onCreate(savedInstanceState);
  506. Log.i(TAG, "[onCreate] ========== START ==========");
  507. Log.w(TAG, "[onCreate] Start to check booting status!!!");
  508. Runtime mRuntime = Runtime.getRuntime();
  509. Process mProcess;
  510. int iDelayCount = 0;
  511. while (true) {
  512. try {
  513. String cmd = "getprop dev.bootcomplete";
  514. mProcess = mRuntime.exec(cmd);
  515. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  516. String line;
  517. String strResult = null;
  518. while ((line = br.readLine()) != null) {
  519. strResult = line;
  520. }
  521. if (strResult!=null && strResult.equals("1")) {
  522. File sdcard = new File("/storage/emulated/0");
  523. if(sdcard.exists() == true) {
  524. iDelayCount = 0;
  525. Thread.sleep(1000);
  526. break;
  527. }
  528. }
  529. {
  530. iDelayCount++;
  531. Thread.sleep(100);
  532. }
  533. if (iDelayCount > 400) {
  534. cmd = "setprop persist.sys.reboot 1";
  535. mProcess = mRuntime.exec(cmd);
  536. }
  537. } catch (RuntimeException re) {
  538. LogUtil.errorLogInfo("", TAG, re);
  539. }
  540. catch (Exception e) {
  541. Log.e(TAG, "[Exception] Checking device booting status -> Unable to execute top command");
  542. e.fillInStackTrace();
  543. LogUtil.errorLogInfo("", TAG, e);
  544. }
  545. }
  546. Log.w(TAG, "[onCreate] Device booting completed!!");
  547. Log.i(TAG, "[onCreate] Wallpad model name [" + Version.getModelType() + "]");
  548. if (Common.DIAGNOSTIC_MODE) {
  549. Log.i(TAG, "------------------ [START - DIAGNOSTIC_MODE] -------------------");
  550. setNetworkAddr( 2, 1, 3);
  551. }
  552. // @ AutoScale 설정 - 1.
  553. if (WpadScale.getWidthPixels() == 800 && WpadScale.getHeightPixels() == 480) {
  554. // 800x480 일 경우에만 AutoScale 을 설정한다.
  555. Log.i(TAG, "[onCreate] Wallpad LCD resolution. -> Width [" + WpadScale.getWidthPixels() + "], Height [" + WpadScale.getHeightPixels() + "] -> setAutoScale ON !!!");
  556. WpadScale.setAutoScale(true);
  557. }
  558. else if (WpadScale.getWidthPixels() == 1366 && WpadScale.getHeightPixels() == 768) {
  559. // 800x480 일 경우에만 AutoScale 을 설정한다.
  560. Log.i(TAG, "[onCreate] Wallpad LCD resolution. -> Width [" + WpadScale.getWidthPixels() + "], Height [" + WpadScale.getHeightPixels() + "] -> setAutoScale ON !!!");
  561. WpadScale.setAutoScale(true);
  562. WpadScale.changeAutoScaleValue(1024, 600);
  563. }
  564. // @ AutoScale 설정 - 2. 에너지관리화면을 위한 구분자 설정
  565. if ((WpadScale.getWidthPixels() == 1024) && (WpadScale.getHeightPixels() == 600)) {
  566. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1024x600;
  567. }
  568. else if ((WpadScale.getWidthPixels() == 1280) && (WpadScale.getHeightPixels() == 800)) {
  569. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1280x800;
  570. }
  571. else if ((WpadScale.getWidthPixels() == 800) && (WpadScale.getHeightPixels() == 480)) {
  572. Common.SCREEN_TYPE = Common.SCREEN_TYPE_800x480;
  573. }
  574. else if ((WpadScale.getWidthPixels() == 1366) && (WpadScale.getHeightPixels() == 768)) {
  575. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1024x600;
  576. }
  577. Log.d(TAG, "[onCreate] SCREEN_TYPE: " + Common.SCREEN_TYPE);
  578. super.setFinishBrEnable(false);
  579. super.AppVersionLogOut(); // [APP Version] + [WallPadSupport Lib Version] 을 로그로 출력한다.
  580. LayoutDevice.InitGetScreenSize(this.getWindowManager(), getApplicationContext() );
  581. try {
  582. // 최초 DB 폴더가 생성되어 있지 않으면 폴더를 생성하도록 한다.
  583. File dbhome = new File(wallpaddbmgr.dblocation);
  584. Log.d(TAG, "[Create] - Step0.3 : dbhome path [" + dbhome.getPath() + "]");
  585. if (dbhome.exists() == false) {
  586. dbhome.mkdir();
  587. Log.d(TAG, "[Create] - Step0.3 : Make DB Folder");
  588. }
  589. else {
  590. Log.d(TAG, "[Create] - Step0.3 : DB exists");
  591. }
  592. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  593. if (mWallpadStatusData != null) {
  594. DebugLogOutput("[Create] - Step0.3 : WallpadStatusData Open OK");
  595. mWallpadStatusData.closeDB();
  596. }
  597. else {
  598. DebugLogOutput("[Create] - Step0.3 : WallpadStatusData Open FAIL");
  599. }
  600. } catch (RuntimeException re) {
  601. LogUtil.errorLogInfo("", TAG, re);
  602. }
  603. catch (Exception e) {
  604. LogUtil.errorLogInfo("", TAG, e);
  605. }
  606. DebugLogOutput("[Create] - Step0.5 : WallpadStatusData end");
  607. Log.i("Version", "<><><><> WallPadAPI Version = [" + define.WALLPADAPI_VERSION + "] " + "<><><><>");
  608. checkISSEnergyType();
  609. runDeviceService();
  610. // 1. 변수 초기화
  611. DebugLogOutput("[Create] - Step1 : EMData Create");
  612. PopupActivityRun = false;
  613. InfoActivityRun = false;
  614. mContext = this;
  615. mContext_call = mContext;
  616. setCallAppRunning(false); // 메인앱 초기화시 통화앱 미실행값을 DB에 저장
  617. // 2. 자동 종료 셋팅
  618. DebugLogOutput("[Create] - Step2 : Auto Finish Setting");
  619. // 3. API 호출
  620. DebugLogOutput("[Create] - Step3 : API Call");
  621. // 3.1. mWallPadAPI 생성
  622. try {
  623. mWallPadAPI = new WallPadAPI(this);
  624. } catch (RuntimeException re) {
  625. LogUtil.errorLogInfo("", TAG, re);
  626. }
  627. catch (Exception e) {
  628. Log.e(TAG, "[ExceptionError] - new WallPadAPI : " + e);
  629. LogUtil.errorLogInfo("", TAG, e);
  630. }
  631. initIOInterface(mWallPadAPI);
  632. Common.CurrentBoardType = mIOInterface.getBoardType(Version.getModelType());
  633. DebugLogOutput("[Create] - Step3.5 : API Call end");
  634. if (Common.GetDeviceSampleMode(this)) {
  635. Log.d(TAG, "[Create] OperationMode = MODE_BUSINESS_SAMPLE");
  636. DEVICE_OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE;
  637. }
  638. else {
  639. Log.d(TAG, "[Create] OperationMode = MODE_NOMAL");
  640. DEVICE_OPERATION_MODE = Common.MODE_NOMAL;
  641. }
  642. // 분전반 정보 가져오기
  643. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  644. Common.CurrentDistributionPanelType = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  645. mWallpadDeviceSet.closeDB();
  646. // 4. Layout registration
  647. DebugLogOutput("[Create] - Step4 : Layout registration");
  648. Common.eGUIType = checkGUIType(this.getContext());
  649. Log.i(TAG, "[Create] eGUIType = " + Common.eGUIType);
  650. mIconManager = new IconManager(mContext, mWallPadAPI);
  651. if (mIconManager == null) {
  652. Log.w(TAG, "[Create] mIconManager is null!!");
  653. }
  654. mIconInfoTable = mIconManager.getAvailableIcons();
  655. if (mIconInfoTable == null) {
  656. Log.w(TAG, "[Create] mIconInfoTable is null!!");
  657. }
  658. else {
  659. Log.i(TAG, "[Create] mIconInfoTable.getCnt() = " + mIconInfoTable.getCnt());
  660. }
  661. WallpadDeviceSet deviceSet = new WallpadDeviceSet(mContext);
  662. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  663. deviceSet.closeDB();
  664. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  665. if (!bSupport) {
  666. mWallpadStatusData.SetEasyModeUxUse(false);
  667. }
  668. bEasyModeUsage = bSupport & mWallpadStatusData.GetEasyModeUxUse();
  669. mWallpadStatusData.closeDB();
  670. // Sound API 등록
  671. mSound = new WpadSound(this);
  672. // 메인화면 레이아웃
  673. MainLayout = new RelativeLayout(this);
  674. RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  675. MainLayout.setLayoutParams(params);
  676. MainLayout.setId(ID_OLD.main.layout.ALL);
  677. super.setAllLayoutRegistration(MainLayout);
  678. // 메인화면 스크린 레이아웃
  679. MainScreenLayout = new RelativeLayout(this);
  680. WpadUtil.LayoutRegistration(MainLayout, MainScreenLayout, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  681. if (getWallPadCameraUsage() && (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT)) {
  682. Log.i(TAG, "[Create] SurfaceLayout Registration!!!");
  683. SurfaceLayout = new RelativeLayout(this);
  684. WpadUtil.LayoutRegistration(MainLayout, SurfaceLayout, WpadScale.getWidthPixels(), WpadScale.getWidthPixels(), 0, 0, ID.MAINACTIVITY.LAYOUT.SURFACE);
  685. }
  686. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) nIconsOnSubScreen = 24;
  687. // else if (eGUIType == GUI_TYPE.METRO) nIconsOnSubScreen = 15;
  688. else nIconsOnSubScreen = 24;
  689. // 서브화면 1 레이아웃
  690. if (mIconInfoTable.getCnt() > 0) {
  691. SubLayout_01 = new RelativeLayout(this);
  692. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  693. SubLayout_01.setLayoutParams(params);
  694. SubLayout_01.setId(ID_OLD.main.layout.ALL);
  695. super.setAllLayoutRegistration(SubLayout_01);
  696. // 서브화면 1 스크린 레이아웃
  697. SubScreenLayout_01 = new RelativeLayout(this);
  698. WpadUtil.LayoutRegistration(SubLayout_01, SubScreenLayout_01, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  699. }
  700. // 서브화면 2 레이아웃
  701. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) {
  702. SubLayout_02 = new RelativeLayout(this);
  703. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  704. SubLayout_02.setLayoutParams(params);
  705. SubLayout_02.setId(ID_OLD.main.layout.ALL);
  706. super.setAllLayoutRegistration(SubLayout_02);
  707. // 서브화면 2 스크린 레이아웃
  708. SubScreenLayout_02 = new RelativeLayout(this);
  709. WpadUtil.LayoutRegistration(SubLayout_02, SubScreenLayout_02, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  710. }
  711. // 간편모드 메인화면 레이아웃
  712. if (bEasyModeUsage) {
  713. EasyMainLayout = new RelativeLayout(this);
  714. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  715. EasyMainLayout.setLayoutParams(params);
  716. EasyMainLayout.setId(ID_OLD.main.layout.ALL);
  717. super.setAllLayoutRegistration(EasyMainLayout);
  718. // 간편모드 메인화면 스크린 레이아웃
  719. EasyMainScreenLayout = new RelativeLayout(this);
  720. WpadUtil.LayoutRegistration(EasyMainLayout, EasyMainScreenLayout, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  721. }
  722. m_ModelHouseSleepModeRelease= Common.GetModelHouseSleepModeRelease(this);
  723. Log.d(TAG, " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% =====> GetModelHouseSleepModeRelease :" + m_ModelHouseSleepModeRelease);
  724. if (m_ModelHouseSleepModeRelease) {
  725. mLCD_SleepHandler.sendEmptyMessageDelayed(0, (30 * 1000));
  726. }
  727. // 5. Top Menu - ImageView registration
  728. DebugLogOutput("[Create] - Step5 : Top Menu - ImageView registration");
  729. // 6. Tab Menu - ImageView registration
  730. restoreSystemVolume();
  731. initProximitySensor();
  732. // 서브 스크린 호출하기 위한 메뉴 리스트 관리 클래스
  733. m_CallSubMenuScreen = new CallSubMenuScreen( this , mWallPadAPI);
  734. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  735. // 메인화면 3가지 등록으로 인해 변경
  736. MainScreen = new MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  737. // EasyUI_MainScreen = new EASYUI_MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  738. }
  739. else if (Common.eGUIType == Common.GUI_TYPE.METRO) {
  740. MetroUI_MainScreen = new METROUI_MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  741. }
  742. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) {
  743. Hyosung_HN_MainScreen = new HYOSUNGUI_MAIN_HN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  744. }
  745. else {
  746. MainScreen = new MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  747. }
  748. DebugLogOutput("[Create] - Step6 : Main Screen registration");
  749. // 7. Draw
  750. DebugLogOutput("[Create] - Step7 : setContentView");
  751. try {
  752. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  753. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) setContentView(R.layout.main);
  754. else setContentView(R.layout.main_2);
  755. }
  756. else if (Common.eGUIType == Common.GUI_TYPE.METRO) setContentView(R.layout.main_metro);
  757. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) setContentView(R.layout.main_hyosung);
  758. else {
  759. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) setContentView(R.layout.main);
  760. else setContentView(R.layout.main_2);
  761. }
  762. if (bEasyModeUsage) setContentView(R.layout.main_easy);
  763. // setContentView(R.layout.main);
  764. // 메인화면 3가지로 슬라이딩 방식으로 구현하기 위하여 뷰플리퍼를 사용하여 처리
  765. mViewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);
  766. if (mViewFlipper != null) {
  767. if (MainLayout != null) mViewFlipper.addView(MainLayout);
  768. if (SubLayout_01 != null) mViewFlipper.addView(SubLayout_01);
  769. if (SubLayout_02 != null && Common.eGUIType == Common.GUI_TYPE.STANDARD) mViewFlipper.addView(SubLayout_02);
  770. if (EasyMainLayout != null && bEasyModeUsage) mViewFlipper.addView(EasyMainLayout);
  771. DebugLogOutput("[Create] - Step8 : Add Flipper !!! ");
  772. }
  773. } catch (RuntimeException re) {
  774. LogUtil.errorLogInfo("", TAG, re);
  775. }
  776. catch (Exception e) {
  777. LogUtil.errorLogInfo("", TAG, e);
  778. }
  779. registerBroadcastReceiver();
  780. Check_Upgrade_File();
  781. //앱 버전정보 DB저장
  782. try {
  783. Log.d(TAG, "mThread_getAppsVersion Start!! ");
  784. if (mThread_getAppsVersion== null) {
  785. mThread_getAppsVersion = new getInstalledPackageInfo();
  786. mThread_getAppsVersion.start();
  787. }
  788. else {
  789. Log.w(TAG, "mThread_getAppsVersion is null!!");
  790. }
  791. Log.d(TAG, "mThread_getAppsVersion End!! ");
  792. } catch (RuntimeException re) {
  793. LogUtil.errorLogInfo("", TAG, re);
  794. }
  795. catch (Exception e) {
  796. LogUtil.errorLogInfo("", TAG, e);
  797. }
  798. try {
  799. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  800. AddressSet addc = SetData.getAddressMGR();
  801. AddressSetBackup addc_Backup = SetData.getAddressMGR_Backup();
  802. overridePendingTransition(0, 0);
  803. if (!isSystemIPSet()) {
  804. Log.w(TAG, "[onCreate] The IP Address of OS is not set!");
  805. startManagerSettingSetAddress();
  806. }
  807. else if (addc.Dong.equals("NONE") || addc.Ho.equals("NONE")) {
  808. Log.w(TAG, "[onCreate] The info. of resi. is not set! [primary db]");
  809. if (addc_Backup.Dong.equals("NONE") || addc_Backup.Ho.equals("NONE")) {
  810. Log.w(TAG, "[onCreate] The info. of resi. is not set! [secondary db]");
  811. startManagerSettingSetAddress();
  812. }
  813. else {
  814. addc.setAddress(addc_Backup.Dong, addc_Backup.Ho);
  815. addc.setIPAddress(addc_Backup.IPAddress);
  816. m_IPActivity = true;
  817. if (addc.IPAddress!=null && !addc.IPAddress.equals("NONE")) {
  818. Log.w(TAG, "[onCreate] ========== start iMapServer service ========== [secondary db]");
  819. Intent intent = new Intent(getApplicationContext(), iMapServer.class);
  820. startService(intent);
  821. Intent intentMobile = new Intent(getApplicationContext(), MobileProcService.class);
  822. Log.w(TAG, "[onCreate] ========== start MobileProcServicee ========== [secondary db]");
  823. startService(intentMobile);
  824. }
  825. MAINStatus = MAIN_NORMAL;
  826. }
  827. }
  828. else {
  829. m_IPActivity = true;
  830. if (!addc.IPAddress.equals("NONE")) {
  831. Log.w(TAG, "[onCreate] ========== start iMapServer service ========== [primary db]");
  832. Intent intent = new Intent(this, iMapServer.class);
  833. startService(intent);
  834. Intent intentMobile = new Intent(getApplicationContext(), MobileProcService.class);
  835. Log.w(TAG, "[onCreate] ========== start MobileProcServicee ========== [secondary db]");
  836. startService(intentMobile);
  837. }
  838. MAINStatus = MAIN_NORMAL;
  839. }
  840. SetData.closeDB();
  841. } catch (RuntimeException re) {
  842. LogUtil.errorLogInfo("", TAG, re);
  843. }
  844. catch (Exception e) {
  845. Log.e(TAG, "[Exception] check device addresses(ip, resi. info.)");
  846. LogUtil.errorLogInfo("", TAG, e);
  847. }
  848. //주차정보 사용여부 체크
  849. getParkedVehicleLocationSysInfo();
  850. //전기차 정보 가져오기
  851. GetElectricCarInfo();
  852. //에너지관리서버 사용여부 가져오기
  853. GetEnergyServerInfo();
  854. //에너지 알람 사용여부 가져오기
  855. GetEnergyAlarm();
  856. //통화타임아웃 초기화
  857. setCallAppTimeoutAsDefault();
  858. //카카오홈 사용 여부 체크(카카오홈)
  859. boolean isUseKakao = getKakaoHomeCheck();
  860. if(isUseKakao)
  861. {
  862. Handler mHandler = new Handler();
  863. mHandler.postDelayed(mLaunchTaskKakao, 500);
  864. mHandler = null;
  865. }
  866. try {
  867. mWallPadApiCheckHandler.sendEmptyMessage(0);
  868. // Checker.sendEmptyMessageDelayed(0, 1000);
  869. } catch (RuntimeException re) {
  870. LogUtil.errorLogInfo("", TAG, re);
  871. }
  872. catch (Exception e) {
  873. LogUtil.errorLogInfo("", TAG, e);
  874. }
  875. // sip 서비스 실행 옮김
  876. Log.d(TAG, "[onCreate] startCallService start");
  877. try {
  878. runCallServices startCallService = new runCallServices();
  879. startCallService.start();
  880. } catch (RuntimeException re) {
  881. LogUtil.errorLogInfo("", TAG, re);
  882. }
  883. catch (Exception e) {
  884. LogUtil.errorLogInfo("", TAG, e);
  885. }
  886. Log.d(TAG, "[onCreate] startCallService end");
  887. try {
  888. // 부팅하고 나서 업그레이드 상태를 false 로 해주지 않으면 통화 수신이 안됨
  889. // 꼭 들어가야 함
  890. // 전체 정전시험시 단지서버도 재부팅은 하나 로긴을 하지 않으면 그시간동안 세대기가 보낸 부트업 메세지를 못 받기 때문에....단말기 시간을 재 셋팅해주도록 한다.
  891. Calendar cal = new GregorianCalendar();
  892. 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));
  893. WallpadStatusData wpd = new WallpadStatusData(getApplicationContext());
  894. wpd.SetUpgradeState(false);
  895. wpd.SetLastHeartbeat(timedata);
  896. wpd.closeDB();
  897. } catch (RuntimeException re) {
  898. LogUtil.errorLogInfo("", TAG, re);
  899. }
  900. catch (Exception e) {
  901. LogUtil.errorLogInfo("", TAG, e);
  902. }
  903. try {
  904. Calendar m_CurCalendar = Calendar.getInstance();
  905. //CurYear , CurMonth, CurDate, CurHour, CurMin, CurSecond;
  906. int CurYear = m_CurCalendar.get(Calendar.YEAR);
  907. if (CurYear < 2018) {
  908. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  909. DBMGR.setSystemTime(2018, 8, 1, 13, 0, 0);
  910. DBMGR.closeDB();
  911. }
  912. } catch (RuntimeException re) {
  913. LogUtil.errorLogInfo("", TAG, re);
  914. }
  915. catch (Exception e) {
  916. LogUtil.errorLogInfo("", TAG, e);
  917. }
  918. mLightInfo = new LightInfo();
  919. getLivinglightPreset();
  920. initLivinglightPreset();
  921. getLivinglightPreset();
  922. initEscapeLadderDownSend();
  923. setPageIndicator();
  924. mGetCallHistoryCheckHandler.sendEmptyMessageDelayed(0, 10000);
  925. try {
  926. int getSleepTime = Settings.System.getInt(this.getContext().getContentResolver(), SCREEN_OFF_TIMEOUT);
  927. int mSleepModeTime = (getSleepTime / 1000);
  928. Log.d(TAG, "[Create] mSleepModeTime [" + mSleepModeTime + "]");
  929. if (mSleepModeTime <= 30) {
  930. Log.d(TAG, "[Create] Reset mSleepModeTime ===== [" + mSleepModeTime + "] =====");
  931. Settings.System.putInt(this.getContext().getContentResolver(), SCREEN_OFF_TIMEOUT, 28 * 1000); // 백라이트 off와 앱 종료가 동시에 일어나면 월패드가 비정상 종료되므로 수정 (2021.04.06 메이드인랩 김수진 선임 요청)
  932. }
  933. } catch (Settings.SettingNotFoundException e) {
  934. e.printStackTrace();
  935. }
  936. try {
  937. handlerEverySecond.sendEmptyMessageDelayed(0, 1000);
  938. // BSP 수정으로 인하여 해당 코드 삭제 (2021.02.24, SEULKI)
  939. // // 월패드 카메라 녹색 노이즈 시험 코드 (월패드 부팅시 월패드 카메라 영상을 잠시 띄운후 없앤다. JEFF/2020.01.21.01)
  940. // /**
  941. // * 부팅시 카메라 서비스 정상동작 여부를 확인한다. (Edited by jeff, 2020.09.08)
  942. // */
  943. // sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_CHECK, 0, 0, 0); // 5초후 월패드 카메라를 초기화 한다. (그냥 화면밖에 영상을 잠시 띄우고 5초뒤에 없앤다.)
  944. } catch (RuntimeException re) {
  945. LogUtil.errorLogInfo("", TAG, re);
  946. }
  947. catch (Exception e) {
  948. LogUtil.errorLogInfo("", TAG, e);
  949. }
  950. if (bKakaoiEnable) {
  951. Log.i(TAG, "[onCreate] ========== Kakao function enabled ==========");
  952. startKakaoiFloatingBTN();
  953. }
  954. // forceCtrlStrangerRecordingUserSettingDisable(false);
  955. getLCDKeeperUsage();
  956. Log.i(TAG, "[onCreate] ==================== onCreate end ====================");
  957. }
  958. /**
  959. * 카카오 실행 관련 핸들러
  960. */
  961. private Runnable mLaunchTaskKakao = new Runnable() {
  962. public void run() {
  963. String Packagename = "com.kakao.i.test.real.wallpad";
  964. //Handler를 이용하여 Timer 사용
  965. Intent mainIntent = mContext.getPackageManager().getLaunchIntentForPackage(Packagename);
  966. if (mainIntent != null) {
  967. boolean isShowKakao = getShowKakaoCheck();
  968. if(isShowKakao)
  969. mainIntent.putExtra("ShowKakao", true);
  970. mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  971. startActivity(mainIntent);
  972. };
  973. }
  974. };
  975. private int nLCDKeeperType = WallpadDeviceSet.LCDKEEPER_NONE;
  976. private String getLCDKeeperType(int nLCDKeeperType) {
  977. try {
  978. Log.i(TAG, "[getLCDKeeperUsage] nLCDKeeperType [" + nLCDKeeperType + "]");
  979. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_NONE) return "LCDKEEPER_NONE";
  980. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT) return "LCDKEEPER_PROTECT";
  981. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER) return "LCDKEEPER_RECOVER";
  982. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) return "LCDKEEPER_PROTECT_RECOVER";
  983. else return "UNKNOWN";
  984. } catch (RuntimeException re) {
  985. LogUtil.errorLogInfo("", TAG, re);
  986. return "ERROR";
  987. }
  988. catch (Exception e) {
  989. Log.e(TAG, "[Exception] getLCDKeeperType(int nLCDKeeperType)");
  990. LogUtil.errorLogInfo("", TAG, e);
  991. return "ERROR";
  992. }
  993. }
  994. private boolean bLCDKeeperUsage = false;
  995. private void getLCDKeeperUsage() {
  996. try {
  997. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  998. nLCDKeeperType = mWallpadDeviceSet.getLCDKeeperUsage();
  999. mWallpadDeviceSet.closeDB();
  1000. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT || nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER || nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) {
  1001. bLCDKeeperUsage = true;
  1002. }
  1003. Log.i(TAG, "[getLCDKeeperUsage] bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  1004. } catch (RuntimeException re) {
  1005. LogUtil.errorLogInfo("", TAG, re);
  1006. }
  1007. catch (Exception e) {
  1008. Log.e(TAG, "[Exception] getLCDKeeperUsage()");
  1009. LogUtil.errorLogInfo("", TAG, e);
  1010. }
  1011. }
  1012. public boolean isSystemIPSet() {
  1013. try {
  1014. Log.i(TAG, "[isSystemIPSet] START!");
  1015. String strResult = "";
  1016. if (Build.VERSION.SDK_INT > 23) {
  1017. // Android 7
  1018. strResult = getIPAddress();
  1019. }
  1020. else {
  1021. // Android 6
  1022. if(NetworkInterface.getByName("eth0")!=null)
  1023. {
  1024. String strNetInfo = NetworkInterface.getByName("eth0").toString();
  1025. Log.i(TAG, "[isSystemIPSet] strNetInfo : " + strNetInfo + "]");
  1026. strNetInfo.trim();
  1027. String[] Parse_01 = strNetInfo.split("\\]");
  1028. // for (int i = 0; i < Parse_01.length; i++) {
  1029. // LOG_DEBUG("[getDeviceIPAddress] Parse_01[" + i + "] : " + Parse_01[i]);
  1030. // }
  1031. String[] Parse_02 = Parse_01[Parse_01.length - 1].split("\\/");
  1032. // for (int i = 0; i < Parse_02.length; i++) {
  1033. // LOG_DEBUG("[getDeviceIPAddress] Parse_02[" + i + "] : " + Parse_02[i]);
  1034. // }
  1035. strResult = Parse_02[1];
  1036. }
  1037. }
  1038. Log.i(TAG, "[isSystemIPSet] DONE! [IP Address : " + strResult + "]");
  1039. 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])$");
  1040. return mPattern.matcher(strResult).matches();
  1041. } catch (RuntimeException re) {
  1042. LogUtil.errorLogInfo("", TAG, re);
  1043. return false;
  1044. }
  1045. catch (Exception e) {
  1046. Log.e(TAG, "[Exception] isSystemIPSet()");
  1047. LogUtil.errorLogInfo("", TAG, e);
  1048. return false;
  1049. }
  1050. }
  1051. public static String getIPAddress() {
  1052. try {
  1053. List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
  1054. for (NetworkInterface intf : interfaces) {
  1055. List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
  1056. for (InetAddress addr : addrs) {
  1057. if (!addr.isLoopbackAddress()) {
  1058. String sAddr = addr.getHostAddress();
  1059. //boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
  1060. boolean isIPv4 = sAddr.indexOf(':')<0;
  1061. if (isIPv4)
  1062. return sAddr;
  1063. }
  1064. }
  1065. }
  1066. } catch (RuntimeException re) {
  1067. LogUtil.errorLogInfo("", TAG, re);
  1068. }
  1069. catch (Exception e) {
  1070. Log.e(TAG, "[Exception] isSystemIPSet()");
  1071. LogUtil.errorLogInfo("", TAG, e);
  1072. }
  1073. return "";
  1074. }
  1075. public void initIOInterface(WallPadAPI wallpadapi) {
  1076. try {
  1077. mIOInterface = new IOInterface(getContext(), wallpadapi);
  1078. } catch (RuntimeException re) {
  1079. LogUtil.errorLogInfo("", TAG, re);
  1080. }
  1081. catch (Exception e) {
  1082. Log.e(TAG, "[Exception] initIOInterface(WallPadAPI wallpadapi)");
  1083. LogUtil.errorLogInfo("", TAG, e);
  1084. }
  1085. }
  1086. public void checkDongHoSetting() {
  1087. try {
  1088. Log.d(TAG, "[checkDongHoSetting] ========== START ==========");
  1089. boolean IP_ExpansionSettingFlag = false;
  1090. EthernetDevInfo info = new EthernetDevInfo();
  1091. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  1092. AddressSet addc = mWallpadStatusData.getAddressMGR();
  1093. mWallpadStatusData.SetCallAPKStatus(false);
  1094. mWallpadStatusData.closeDB();
  1095. if (addc.Dong!=null && !addc.Dong.equals("NONE") && addc.Ho!=null&& !addc.Ho.equals("NONE") && addc.IPAddress!=null&& !addc.IPAddress.equals("NONE")) {
  1096. if (Version.getModelType() == MODEL_TYPE.IHN_1020GL && Version.getModelType() == MODEL_TYPE.IHN_1020B_A
  1097. && Version.getModelType() == MODEL_TYPE.IHN_1020SA_A && Version.getModelType() == MODEL_TYPE.IHN_750) {
  1098. // LH 게이트웨이 때문에 위치 옮김 제어 서비스 보다 먼저 처리
  1099. if(addc.IPAddress!=null)
  1100. {
  1101. String[] iptbl = addc.IPAddress.split("[.]");
  1102. Log.d(TAG, "[checkDongHoSetting] Mac Set -> IP : " + addc.IPAddress +", Length : " + iptbl.length);
  1103. // BSP에서 초기 이더넷 비활성화시 jni 맥 셋팅시 메인어플 다이~~
  1104. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1105. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1106. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_DISABLED!!!");
  1107. if (IP_ExpansionSettingFlag == true) {
  1108. mEthManager.UpdateEthDevInfo(info);
  1109. }
  1110. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1111. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_ENABLING!!!");
  1112. if (iptbl.length == 4) {
  1113. 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]));
  1114. Log.d(TAG, "[checkDongHoSetting] Mac Set "+macadd);
  1115. try {
  1116. WallPadInterface wpdifc = new WallPadInterface();
  1117. wpdifc.setMacAddr(macadd);
  1118. } catch (RuntimeException re) {
  1119. LogUtil.errorLogInfo("", TAG, re);
  1120. }
  1121. catch (Exception ex) {
  1122. //ex.printStackTrace();
  1123. LogUtil.errorLogInfo("", TAG, ex);
  1124. }
  1125. Log.d(TAG, "[checkDongHoSetting] -----------------------------------MacSet");
  1126. }
  1127. else {
  1128. Log.d(TAG,"[checkDongHoSetting] -----------------------------------Mac iptbl.length fail !!");
  1129. }
  1130. //EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1131. //mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1132. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1133. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_ENABLING!!!");
  1134. }
  1135. }
  1136. }
  1137. } catch (RuntimeException re) {
  1138. LogUtil.errorLogInfo("", TAG, re);
  1139. }
  1140. catch (Exception e) {
  1141. Log.e(TAG, "[Exception] checkDongHoSetting()");
  1142. LogUtil.errorLogInfo("", TAG, e);
  1143. }
  1144. }
  1145. public void registerSubScreen() {
  1146. try {
  1147. if (Common.eGUIType == Common.GUI_TYPE.METRO) {
  1148. if (MetroUI_SUB_GroupScreen == null && SubScreenLayout_01 != null ) MetroUI_SUB_GroupScreen = new METROUI_SUB_GROUP(getContext() , SubScreenLayout_01, mWallPadAPI);
  1149. }
  1150. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) {
  1151. if (MetroUI_SUB_GroupScreen == null && SubScreenLayout_01 != null ) MetroUI_SUB_GroupScreen = new METROUI_SUB_GROUP(getContext() , SubScreenLayout_01, mWallPadAPI);
  1152. }
  1153. else {
  1154. if (mIconInfoTable.getCnt() > 0) {
  1155. if (SUB_01Screen == null && SubScreenLayout_01 != null ) SUB_01Screen = new SUB_01(getContext() , SubScreenLayout_01, mWallPadAPI);
  1156. }
  1157. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) {
  1158. if (SUB_02Screen == null && SubScreenLayout_02 != null ) SUB_02Screen = new SUB_02(getContext() , SubScreenLayout_02, mWallPadAPI);
  1159. }
  1160. if (bEasyModeUsage) {
  1161. if (EasyUI_MainScreen == null && EasyMainScreenLayout != null ) EasyUI_MainScreen = new EASYUI_MAIN(getContext() , EasyMainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  1162. }
  1163. }
  1164. // restoreSystemVolume();
  1165. SCManager = new ScheduleManager();
  1166. } catch (RuntimeException re) {
  1167. LogUtil.errorLogInfo("", TAG, re);
  1168. }
  1169. catch (Exception e) {
  1170. Log.w(TAG, "[registerSubScreen] registerSubScreen()");
  1171. LogUtil.errorLogInfo("", TAG, e);
  1172. }
  1173. }
  1174. public void moveNextPage() {
  1175. try {
  1176. Log.d(TAG, "[moveNextPage] ===== START =====");
  1177. aniSlideIn = AnimationUtils.loadAnimation(getContext(), R.layout.appear_from_right);
  1178. aniSlideOut = AnimationUtils.loadAnimation(getContext(), R.layout.disappear_to_left);
  1179. mViewFlipper.setInAnimation(aniSlideIn);
  1180. mViewFlipper.setOutAnimation(aniSlideOut);
  1181. mViewFlipper.showNext();
  1182. } catch (RuntimeException re) {
  1183. LogUtil.errorLogInfo("", TAG, re);
  1184. }
  1185. catch (Exception e) {
  1186. Log.e(TAG, "[Exception] moveNextPage()");
  1187. LogUtil.errorLogInfo("", TAG, e);
  1188. }
  1189. }
  1190. public void movePreviousPage() {
  1191. try {
  1192. Log.d(TAG, "[movePreviousPage] ===== START =====");
  1193. aniSlideIn = AnimationUtils.loadAnimation(getContext(), R.layout.appear_from_left);
  1194. aniSlideOut = AnimationUtils.loadAnimation(getContext(), R.layout.disappear_to_right);
  1195. mViewFlipper.setInAnimation(aniSlideIn);
  1196. mViewFlipper.setOutAnimation(aniSlideOut);
  1197. mViewFlipper.showPrevious();
  1198. } catch (RuntimeException re) {
  1199. LogUtil.errorLogInfo("", TAG, re);
  1200. }
  1201. catch (Exception e) {
  1202. Log.e(TAG, "[Exception] moveNextPage()");
  1203. LogUtil.errorLogInfo("", TAG, e);
  1204. }
  1205. }
  1206. boolean bScreenCheck = false;
  1207. int nSubScreenTimeout = 20, SCREENTIMEOUT = 20;
  1208. public void checkMainPage() {
  1209. try {
  1210. if (!bScreenCheck) {
  1211. nSubScreenTimeout = SCREENTIMEOUT;
  1212. return;
  1213. }
  1214. int nViewFlipperIndex = mViewFlipper.getDisplayedChild();
  1215. if (nViewFlipperIndex != 0) {
  1216. if (nSubScreenTimeout > 0) {
  1217. nSubScreenTimeout--;
  1218. }
  1219. else {
  1220. nSubScreenTimeout = SCREENTIMEOUT;
  1221. mViewFlipper.setDisplayedChild(0);
  1222. }
  1223. Log.i(TAG, "[checkMainPage] nViewFlipperIndex [" + nViewFlipperIndex + "], nSubScreenTimeout [" + nSubScreenTimeout + "]");
  1224. }
  1225. else {
  1226. if (nSubScreenTimeout <= 0) {
  1227. nSubScreenTimeout = SCREENTIMEOUT;
  1228. Log.i(TAG, "[checkMainPage] nViewFlipperIndex [" + nViewFlipperIndex + "], nSubScreenTimeout [" + nSubScreenTimeout + "]");
  1229. }
  1230. }
  1231. } catch (RuntimeException re) {
  1232. LogUtil.errorLogInfo("", TAG, re);
  1233. }
  1234. catch (Exception e) {
  1235. Log.e(TAG, "[Exception] checkMainPage()");
  1236. LogUtil.errorLogInfo("", TAG, e);
  1237. }
  1238. }
  1239. String strWallPadMainPakageName = "kr.co.icontrols.wallpadmain";
  1240. private boolean isPackageTop(String strPackageName) {
  1241. try {
  1242. ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  1243. Log.i(TAG, "[isPackageTop] Build.VERSION.SDK_INT [" + Build.VERSION.SDK_INT + "]");
  1244. if (Build.VERSION.SDK_INT > 23) {
  1245. // Android 7
  1246. List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses();
  1247. for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) {
  1248. if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
  1249. for (String activeProcess : processInfo.pkgList) {
  1250. if (activeProcess.equals(strPackageName)) {
  1251. Log.i(TAG, "[isPackageTop] The top package is [" + strPackageName + "]");
  1252. return true;
  1253. }
  1254. }
  1255. }
  1256. }
  1257. }
  1258. else {
  1259. // Android 6
  1260. List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  1261. ComponentName componentInfo = taskInfo.get(0).topActivity;
  1262. if (componentInfo.getPackageName().equals(strPackageName)) {
  1263. Log.i(TAG, "[isPackageTop] The top package is [" + strPackageName + "]");
  1264. return true;
  1265. }
  1266. }
  1267. } catch (RuntimeException re) {
  1268. LogUtil.errorLogInfo("", TAG, re);
  1269. }
  1270. catch (Exception e) {
  1271. Log.e(TAG, "[Exception] isPackageTop(String strPackageName)");
  1272. LogUtil.errorLogInfo("", TAG, e);
  1273. }
  1274. return false;
  1275. }
  1276. // 부팅시에는 최초 DB에서 값을 읽어와서 변경하도록 한다.
  1277. private boolean m_SetBookMarkMainScreen = false;
  1278. private int m_CheckBookMarkReturnCount = 0 ;
  1279. private final int BOOKMARK_SCREEN_RETURN_CHECK_TIME = 30;
  1280. private boolean m_thisAcitivityRusume = false;
  1281. // 즐겨찾기 메인화면을 항상 고정해서 쓸것인지 설정하는 함수
  1282. public void SetBookMarkMainScreen(boolean Set)
  1283. {
  1284. m_SetBookMarkMainScreen = Set;
  1285. try
  1286. {
  1287. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  1288. if( wdb != null )
  1289. {
  1290. if( Set == true )
  1291. {
  1292. wdb.SetSelectedMainScreen( WallpadStatusData.MAIN_BOOKMARK_SCREEN);
  1293. }
  1294. else
  1295. {
  1296. wdb.SetSelectedMainScreen( WallpadStatusData.MAIN_DEFAULT_SCREEN);
  1297. }
  1298. wdb.closeDB();
  1299. }
  1300. }
  1301. catch (RuntimeException re) {
  1302. LogUtil.errorLogInfo("", TAG, re);
  1303. }
  1304. catch (Exception e )
  1305. {
  1306. LogUtil.errorLogInfo("", TAG, e);
  1307. }
  1308. }
  1309. public boolean CheckCurrentEnergyScreen()
  1310. {
  1311. int currentView = mViewFlipper.getDisplayedChild();
  1312. Log.d(TAG, "-------> currentView : " + currentView);
  1313. if( currentView == 1)
  1314. return true;
  1315. else
  1316. return false;
  1317. }
  1318. private int nTouchDownPosX = 0;
  1319. private int nTouchUpPosX = 0;
  1320. @Override
  1321. public boolean dispatchTouchEvent(MotionEvent ev) {
  1322. boolean bReturn = false;
  1323. //Log.d("Move" , "dispatchTouchEvent-----------1");
  1324. try {
  1325. if (ev.getAction() == MotionEvent.ACTION_DOWN) {
  1326. nTouchDownPosX = (int)ev.getX();
  1327. }
  1328. else if (ev.getAction() == MotionEvent.ACTION_UP) {
  1329. nTouchUpPosX = (int)ev.getX();
  1330. Log.d(TAG, "[dispatchTouchEvent] nTouchDownPosX [" + nTouchDownPosX + "], nTouchUpPosX [" + nTouchUpPosX + "]");
  1331. if (nTouchUpPosX < nTouchDownPosX - 50) {
  1332. moveNextPage();
  1333. setPageIndicator();
  1334. }
  1335. else if (nTouchUpPosX > nTouchDownPosX + 50) {
  1336. movePreviousPage();
  1337. setPageIndicator();
  1338. }
  1339. nTouchDownPosX = nTouchUpPosX;
  1340. }
  1341. } catch (RuntimeException re) {
  1342. LogUtil.errorLogInfo("", TAG, re);
  1343. }
  1344. catch (Exception e) {
  1345. Log.e(TAG, "[Exception] dispatchTouchEvent(MotionEvent ev)");
  1346. LogUtil.errorLogInfo("", TAG, e);
  1347. }
  1348. bReturn = super.dispatchTouchEvent(ev);
  1349. return bReturn;
  1350. }
  1351. private void setPageIndicator() {
  1352. try {
  1353. int nViewFlipperIndex = mViewFlipper.getDisplayedChild();
  1354. int nChildCnt = mViewFlipper.getChildCount();
  1355. Log.d(TAG, "[setPageIndicator] nViewFlipperIndex [" + nViewFlipperIndex + "], nChildCnt [" + nChildCnt + "]");
  1356. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  1357. Log.d(TAG, "[setPageIndicator] eGUIType == GUI_TYPE.STANDARD");
  1358. ImageView[] IMG_INDICATOR;
  1359. 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) };
  1360. else IMG_INDICATOR = new ImageView[] { (ImageView) findViewById(R.id.pageindex_main), (ImageView) findViewById(R.id.pageindex_sub1), (ImageView) findViewById(R.id.pageindex_sub2) };
  1361. for (int i = 0; i < nChildCnt; i++) {
  1362. if (i == nViewFlipperIndex) {
  1363. if (i == 0) IMG_INDICATOR[i].setSelected(true);
  1364. else IMG_INDICATOR[i].setSelected(true);
  1365. }
  1366. else {
  1367. if (i == 0) IMG_INDICATOR[i].setSelected(false);
  1368. else IMG_INDICATOR[i].setSelected(false);
  1369. }
  1370. }
  1371. }
  1372. // else if (eGUIType == GUI_TYPE.METRO) {
  1373. // ImageView[] IMG_INDICATOR = { (ImageView) findViewById(R.id.pageindex_sub1), (ImageView) findViewById(R.id.pageindex_sub2) };
  1374. // if (nViewFlipperIndex == 0) {
  1375. // for (int i = 0; i < nChildCnt; i++) {
  1376. // if (i != 0) IMG_INDICATOR[i - 1].setVisibility(View.INVISIBLE);
  1377. // }
  1378. // }
  1379. // else {
  1380. // for (int i = 0; i < nChildCnt; i++) {
  1381. // if (i != 0) {
  1382. // IMG_INDICATOR[i - 1].setVisibility(View.VISIBLE);
  1383. // if (i == nViewFlipperIndex) IMG_INDICATOR[i - 1].setSelected(true);
  1384. // else IMG_INDICATOR[i - 1].setSelected(false);
  1385. // }
  1386. // }
  1387. // }
  1388. // }
  1389. } catch (RuntimeException re) {
  1390. LogUtil.errorLogInfo("", TAG, re);
  1391. }
  1392. catch (Exception e) {
  1393. Log.e(TAG, "[Exception] setPageIndicator()");
  1394. LogUtil.errorLogInfo("", TAG, e);
  1395. }
  1396. }
  1397. /**
  1398. * (임시코드) WallPadAPI 초기생성시 Connect 에 시간이 걸리며, <br>
  1399. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  1400. * 본 딜레이 코드를 임시로 적용한다.
  1401. */
  1402. @SuppressLint("HandlerLeak")
  1403. protected Handler mWallPadApiCheckHandler = new Handler()
  1404. {
  1405. @SuppressLint("HandlerLeak")
  1406. @Override
  1407. public void handleMessage(Message msg)
  1408. {
  1409. if (msg.what == 0) {
  1410. if (mWallPadAPI != null) {
  1411. if (mWallPadAPI.Check_Connect()) mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10);
  1412. else mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  1413. }
  1414. }
  1415. else if (msg.what == 1) {
  1416. // 현산향
  1417. AutoIGALStatusReleaseSinario();
  1418. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1419. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1420. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1421. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  1422. mSdbAPI = mWallPadAPI.Get_SdbController();
  1423. if (mSdb_LivingRoomLightAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_Sdb_LivingRoomLightAPI Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1424. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_Sdb_LivingRoomLightAPI Success !");
  1425. if (mSdbAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_SdbController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1426. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_SdbController Success !");
  1427. // ChangeLEDButtonLevel();
  1428. }
  1429. else if (Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1430. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410) {
  1431. mIntLightAPI = mWallPadAPI.Get_IntLightController();
  1432. if (mIntLightAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_IntLightController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1433. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_IntLightController Success !");
  1434. // ChangeLEDButtonLevel();
  1435. }
  1436. else {
  1437. // 대외향
  1438. WallpadDeviceSet devDB = new WallpadDeviceSet( getApplicationContext() );
  1439. int[] retArray = devDB.Get_Light_info();
  1440. devDB.closeDB();
  1441. if (retArray!= null && retArray[0] == 1) {
  1442. if (retArray[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  1443. // 거실 스위치
  1444. m_LightCtrl = mWallPadAPI.Get_LightController();
  1445. if (m_LightCtrl == null) Log.d(TAG , "Get_LightController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1446. else Log.d(TAG , "Get_LightController Success !");
  1447. }
  1448. else {
  1449. // 멀티스위치
  1450. m_MultiSwitch = mWallPadAPI.Get_MultiSwitchController();
  1451. if (m_MultiSwitch == null) Log.d(TAG , "Get_MultiSwitchController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1452. else Log.d(TAG , "Get_MultiSwitchController Success !");
  1453. }
  1454. }
  1455. }
  1456. }
  1457. else if (msg.what == 10) {
  1458. // 부트업 실패시 5초 간격으로 보내도록 수정
  1459. Log.d(TAG , "NOTIFY_SENDBOOTUP_FAIL Retry!!!!");
  1460. Intent Newintent = new Intent();
  1461. Newintent.setAction(define.NOTIFY_ACNAME);
  1462. Newintent.putExtra(define.NOTIBR_KIND,Common.DEVICE_BOOTUP_RETRY);
  1463. sendBroadcast(Newintent);
  1464. }
  1465. }
  1466. };
  1467. private void ChangeLEDButtonLevel()
  1468. {
  1469. if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL )
  1470. {
  1471. try
  1472. {
  1473. String filename = "/sdcard/led_button_reset.txt";
  1474. File savefile = new File(filename);
  1475. Log.d(TAG, "8888888888888888888888 savefile : " + savefile.exists());
  1476. if(savefile.exists())
  1477. {
  1478. Log.d(TAG, "try file is exist... ");
  1479. if( mIntLightAPI != null)
  1480. {
  1481. int ret = mIntLightAPI.LedBrightCtrl((byte)0x01);
  1482. if( ret >= 0 )
  1483. {
  1484. WallpadStatusData wd = new WallpadStatusData( getApplicationContext());
  1485. wd.SetLEDButtonBrightnessLevel(1); // DB 저장이 실패하게 되면 초기값을 2로 셋팅하기 때문에 다시 한번 셋팅해준다.
  1486. int level = wd.GetLEDButtonBrightnessLevel();
  1487. wd.closeDB();
  1488. Log.d(TAG, "88888888 button brightness Level 1 == " + level);
  1489. WallpadStatusData wd1 = new WallpadStatusData( getApplicationContext());
  1490. wd1.SetLEDButtonBrightnessLevel(1);
  1491. level = wd1.GetLEDButtonBrightnessLevel();
  1492. wd1.closeDB();
  1493. FileDelete(savefile);//.delete();
  1494. // 생산 기술팀 요청사항
  1495. // LED 버튼 보디 교체로 레벨이 너무 밝아 디폴트값 변경을 요청함 ,,
  1496. Log.d(TAG, "8888888888888888888888 button brightness Level 1 == " + level);
  1497. }
  1498. }
  1499. }
  1500. }
  1501. catch (RuntimeException re) {
  1502. LogUtil.errorLogInfo("", TAG, re);
  1503. }
  1504. catch (Exception e )
  1505. {
  1506. LogUtil.errorLogInfo("", TAG, e);
  1507. }
  1508. }
  1509. }
  1510. private void AutoIGALStatusReleaseSinario()
  1511. {
  1512. // 에너지미터 설정에 따라 조명 상태 변경시 일괄소등 해제 처리 시나리오를 설정하도록 한다.
  1513. // 일괄소등 해제 시나리오 적용시...
  1514. try
  1515. {
  1516. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  1517. int setIparkEnergy = devset.Get_Energy_Devices_Info();
  1518. Log.d(TAG , "Get_IPark_Energy_Info bSet: setIparkEnergy : " + setIparkEnergy);
  1519. if( setIparkEnergy == 1 )
  1520. {
  1521. mWallPadAPI.SetAutoIGALStatusClear(true);
  1522. Log.d(TAG , "AutoIGALStatusReleaseSinario bSet: true");
  1523. }
  1524. devset.closeDB();
  1525. }
  1526. catch (RuntimeException re) {
  1527. LogUtil.errorLogInfo("", TAG, re);
  1528. }
  1529. catch (Exception e )
  1530. {
  1531. Log.e(TAG, e.toString());
  1532. LogUtil.errorLogInfo("", TAG, e);
  1533. }
  1534. }
  1535. /**
  1536. * onDestroy
  1537. */
  1538. @Override
  1539. protected void onDestroy() {
  1540. // 이걸 왜 넣었지?
  1541. setChangeScreen(mCurrentScreenId, true, false);
  1542. unregisterBroadcastReceiver();
  1543. super.setFinishTimerDestroy();
  1544. Log.i(TAG, "*************************************************************");
  1545. Log.i(TAG, "****************** [END - MainActivity] *******************");
  1546. Log.i(TAG, "*************************************************************");
  1547. super.onDestroy();
  1548. }
  1549. /**
  1550. * onResume
  1551. */
  1552. @Override
  1553. protected void onResume() {
  1554. super.onResume();
  1555. m_thisAcitivityRusume = true;
  1556. if (mWallPadAPI != null) {
  1557. if (mWallPadAPI.Check_Connect()) Log.w(TAG, "[onResume] mWallPadAPI.Check_Connect() = true!!!");
  1558. else Log.w(TAG, "[onResume] mWallPadAPI.Check_Connect() = false!!!");
  1559. mWallPadAPI.Resume();
  1560. }
  1561. //CallDataChecker();
  1562. try {
  1563. if (m_ModelHouseSleepModeRelease) {
  1564. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  1565. // pm.userActivity(1, true);
  1566. // pm.userActivity(2, true);1qn
  1567. // LCD 항상 ON
  1568. ((Activity)this.getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  1569. }
  1570. } catch (RuntimeException re) {
  1571. LogUtil.errorLogInfo("", TAG, re);
  1572. }
  1573. catch (Exception e) {
  1574. LogUtil.errorLogInfo("", TAG, e);
  1575. }
  1576. if (MAINStatus == MAIN_WAIT_SETIP) {
  1577. try {
  1578. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  1579. AddressSet addc = SetData.getAddressMGR();
  1580. SetData.closeDB();
  1581. Log.i("MAINSCREEN", "onResume MAIN_WAIT_SETIP "+addc.IPAddress);
  1582. if (addc.IPAddress!=null && !addc.IPAddress.equals("NONE")) {
  1583. Log.i("MAINSCREEN", "onResume Start Server");
  1584. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1585. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1586. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1587. Intent intent = new Intent(getApplicationContext(), iMapServer.class);
  1588. Log.w("MAINSCREEN", "Call Start iMapServer");
  1589. startService(intent);
  1590. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1591. String[] sitecode = devSet.GetSettingData("site_code");
  1592. try {
  1593. if (sitecode != null) {
  1594. Intent sipServiceLauncher = new Intent ("cm.sip.hns.SIPStun.StartService");
  1595. getApplicationContext().startService(sipServiceLauncher);
  1596. }
  1597. } catch (RuntimeException re) {
  1598. LogUtil.errorLogInfo("", TAG, re);
  1599. }
  1600. catch (Exception e) {
  1601. Common.DebugLog("SIP StartServerice Error!!!!!!!!!!!!!!");
  1602. }
  1603. devSet.closeDB();
  1604. MAINStatus = MAIN_NORMAL;
  1605. }
  1606. } catch (RuntimeException re) {
  1607. LogUtil.errorLogInfo("", TAG, re);
  1608. }
  1609. catch (Exception e ) {
  1610. LogUtil.errorLogInfo("", TAG, e);
  1611. }
  1612. }
  1613. //CheckMainScreen();
  1614. //refreshUserCtr();
  1615. //reloadData();
  1616. try {
  1617. WallPadInterface wpdifc = new WallPadInterface();
  1618. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1619. amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  1620. wpdifc.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1621. Intent intent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1622. getContext().sendBroadcast(intent);
  1623. mGetCallHistoryCheckHandler.sendEmptyMessageDelayed(0, 1000);
  1624. } catch (RuntimeException re) {
  1625. LogUtil.errorLogInfo("", TAG, re);
  1626. }
  1627. catch (Exception e) {
  1628. LogUtil.errorLogInfo("", TAG, e);
  1629. }
  1630. bScreenCheck = true;
  1631. DebugLogOutput("@@@@@@@@ [onResume] @@@@@@@@");
  1632. }
  1633. protected String getForegroundAPK() {
  1634. try {
  1635. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  1636. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  1637. ComponentName topActivity=taskInfo.get(0).topActivity;
  1638. String str=topActivity.getPackageName();
  1639. return str;
  1640. } catch (RuntimeException re) {
  1641. LogUtil.errorLogInfo("", TAG, re);
  1642. return " ";
  1643. }
  1644. catch (Exception e) {
  1645. LogUtil.errorLogInfo("", TAG, e);
  1646. return " ";
  1647. }
  1648. }
  1649. /**
  1650. * onPause
  1651. */
  1652. @Override
  1653. protected void onPause() {
  1654. m_thisAcitivityRusume = false;
  1655. if(mWallPadAPI != null) mWallPadAPI.Pause();
  1656. bScreenCheck = false;
  1657. DebugLogOutput("@@@@@@@@ [onPause] @@@@@@@@");
  1658. super.onPause();
  1659. }
  1660. /* ================================================================================================
  1661. * [BroadcastReceiver] Section
  1662. ================================================================================================ */
  1663. /**
  1664. * BroadcastReceiver.onReceive for [WpadActivity]
  1665. */
  1666. @Override
  1667. protected void onBrReceive(Intent intent) {
  1668. try {
  1669. String strAction = intent.getAction();
  1670. Log.i(TAG, "[onBrReceive] Action [" + strAction + "]");
  1671. if (strAction.equals(BR_CTRL_LIGHT_LIVINGROOM)) {
  1672. Log.d(TAG, "[onBrReceive] (BR) BR_CTRL_LIGHT_LIVINGROOM");
  1673. mLightInfo.nLightPresetNo = 0;
  1674. }
  1675. } catch (RuntimeException re) {
  1676. LogUtil.errorLogInfo("", TAG, re);
  1677. }
  1678. catch (Exception e) {
  1679. Log.e(TAG, "[Exception] onBrReceive(Intent intent)");
  1680. LogUtil.errorLogInfo("", TAG, e);
  1681. }
  1682. super.onBrReceive(intent);
  1683. }
  1684. /* ================================================================================================
  1685. * [Touch & Key Event] Section
  1686. ================================================================================================ */
  1687. /**
  1688. * TouchEvent for [WpadActivity]
  1689. */
  1690. @Override
  1691. protected void onTouchEvent(View v, MotionEvent event) {
  1692. super.onTouchEvent(v, event);
  1693. int TargetId = v.getId();
  1694. int MoveEvent = event.getAction();
  1695. Log.i(TAG, "[onTouchEvent] TargetId [" + TargetId + "], MoveEvent [" + MoveEvent + "]");
  1696. if (MoveEvent == MotionEvent.ACTION_UP) {
  1697. }
  1698. }
  1699. /**
  1700. * H/W Key Event
  1701. */
  1702. @Override
  1703. public boolean onKeyDown(int keyCode, KeyEvent event) {
  1704. Log.i(TAG, "[onKeyDown] keyCode : " + keyCode + ", Action : " + event.getAction());
  1705. // sendKeyEventBR(keyCode);
  1706. return super.onKeyDown(keyCode, event);
  1707. }
  1708. @Override
  1709. public boolean onKeyUp(int keyCode, KeyEvent event) {
  1710. // TODO Auto-generated method stub
  1711. Log.i(TAG, "[onKeyUp] keyCode : " + keyCode + ", Action : " + event.getAction());
  1712. return super.onKeyUp(keyCode, event);
  1713. }
  1714. @Override
  1715. public boolean onKeyLongPress(int keyCode, KeyEvent event) {
  1716. // TODO Auto-generated method stub
  1717. DebugLogOutput("onKeyLongPress - " + " / keyCode : " + keyCode + " / Action : " + event.getAction());
  1718. return super.onKeyLongPress(keyCode, event);
  1719. }
  1720. /* ================================================================================================
  1721. * [Popup Activity] Section
  1722. ================================================================================================ */
  1723. /**
  1724. * Popup Activity 를 시작시킨다.
  1725. *
  1726. * @param ScreenId - 팝업시작시 Screen ID_OLD
  1727. * @return (boolean) true : 성공, false : 실패
  1728. */
  1729. public boolean StartPopup(int ScreenId){
  1730. try {
  1731. if (ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED <= ScreenId && ScreenId <= ID.POPUPS.POPUP_POSTRECEIVED) { // 알림 팝업에 한하여
  1732. if (Common.bWallPadCallLive) {
  1733. Log.w(TAG, "[StartPopup] StartPopup denied!!! === WallPadCall is running!! ScreenId [" + ScreenId + "]");
  1734. return false; // 통화 앱이 실행되어 있는 경우, 팝업 출력 안함
  1735. }
  1736. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  1737. int AlarmStatus = WsDB.GetAlarmStatus();
  1738. WsDB.closeDB();
  1739. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1740. Log.w(TAG, "[StartPopup] StartPopup denied!!! === AlarmStatus [" + AlarmStatus + "]");
  1741. return false; // 방범모드 실행중인 경우, 팝업 출력 안함
  1742. }
  1743. }
  1744. if (getPopupActivityRun()) {
  1745. if (ScreenId == ID.POPUPS.POPUP_NOTICESTRANGER) return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId);
  1746. else return false;
  1747. }
  1748. else {
  1749. setPopupActivityRun(true);
  1750. Intent intent = new Intent(mContext, PopupActivity.class);
  1751. intent.putExtra("ScreenId", ScreenId);
  1752. overridePendingTransition(0, 0);
  1753. startActivityForResult(intent, 0);
  1754. return true;
  1755. }
  1756. } catch (RuntimeException re) {
  1757. LogUtil.errorLogInfo("", TAG, re);
  1758. return false;
  1759. }
  1760. catch (Exception e) {
  1761. Log.e(TAG, "[Exception] StartPopup(int ScreenId)");
  1762. LogUtil.errorLogInfo("", TAG, e);
  1763. return false;
  1764. }
  1765. }
  1766. /**
  1767. * Popup Activity 를 시작시킨다. (시작시 Intent Type 데이터를 전달한다)
  1768. *
  1769. * @param ScreenId - 팝업시작시 Screen ID_OLD
  1770. * @param data - 전달할 데이터
  1771. * @return (boolean) true : 성공, false : 실패
  1772. */
  1773. public boolean StartPopup(int ScreenId, Intent data) {
  1774. try {
  1775. if (ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED <= ScreenId && ScreenId <= ID.POPUPS.POPUP_POSTRECEIVED) { // 알림 팝업에 한하여
  1776. if (Common.bWallPadCallLive) {
  1777. Log.w(TAG, "[StartPopup] StartPopup denied!!! === WallPadCall is running!! ScreenId [" + ScreenId + "]");
  1778. return false; // 통화 앱이 실행되어 있는 경우, 팝업 출력 안함
  1779. }
  1780. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  1781. int AlarmStatus = WsDB.GetAlarmStatus();
  1782. WsDB.closeDB();
  1783. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1784. Log.w(TAG, "[StartPopup] StartPopup denied!!! === AlarmStatus [" + AlarmStatus + "]");
  1785. return false; // 방범모드 실행중인 경우, 팝업 출력 안함
  1786. }
  1787. }
  1788. if (getPopupActivityRun()) {
  1789. if (ScreenId == ID.POPUPS.POPUP_NOTICESTRANGER) return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId);
  1790. else return false;
  1791. }
  1792. else {
  1793. setPopupActivityRun(true);
  1794. Intent intent = new Intent(mContext, PopupActivity.class);
  1795. intent.putExtra("ScreenId", ScreenId);
  1796. intent.putExtra("PopupScreenDataIntent", data);
  1797. overridePendingTransition(0, 0);
  1798. startActivityForResult(intent, 0);
  1799. return true;
  1800. }
  1801. } catch (RuntimeException re) {
  1802. LogUtil.errorLogInfo("", TAG, re);
  1803. return false;
  1804. }
  1805. catch (Exception e) {
  1806. Log.e(TAG, "[Exception] StartPopup(int ScreenId, Intent data)");
  1807. LogUtil.errorLogInfo("", TAG, e);
  1808. return false;
  1809. }
  1810. }
  1811. /**
  1812. * Activity Result Reception
  1813. */
  1814. @Override
  1815. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  1816. super.onActivityResult(requestCode, resultCode, data);
  1817. try {
  1818. Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@");
  1819. // int screenId = data.getIntExtra("SCREENS", -1);
  1820. // Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@ screenId : " + screenId );
  1821. //if( mViewFlipper)
  1822. if (requestCode == UNINSTALL_REQUEST_CODE) {
  1823. if (resultCode == RESULT_OK) {
  1824. Log.w(TAG, "[onActivityResult] user accepted the uninstall");
  1825. } else if (resultCode == RESULT_CANCELED) {
  1826. Log.w(TAG, "[onActivityResult] user canceled the uninstall");
  1827. } else if (resultCode == RESULT_FIRST_USER) {
  1828. Log.w(TAG, "[onActivityResult] failed to uninstall");
  1829. }
  1830. }
  1831. else {
  1832. if (data != null) {
  1833. int nSenderScreenID = data.getIntExtra(Common.BR_SENDER_SCREEN, -1);
  1834. int nReceiveScreenID = data.getIntExtra(Common.BR_RECEIVE_SCREEN, -1);
  1835. int nCallSubMenuScreen = data.getIntExtra(Common.CALL_SUBMAIN_SCREEN, -1);
  1836. if (nCallSubMenuScreen > 0) {
  1837. CallSubMenuScreen(nCallSubMenuScreen);
  1838. }
  1839. else {
  1840. Log.d(TAG, "[onActivityResult] nSenderScreenID : " + nSenderScreenID + " , nReceiveScreenID : " + nReceiveScreenID );
  1841. if (nSenderScreenID == ID.POPUPS.POPUP_DELETESHORTCUT) {
  1842. if (nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  1843. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  1844. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  1845. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  1846. MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  1847. return;
  1848. }
  1849. else if (nReceiveScreenID == ID.SCREENS.SCREEN_HYOSUNGUI_MAIN_HN) {
  1850. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  1851. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  1852. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  1853. Hyosung_HN_MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  1854. return;
  1855. }
  1856. else if (nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_MAIN) {
  1857. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  1858. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  1859. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  1860. MetroUI_MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  1861. return;
  1862. }
  1863. }
  1864. else if (nSenderScreenID == ID.POPUPS.POPUP_ADDSHORTCUT) {
  1865. if (nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  1866. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  1867. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  1868. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  1869. MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  1870. return;
  1871. }
  1872. else if (nReceiveScreenID == ID.SCREENS.SCREEN_HYOSUNGUI_MAIN_HN) {
  1873. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  1874. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  1875. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  1876. Hyosung_HN_MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  1877. return;
  1878. }
  1879. else if (nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_MAIN) {
  1880. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  1881. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  1882. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  1883. MetroUI_MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  1884. return;
  1885. }
  1886. }
  1887. else if (nSenderScreenID == ID.POPUPS.POPUP_CONFIGUREPRESET && nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  1888. String strLivinglightPresetInfo = data.getStringExtra(Common.BR_LIVINGLIGHT_PRESET_INFO);
  1889. Log.d(TAG, "[onActivityResult] strLivinglightPresetInfo [" + strLivinglightPresetInfo + "]");
  1890. savePresetValue(strLivinglightPresetInfo);
  1891. return;
  1892. }
  1893. else if ((ID.POPUPS.POPUP_GROUP_CTRL <= nSenderScreenID && nSenderScreenID <= ID.POPUPS.POPUP_GROUP_SETTING) && nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_GROUP) {
  1894. boolean bRun = data.getBooleanExtra(Common.BR_RUN_WIDGET, false);
  1895. int nIconID = data.getIntExtra(Common.BR_RUN_WIDGET_ID, 0);
  1896. Log.d(TAG, "[onPopupResult] bRun [" + bRun + "], nIconID [" + nIconID + "]") ;
  1897. if (bRun) runIcon(nIconID);
  1898. }
  1899. }
  1900. }
  1901. if (resultCode == RESULT_OK) {
  1902. // // 팝업을 종료하고 다른 팝업을 띄울경우가 있다.
  1903. // int screenIdCode = data.getExtras().getInt("CHANGE_POPUP" );
  1904. // int popupKind = data.getExtras().getInt("POPUP_KIND");
  1905. //
  1906. // Log.d(TAG, "@@@ CHANGE_POPUP : " + screenIdCode + " , popupKind : " +popupKind);
  1907. // if( screenIdCode > 0 )
  1908. // {
  1909. // setPopupActivityRun(false);
  1910. // Intent intent = new Intent();
  1911. // intent.putExtra("POPUP_KIND", popupKind );
  1912. // StartPopup(screenIdCode , intent);
  1913. // }
  1914. }
  1915. }
  1916. }
  1917. catch (RuntimeException re) {
  1918. LogUtil.errorLogInfo("", TAG, re);
  1919. }
  1920. catch (Exception e )
  1921. {
  1922. Log.e(TAG, e.toString());
  1923. LogUtil.errorLogInfo("", TAG, e);
  1924. }
  1925. }
  1926. /* ================================================================================================
  1927. * [Info Activity] Section
  1928. ================================================================================================ */
  1929. public static ManualActivity mManualActivity;
  1930. /**
  1931. * Info Activity를 시작시킨다.
  1932. *
  1933. * @param screenId - 매뉴얼 시작시 Screen ID_OLD
  1934. * @return (boolean) true : 성공, false : 실패
  1935. */
  1936. public boolean startManualPopup(int screenId) {
  1937. Log.d(TAG, "[startManualPopup] ScreenId [" + screenId +"], mCurrentInfoScreenId [" + mCurrentInfoScreenId + "]" );
  1938. if (getInfoActivityRun() == true) {
  1939. mCurrentInfoScreenId = screenId;
  1940. return ((WpadActivity)(ManualActivity.getContext())).ChangeScreen(screenId);
  1941. } else {
  1942. if (mCurrentInfoScreenId == screenId) return false;
  1943. mCurrentInfoScreenId = screenId;
  1944. setInfoActivityRun(true);
  1945. Intent intent = new Intent(mContext, ManualActivity.class);
  1946. intent.putExtra("ScreenId", screenId);
  1947. overridePendingTransition(0, 0);
  1948. startActivityForResult(intent, 0);
  1949. return true;
  1950. }
  1951. }
  1952. public static void resetCurrentInfoScreenID() {
  1953. try {
  1954. mCurrentInfoScreenId = -1;
  1955. } catch (RuntimeException re) {
  1956. LogUtil.errorLogInfo("", TAG, re);
  1957. }
  1958. catch (Exception e) {
  1959. Log.e(TAG, "[Exception] resetCurrentInfoScreenID()");
  1960. LogUtil.errorLogInfo("", TAG, e);
  1961. }
  1962. }
  1963. /**
  1964. * 매뉴얼 버튼 사용 유무
  1965. *
  1966. * @return boolean 타입 - true:사용, false:미사용
  1967. */
  1968. public boolean GetManualUse() {
  1969. WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
  1970. String[] DBinfo = devSet.GetSettingData("매뉴얼");
  1971. devSet.closeDB();
  1972. if (DBinfo != null) {
  1973. if (DBinfo[1].indexOf("사용함") > 0) {
  1974. Log.d(TAG, "[GetManualUse] Use Manual");
  1975. return true;
  1976. }
  1977. else {
  1978. // 미사용
  1979. Log.d(TAG, "[GetManualUse] Not Use Manual");
  1980. return false;
  1981. }
  1982. }
  1983. else {
  1984. //미사용
  1985. return false;
  1986. }
  1987. }
  1988. /* ================================================================================================
  1989. * [Screen] Section
  1990. ================================================================================================ */
  1991. /**
  1992. * Screen 에서 Screen 변경을 요청할 경우 호출된다.<br>
  1993. * Override 사용하여 Screen 변경을 처리한다.<br>
  1994. *
  1995. * @param nScreenId - 변경할 Screen ID_OLD
  1996. * @return (boolean) true : 성공, false : 실패
  1997. */
  1998. @Override
  1999. protected boolean onChangeScreen(int nScreenId) {
  2000. super.onChangeScreen(nScreenId);
  2001. return setChangeScreen(nScreenId, false, false);
  2002. }
  2003. /**
  2004. * Screen 등록자<br>
  2005. * MainScreenLayout 에 현재 Screen 을 삭제하고, 새로운 Screen 을 등록시킨다.
  2006. *
  2007. * @param nScreenId - 변경할 Screen ID_OLD
  2008. * @param OnlyRemove - 현재 Screen 을 삭제만 할 경우 (onDestroy 에서 사용)
  2009. * @return (boolean) true : 성공, false : 실패
  2010. */
  2011. private boolean setChangeScreen(int nScreenId, boolean OnlyRemove, boolean setAnimation) {
  2012. DebugLogOutput("setChangeScreen - " + "CurrentSelectDeviceId : " + mCurrentScreenId + " / NextLayoutId : " + nScreenId + " / OnlyRemove : " + OnlyRemove);
  2013. // 1. 현재 Layout 삭제
  2014. boolean remove = false;
  2015. if (mCurrentScreenId > 0) {
  2016. remove = true;
  2017. MainScreenLayout.removeAllViews();
  2018. super.setCurrentScreen(null);
  2019. }
  2020. if (OnlyRemove) return true;
  2021. mCurrentScreenId = nScreenId;
  2022. // 2. 새로운 Layout 표시
  2023. try {
  2024. switch (nScreenId) {
  2025. case ID.SCREENS.SCREEN_MAIN:
  2026. MainScreen = new MAIN(getContext(), MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  2027. super.setCurrentScreen(MainScreen);
  2028. break;
  2029. case ID.SCREENS.SCREEN_SUB_01:
  2030. SUB_01Screen = new SUB_01(getContext(), MainScreenLayout, mWallPadAPI);
  2031. super.setCurrentScreen(SUB_01Screen);
  2032. break;
  2033. case ID.SCREENS.SCREEN_SUB_02:
  2034. SUB_02Screen = new SUB_02(getContext(), MainScreenLayout, mWallPadAPI);
  2035. super.setCurrentScreen(SUB_02Screen);
  2036. break;
  2037. case ID.SCREENS.SCREEN_METROUI_MAIN:
  2038. MetroUI_MainScreen = new METROUI_MAIN(getContext(), MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  2039. super.setCurrentScreen(MetroUI_MainScreen);
  2040. break;
  2041. case ID.SCREENS.SCREEN_METROUI_SUB_01:
  2042. MetroUI_SUB_01Screen = new METROUI_SUB_01(getContext(), MainScreenLayout, mWallPadAPI);
  2043. super.setCurrentScreen(MetroUI_SUB_01Screen);
  2044. break;
  2045. case ID.SCREENS.SCREEN_METROUI_SUB_02:
  2046. MetroUI_SUB_02Screen = new METROUI_SUB_02(getContext(), MainScreenLayout, mWallPadAPI);
  2047. super.setCurrentScreen(MetroUI_SUB_02Screen);
  2048. break;
  2049. default:
  2050. Log.e(TAG, "[Error] setChangeScreen - nScreenId Not found!!! (" + mCurrentScreenId + ")");
  2051. mCurrentScreenId = -1;
  2052. return false;
  2053. }
  2054. } catch (RuntimeException re) {
  2055. LogUtil.errorLogInfo("", TAG, re);
  2056. return false;
  2057. }
  2058. catch (Exception e) {
  2059. Log.e(TAG, "[ExceptionError] - setChangeScreen->Screen Create : " + e);
  2060. return false;
  2061. }
  2062. return true;
  2063. }
  2064. /////////////////////////////////////////////////////////////////////////////////
  2065. private void runDeviceService() {
  2066. try {
  2067. Log.i(TAG, "[runDeviceService] ===== START =====");
  2068. /* 2018.01.30 속초 아이파크 RF현관카메라 연동으로 인하여 수정
  2069. // 우선 제어기기 연동 기능이 없음
  2070. if( Version.getModelType() == Version.MODEL_TYPE.IHN_750 )
  2071. return;
  2072. */
  2073. if (!getIsSubWallpad()) {
  2074. ActivityManager mActivityManager = (ActivityManager)getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  2075. List<ActivityManager.RunningAppProcessInfo> RunningAppList = mActivityManager.getRunningAppProcesses();
  2076. Common.DebugLog("[runDeviceService] -----> RunningAppProcessInfo : " + RunningAppList.size() + " +++ Version : " + this.getAppVersion());
  2077. for (int i = 0; i < RunningAppList.size(); i++) {
  2078. ActivityManager.RunningAppProcessInfo RunningAppListInfo = RunningAppList.get(i);
  2079. Common.DebugLog("[runDeviceService] -----> RunningAppListInfo.processName : " + RunningAppListInfo.processName);
  2080. if (RunningAppListInfo.processName.equals("com.artncore.deviceservice")) {
  2081. Log.w(TAG, "[runDeviceService] DevService is already running");
  2082. return;
  2083. }
  2084. }
  2085. Log.i(TAG, "[runDeviceService] Start DevService!!");
  2086. Intent mIntent = new Intent("wallpaddevservice.ServiceMain");
  2087. startService(mIntent);
  2088. }
  2089. else {
  2090. Log.w(TAG, "[runDeviceService] This wallpad is sub-wallpad. not need DevService!!!");
  2091. }
  2092. } catch (RuntimeException re) {
  2093. LogUtil.errorLogInfo("", TAG, re);
  2094. }
  2095. catch (Exception e) {
  2096. Log.e(TAG, "[Exception] runDeviceService()");
  2097. LogUtil.errorLogInfo("", TAG, e);
  2098. }
  2099. }
  2100. // 통신으로 들어오는 비상버튼 스킵하기 위한 딜레이 체크 변수
  2101. private long EmerCommDelayTime = 0;
  2102. public static String WALLPAD_ALERT = "WALLPAD_ALERT";
  2103. BroadcastReceiver mWallPadAlertBR = new BroadcastReceiver() {
  2104. @Override
  2105. public void onReceive(Context context, Intent intent) {
  2106. Log.i(TAG, "[mWallPadAlertBR] Receive alert BR");
  2107. String strAction = intent.getAction();
  2108. Log.d(TAG, "[mWallPadAlertBR] strAction [" + strAction + "]");
  2109. if (strAction.equalsIgnoreCase(WALLPAD_ALERT)) {
  2110. int kind = intent.getIntExtra("KIND",0);
  2111. Log.i(TAG, "[mWallPadAlertBR] " + String.format("Receive alert BR [%d][tag:%s]", kind,String.valueOf(Alert_App_On)));
  2112. // 제주 아이파크 스위트현장의 비상발생 증상을 디버깅하기 위한 코드 (JEFF, 2019.09.26)
  2113. // if (kind == 4) {
  2114. // try {
  2115. // byte hFrom = intent.getByteExtra("FROM", (byte) 0xFF);
  2116. // if (hFrom != (byte) 0xFF) {
  2117. // if (hFrom % 10 == 3) {
  2118. // Log.w(TAG, "[mWallPadAlertBR] Emergency from BathPhone!!!");
  2119. // int nDstPort = 10000;
  2120. // sendAlarmOperationToMainServer("10.0.1.1", nDstPort, EMER_STATE.FIRE, EMER_DETAIL_INFO.EMERGENCY_COMM);
  2121. // return;
  2122. // }
  2123. // }
  2124. // } catch (RuntimeException re) {
  2125. // LogUtil.errorLogInfo("", TAG, re);
  2126. // }
  2127. // catch (Exception e) {
  2128. // Log.e(TAG, "[Exception] mWallPadAlertBR - 1");
  2129. // e.printStackTrace();
  2130. // }
  2131. // }
  2132. if (kind == 30) Alert_App_On = true;
  2133. else if (kind == 40) Alert_App_On = false;
  2134. else {
  2135. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2136. int alarmState = wdb.GetAlarmStatus();
  2137. wdb.closeDB();
  2138. if (alarmState == WallpadStatusData.ALARM_ARISE || alarmState == WallpadStatusData.ALARM_STOP) {
  2139. // 알람화면이 현재 실행중이면 스킵
  2140. Log.d(TAG, "Skip BR ==> Current Alarm state : "+ alarmState );
  2141. return;
  2142. }
  2143. if (kind == 4 && ( Math.abs(System.currentTimeMillis()-EmerCommDelayTime) < 1000)) {
  2144. // 통신 비상알람의 경우 중복으로 날라오는 경우가 있어서 필터링
  2145. Log.d(TAG, "Skip BR ==> deleayTime :" + String.valueOf( Math.abs(System.currentTimeMillis()-EmerCommDelayTime)));
  2146. return;
  2147. }
  2148. EmerCommDelayTime = System.currentTimeMillis();
  2149. SendAppFinishReqBR();
  2150. Log.i(TAG, "[mWallPadAlertBR] before Call Alert App");
  2151. int base = 7000;
  2152. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41, base+51};
  2153. int Menu_Start_Id = base+21;
  2154. int Menu_Start_Option = 1;
  2155. String Cause = "none";
  2156. if (kind == 1) Cause = "gas";
  2157. else if (kind == 2) Cause = "fire";
  2158. else if (kind == 4) Cause = "emergency_Comm";
  2159. else if (kind == 5) {
  2160. Cause = "heating_Leak";
  2161. Menu_Start_Id = base + 51;
  2162. }
  2163. else {
  2164. Cause = "unknown(" + kind + ")";
  2165. }
  2166. Intent newintent = new Intent(Intent.ACTION_MAIN);
  2167. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2168. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  2169. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2170. newintent.putExtra("MENU_DETAIL_INFO", Cause);
  2171. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2172. newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  2173. startActivity(newintent);
  2174. }
  2175. }
  2176. }
  2177. };
  2178. private void sendAlarmOperationToMainServer(String DstIP, int DstPort, EMER_STATE alarm_mode, EMER_DETAIL_INFO cause) {
  2179. Log.d(TAG, "[sendAlarmOperationToMainServer] DstIP [" + DstIP + "], DstPort [" + DstPort + "], alarm_mode [" + EMER_STATE.GetXMLData(alarm_mode) + "], cause [" + EMER_DETAIL_INFO.GetXMLData(cause) + "]");
  2180. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  2181. AddressSet addc = wdb.getAddressMGR(); //DB에서 동호 정보 받아옴
  2182. wdb.closeDB();
  2183. final iMAPAlarmOperation imapAlarmOperation = new iMAPAlarmOperation(getContext() , addc);
  2184. imapAlarmOperation.SetServerIPcfg(DstIP, DstPort);
  2185. imapAlarmOperation.DoWork(alarm_mode, cause);
  2186. imapAlarmOperation.SetRetCtr(new RetProci(){
  2187. @Override
  2188. public void ProcSuccess() {
  2189. // TODO Auto-generated method stub
  2190. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcSuccess()");
  2191. String result = imapAlarmOperation.GetAttributeVal(0, "result");
  2192. Log.i(TAG, "[sendAlarmOperationToMainServer] result [" + result +"]");
  2193. if (result.equalsIgnoreCase("ok")) {
  2194. Log.i(TAG, "[sendAlarmOperationToMainServer] result [" + result +"]");
  2195. }
  2196. }
  2197. @Override
  2198. public void ProcError() {
  2199. // TODO Auto-generated method stub
  2200. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcError() -> " + APIErrorCode.GetLogPrefix());
  2201. }
  2202. @Override
  2203. public void ProcDoing() {
  2204. // TODO Auto-generated method stub
  2205. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcDoing()");
  2206. }
  2207. });
  2208. }
  2209. private String getMainVersion() {
  2210. return this.getAppVersion();
  2211. }
  2212. private int m_LiveImapServer = 0;
  2213. private int m_LiveMainActivity = 0;
  2214. private boolean m_IPActivity = false;
  2215. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  2216. @Override
  2217. public void onReceive(Context context, Intent intent) {
  2218. String strAction = intent.getAction();
  2219. int item = 0;
  2220. Log.i(TAG, "[mWallPadNotifyBR] strAction [" + strAction + "]");
  2221. if (strAction.equals(define.NOTIFY_ACNAME)) {
  2222. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND,0);
  2223. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACNAME -> kind : " + kind);
  2224. switch (kind) {
  2225. case define.NOTIFY_GET_ELEC_CHARGE:
  2226. String strState = intent.getStringExtra("sCharging_Status");
  2227. String strCarNum = intent.getStringExtra("sCar_Num");
  2228. if (strState.equals("start")) {
  2229. try {
  2230. WallpadStatusData SetData = new WallpadStatusData(getContext());
  2231. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2232. SetData.closeDB();
  2233. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  2234. } catch (RuntimeException re) {
  2235. LogUtil.errorLogInfo("", TAG, re);
  2236. }
  2237. catch (Exception e) {
  2238. LogUtil.errorLogInfo("", TAG, e);
  2239. }
  2240. // 충전시작
  2241. Intent data = new Intent();
  2242. data.putExtra("CarNum", strCarNum); // KEY : MENU_ID_LIST
  2243. data.putExtra("Msg", "충전을 시작합니다.");
  2244. mIOInterface.ctrlLcdWakeUp();
  2245. StartPopup(ID.POPUPS.POPUP_CHARGINGELECTRICVEHICLE, data);
  2246. }
  2247. else if (strState.equals("stop")) {
  2248. try {
  2249. WallpadStatusData SetData = new WallpadStatusData(getContext());
  2250. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2251. SetData.closeDB();
  2252. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  2253. } catch (RuntimeException re) {
  2254. LogUtil.errorLogInfo("", TAG, re);
  2255. }
  2256. catch (Exception e) {
  2257. LogUtil.errorLogInfo("", TAG, e);
  2258. }
  2259. // 충전 종료
  2260. Intent data = new Intent();
  2261. data.putExtra("CarNum", strCarNum); // KEY : MENU_ID_LIST
  2262. data.putExtra("Msg", "충전이 종료되었습니다.");
  2263. mIOInterface.ctrlLcdWakeUp();
  2264. StartPopup(ID.POPUPS.POPUP_CHARGINGELECTRICVEHICLE, data);
  2265. }
  2266. break;
  2267. case define.NOTIFY_INTERLAYTER_NOISE_ALARM:
  2268. if (checkInterFloorNoiseFuncUsage()) {
  2269. mIOInterface.ctrlLcdWakeUp();
  2270. StartPopup(ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED);
  2271. }
  2272. break;
  2273. case define.NOTIFY_INTERLAYTER_SENSOR_STATUS_CHANGE :
  2274. if (checkInterFloorNoiseFuncUsage() && checkInterFloorNoiseError()) {
  2275. mIOInterface.ctrlLcdWakeUp();
  2276. StartPopup(ID.POPUPS.POPUP_INTERFLOORNOISEERROR);
  2277. }
  2278. break;
  2279. case define.NOTIFY_AUTOPICTURE_FINISH:
  2280. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_AUTOPICTURE_FINISH");
  2281. // 전자액자 종료 BR 수신시 LCD ON Flag 제거
  2282. ctrlLCDOnOff(false);
  2283. break;
  2284. case define.NOTIFY_ALARM_CHANGE:
  2285. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_ALARM_CHANGE");
  2286. // WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2287. // int nAlarmStatus = SetData.GetAlarmStatus();
  2288. // SetData.closeDB();
  2289. //
  2290. // Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus = " + nAlarmStatus);
  2291. // if (nAlarmStatus == WallpadStatusData.GUARD_IN) {
  2292. // mSound.PlayMent(SND.mode.INMODE_SETTING);
  2293. // }
  2294. // else if (nAlarmStatus == WallpadStatusData.GUARD_OUT) {
  2295. // mSound.PlayMent(SND.mode.OUTMODE_SETTING);
  2296. // }
  2297. // else if (nAlarmStatus == WallpadStatusData.ALARM_NONE) {
  2298. // mSound.PlayMent(SND.mode.NORMALMODE_COMEBACK);
  2299. // }
  2300. break;
  2301. case define.NOTIFY_PLAYMENT:
  2302. int sndidx = intent.getIntExtra(define.NOTIBR_CONTENT,0);
  2303. Sound().PlayMent(sndidx);
  2304. case define.NOTIFY_DEVICE_INIT_COMPLETION:
  2305. Log.i(TAG, "[mWallPadNotifyBR] NOTIFY_DEVICE_INIT_COMPLETION: bLCDKeeperUsage [" + bLCDKeeperUsage +"]");
  2306. if (bLCDKeeperUsage) registerLCDKeeper();
  2307. break;
  2308. default:
  2309. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  2310. break;
  2311. }
  2312. }
  2313. else if (strAction.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  2314. Log.d(TAG, "[mWallPadNotifyBR] Common.BR_ACK_WALLPADCALL_LIVE");
  2315. return;
  2316. }
  2317. else if (strAction.equals(define.DRIVER_VENTIL_BR)) {
  2318. Log.d(TAG, "[mWallPadNotifyBR] define.DRIVER_VENTIL_BR");
  2319. return;
  2320. }
  2321. else if (strAction.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  2322. try {
  2323. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND,0);
  2324. Log.d(TAG, "[mWallPadNotifyBR] ACNAME_MAIN_NOTI -> kind : " + kind);
  2325. switch (kind) {
  2326. case Common.BR_MAIN_NOTI.ARRIVED_CAR:
  2327. StartPopup(ID.POPUPS.POPUP_VEHICLEARRIVED, intent);
  2328. // StartPopup(ID_OLD.SCREENS.ArrivedCarPopupScreen);
  2329. break;
  2330. case Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL:
  2331. StartPopup(ID.POPUPS.POPUP_PARCELRECEIVED);
  2332. // StartPopup(ID_OLD.SCREENS.DeliveryBox);
  2333. break;
  2334. case Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR:
  2335. StartPopup(ID.POPUPS.POPUP_SMARTKEYEMERGENCY, intent);
  2336. // StartPopup(ID_OLD.SCREENS.SmartKeyAlarmPopupScreen, intent);
  2337. break;
  2338. case Common.BR_MAIN_NOTI.UI_BANDLOCATION_ALARM:
  2339. ctrlLCDOnOff(true);
  2340. int nCardNum = intent.getIntExtra(Common.BR_MAIN_NOTI.CARD_NUM,0);
  2341. Intent mIntent = new Intent();
  2342. mIntent.putExtra(Common.BR_MAIN_NOTI.CARD_NUM, nCardNum);
  2343. StartPopup(ID.POPUPS.POPUP_BANDLOCATIONALARM, mIntent);
  2344. break;
  2345. case Common.BR_MAIN_NOTI.UI_UPDATE_POST:
  2346. ctrlLCDOnOff(true);
  2347. StartPopup(ID.POPUPS.POPUP_POSTRECEIVED);
  2348. break;
  2349. case Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER:
  2350. // 알람 상태 확인
  2351. int doorCamType = intent.getIntExtra("DOORCAM_TYPE", -1);
  2352. Intent data = new Intent();
  2353. data.putExtra("DOORCAM_TYPE", doorCamType);
  2354. mIOInterface.ctrlLcdWakeUp();
  2355. // StartPopup(ID.POPUPS.POPUP_NOTICESTRANGER, data); // 시나리오 변경: 거동수상자 알림 팝업 삭제 (바로 녹화 시작)
  2356. WallpadStatusData SetData = new WallpadStatusData(mContext);
  2357. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2358. SetData.closeDB();
  2359. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  2360. // 메인 앱으로 BR 전송
  2361. Intent notiIntent = new Intent();
  2362. notiIntent.setAction(define.NOTIFY_ACNAME);
  2363. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ACCEPT_RECORD_STRANGER);
  2364. mContext.sendBroadcast(notiIntent);
  2365. break;
  2366. case Common.BR_MAIN_NOTI.ACCEPT_RECORDING:
  2367. int nEmerState = intent.getIntExtra("EMERGENCY_STATE", -1);
  2368. //여기서 거동 수상자 녹화 시작 여부 확인
  2369. Common.bRecordStatus = true;
  2370. boolean bFromCall = intent.getBooleanExtra("FROMCALL", false);
  2371. if (!bFromCall) {
  2372. // yjyoon. 2443에서는 Call 앱에서 녹화 수행
  2373. // 여기서 해당하는 br 정보를 저장 해야 함
  2374. //jglee - 여기서 BR들을 관리하기 위하여
  2375. if(CallBrList == null)
  2376. CallBrList = new ArrayList<Intent>();
  2377. Intent brListIntent = new Intent();
  2378. brListIntent.setAction(define.NOTIFY_ACNAME);
  2379. brListIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SMART_DCAM_DETECT);
  2380. if(CallBrList.size() > 1)
  2381. {
  2382. if(CallBrList.get(0) != brListIntent)
  2383. {
  2384. CallBrList.add(brListIntent);
  2385. Log.d(TAG, "jglee - Call 인텐트 추가 > size : " + CallBrList.size() + ", Action : " + CallBrList.get(0).getAction());
  2386. }
  2387. }
  2388. else {
  2389. CallBrList.add(brListIntent);
  2390. Log.d(TAG, "jglee - Call 인텐트 추가 > size : " + CallBrList.size() + ", Action : " + CallBrList.get(0).getAction());
  2391. }
  2392. //여기서 BrList에 남아 있는 갯수를 확인
  2393. if(CallBrList!=null && CallBrList.size() > 1)
  2394. {
  2395. return;
  2396. }
  2397. Log.d(TAG, "jglee - Call Record");
  2398. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Door_Record, nEmerState);
  2399. }
  2400. break;
  2401. case Common.BR_MAIN_NOTI.STOP_RECORDING:
  2402. // yjyoon. 거동수상자 녹화중지 시 상태값 변경.
  2403. Log.v("yjyoon", "Common.BR_MAIN_NOTI.STOP_RECORDING Common.bWallPadRecoder = false");
  2404. //Common.bWallPadRecoder = false;
  2405. Common.bRecordStatus = false;
  2406. mediaStopRecord();
  2407. break;
  2408. default:
  2409. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  2410. break;
  2411. }
  2412. } catch (RuntimeException re) {
  2413. LogUtil.errorLogInfo("", TAG, re);
  2414. }
  2415. catch (Exception e) {
  2416. e.toString();
  2417. }
  2418. return;
  2419. }
  2420. else if(strAction.equals(BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER )) {
  2421. int kind = intent.getIntExtra(BR_MAIN_LIVE_CHECKER.KIND,0);
  2422. Log.d(TAG, "[mWallPadNotifyBR] BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER -> kind : " + kind + ", m_LiveImapServer [" + m_LiveImapServer + "], m_LiveMainActivity [" + m_LiveMainActivity + "]");
  2423. if (kind == BR_MAIN_LIVE_CHECKER.IMAP_SERVER) {
  2424. Log.d(TAG, "[mWallPadNotifyBR] received Imap Server Live !");
  2425. m_LiveImapServer++;
  2426. }
  2427. else if( kind == BR_MAIN_LIVE_CHECKER.MAIN_ACTIVITY) {
  2428. Log.d(TAG, "[mWallPadNotifyBR] received Main Activity Live !");
  2429. m_LiveMainActivity++;
  2430. if (m_IPActivity == false) {
  2431. Log.d(TAG, "[mWallPadNotifyBR] IP is not set");
  2432. m_LiveImapServer++;
  2433. }
  2434. }
  2435. Log.d(TAG, "[mWallPadNotifyBR] m_LiveImapServer [" + m_LiveImapServer + "], m_LiveMainActivity [" + m_LiveMainActivity +"]");
  2436. return;
  2437. }
  2438. int kind = intent.getIntExtra("KIND",0);
  2439. Log.d(TAG, "MainActivity mWallPadNotifyBR Receive Notify BR "+kind+" "/*+electr.isActive()*/);
  2440. switch (kind) {
  2441. case define.NOTIFY_ELE_MOVE:
  2442. // if (electr!= null /*&& electr.isActive()*/)
  2443. // {
  2444. // Log.i("MAINSCREEN", "Receive NOTIFY_ELE_MOVE");
  2445. // electr.updateUI(intent.getStringExtra("FLOOR"), intent.getByteExtra("UPDOWN",(byte)-1));
  2446. // }
  2447. break;
  2448. case define.NOTIFY_ELE_ARRIVAL_UP:
  2449. Log.i("AIDLTEST", "Receive NOTIFY_ELE_ARRIVAL_UP");
  2450. Sound().Play(SND.elevator.UP_ARRIVED);
  2451. break;
  2452. case define.NOTIFY_ELE_ARRIVAL_DOWN:
  2453. try {
  2454. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  2455. int eleinfo = devset.Get_Elevator_Info();
  2456. devset.closeDB();
  2457. if (WallpadDeviceSet.ELEVATOR_SIMPLE == eleinfo) Sound().Play(SND.elevator.ORG_ARRIVED);
  2458. else if (WallpadDeviceSet.ELEVATOR_FLOOR == eleinfo) Sound().Play(SND.elevator.DN_ARRIVED);
  2459. } catch (RuntimeException re) {
  2460. LogUtil.errorLogInfo("", TAG, re);
  2461. }
  2462. catch (Exception e) {
  2463. LogUtil.errorLogInfo("", TAG, e);
  2464. }
  2465. break;
  2466. case define.NOTIFY_UPDATE_START:
  2467. try {
  2468. String updateFile = intent.getStringExtra("PATH");
  2469. Log.i("WALLPADAPI","Call Update App :" + updateFile);
  2470. if (updateFile==null) return;
  2471. ComponentName cn = new ComponentName("com.telechips.android.systemupdater","com.telechips.android.systemupdater.SystemUpdate");
  2472. Intent Uintent = new Intent(Intent.ACTION_MAIN);
  2473. Uintent.addCategory(Intent.CATEGORY_LAUNCHER);
  2474. Uintent.putExtra("updatefile",updateFile);
  2475. Uintent.setComponent(cn);
  2476. startActivity(Uintent);
  2477. } catch (RuntimeException re) {
  2478. LogUtil.errorLogInfo("", TAG, re);
  2479. }
  2480. catch (Exception e) {
  2481. LogUtil.errorLogInfo("", TAG, e);
  2482. }
  2483. break;
  2484. case define.NOTIFY_DEVSERVICE_START:
  2485. mWallPadAPI = new WallPadAPI(getApplicationContext());
  2486. break;
  2487. case define.NOTIFY_DEVICECONNECTED:
  2488. //DevLockCtr.ReleaseLock(define.DEVICE_LOCK_SVC_INIT);
  2489. break;
  2490. case define.NOTIFY_SENDBOOTUP_FAIL:
  2491. // 부트업 실패시 5초 간격으로 다시 시도하도록 수정.
  2492. mWallPadApiCheckHandler.sendEmptyMessageDelayed(10, 10000);
  2493. break;
  2494. case define.NOTIFY_IMAPSERVER_START:
  2495. case Common.DEVICE_BOOTUP_RETRY:
  2496. Log.i(TAG, "Try Send Boot up MSG kind : " + kind );
  2497. bootupretryCNT++;
  2498. if (bootupretryCNT > MAX_BOOTUP_RETRY_COUNT) break;
  2499. try {
  2500. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2501. if (SetData != null) {
  2502. // AnC 기존 코드는 네트워크 연결이 안된경우 DB Close를 50회를 안 하도록 되어있어서 수정함.
  2503. String strServerIP = SetData.GetServerIP();
  2504. int nServerPort = SetData.GetServerPort();
  2505. String svrVersion = SetData.GetServerVer();
  2506. Log.d(TAG, "DB Server Version : " + svrVersion );
  2507. if (svrVersion == null) svrVersion = "1.0";
  2508. //설정정보 버전 가져오기
  2509. StringBuilder result = new StringBuilder();
  2510. result.append(SetData.GetSettingVer());
  2511. SetData.closeDB();
  2512. String Setting_Version = result.toString();
  2513. Log.i(TAG, "Setting's Version :"+Setting_Version);
  2514. boolean mNewDanjiServer = false;
  2515. try {
  2516. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2517. //mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2518. int danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  2519. if(danjiserverType == 1)
  2520. {
  2521. mNewDanjiServer = false;
  2522. }
  2523. else if(danjiserverType == 2)
  2524. {
  2525. mNewDanjiServer = true;
  2526. }
  2527. else
  2528. {
  2529. mNewDanjiServer = true;
  2530. }
  2531. wallpadDeviceSet.closeDB();
  2532. } catch (RuntimeException re) {
  2533. LogUtil.errorLogInfo("", TAG, re);
  2534. mNewDanjiServer = false;
  2535. }
  2536. catch (Exception e) {
  2537. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2538. LogUtil.errorLogInfo("", TAG, e);
  2539. mNewDanjiServer = false;
  2540. }
  2541. if (mNewDanjiServer == true) {
  2542. // DB 값하고 , 신형단지서버 사용 설정이 동일 하다면 DB값을 전달한다.
  2543. // 나중에 2.X 이상 버전이 갱신될 경우를 위해서
  2544. }
  2545. else {
  2546. svrVersion = "1.0";
  2547. }
  2548. //Main App 버전정보 가져오기
  2549. WallPadiMAPNotifyAPI notify = new WallPadiMAPNotifyAPI(getApplicationContext());
  2550. notify.SetSocketWaitCount(3000);
  2551. notify.SetServerIPcfg(strServerIP, nServerPort);
  2552. notify.Send_Device_BootUP(getMainVersion(), Setting_Version , svrVersion );
  2553. }
  2554. } catch (RuntimeException re) {
  2555. LogUtil.errorLogInfo("", TAG, re);
  2556. Intent Newintent = new Intent();
  2557. Newintent.setAction(define.NOTIFY_ACNAME);
  2558. Newintent.putExtra(define.NOTIBR_KIND,define.NOTIFY_SENDBOOTUP_FAIL);
  2559. sendBroadcast(Newintent);
  2560. }
  2561. catch (Exception e) {
  2562. LogUtil.errorLogInfo("", TAG, e);
  2563. Intent Newintent = new Intent();
  2564. Newintent.setAction(define.NOTIFY_ACNAME);
  2565. Newintent.putExtra(define.NOTIBR_KIND,define.NOTIFY_SENDBOOTUP_FAIL);
  2566. sendBroadcast(Newintent);
  2567. }
  2568. break;
  2569. case define.NOTIFY_SUBDEVCALLBUSY:
  2570. /*
  2571. callbtn = (Button)findViewById(R.id.Callbtn);
  2572. callbtn.setBackgroundResource(R.drawable.but_call_on);
  2573. MAIN_CALL_LOCK = true;
  2574. */
  2575. break;
  2576. case define.NOTIFY_SUBDEVCALLEND:
  2577. /*
  2578. callbtn = (Button)findViewById(R.id.Callbtn);
  2579. callbtn.setBackgroundResource(R.drawable.but_call);
  2580. MAIN_CALL_LOCK = false;
  2581. */
  2582. break;
  2583. case define.NOTIFY_UPDATECALLDATA:
  2584. try{
  2585. String[] UpdateCallData = intent.getStringExtra(define.NOTIBR_CONTENT).split(define.DEVCTR_CMD_SPLITER);
  2586. Log.i(APIErrorCode.GetLogPrefix(),"Receive NOTIFY_UPDATECALLDATA "+UpdateCallData[0]+";"+UpdateCallData[1]);
  2587. int IncallCnt = 0;
  2588. int VisitorCNT = 0;
  2589. try {
  2590. IncallCnt = Integer.parseInt(UpdateCallData[0]);
  2591. VisitorCNT = Integer.parseInt(UpdateCallData[1]);
  2592. } catch (RuntimeException re) {
  2593. LogUtil.errorLogInfo("", TAG, re);
  2594. }
  2595. catch (Exception e) {
  2596. LogUtil.errorLogInfo("", TAG, e);
  2597. }
  2598. } catch (RuntimeException re) {
  2599. LogUtil.errorLogInfo("", TAG, re);
  2600. }
  2601. catch (Exception e) {
  2602. LogUtil.errorLogInfo("", TAG, e);
  2603. }
  2604. break;
  2605. case define.NOTIFY_UPDATENOTICE:
  2606. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATENOTICE ");
  2607. try {
  2608. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2609. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2610. SetData.closeDB();
  2611. if (soundOut) {
  2612. Sound().PlayMent(SND.effect.EFFECT1);
  2613. }
  2614. mIOInterface.ctrlLcdWakeUp();
  2615. } catch (RuntimeException re) {
  2616. LogUtil.errorLogInfo("", TAG, re);
  2617. }
  2618. catch (Exception e) { LogUtil.errorLogInfo("", TAG, e);
  2619. }
  2620. break;
  2621. case define.NOTIFY_UPDATEPARCEL:
  2622. try {
  2623. String type = intent.getStringExtra(define.NOTIBR_CONTENT);
  2624. int itemcnt = intent.getIntExtra("ITEM",-1);
  2625. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2626. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2627. if (itemcnt !=-1) SetData.SetParcelCNT(itemcnt);
  2628. SetData.closeDB();
  2629. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPARCEL itemcnt : " + itemcnt);
  2630. // if (soundOut) {
  2631. // if (type.equals("parcel_in")) {
  2632. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2633. // pm.userActivity(1, true);
  2634. // Sound().PlayMent(SND.mode.BOX_ARRIVED);
  2635. // }
  2636. // }
  2637. Log.d(TAG, "Send BR --> Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL");
  2638. Intent Newintent = new Intent();
  2639. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2640. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL);
  2641. getApplicationContext().sendBroadcast(Newintent);
  2642. //NoticeIconOnoff(true);
  2643. } catch (RuntimeException re) {
  2644. LogUtil.errorLogInfo("", TAG, re);
  2645. }
  2646. catch (Exception e) {
  2647. LogUtil.errorLogInfo("", TAG, e);
  2648. }
  2649. // if (type.equals("parcel_in"))
  2650. // {
  2651. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2652. // pm.userActivity(1, true);
  2653. // PlayNotiSound(WpadSound.SND.mode.BOX_ARRIVED);
  2654. // }
  2655. //
  2656. // if (itemcnt!=-1){
  2657. // if (itemcnt > 0)
  2658. // ParcelIconOnoff(true);
  2659. // else
  2660. // ParcelIconOnoff(false);
  2661. // WallpadStatusData ParData = new WallpadStatusData(getApplicationContext());
  2662. // ParData.SetParcelCNT(itemcnt);
  2663. // ParData.closeDB();
  2664. // if (ParcelMGR!=null) ParcelMGR.updateParcel();
  2665. // }
  2666. break;
  2667. case define.NOTIFY_UPDATEPOST:
  2668. try {
  2669. int nItemCnt = intent.getIntExtra("ITEM",-1);
  2670. Log.d(TAG, "[UI_UPDATE_POST] nItemCnt [" + nItemCnt + "]");
  2671. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2672. if (nItemCnt != -1) SetData.SetPostCNT(nItemCnt);
  2673. SetData.closeDB();
  2674. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPOST nItemCnt : " + nItemCnt);
  2675. Log.d(TAG, "Send BR --> Common.BR_MAIN_NOTI.UI_UPDATE_POST");
  2676. Intent Newintent = new Intent();
  2677. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2678. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.UI_UPDATE_POST);
  2679. getApplicationContext().sendBroadcast(Newintent);
  2680. } catch (RuntimeException re) {
  2681. LogUtil.errorLogInfo("", TAG, re);
  2682. }
  2683. catch (Exception e) {
  2684. Log.e(TAG, "[Exception] mWallPadNotifyBR.onReceive()");
  2685. LogUtil.errorLogInfo("", TAG, e);
  2686. }
  2687. break;
  2688. case define.NOTIFY_UPDATEPARKING:
  2689. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPARKING ");
  2690. /*
  2691. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  2692. List<String[]> parkList = parkdb.GetParkInfo();
  2693. if(parkList != null)
  2694. {
  2695. for(int j= 0; j<parkList.size(); j++)
  2696. {
  2697. for(int i = 0; i<4; i++)
  2698. {
  2699. Common.DebugLog("parkList.get("+j+")["+i+"]:"+ parkList.get(j)[i]);
  2700. }
  2701. }
  2702. }
  2703. parkdb.closeDB();
  2704. */
  2705. break;
  2706. case define.NOTIFY_DEVICEREBOOT:
  2707. try {
  2708. //[Model]
  2709. // if (Version.getPlatformType() == Version.PLATFORM_TYPE.A20) {
  2710. // // A20
  2711. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  2712. // pm.userActivity(8, true);
  2713. // }
  2714. // else if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  2715. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  2716. // V40
  2717. V40IOInterface mV40IOInterface = new V40IOInterface();
  2718. mV40IOInterface.setV40Reboot(5);
  2719. }
  2720. else {
  2721. // TCC8935
  2722. SendAppFinishReqBR();
  2723. ComponentName cnA = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  2724. intent = new Intent(Intent.ACTION_MAIN);
  2725. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  2726. intent.putExtra("updatesystem", "no");
  2727. intent.putExtra("updateapp", " no ");
  2728. intent.putExtra("rebootcmd", "reboot");
  2729. intent.setComponent(cnA);
  2730. startActivity(intent);
  2731. }
  2732. } catch (RuntimeException re) {
  2733. LogUtil.errorLogInfo("", TAG, re);
  2734. }
  2735. catch (Exception e) {
  2736. LogUtil.errorLogInfo("", TAG, e);
  2737. }
  2738. break;
  2739. case define.NOTIFY_DEVICEDEEPSLEEP:
  2740. try {
  2741. Log.d(TAG, "[mWallPadAlertBR] NOTIFY_DEVICEDEEPSLEEP");
  2742. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  2743. String[] getstate = sdb.GetSystemUpdateStatus();
  2744. for (int i = 0; i < getstate.length; i++) {
  2745. Log.d(TAG, "[mWallPadAlertBR] getstate[" + i + "] = " + getstate[i]);
  2746. }
  2747. if (getstate[0].equalsIgnoreCase("SET")) {
  2748. sdb.SetSystemUpdate(null, null);
  2749. sdb.SetUpgradeState(true);
  2750. ComponentName cnn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  2751. intent = new Intent(Intent.ACTION_MAIN);
  2752. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2753. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  2754. intent.putExtra("updatesystem", getstate[1]);
  2755. intent.putExtra("updateapp", getstate[2]);
  2756. intent.setComponent(cnn);
  2757. Log.e("MAINSCREEN","Call Upgrade Request BSP : "+getstate[1]+" APP : "+getstate[2]);
  2758. startActivity(intent);
  2759. }
  2760. sdb.closeDB();
  2761. } catch (RuntimeException re) {
  2762. LogUtil.errorLogInfo("", TAG, re);
  2763. }
  2764. catch (Exception e) {
  2765. LogUtil.errorLogInfo("", TAG, e);
  2766. }
  2767. break;
  2768. case define.NOTIFY_SYSTEMTIMESETTED:
  2769. try {
  2770. Common.DebugLog("MainActivity ---------- > define.NOTIFY_SYSTEMTIMESETTED");
  2771. Calendar caldata = new GregorianCalendar();
  2772. // refreshdate(caldata);
  2773. // refreshclock(caldata);
  2774. if (SYSTEM_TIME_SET == false) {
  2775. SYSTEM_TIME_SET = true;
  2776. if (SCManager != null) {
  2777. if (SCManager.isSetted != true) SCManager.refreshSchedule();
  2778. }
  2779. }
  2780. } catch (RuntimeException re) {
  2781. LogUtil.errorLogInfo("", TAG, re);
  2782. }
  2783. catch (Exception e) {
  2784. LogUtil.errorLogInfo("", TAG, e);
  2785. }
  2786. break;
  2787. case define.NOTIFY_SCHEDULEUPDATED:
  2788. // item = intent.getIntExtra("ITEM",0);
  2789. // if (item == ScheduleManager.SCHEDULE_TYPE_SCHEDULER && SYSTEM_TIME_SET)
  2790. // SCManager.refreshSchedulerData();
  2791. // else if (item == ScheduleManager.SCHEDULE_TYPE_SYSRESET && SYSTEM_TIME_SET)
  2792. // SCManager.refreshsysreset();
  2793. // else if (item == ScheduleManager.SCHEDULE_TYPE_MORNINGCALL && SYSTEM_TIME_SET)
  2794. // SCManager.refreshMorningCall();
  2795. // break;
  2796. case define.NOTIFY_ALARMSTAUSCHANGED:
  2797. try {
  2798. item = intent.getIntExtra("ITEM",0);
  2799. if (item == WallpadStatusData.GUARD_OUT) {
  2800. int base = 8000;
  2801. int [] Menu_Id_List = { base+11};
  2802. int Menu_Start_Id = base+11;
  2803. int Menu_Start_Option = -1;
  2804. Intent iintent = new Intent(Intent.ACTION_MAIN);
  2805. iintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2806. iintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  2807. iintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2808. iintent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun","kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  2809. startActivity(iintent);
  2810. }
  2811. else if (item == WallpadStatusData.GUARD_IN) {
  2812. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  2813. // Button callBtn = (Button)findViewById(R.id.GuardBtn);
  2814. // callBtn.setBackgroundResource((SettData.GetAlarmStatus() == WallpadStatusData.GUARD_IN)?R.drawable.but_guard_on:R.drawable.but_guard);
  2815. SettData.closeDB();
  2816. }
  2817. } catch (RuntimeException re) {
  2818. LogUtil.errorLogInfo("", TAG, re);
  2819. }
  2820. catch (Exception e) {
  2821. LogUtil.errorLogInfo("", TAG, e);
  2822. }
  2823. break;
  2824. case define.NOTIFY_ENERGYUPDATE:
  2825. try
  2826. {
  2827. Calendar caldata = new GregorianCalendar();
  2828. String[] getData = intent.getStringExtra(define.NOTIBR_CONTENT).split(define.DEVCTR_CMD_SPLITER);
  2829. String checkDate = String.format("%04d%02d%02d",caldata.get(Calendar.YEAR),caldata.get(Calendar.MONTH)+1,caldata.get(Calendar.DAY_OF_MONTH));
  2830. WallpadStatusData energyData = new WallpadStatusData(getApplicationContext());
  2831. energyData.SetEnergyData(intent.getStringExtra(define.NOTIBR_CONTENT));
  2832. energyData.SetEnergyCheckDate(checkDate);
  2833. energyData.closeDB();
  2834. //if (NeedCheckEnergy)
  2835. // CheckEnergyUsage(getData);
  2836. // if (EnergyMGR!=null)
  2837. // EnergyMGR.UpdateData(getData);
  2838. }
  2839. catch (RuntimeException re) {
  2840. LogUtil.errorLogInfo("", TAG, re);
  2841. }
  2842. catch (Exception e )
  2843. {
  2844. LogUtil.errorLogInfo("", TAG, e);
  2845. }
  2846. break;
  2847. case define.NOTIFY_STARTEFRAME:
  2848. try
  2849. {
  2850. Log.w("MAINSCREEN"," Receive NOTIFY_STARTEFRAME Start StartAutoPictureAPP ");
  2851. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  2852. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar()))
  2853. {
  2854. if (!SettData.StartAutoPictureAPP())
  2855. {
  2856. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2857. // pm.userActivity(3, true);
  2858. }
  2859. }
  2860. else
  2861. {
  2862. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2863. // pm.userActivity(3, true);
  2864. }
  2865. SettData.closeDB();
  2866. }
  2867. catch (RuntimeException re) {
  2868. LogUtil.errorLogInfo("", TAG, re);
  2869. }
  2870. catch (Exception e )
  2871. {
  2872. LogUtil.errorLogInfo("", TAG, e);
  2873. }
  2874. break;
  2875. case define.NOTIFY_ADDDEVICELOCK:
  2876. Log.w("MAINSCREEN"," Receive NOTIFY_ADDDEVICELOCK Start ");
  2877. //DevLockCtr.AddLock(intent.getIntExtra(define.NOTIBR_CONTENT, 0));
  2878. break;
  2879. case define.NOTIFY_RELEASEDEVICELOCK:
  2880. Log.w("MAINSCREEN"," Receive NOTIFY_RELEASEDEVICELOCK Start ");
  2881. //DevLockCtr.ReleaseLock(intent.getIntExtra(define.NOTIBR_CONTENT, 0));
  2882. break;
  2883. case define.NOTIFY_PLAYMENT:
  2884. {
  2885. int sndidx = intent.getIntExtra(define.NOTIBR_CONTENT,0);
  2886. Sound().PlayMent(sndidx);
  2887. if (sndidx == WpadSound.SND.elevator.CALL) {
  2888. byte floorInfo = intent.getByteExtra(define.NOTIBR_FLOOR,(byte)0);
  2889. Log.e("MANUAL_MAIN", " PLAY MENT Get Ele Call : "+floorInfo);
  2890. }
  2891. }
  2892. break;
  2893. case define.NOTIFY_ENERGY_DATA:
  2894. {
  2895. try
  2896. {
  2897. Log.w("MAINSCREEN"," Receive NOTIFY_ENERGY DATA Start ");
  2898. //에너지 데이터 개수 - 3종 또는 5종
  2899. EnergyAlramPopupMgr.m_EnergyInfoCount = intent.getIntExtra(Common.ENERGY_INTENT_ENERGY_COUNT, -1);
  2900. Log.w("MAINSCREEN"," ENERGY_INTENT_ENERGY_COUNT :"+ EnergyAlramPopupMgr.m_EnergyInfoCount);
  2901. //에너지 단지서버에서 받아온 시간
  2902. EnergyAlramPopupMgr.m_ReceiveYear = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_YEAR, -1);
  2903. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_YEAR :"+ EnergyAlramPopupMgr.m_ReceiveYear);
  2904. EnergyAlramPopupMgr.m_ReceiveMonth = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_MONTH, -1);
  2905. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_MONTH :"+ EnergyAlramPopupMgr.m_ReceiveMonth);
  2906. EnergyAlramPopupMgr.m_ReceiveDay = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_DAY, -1);
  2907. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_DAY :"+ EnergyAlramPopupMgr.m_ReceiveDay );
  2908. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_HOUR :"+ intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_HOUR, -1));
  2909. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_MINUTE :"+ intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_MINUTE, -1));
  2910. //전기 에너지 정보
  2911. String Vaule = "";
  2912. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_ELECTRIC);
  2913. if( Vaule != null && Vaule.length() > 0 )
  2914. EnergyAlramPopupMgr.m_Elec_UseValue = Double.parseDouble(Vaule);
  2915. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC);
  2916. if( Vaule != null && Vaule.length() > 0 )
  2917. EnergyAlramPopupMgr.m_Elec_GoalValue = Double.parseDouble(Vaule);
  2918. //수도 에너지 정보
  2919. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_WATER);
  2920. if( Vaule != null && Vaule.length() > 0 )
  2921. EnergyAlramPopupMgr.m_Water_UseValue = Double.parseDouble(Vaule);
  2922. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_WATER);
  2923. if( Vaule != null && Vaule.length() > 0 )
  2924. EnergyAlramPopupMgr.m_Water_GoalValue = Double.parseDouble(Vaule);
  2925. //가스 에너지 정보
  2926. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_GAS);
  2927. if( Vaule != null && Vaule.length() > 0 )
  2928. EnergyAlramPopupMgr.m_Gas_UseValue = Double.parseDouble(Vaule);
  2929. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_GAS);
  2930. if( Vaule != null && Vaule.length() > 0 )
  2931. EnergyAlramPopupMgr.m_Gas_GoalValue = Double.parseDouble(Vaule);
  2932. //온수 에너지 정보
  2933. if( EnergyAlramPopupMgr.m_EnergyInfoCount >= 5 )
  2934. {
  2935. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_HOTWATER);
  2936. if( Vaule != null && Vaule.length() > 0 )
  2937. EnergyAlramPopupMgr.m_HotWater_UseValue = Double.parseDouble(Vaule);
  2938. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_HOTWATER);
  2939. if( Vaule != null && Vaule.length() > 0 )
  2940. EnergyAlramPopupMgr.m_HotWater_GoalValue = Double.parseDouble(Vaule);
  2941. //난방 에너지 정보
  2942. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_HEATING);
  2943. if( Vaule != null && Vaule.length() > 0 )
  2944. EnergyAlramPopupMgr.m_Heating_UseValue = Double.parseDouble(Vaule);
  2945. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_HEATING);
  2946. if( Vaule != null && Vaule.length() > 0 )
  2947. EnergyAlramPopupMgr.m_Heating_GoalValue = Double.parseDouble(Vaule);
  2948. }
  2949. }
  2950. catch (RuntimeException re) {
  2951. LogUtil.errorLogInfo("", TAG, re);
  2952. }
  2953. catch (Exception e )
  2954. {
  2955. LogUtil.errorLogInfo("", TAG, e);
  2956. }
  2957. }
  2958. break;
  2959. case define.NOTIFY_GET_CAR_PARKING:
  2960. try
  2961. {
  2962. if(bUseofNot_ParkingInfo == true)
  2963. {
  2964. bSetMSG_GetParkingInfo = true;
  2965. LoadParkingDataFromServer();
  2966. }
  2967. else
  2968. {
  2969. DebugLogOutput("bUseofNot_ParkingInfo == false");
  2970. }
  2971. }
  2972. catch (RuntimeException re) {
  2973. LogUtil.errorLogInfo("", TAG, re);
  2974. }
  2975. catch (Exception e )
  2976. {
  2977. LogUtil.errorLogInfo("", TAG, e);
  2978. }
  2979. break;
  2980. case define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER:
  2981. String tempFromWhere = intent.getStringExtra("FromWhere");
  2982. if(tempFromWhere == null)
  2983. {
  2984. ResultGetIntent = true;
  2985. }
  2986. String tempElect_target = intent.getStringExtra("elect_target");
  2987. if(tempElect_target != null)
  2988. {
  2989. elect_target = tempElect_target;
  2990. }
  2991. String tempElect_used = intent.getStringExtra("elect_used");
  2992. if(tempElect_used != null)
  2993. {
  2994. elect_used = tempElect_used;
  2995. }
  2996. String tempElect_info = intent.getStringExtra("elect_info");
  2997. if(tempElect_info != null)
  2998. {
  2999. elect_info = tempElect_info;
  3000. }
  3001. String tempWater_target = intent.getStringExtra("water_target");
  3002. if(tempWater_target != null)
  3003. {
  3004. water_target = tempWater_target;
  3005. }
  3006. String tempWater_used = intent.getStringExtra("water_used");
  3007. if(tempWater_used != null)
  3008. {
  3009. water_used = tempWater_used;
  3010. }
  3011. String tempWater_info = intent.getStringExtra("water_info");
  3012. if(tempWater_info != null)
  3013. {
  3014. water_info = tempWater_info;
  3015. }
  3016. String tempGas_target = intent.getStringExtra("gas_target");
  3017. if(tempGas_target != null)
  3018. {
  3019. gas_target = tempGas_target;
  3020. }
  3021. String tempGas_used = intent.getStringExtra("gas_used");
  3022. if(tempGas_used != null)
  3023. {
  3024. gas_used = tempGas_used;
  3025. }
  3026. String tempGas_info = intent.getStringExtra("gas_info");
  3027. if(tempGas_info != null)
  3028. {
  3029. gas_info = tempGas_info;
  3030. }
  3031. String tempHotwater_target = intent.getStringExtra("hotwater_target");
  3032. if(tempHotwater_target != null)
  3033. {
  3034. hotwater_target = tempHotwater_target;
  3035. }
  3036. String tempHotwater_used = intent.getStringExtra("hotwater_used");
  3037. if(tempHotwater_used != null)
  3038. {
  3039. hotwater_used = tempHotwater_used;
  3040. }
  3041. String tempHotwater_info = intent.getStringExtra("hotwater_info");
  3042. if(tempHotwater_info != null)
  3043. {
  3044. hotwater_info = tempHotwater_info;
  3045. }
  3046. String tempHeating_target = intent.getStringExtra("heating_target");
  3047. if(tempHeating_target != null)
  3048. {
  3049. heating_target = tempHeating_target;
  3050. }
  3051. String tempHeating_used = intent.getStringExtra("heating_used");
  3052. if(tempHeating_used != null)
  3053. {
  3054. heating_used = tempHeating_used;
  3055. }
  3056. String tempHeatin_info = intent.getStringExtra("heating_info");
  3057. if(tempHeatin_info != null)
  3058. {
  3059. heating_info = tempHeatin_info;
  3060. }
  3061. break;
  3062. }
  3063. }
  3064. };
  3065. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3066. private void ctrlLCDOnOff(boolean bOn) {
  3067. try {
  3068. if (bOn) {
  3069. PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  3070. Log.d(TAG, "[ctrlLCDOnOff] Screen On: " + pm.isScreenOn());
  3071. if (getCompareBSPVersion()) {
  3072. if (!checkLCDOnByCMD()) {
  3073. Log.d(TAG, "[ctrlLCDOnOff] V40Interface LcdWakeUp Call!!");
  3074. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  3075. }
  3076. }
  3077. else {
  3078. if (!pm.isScreenOn()) {
  3079. Log.d(TAG, "[ctrlLCDOnOff] V40Interface LcdWakeUp Call!!");
  3080. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  3081. }
  3082. }
  3083. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3084. } else
  3085. getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3086. } catch (RuntimeException re) {
  3087. LogUtil.errorLogInfo("", TAG, re);
  3088. }
  3089. catch (Exception e) {
  3090. Log.e(TAG, "[Exception] ctrlLCDOnOff(boolean bOn)");
  3091. LogUtil.errorLogInfo("", TAG, e);
  3092. }
  3093. }
  3094. protected void refreshUserCtr() {
  3095. Intent intent = new Intent();
  3096. intent.setAction(define.DRIVER_LIGHT_BR);
  3097. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_LIGHT_BR);
  3098. sendBroadcast(intent);
  3099. intent = new Intent();
  3100. intent.setAction(define.DRIVER_BATCHLIGHT_BR);
  3101. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_BATCHLIGHT_BR);
  3102. sendBroadcast(intent);
  3103. intent = new Intent();
  3104. intent.setAction(define.DRIVER_VENTIL_BR);
  3105. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_VENTIL_BR);
  3106. sendBroadcast(intent);
  3107. // intent = new Intent();
  3108. // intent.setAction(HEATERBR);
  3109. // Log.i("HIGH","StatusChanged BR Send "+HEATERBR);
  3110. // sendBroadcast(intent);
  3111. }
  3112. private void Check_Upgrade_File() {
  3113. try {
  3114. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3115. String[] getstate = sdb.GetSystemUpdateStatus();
  3116. if (getstate[0].equalsIgnoreCase("SET")) {
  3117. for (int i = 1; i < 3; i++) {
  3118. if (!getstate[i].equals("no")) {
  3119. String filePath = "/sdcard/"+getstate[i];
  3120. File updradef = new File(filePath);
  3121. if (updradef.exists()) FileDelete(updradef);//.delete();
  3122. }
  3123. }
  3124. sdb.SetSystemUpdate(null, null);
  3125. }
  3126. sdb.closeDB();
  3127. } catch (RuntimeException re) {
  3128. LogUtil.errorLogInfo("", TAG, re);
  3129. }
  3130. catch (Exception e) {
  3131. Log.e(TAG, "[Exception] Check_Upgrade_File()");
  3132. LogUtil.errorLogInfo("", TAG, e);
  3133. }
  3134. }
  3135. protected void SendAppFinishReqBR() {
  3136. try {
  3137. Log.e("MANUAL_MAIN", "Send Finish BR");
  3138. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  3139. // pm.userActivity(1, true);
  3140. // LCD Always ON
  3141. getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3142. Intent notiIntent = new Intent();
  3143. notiIntent.setAction(define.BR_APP_FINISH);
  3144. getApplicationContext().sendBroadcast(notiIntent);
  3145. } catch (RuntimeException re) {
  3146. LogUtil.errorLogInfo("", TAG, re);
  3147. }
  3148. catch (Exception e) {
  3149. Log.e(TAG, "[Exception] SendAppFinishReqBR()");
  3150. LogUtil.errorLogInfo("", TAG, e);
  3151. }
  3152. }
  3153. private void registerBroadcastReceiver() {
  3154. try {
  3155. IntentFilter mIntentFilter = new IntentFilter();
  3156. mIntentFilter.addAction("WALLPAD_ALERT");
  3157. registerReceiver(mWallPadAlertBR, mIntentFilter);
  3158. mIntentFilter = new IntentFilter();
  3159. mIntentFilter.addAction("WALLPAD_NOTIFY");
  3160. mIntentFilter.addAction(define.DRIVER_VENTIL_BR);
  3161. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI); // ACC 꺼와 구분되는 Noti 추가
  3162. mIntentFilter.addAction(BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER);
  3163. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  3164. registerReceiver(mWallPadNotifyBR, mIntentFilter);
  3165. registerMainActivityBR();
  3166. registerStrangeRecordBR();
  3167. } catch (RuntimeException re) {
  3168. LogUtil.errorLogInfo("", TAG, re);
  3169. }
  3170. catch (Exception e) {
  3171. Log.e(TAG, "[Exception] registerBroadcastReceiver()");
  3172. LogUtil.errorLogInfo("", TAG, e);
  3173. }
  3174. }
  3175. private void unregisterBroadcastReceiver() {
  3176. try {
  3177. unregisterReceiver(mWallPadAlertBR);
  3178. unregisterReceiver(mWallPadNotifyBR);
  3179. unregisterReceiver(MainActivityBroadcastReceiver);
  3180. //거동수상자 관련 리시버 해제
  3181. unregisterReceiver(StrangeRecordBroadcastReceiver);
  3182. } catch (RuntimeException re) {
  3183. LogUtil.errorLogInfo("", TAG, re);
  3184. }
  3185. catch (Exception e) {
  3186. Log.e(TAG, "[Exception] unregisterBroadcastReceiver()");
  3187. LogUtil.errorLogInfo("", TAG, e);
  3188. }
  3189. }
  3190. private void MainScrLog(String msg) {
  3191. Log.e("MAINSCREEN",APIErrorCode.GetLogPrefix()+msg);
  3192. }
  3193. protected void CheckEnv() {
  3194. try {
  3195. File dnDIC = new File(BESTIN_LOCATION);
  3196. if (!dnDIC.exists()) dnDIC.mkdir();
  3197. dnDIC = new File(ALBUM_PICTURE_LOCATION);
  3198. if (!dnDIC.exists()) dnDIC.mkdir();
  3199. } catch (RuntimeException re) {
  3200. LogUtil.errorLogInfo("", TAG, re);
  3201. }
  3202. catch (Exception e) {
  3203. Log.e(TAG, "[Exception] CheckEnv()");
  3204. LogUtil.errorLogInfo("", TAG, e);
  3205. }
  3206. }
  3207. public void FileCopy(String Target, String Source) {
  3208. FileInputStream input = null;
  3209. FileOutputStream output = null;
  3210. try {
  3211. input = new FileInputStream(Source);
  3212. long size = input.available();
  3213. byte buff[] = new byte[(int)size];
  3214. input.read(buff);
  3215. output = new FileOutputStream(Target);
  3216. output.write(buff);
  3217. output.flush();
  3218. } catch (RuntimeException re) {
  3219. LogUtil.errorLogInfo("", TAG, re);
  3220. }
  3221. catch (Exception e ) {
  3222. Log.e(TAG, "[Exception] FileCopy(String Target, String Source)");
  3223. LogUtil.errorLogInfo("", TAG, e);
  3224. }
  3225. finally {
  3226. if(input!=null) {
  3227. try {
  3228. input.close( );
  3229. } catch (IOException e) {
  3230. LogUtil.errorLogInfo("", TAG, e);
  3231. }
  3232. }
  3233. input = null;
  3234. if(output!=null) {
  3235. try {
  3236. output.close();
  3237. } catch (IOException e) {
  3238. LogUtil.errorLogInfo("", TAG, e);
  3239. }
  3240. }
  3241. output = null;
  3242. }
  3243. }
  3244. public void checkEventNotifications() {
  3245. try {
  3246. Log.d(TAG,"[checkEventNotifications] ========== START ==========)");
  3247. // 스마트우편함, 전기차충전 연동 여부 확인
  3248. int nRetElecVehicle = -1;
  3249. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this.getContext());
  3250. bSmartPostUsage = mWallpadDeviceSet.Get_SmartPostUse();
  3251. nRetElecVehicle = mWallpadDeviceSet.GetDeviceSetted("전기차충전");
  3252. mWallpadDeviceSet.closeDB();
  3253. if (nRetElecVehicle == WallpadDeviceSet.DEV_DATA_ENABLE) bElecVehicleUsage = true;
  3254. else bElecVehicleUsage = false;
  3255. Log.d(TAG, "[checkEventNotifications] bSmartPostUsage [" + bSmartPostUsage + "], nRetElecVehicle [" + nRetElecVehicle + "], bElecVehicleUsage [" + bElecVehicleUsage + "]");
  3256. // 부재중 통화
  3257. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3258. try {
  3259. nMissedCallCnt = mWallpadCallHistoryData.RowCallHistoryCountData();
  3260. } catch (RuntimeException re) {
  3261. LogUtil.errorLogInfo("", TAG, re);
  3262. }
  3263. catch (Exception e) {
  3264. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadCallHistoryData");
  3265. LogUtil.errorLogInfo("", TAG, e);
  3266. }
  3267. mWallpadCallHistoryData.closeDB();
  3268. // 방문자 사진
  3269. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3270. try {
  3271. nVisitorPicCnt = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3272. } catch (RuntimeException re) {
  3273. LogUtil.errorLogInfo("", TAG, re);
  3274. }
  3275. catch (Exception e) {
  3276. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadVisitorPicData_A20");
  3277. LogUtil.errorLogInfo("", TAG, e);
  3278. }
  3279. mWallpadVisitorPicData_A20.closeDB();
  3280. // 공지사항, 택배, 스마트 우편
  3281. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  3282. try {
  3283. nNoticeCnt = mWallpadStatusData.GetNoticeCNT();
  3284. nParcelCnt = mWallpadStatusData.GetParcelCNT();
  3285. nPostCnt = mWallpadStatusData.GetPostCNT();
  3286. } catch (RuntimeException re) {
  3287. LogUtil.errorLogInfo("", TAG, re);
  3288. }
  3289. catch (Exception e) {
  3290. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadStatusData");
  3291. LogUtil.errorLogInfo("", TAG, e);
  3292. }
  3293. mWallpadStatusData.closeDB();
  3294. if (0 > nMissedCallCnt) {
  3295. Log.w(TAG,"[checkEventNotifications] out of range!! nMissedCallCnt [" + nMissedCallCnt + "]");
  3296. nMissedCallCnt = 0;
  3297. }
  3298. if (0 > nVisitorPicCnt) {
  3299. Log.w(TAG,"[checkEventNotifications] out of range!! nVisitorPicCnt [" + nVisitorPicCnt + "]");
  3300. nVisitorPicCnt = 0;
  3301. }
  3302. if (0 > nNoticeCnt) {
  3303. Log.w(TAG,"[checkEventNotifications] out of range!! nNoticeCnt [" + nNoticeCnt + "]");
  3304. nNoticeCnt = 0;
  3305. }
  3306. if (0 > nParcelCnt) {
  3307. Log.w(TAG,"[checkEventNotifications] out of range!! nParcelCnt [" + nParcelCnt + "]");
  3308. nParcelCnt = 0;
  3309. }
  3310. if (0 > nPostCnt) {
  3311. Log.w(TAG,"[checkEventNotifications] out of range!! nPostCnt [" + nPostCnt + "]");
  3312. nPostCnt = 0;
  3313. }
  3314. if (0 > nElecVehicleChangingCnt) {
  3315. Log.w(TAG,"[checkEventNotifications] out of range!! nElecVehicleChangingCnt [" + nElecVehicleChangingCnt + "]");
  3316. nElecVehicleChangingCnt = 0;
  3317. }
  3318. if (!bSmartPostUsage) {
  3319. Log.w(TAG,"[checkEventNotifications] bSmartPostUsage is not supported!! -> bSmartPostUsage [" + bSmartPostUsage + "]");
  3320. nPostCnt = 0;
  3321. }
  3322. if (!bElecVehicleUsage) {
  3323. Log.w(TAG,"[checkEventNotifications] bElecVehicleUsage is not supported!! -> bElecVehicleUsage [" + bElecVehicleUsage + "]");
  3324. nElecVehicleChangingCnt = 0;
  3325. }
  3326. Log.d(TAG,"[checkEventNotifications] nMissedCallCnt [" + nMissedCallCnt + "], nVisitorPicCnt [" + nVisitorPicCnt + "], nNoticeCnt [" + nNoticeCnt + "], nParcelCnt [" + nParcelCnt + "], nPostCnt [" + nPostCnt + "], nElecVehicleChangingCnt [" + nElecVehicleChangingCnt + "]");
  3327. sendEventNotiBR(nMissedCallCnt, nVisitorPicCnt, nNoticeCnt, nParcelCnt, nPostCnt, nElecVehicleChangingCnt);
  3328. Send_NotiSmartSwitch(MainActivity.nNoticeCnt, MainActivity.nParcelCnt, MainActivity.nVisitorPicCnt);
  3329. } catch (RuntimeException re) {
  3330. LogUtil.errorLogInfo("", TAG, re);
  3331. }
  3332. catch (Exception e) {
  3333. Log.e(TAG, "[Exception] checkEventNotifications()");
  3334. LogUtil.errorLogInfo("", TAG, e);
  3335. }
  3336. }
  3337. public String getEventNotificationInfo() {
  3338. try {
  3339. Log.d(TAG,"[getEventNotificationInfo] ========== START ==========)");
  3340. // 부재중 통화, 방문자 사진, 공지사항, 택배
  3341. int nMissedCallCnt = 0, nVisitorPicCnt = 0, nNoticeCnt = 0, nParcelCnt = 0, nPostCnt = 0;
  3342. // 부재중 통화
  3343. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3344. try {
  3345. nMissedCallCnt = mWallpadCallHistoryData.RowCallHistoryCountData();
  3346. } catch (RuntimeException re) {
  3347. LogUtil.errorLogInfo("", TAG, re);
  3348. }
  3349. catch (Exception e) {
  3350. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadCallHistoryData");
  3351. LogUtil.errorLogInfo("", TAG, e);
  3352. }
  3353. mWallpadCallHistoryData.closeDB();
  3354. // 방문자 사진
  3355. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3356. try {
  3357. nVisitorPicCnt = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3358. } catch (RuntimeException re) {
  3359. LogUtil.errorLogInfo("", TAG, re);
  3360. }
  3361. catch (Exception e) {
  3362. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadVisitorPicData_A20");
  3363. LogUtil.errorLogInfo("", TAG, e);
  3364. }
  3365. mWallpadVisitorPicData_A20.closeDB();
  3366. // 공지사항, 택배
  3367. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  3368. try {
  3369. nNoticeCnt = mWallpadStatusData.GetNoticeCNT();
  3370. nParcelCnt = mWallpadStatusData.GetParcelCNT();
  3371. nPostCnt = mWallpadStatusData.GetPostCNT();
  3372. } catch (RuntimeException re) {
  3373. LogUtil.errorLogInfo("", TAG, re);
  3374. }
  3375. catch (Exception e) {
  3376. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadStatusData");
  3377. LogUtil.errorLogInfo("", TAG, e);
  3378. }
  3379. mWallpadStatusData.closeDB();
  3380. if (0 > nMissedCallCnt) {
  3381. Log.w(TAG,"[getEventNotificationInfo] out of range!! nMissedCallCnt [" + nMissedCallCnt + "]");
  3382. nMissedCallCnt = 0;
  3383. }
  3384. if (0 > nVisitorPicCnt) {
  3385. Log.w(TAG,"[getEventNotificationInfo] out of range!! nVisitorPicCnt [" + nVisitorPicCnt + "]");
  3386. nVisitorPicCnt = 0;
  3387. }
  3388. if (0 > nNoticeCnt) {
  3389. Log.w(TAG,"[getEventNotificationInfo] out of range!! nNoticeCnt [" + nNoticeCnt + "]");
  3390. nNoticeCnt = 0;
  3391. }
  3392. if (0 > nParcelCnt) {
  3393. Log.w(TAG,"[getEventNotificationInfo] out of range!! nParcelCnt [" + nParcelCnt + "]");
  3394. nParcelCnt = 0;
  3395. }
  3396. if (0 > nPostCnt) {
  3397. Log.w(TAG,"[getEventNotificationInfo] out of range!! nPostCnt [" + nPostCnt + "]");
  3398. nPostCnt = 0;
  3399. }
  3400. Log.d(TAG,"[getEventNotificationInfo] nMissedCallCnt [" + nMissedCallCnt + "], nVisitorPicCnt [" + nVisitorPicCnt + "], nNoticeCnt [" + nNoticeCnt + "], nParcelCnt [" + nParcelCnt + "], nPostCnt [" + nPostCnt + "]");
  3401. if (bSmartPostUsage) return nMissedCallCnt + define.DEVCTR_CMD_SPLITER + nVisitorPicCnt + define.DEVCTR_CMD_SPLITER + nNoticeCnt + define.DEVCTR_CMD_SPLITER + nParcelCnt + define.DEVCTR_CMD_SPLITER + nPostCnt;
  3402. else return nMissedCallCnt + define.DEVCTR_CMD_SPLITER + nVisitorPicCnt + define.DEVCTR_CMD_SPLITER + nNoticeCnt + define.DEVCTR_CMD_SPLITER + nParcelCnt;
  3403. } catch (RuntimeException re) {
  3404. LogUtil.errorLogInfo("", TAG, re);
  3405. return null;
  3406. }
  3407. catch (Exception e) {
  3408. Log.e(TAG, "[Exception] getEventNotificationInfo()");
  3409. LogUtil.errorLogInfo("", TAG, e);
  3410. return null;
  3411. }
  3412. }
  3413. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel) {
  3414. try {
  3415. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "]");
  3416. 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);
  3417. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3418. Intent mIntent = new Intent();
  3419. mIntent.setAction(define.NOTIFY_ACNAME);
  3420. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3421. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3422. getApplicationContext().sendBroadcast(mIntent);
  3423. } catch (RuntimeException re) {
  3424. LogUtil.errorLogInfo("", TAG, re);
  3425. }
  3426. catch (Exception e) {
  3427. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel)");
  3428. LogUtil.errorLogInfo("", TAG, e);
  3429. }
  3430. }
  3431. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post) {
  3432. try {
  3433. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "], post [" + post + "]");
  3434. 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);
  3435. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3436. Intent mIntent = new Intent();
  3437. mIntent.setAction(define.NOTIFY_ACNAME);
  3438. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3439. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3440. getApplicationContext().sendBroadcast(mIntent);
  3441. } catch (RuntimeException re) {
  3442. LogUtil.errorLogInfo("", TAG, re);
  3443. }
  3444. catch (Exception e) {
  3445. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post)");
  3446. LogUtil.errorLogInfo("", TAG, e);
  3447. }
  3448. }
  3449. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post, int elecvehiclecharging) {
  3450. try {
  3451. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "], post [" + post + "], elecvehiclecharging [" + elecvehiclecharging +"]");
  3452. String strResult = String.valueOf(missedcall) + define.DEVCTR_CMD_SPLITER + String.valueOf(visitorpic) + define.DEVCTR_CMD_SPLITER + String.valueOf(notice)
  3453. + define.DEVCTR_CMD_SPLITER + String.valueOf(parcel) + define.DEVCTR_CMD_SPLITER + String.valueOf(post) + define.DEVCTR_CMD_SPLITER + String.valueOf(elecvehiclecharging);
  3454. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3455. Intent mIntent = new Intent();
  3456. mIntent.setAction(define.NOTIFY_ACNAME);
  3457. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3458. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3459. getApplicationContext().sendBroadcast(mIntent);
  3460. } catch (RuntimeException re) {
  3461. LogUtil.errorLogInfo("", TAG, re);
  3462. }
  3463. catch (Exception e) {
  3464. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post, int elecvehiclecharging)");
  3465. LogUtil.errorLogInfo("", TAG, e);
  3466. }
  3467. }
  3468. private void CheckCallData_CalledCountAndVisitorCount() {
  3469. try {
  3470. int Vcount = 0;
  3471. int Ccount = 0;
  3472. try {
  3473. //DB정보 읽어서 처리
  3474. Log.d(TAG,"CheckCallData_CalledCountAndVisitorCount Start");
  3475. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3476. int TempCcount = mWallpadCallHistoryData.RowCallHistoryCountData();
  3477. mWallpadCallHistoryData.closeDB();
  3478. Log.d(TAG,"RowCallHistoryCountData() :" + TempCcount);
  3479. if (TempCcount != -999) {
  3480. Ccount = TempCcount;
  3481. }
  3482. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3483. int TempVcount = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3484. mWallpadVisitorPicData_A20.closeDB();
  3485. Log.d(TAG,"RowVisitorPictureCountData() :" + TempVcount);
  3486. if (TempVcount != -999) {
  3487. Vcount = TempVcount;
  3488. }
  3489. } catch (RuntimeException re) {
  3490. LogUtil.errorLogInfo("", TAG, re);
  3491. }
  3492. catch (Exception e) {
  3493. LogUtil.errorLogInfo("", TAG, e);
  3494. }
  3495. Log.d(TAG," Call Count Check Receive Ccount :" + Ccount + " , Photo Count : " + Vcount );
  3496. String Retdata = String.valueOf(Ccount)+define.DEVCTR_CMD_SPLITER+String.valueOf(Vcount);
  3497. Intent intent = new Intent();
  3498. intent.setAction(define.NOTIFY_ACNAME);
  3499. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3500. intent.putExtra(define.NOTIBR_CONTENT, Retdata);
  3501. getApplicationContext().sendBroadcast(intent);
  3502. } catch (RuntimeException re) {
  3503. LogUtil.errorLogInfo("", TAG, re);
  3504. }
  3505. catch (Exception e) {
  3506. Log.e(TAG, "[Exception] CheckCallData_CalledCountAndVisitorCount()");
  3507. LogUtil.errorLogInfo("", TAG, e);
  3508. }
  3509. }
  3510. class ScheduleManager {
  3511. public static final int SCHEDULE_TYPE_GETINFO = 5000;
  3512. public static final int SCHEDULE_TYPE_MORNINGCALL = 5001;
  3513. public static final int SCHEDULE_TYPE_SCHEDULER = 5002;
  3514. public static final int SCHEDULE_TYPE_SYSRESET = 5003;
  3515. public static final int SCHEDULE_TYPE_NONE = 5004;
  3516. public boolean isSetted = false;
  3517. List<TimeScheduleUnit> SchedulerData = new ArrayList<TimeScheduleUnit>();
  3518. List<TimeScheduleUnit> GeneralData = new ArrayList<TimeScheduleUnit>();
  3519. public ScheduleManager() {
  3520. }
  3521. public class TimeScheduleUnit {
  3522. int type;
  3523. Calendar TimeSet;
  3524. String message;
  3525. TimeScheduleUnit(int sctype, Calendar target) {
  3526. type = sctype;
  3527. TimeSet = target;
  3528. }
  3529. TimeScheduleUnit(int sctype, Calendar target, String msg) {
  3530. Log.i("MAINSCREEN","TimeScheduleUnit Create "+sctype+" : MSG : "+msg);
  3531. type = sctype;
  3532. TimeSet = target;
  3533. message = msg;
  3534. }
  3535. public boolean isOver() {
  3536. Calendar cal_now = new GregorianCalendar();
  3537. if (cal_now.after(TimeSet)) {
  3538. return true;
  3539. }
  3540. return false;
  3541. }
  3542. }
  3543. private void CheckSysResetData() {
  3544. try {
  3545. Calendar today = new GregorianCalendar();
  3546. Log.i("MAINSCREEN","CheckSysResetData Schedule");
  3547. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3548. String[] ResetData = WsDB.GetResetSchedule();
  3549. if (!ResetData[0].equals("NONE")) {
  3550. int type = Integer.parseInt(ResetData[0]);
  3551. Log.i("MAINSCREEN","CheckSysResetData Schedule check typr : "+type + " Week : "+today.get(Calendar.DAY_OF_WEEK)+" Set Week : "+ResetData[1]);
  3552. if ((type == WallpadStatusData.RESET_MONTH && today.get(Calendar.DAY_OF_MONTH)+1 == Integer.parseInt(ResetData[1])) ||
  3553. (type == WallpadStatusData.RESET_WEEK && today.get(Calendar.DAY_OF_WEEK) == (Integer.parseInt(ResetData[1]))+1) )
  3554. {
  3555. if (today.get(Calendar.HOUR_OF_DAY) == Integer.parseInt(ResetData[2]) && today.get(Calendar.MINUTE) < 2) {
  3556. SendAppFinishReqBR();
  3557. ComponentName cn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  3558. Intent intent = new Intent(Intent.ACTION_MAIN);
  3559. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  3560. intent.putExtra("updatesystem", "no");
  3561. intent.putExtra("updateapp", " no ");
  3562. intent.putExtra("rebootcmd", "reboot");
  3563. intent.setComponent(cn);
  3564. startActivity(intent);
  3565. }
  3566. }
  3567. }
  3568. WsDB.closeDB();
  3569. } catch (RuntimeException re) {
  3570. LogUtil.errorLogInfo("", TAG, re);
  3571. }
  3572. catch (Exception e) {
  3573. Log.e(TAG, "[Exception] CheckSysResetData()");
  3574. LogUtil.errorLogInfo("", TAG, e);
  3575. }
  3576. }
  3577. private boolean checkMorningCall() {
  3578. try {
  3579. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3580. int AlarmStatus = WsDB.GetAlarmStatus();
  3581. if (AlarmStatus != WallpadStatusData.ALARM_NONE && AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.ALARM_STOP) {
  3582. WsDB.closeDB();
  3583. return false;
  3584. }
  3585. Calendar today = new GregorianCalendar();
  3586. int MCStatus = WsDB.GetMorningCallStatus();
  3587. Log.i(TAG,"[checkMorningCall] GetMorningCallStatus : "+MCStatus);
  3588. if (MCStatus==WallpadStatusData.MORNINGCALL_ON) {
  3589. int MCPer = WsDB.GetMorningCallPeriod();
  3590. Log.i(TAG,"[checkMorningCall] GetMorningCallPeriod : "+MCPer);
  3591. int TodatofWeek = today.get(Calendar.DAY_OF_WEEK);
  3592. if ((MCPer == WallpadStatusData.MORNINGCALL_EWORKDAY && TodatofWeek != Calendar.SUNDAY) ||
  3593. (MCPer == WallpadStatusData.MORNINGCALL_WORKDAY && TodatofWeek!=Calendar.SUNDAY && TodatofWeek != Calendar.SATURDAY) ||
  3594. (MCPer == WallpadStatusData.MORNINGCALL_ONCE || MCPer == WallpadStatusData.MORNINGCALL_EVERYDAY )) {
  3595. Log.i(TAG,"[checkMorningCall] "+today.get(Calendar.HOUR_OF_DAY)+";"+WsDB.MorningHour + " -- " +today.get(Calendar.MINUTE)+":"+WsDB.MorningMin);
  3596. if (today.get(Calendar.HOUR_OF_DAY) == WsDB.MorningHour && today.get(Calendar.MINUTE) == WsDB.MorningMin) {
  3597. SendAppFinishReqBR();
  3598. mIOInterface.ctrlLcdWakeUp();
  3599. StartPopup(ID.POPUPS.POPUP_MORNINGCALL);
  3600. int[] MC_Doing = WsDB.GetMorningCallReserve();
  3601. if (MC_Doing != null && MC_Doing.length > 0) {
  3602. for (int k=0;k<MC_Doing.length;k++) {
  3603. switch (MC_Doing[k]) {
  3604. case WallpadStatusData.MCALLR_VENTIL_ON:
  3605. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  3606. break;
  3607. case WallpadStatusData.MCALLR_LIGHT_ON:
  3608. //에너지 미터인 경우 안방 조명을 켜도록 하고
  3609. //에너지 미터가 안 달린 경우 거실 조명을 켜도록 한다
  3610. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  3611. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3612. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3613. // 안방조명에 1번 조명만 제어하도록 한다
  3614. // 모닝콜이 울리면 일괄소등시나리오에 의해 일괄소등이 해제가 되겠네 ? 음.....이건 아닌데
  3615. // 모닝콜이 울리는 동안만 켜고 끄자 일괄소등 시나리오를 해제할까나? 그러면 팝업 화면에서 제어처리를?
  3616. Log.d(TAG, "[checkMorningCall] mSdbAPI Room 2 - Lamp 1 On");
  3617. if (mSdbAPI != null) {
  3618. int nResult = mSdbAPI.SetLightOnOff((byte) 0x01, (byte) 0x00, true);
  3619. Log.d(TAG, "[checkMorningCall] mSdbAPI nResult = " + nResult);
  3620. }
  3621. }
  3622. else if (Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  3623. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410) {
  3624. Log.d(TAG, "[checkMorningCall] mIntLightAPI Living Room - Lamp 1 On");
  3625. if (mIntLightAPI != null) {
  3626. int nResult = mIntLightAPI.LightControl((byte) 0x01, true);
  3627. Log.d(TAG, "[checkMorningCall] mIntLightAPI nResult = " + nResult);
  3628. }
  3629. }
  3630. else {
  3631. // 대외향 구분하여 처리
  3632. WallpadDeviceSet devDB = new WallpadDeviceSet( getApplicationContext() );
  3633. int[] retArray = devDB.Get_Light_info();
  3634. devDB.closeDB();
  3635. if (retArray!= null && retArray[0] == 1) {
  3636. if (retArray[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  3637. // 거실 스위치
  3638. if (m_LightCtrl != null) {
  3639. m_LightCtrl.Refresh(false);
  3640. m_LightCtrl.SetLightOnOff((byte)0x01, true);
  3641. }
  3642. }
  3643. else {
  3644. // 멀티 스위치
  3645. if (m_MultiSwitch != null) {
  3646. m_MultiSwitch.Refresh((byte)0x00, false);
  3647. if (m_MultiSwitch.data.DeviceCnt > 1) {
  3648. m_MultiSwitch.SetLightOnOff((byte)0x01 ,(byte)0x00 , true);
  3649. }
  3650. else if(m_MultiSwitch.data.DeviceCnt == 1) {
  3651. m_MultiSwitch.SetLightOnOff((byte)0x00 ,(byte)0x00 , true);
  3652. }
  3653. }
  3654. }
  3655. }
  3656. }
  3657. break;
  3658. case WallpadStatusData.MCALLR_CURTAIN_OPEN: //fill lather
  3659. break;
  3660. }
  3661. }
  3662. }
  3663. if (MCPer == WallpadStatusData.MORNINGCALL_ONCE) {
  3664. // Button morning = (Button)findViewById(R.id.top_alarm);
  3665. // morning.setVisibility(View.INVISIBLE);
  3666. WsDB.SetMorningCall(WallpadStatusData.MORNINGCALL_OFF, WsDB.MorningHour, WsDB.MorningMin);
  3667. }
  3668. }
  3669. }
  3670. }
  3671. WsDB.closeDB();
  3672. } catch (RuntimeException re) {
  3673. LogUtil.errorLogInfo("", TAG, re);
  3674. }
  3675. catch (Exception e) {
  3676. LogUtil.errorLogInfo("", TAG, e);
  3677. }
  3678. return false;
  3679. }
  3680. private void scheduleCheck()
  3681. {
  3682. try
  3683. {
  3684. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++");
  3685. Log.d("scheduleCheck", "Enter scheduleCheck "+GeneralData.size()+" : "+SchedulerData.size());
  3686. checkMorningCall();
  3687. if (GeneralData.size() > 0)
  3688. {
  3689. for (int i = 0;i < GeneralData.size(); i++)
  3690. {
  3691. TimeScheduleUnit scUnit = GeneralData.get(i);
  3692. if (scUnit.isOver())
  3693. {
  3694. switch (scUnit.type)
  3695. {
  3696. case SCHEDULE_TYPE_SYSRESET:
  3697. GeneralData.remove(scUnit);
  3698. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++ SCHEDULE_TYPE_SYSRESET");
  3699. SendAppFinishReqBR();
  3700. ComponentName cn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  3701. Intent intent = new Intent(Intent.ACTION_MAIN);
  3702. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  3703. intent.putExtra("updatesystem", "no");
  3704. intent.putExtra("updateapp", "no");
  3705. intent.putExtra("rebootcmd", "reboot");
  3706. intent.setComponent(cn);
  3707. startActivity(intent);
  3708. break;
  3709. case SCHEDULE_TYPE_GETINFO:
  3710. GeneralData.remove(scUnit);
  3711. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++ SCHEDULE_TYPE_GETINFO");
  3712. WallPadiMAPNotifyAPI notifyAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  3713. notifyAPI.ReqGetSet();
  3714. break;
  3715. }
  3716. }
  3717. }
  3718. Log.d("scheduleCheck", "after scheduleCheck "+GeneralData.size() );
  3719. }
  3720. }
  3721. catch (RuntimeException re) {
  3722. LogUtil.errorLogInfo("", TAG, re);
  3723. }
  3724. catch (Exception e)
  3725. {
  3726. LogUtil.errorLogInfo("", TAG, e);
  3727. }
  3728. }
  3729. public void doSchedule(String mess, int cnt)
  3730. {
  3731. // SendAppFinishReqBR();
  3732. // Intent intent = new Intent(getApplicationContext(), schedulepopup.class);
  3733. // String SendMSG = mess;
  3734. // if (cnt > 1) SendMSG+=(" 외 "+cnt+"건을 알려드립니다.");
  3735. // intent.putExtra("MESSAGE", SendMSG);
  3736. // Log.i("MAINSCREEN","Call Schedule POPUP");
  3737. // startActivity(intent);
  3738. }
  3739. public void refreshSchedulerData()
  3740. {
  3741. try
  3742. {
  3743. SchedulerData.clear();
  3744. WallpadScheduleData schedata = new WallpadScheduleData(getApplicationContext());
  3745. List<WallpadScheduleData.ScheduleData> scheduledata = schedata.GetTodaySchedule();
  3746. Log.i("MAINSCREEN","refreshSchedulerData "+scheduledata.size());
  3747. for(int i=0;i<scheduledata.size();i++)
  3748. {
  3749. WallpadScheduleData.ScheduleData ScUnit = scheduledata.get(i);
  3750. int hour;
  3751. int min;
  3752. Log.i("MAINSCREEN","refreshSchedulerData "+ScUnit.inqatype+" : "+ScUnit.inqhour+" : ");
  3753. if (ScUnit.inqatype.equals("no")) continue;
  3754. else if (ScUnit.inqatype.equals("intime")||ScUnit.inqatype.equals("day"))
  3755. {
  3756. hour = ScUnit.inqhour;
  3757. min = 0;
  3758. }
  3759. else if (ScUnit.inqatype.equals("hour"))
  3760. {
  3761. hour = ScUnit.inqhour-1;
  3762. if (hour < 0) continue;
  3763. min = 0;
  3764. }
  3765. else if (ScUnit.inqatype.equals("min"))
  3766. {
  3767. hour = ScUnit.inqhour-1;
  3768. if (hour < 0) continue;
  3769. min = 50;
  3770. }
  3771. else
  3772. continue;
  3773. Calendar today = new GregorianCalendar();
  3774. int MoonM = 0;
  3775. int MoonD = 0;
  3776. try
  3777. {
  3778. String Moon = schedata.GetLunarDate(String.format("%04d%02d%02d", today.get(Calendar.YEAR),today.get(Calendar.MONTH)+1,today.get(Calendar.DAY_OF_MONTH) ));
  3779. if(Moon!=null)
  3780. {
  3781. MoonM = Integer.parseInt(Moon.substring(4, 6));
  3782. MoonD = Integer.parseInt(Moon.substring(6, 8));
  3783. Log.i("MAINSCREEN", " Get Lunar Date "+Moon+" : "+MoonM+"/"+MoonD);
  3784. }
  3785. }
  3786. catch (RuntimeException re) {
  3787. LogUtil.errorLogInfo("", TAG, re);
  3788. }
  3789. catch (Exception e)
  3790. {
  3791. LogUtil.errorLogInfo("", TAG, e);
  3792. MoonM = 0;
  3793. MoonD = 0;
  3794. }
  3795. today.set(Calendar.HOUR_OF_DAY, hour);
  3796. today.set(Calendar.MINUTE, min);
  3797. 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;
  3798. Log.i("MAINSCREEN","refreshSchedulerData add "+ScUnit.inqatype+" : "+ScUnit.inqhour+" : "+Mesg);
  3799. TimeScheduleUnit newUnit = new TimeScheduleUnit(SCHEDULE_TYPE_SCHEDULER, today, Mesg);
  3800. isSetted = true;
  3801. SchedulerData.add(newUnit);
  3802. }
  3803. schedata.closeDB();
  3804. }
  3805. catch (RuntimeException re) {
  3806. LogUtil.errorLogInfo("", TAG, re);
  3807. }
  3808. catch (Exception e)
  3809. {
  3810. LogUtil.errorLogInfo("", TAG, e);
  3811. }
  3812. }
  3813. public void refreshMorningCall()
  3814. {
  3815. try
  3816. {
  3817. for (int i = 0; i < GeneralData.size(); i++)
  3818. {
  3819. TimeScheduleUnit scUnit = SchedulerData.get(i);
  3820. if (scUnit.type == SCHEDULE_TYPE_MORNINGCALL)
  3821. {
  3822. SchedulerData.remove(i);
  3823. break;
  3824. }
  3825. }
  3826. SetMorningCallData();
  3827. }
  3828. catch (RuntimeException re) {
  3829. LogUtil.errorLogInfo("", TAG, re);
  3830. }
  3831. catch (Exception e)
  3832. {
  3833. LogUtil.errorLogInfo("", TAG, e);
  3834. }
  3835. }
  3836. private void SetMorningCallData()
  3837. {
  3838. try
  3839. {
  3840. Log.i("MAINSCREEN","SetMorningCallData Schedule");
  3841. Calendar today = new GregorianCalendar();
  3842. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3843. int MCStatus = WsDB.GetMorningCallStatus();
  3844. if (MCStatus==WallpadStatusData.MORNINGCALL_ON)
  3845. {
  3846. int MCPer = WsDB.GetMorningCallPeriod();
  3847. int TodatofWeek = today.get(Calendar.DAY_OF_WEEK);
  3848. if ((MCPer == WallpadStatusData.MORNINGCALL_EWORKDAY && TodatofWeek != Calendar.SUNDAY) &&
  3849. (MCPer == WallpadStatusData.MORNINGCALL_WORKDAY && TodatofWeek!=Calendar.SUNDAY && TodatofWeek != Calendar.SATURDAY) &&
  3850. (MCPer == WallpadStatusData.MORNINGCALL_ONCE || MCPer == WallpadStatusData.MORNINGCALL_EVERYDAY ))
  3851. {
  3852. today.set(Calendar.HOUR_OF_DAY, WsDB.MorningHour);
  3853. today.set(Calendar.MINUTE, WsDB.MorningMin);
  3854. today.set(Calendar.SECOND, 0);
  3855. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_MORNINGCALL, today);
  3856. if (!scUnit.isOver())
  3857. {
  3858. isSetted = true;
  3859. // Button morning = (Button)findViewById(R.id.top_alarm);
  3860. // morning.setVisibility(View.VISIBLE);
  3861. GeneralData.add(scUnit);
  3862. }
  3863. else
  3864. {
  3865. // Button morning = (Button)findViewById(R.id.top_alarm);
  3866. // morning.setVisibility(View.INVISIBLE);
  3867. }
  3868. }
  3869. }
  3870. WsDB.closeDB();
  3871. }
  3872. catch (RuntimeException re) {
  3873. LogUtil.errorLogInfo("", TAG, re);
  3874. }
  3875. catch (Exception e)
  3876. {
  3877. LogUtil.errorLogInfo("", TAG, e);
  3878. }
  3879. }
  3880. public void refreshsysreset()
  3881. {
  3882. try
  3883. {
  3884. Log.i("MAINSCREEN","refreshsysreset Schedule");
  3885. for (int i = 0; i < GeneralData.size(); i++)
  3886. {
  3887. TimeScheduleUnit scUnit = SchedulerData.get(i);
  3888. if (scUnit.type == SCHEDULE_TYPE_SYSRESET)
  3889. {
  3890. SchedulerData.remove(i);
  3891. break;
  3892. }
  3893. }
  3894. SetSysResetData();
  3895. }
  3896. catch (RuntimeException re) {
  3897. LogUtil.errorLogInfo("", TAG, re);
  3898. }
  3899. catch (Exception e)
  3900. {
  3901. LogUtil.errorLogInfo("", TAG, e);
  3902. }
  3903. }
  3904. private void SetSysResetData()
  3905. {
  3906. try
  3907. {
  3908. Calendar today = new GregorianCalendar();
  3909. Log.i("MAINSCREEN","SetSysResetData Schedule");
  3910. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3911. String[] ResetData = WsDB.GetResetSchedule();
  3912. if (!ResetData[0].equals("NONE"))
  3913. {
  3914. int type = Integer.parseInt(ResetData[0]);
  3915. if ((type == WallpadStatusData.RESET_MONTH && today.get(Calendar.DAY_OF_MONTH) == Integer.parseInt(ResetData[1])) ||
  3916. (type == WallpadStatusData.RESET_WEEK && today.get(Calendar.DAY_OF_WEEK) == Integer.parseInt(ResetData[1])) )
  3917. {
  3918. Log.i("MAINSCREEN","SetSysResetData Setted");
  3919. today.set(Calendar.HOUR_OF_DAY, Integer.parseInt(ResetData[2]));
  3920. today.set(Calendar.MINUTE, 0);
  3921. today.set(Calendar.SECOND, 0);
  3922. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_SYSRESET, today);
  3923. if (!scUnit.isOver())
  3924. {
  3925. isSetted = true;
  3926. GeneralData.add(scUnit);
  3927. }
  3928. }
  3929. }
  3930. WsDB.closeDB();
  3931. }
  3932. catch (RuntimeException re) {
  3933. LogUtil.errorLogInfo("", TAG, re);
  3934. }
  3935. catch (Exception e)
  3936. {
  3937. LogUtil.errorLogInfo("", TAG, e);
  3938. }
  3939. }
  3940. public void refreshSchedule()
  3941. {
  3942. try
  3943. {
  3944. Log.i("MAINSCREEN","Refresh Schedule");
  3945. GeneralData.clear();
  3946. Calendar today = new GregorianCalendar();
  3947. // 하루에 한번 가져오는 걸로 변경함
  3948. //if (today.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY)
  3949. {
  3950. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  3951. AddressSet addc = SetData.getAddressMGR();
  3952. SetData.closeDB();
  3953. int dong = Integer.parseInt(addc.Dong);
  3954. int ho = 101;
  3955. if(addc.UseOrNotRentHouse == true)
  3956. {
  3957. ho = addc.Ho_Integer;
  3958. }
  3959. else
  3960. {
  3961. ho = Integer.parseInt(addc.Ho);
  3962. }
  3963. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  3964. int hour;
  3965. int min;
  3966. int sec;
  3967. if (interval/3600 > 0)
  3968. {
  3969. hour = 3+interval/3600;
  3970. interval=interval%3600;
  3971. }
  3972. else hour = 3;
  3973. if (interval/60 > 0)
  3974. {
  3975. min = interval/60;
  3976. sec = interval%60;
  3977. }
  3978. else
  3979. {
  3980. min = 0;
  3981. sec = interval;
  3982. }
  3983. today.set(Calendar.HOUR_OF_DAY, hour);
  3984. today.set(Calendar.MINUTE, min);
  3985. today.set(Calendar.SECOND, sec);
  3986. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_GETINFO, today);
  3987. if (!scUnit.isOver())
  3988. GeneralData.add(scUnit);
  3989. }
  3990. SetMorningCallData();
  3991. SetSysResetData();
  3992. refreshSchedulerData();
  3993. }
  3994. catch (RuntimeException re) {
  3995. LogUtil.errorLogInfo("", TAG, re);
  3996. }
  3997. catch (Exception e)
  3998. {
  3999. LogUtil.errorLogInfo("", TAG, e);
  4000. }
  4001. }
  4002. }
  4003. class runCallServices extends Thread {
  4004. public runCallServices() {
  4005. super();
  4006. }
  4007. public void run() {
  4008. try {
  4009. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  4010. if (getIsSubWallpad()) {
  4011. Log.w(TAG, "[runCallServices.run()] ############### This wallpad is set as a sub-wallpad ###############");
  4012. Intent SubWallpadServiceLauncher = new Intent ("kr.co.icontrols.callengine.subwallpad.SubWallPadSerialManager.StartService");
  4013. getApplicationContext().startService(SubWallpadServiceLauncher);
  4014. }
  4015. else {
  4016. Log.w(TAG, "[runCallServices.run()] ############### This wallpad is set as a main-wallpad ###############");
  4017. // SIP/Subphone 서비스 실행
  4018. Intent SIPServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  4019. getApplicationContext().startService(SIPServiceLauncher);
  4020. Intent SubPhoneServiceLauncher = new Intent ("kr.co.icontrols.callengine.subphone.SubPhoneSerialManager.StartService");
  4021. getApplicationContext().startService(SubPhoneServiceLauncher);
  4022. if (GetRemoteCallUseInfo()) {
  4023. Intent remoteCallServiceLauncher = new Intent ("kr.co.icontrols.callengine.remotecall.RemoteCallManager.StartService");
  4024. getApplicationContext().startService(remoteCallServiceLauncher);
  4025. }
  4026. }
  4027. }
  4028. else {
  4029. int nModelType = Version.getModelType();
  4030. if (nModelType == MODEL_TYPE.IHN_750) {
  4031. // SIP 서비스만 실행
  4032. Intent sipServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  4033. getApplicationContext().startService(sipServiceLauncher);
  4034. }
  4035. else {
  4036. // SIP/PSTN/Subphone 서비스 실행
  4037. Intent sipServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  4038. getApplicationContext().startService(sipServiceLauncher);
  4039. Intent PSTNServiceLauncher = new Intent ("kr.co.icontrols.callengine.pstn.PSTNSerialManager.StartService");
  4040. getApplicationContext().startService(PSTNServiceLauncher);
  4041. Intent SubPhoneServiceLauncher = new Intent ("kr.co.icontrols.callengine.subphone.SubPhoneSerialManager.StartService");
  4042. getApplicationContext().startService(SubPhoneServiceLauncher);
  4043. }
  4044. }
  4045. } catch (RuntimeException re) {
  4046. LogUtil.errorLogInfo("", TAG, re);
  4047. }
  4048. catch (Exception e) {
  4049. Log.e(TAG, "[Exception] runCallServices().run()");
  4050. LogUtil.errorLogInfo("", TAG, e);
  4051. }
  4052. }
  4053. }
  4054. // 방문객원격통화 솔루션 사용여부 판별
  4055. private boolean GetRemoteCallUseInfo() {
  4056. try {
  4057. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  4058. if (mWallpadDeviceSet != null) {
  4059. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  4060. if (astrRemoteCall != null) {
  4061. if (astrRemoteCall[1].contains("사용함"))
  4062. return true;
  4063. } else {
  4064. Log.d(TAG, "[GetRemoteCallUseInfo] astrRemoteCall is null!!");
  4065. }
  4066. }
  4067. mWallpadDeviceSet.closeDB();
  4068. } catch (RuntimeException re) {
  4069. LogUtil.errorLogInfo("", TAG, re);
  4070. }
  4071. catch (Exception e) {
  4072. Log.e(TAG, "[Exception] GetRemoteCallUseInfo()");
  4073. LogUtil.errorLogInfo("", TAG, e);
  4074. }
  4075. return false;
  4076. }
  4077. int UNINSTALL_REQUEST_CODE = 1;
  4078. private void uninstallAnCCallApp(String strAPK) {
  4079. try {
  4080. Log.w(TAG, "[uninstallAnCCallApp] strAPK [" + strAPK + "]");
  4081. if (checkAppInstalled(strAPK)) {
  4082. // Intent mIntent = new Intent(Intent.ACTION_DELETE);
  4083. Intent mIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
  4084. mIntent.setData(Uri.parse("package:" + strAPK));
  4085. mIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
  4086. startActivityForResult(mIntent, UNINSTALL_REQUEST_CODE);
  4087. }
  4088. else {
  4089. Log.w(TAG, "[uninstallAnCCallApp] Not installed [" + strAPK + "]");
  4090. }
  4091. } catch (RuntimeException re) {
  4092. LogUtil.errorLogInfo("", TAG, re);
  4093. }
  4094. catch (Exception e) {;
  4095. Log.e(TAG, "[Exception] uninstallAnCCallApp()");
  4096. LogUtil.errorLogInfo("", TAG, e);
  4097. }
  4098. }
  4099. private boolean checkAppInstalled(String strAPK) {
  4100. try {
  4101. PackageManager mPackageManager = getPackageManager();
  4102. try {
  4103. mPackageManager.getPackageInfo(strAPK, PackageManager.GET_ACTIVITIES);
  4104. return true;
  4105. } catch (PackageManager.NameNotFoundException pne) {
  4106. Log.w(TAG, "[checkAppInstalled] No Package [" + strAPK + "]");
  4107. }
  4108. return false;
  4109. } catch (RuntimeException re) {
  4110. LogUtil.errorLogInfo("", TAG, re);
  4111. return false;
  4112. }
  4113. catch (Exception e) {
  4114. Log.e(TAG, "[Exception] checkAppInstalled(String strAPK)");
  4115. LogUtil.errorLogInfo("", TAG, e);
  4116. return false;
  4117. }
  4118. }
  4119. private boolean MainSubScreenLoadingComplite = false;
  4120. public boolean getMainSubScreenLoadingComplite() {
  4121. return MainSubScreenLoadingComplite;
  4122. }
  4123. /**
  4124. * 설치된 모든 어플의 이름/버전정보 Version DB에 저장하는 쓰레드. <br>
  4125. * main Activity 생성 시 최초 1회 실행 후 die
  4126. */
  4127. class getInstalledPackageInfo extends Thread {
  4128. @Override
  4129. public void run() {
  4130. super.run();
  4131. try {
  4132. Log.d(TAG, "[getInstalledPackageInfo] Started getting installed package infomation");
  4133. ArrayList<PackageVersionInfo> PackageVersionInfos = new ArrayList<PackageVersionInfo>();
  4134. List<PackageInfo> PackageInfoList = getPackageManager().getInstalledPackages(PackageManager.PERMISSION_GRANTED);
  4135. while (true) {
  4136. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages start!!");
  4137. try {
  4138. for (PackageInfo pack : PackageInfoList) {
  4139. Log.d(TAG, "# PackageName : " + pack.packageName);
  4140. Log.d(TAG, "# VersionName : " + pack.versionName);
  4141. if ((pack.packageName.contains("icontrols")) || (pack.packageName.contains("artncore")) || (pack.packageName.contains("dadam"))) {
  4142. PackageVersionInfos.add(new PackageVersionInfo(pack.packageName, pack.versionName));
  4143. }
  4144. }
  4145. } catch (RuntimeException re) {
  4146. LogUtil.errorLogInfo("", TAG, re);
  4147. break;
  4148. }
  4149. catch (Exception e) {
  4150. LogUtil.errorLogInfo("", TAG, e);
  4151. break;
  4152. }
  4153. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages end!!");
  4154. break;
  4155. }
  4156. Log.d(TAG, "[getInstalledPackageInfo.run()] Save installed packages start!!");
  4157. wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  4158. if (PackageVersionInfos != null) {
  4159. for (int i = 0; i < PackageVersionInfos.size(); i++) {
  4160. WallpadDBMGR.UpdateVersionData(PackageVersionInfos.get(i).getPackageName(), PackageVersionInfos.get(i).getPackageVersion());
  4161. }
  4162. }
  4163. WallpadDBMGR.closeDB();
  4164. Log.d(TAG, "[getInstalledPackageInfo.run()] Save installed packages end!!");
  4165. try {
  4166. Thread.sleep(1500);
  4167. } catch (RuntimeException re) {
  4168. LogUtil.errorLogInfo("", TAG, re);
  4169. }
  4170. catch (Exception e) {
  4171. LogUtil.errorLogInfo("", TAG, e);
  4172. }
  4173. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  4174. try {
  4175. Thread.sleep(1000);
  4176. } catch (RuntimeException re) {
  4177. LogUtil.errorLogInfo("", TAG, re);
  4178. }
  4179. catch (Exception e) {
  4180. LogUtil.errorLogInfo("", TAG, e);
  4181. }
  4182. }
  4183. runOnUiThread(new Runnable() {
  4184. @Override
  4185. public void run() {
  4186. registerSubScreen();
  4187. }
  4188. });
  4189. try
  4190. {
  4191. WallpadScheduleData schedb = new WallpadScheduleData(getApplicationContext());
  4192. boolean bLunarTableExist = schedb.CheckLunarTable();
  4193. schedb.closeDB();
  4194. if (!bLunarTableExist) {
  4195. try {
  4196. Log.d(TAG, "DB File Copy Start");
  4197. copyDataBase(wallpaddbmgr.dblocation + "/" + wallpaddbmgr.Schedule_LunaDB);
  4198. Log.d(TAG, "DB File Copy End");
  4199. } catch (IOException e) {
  4200. LogUtil.errorLogInfo("", TAG, e);
  4201. }
  4202. }
  4203. } catch (RuntimeException re) {
  4204. LogUtil.errorLogInfo("", TAG, re);
  4205. }
  4206. catch (Exception e) {
  4207. LogUtil.errorLogInfo("", TAG, e);
  4208. }
  4209. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) checkDongHoSetting();
  4210. checkDongHoSetting();
  4211. if (Common.GetElevatorSampleMode(getApplicationContext())) {
  4212. int retCount = EnergyAlramPopupMgr.get_WallPadRebootingCount( getApplicationContext()) + 1;
  4213. EnergyAlramPopupMgr.set_WallPadRebootingCount(getApplicationContext(), retCount);
  4214. Log.d(TAG, "################################# rebooting Count : " + retCount );
  4215. }
  4216. // 하드웨어 키 샘플 모드 동작 여부 설정
  4217. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  4218. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  4219. sdata.closeDB();
  4220. WallPadInterface wpdifc = new WallPadInterface();
  4221. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  4222. wpdifc.DoControl(WallPadInterface.IOCTL_KEY_ONOFF_SET, 0);
  4223. CheckEnv();
  4224. }
  4225. catch (RuntimeException re) {
  4226. LogUtil.errorLogInfo("", TAG, re);
  4227. }
  4228. catch (Exception e)
  4229. {
  4230. LogUtil.errorLogInfo("", TAG, e);
  4231. }
  4232. try {Thread.sleep(5000);}
  4233. catch (RuntimeException re) {
  4234. LogUtil.errorLogInfo("", TAG, re);
  4235. MainSubScreenLoadingComplite = true;
  4236. }
  4237. catch (Exception e){LogUtil.errorLogInfo("", TAG, e);}
  4238. MainSubScreenLoadingComplite = true;
  4239. }
  4240. }
  4241. public static String DB_WALLPAD_WIDGET_INIT = "DB_WALLPAD_WIDGET_INIT";
  4242. public void set_WallPadWidgetInit(Context context) {
  4243. try {
  4244. wallpaddbmgr mgr = new wallpaddbmgr(context);
  4245. boolean bRet = mgr.UpdateWallPADData(DB_WALLPAD_WIDGET_INIT, String.valueOf(1));
  4246. if (bRet == false ) {
  4247. Log.d(TAG, "----- DB_WALLPAD_WIDGET_INIT insert ==> false ");
  4248. mgr.insertWallPADDB(DB_WALLPAD_WIDGET_INIT, "1");
  4249. }
  4250. mgr.closeDB();
  4251. } catch (RuntimeException re) {
  4252. LogUtil.errorLogInfo("", TAG, re);
  4253. }
  4254. catch (Exception e) {
  4255. LogUtil.errorLogInfo("", TAG, e);
  4256. }
  4257. }
  4258. public int get_WallPadWidgetInit(Context context) {
  4259. int ret = 0;
  4260. try {
  4261. wallpaddbmgr mgr = new wallpaddbmgr(context);
  4262. String strRet = mgr.GetWallPADData(DB_WALLPAD_WIDGET_INIT);
  4263. if (strRet == null) {
  4264. Log.d(TAG, "----- get_WallPadRebootingCount strRet == null && insert ==> false ");
  4265. mgr.insertWallPADDB(DB_WALLPAD_WIDGET_INIT, "0");
  4266. return 0;
  4267. }
  4268. ret = Integer.parseInt(strRet);
  4269. mgr.closeDB();
  4270. } catch (RuntimeException re) {
  4271. LogUtil.errorLogInfo("", TAG, re);
  4272. }
  4273. catch (Exception e) {
  4274. LogUtil.errorLogInfo("", TAG, e);
  4275. }
  4276. return ret;
  4277. }
  4278. /**
  4279. * 스케줄 관련 처리 핸들러 추가
  4280. * 모닝콜, 일정관리, 엘리베이터 호출상태, 에너지 사용량 확인
  4281. * 현재는 사용하지 않음. checkTimeTasks()로 대체
  4282. */
  4283. private int nDay, nHour, nMin;
  4284. Handler Checker = new Handler() {
  4285. public void handleMessage(Message msg) {
  4286. super.handleMessage(msg);
  4287. Calendar cal = new GregorianCalendar();
  4288. if (cal.get(Calendar.DAY_OF_MONTH) != nDay) {
  4289. // 날짜가 바뀌었을때...
  4290. nDay = cal.get(Calendar.DAY_OF_MONTH);
  4291. Log.d(TAG , "-----------------day change repeat");
  4292. if (SCManager != null) {
  4293. if (SYSTEM_TIME_SET)SCManager.refreshSchedule();
  4294. }
  4295. //
  4296. // Intent intent = new Intent();
  4297. // intent.setAction(define.NOTIFY_ACNAME);
  4298. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DAYCHANGED);
  4299. // getApplicationContext().sendBroadcast(intent);
  4300. //에너지사용량 알림 초기화
  4301. ClearEnergyUsage();
  4302. Log.d(TAG , "cal.get(Calendar.YEAR) :" + cal.get(Calendar.YEAR) );
  4303. if ((bUseofNot_ZeroEnergyHouseInfo == true) && (cal.get(Calendar.YEAR) > 2016) && (SYSTEM_TIME_SET == true)) {
  4304. //어제 시간 재입력
  4305. Log.d(TAG , "/**********************************************/");
  4306. Log.d(TAG , "GetZeroEnergyHouseInfo_RandomCheckHandler(true);");
  4307. Log.d(TAG , "/**********************************************/");
  4308. DayofLastSecond = StringUtil.GetDayofLastSecondTimeString(cal); //하루전 날짜의 마지막 시간 입력
  4309. Log.d(TAG , "DayofLastSecond : "+ DayofLastSecond);
  4310. }
  4311. }
  4312. if (cal.get(Calendar.HOUR_OF_DAY) != nHour) {
  4313. nHour = cal.get(Calendar.HOUR_OF_DAY);
  4314. DoScheduleHourUnit(cal);
  4315. }
  4316. if (cal.get(Calendar.MINUTE) != nMin) {
  4317. nMin = cal.get(Calendar.MINUTE);
  4318. /**
  4319. * A20월패드 BSP는 전자액자 실행을 시키지 않기때문에 main app에서 전자액자 실행 여부 확인하여
  4320. * 실행시킴
  4321. * **/
  4322. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A20) {
  4323. Log.i(TAG, "[Checker handler] ========== JEFF 1 ========== m_LiveMainActivity : " + m_LiveMainActivity);
  4324. if (m_LiveMainActivity > 0) {
  4325. String LCD_Sleep_Status = null;
  4326. Runtime runtime = Runtime.getRuntime();
  4327. Process process;
  4328. try {
  4329. String cmd = "getprop persist.sys.display.lcdoff";
  4330. process = runtime.exec(cmd);
  4331. BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
  4332. String line;
  4333. while ((line = br.readLine()) != null) {
  4334. LCD_Sleep_Status = line;
  4335. }
  4336. } catch (RuntimeException re) {
  4337. LogUtil.errorLogInfo("", TAG, re);
  4338. }
  4339. catch (Exception e) {
  4340. e.fillInStackTrace();
  4341. Log.e("Process Manager", "Unable to execute top command");
  4342. }
  4343. if (LCD_Sleep_Status != null) {
  4344. Log.d(TAG, "The LCD_Sleep_Status : " + LCD_Sleep_Status);
  4345. if (LCD_Sleep_Status.equals("1") == true) {
  4346. // LCD 꺼져있음
  4347. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4348. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4349. if (SettData.StartAutoPictureAPP() == true) {
  4350. Log.d(TAG, "StartAutoPictureAPP is true");
  4351. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  4352. // pm.userActivity(2, true);
  4353. // LCD backlight normal
  4354. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4355. Log.d(TAG, "PowerManager will be set");
  4356. }
  4357. else {
  4358. Log.d(TAG, "StartAutoPictureAPP is false");
  4359. }
  4360. }
  4361. else {
  4362. Log.d(TAG, "DecideAutoPictureAppStartOrNot is false");
  4363. }
  4364. SettData.closeDB();
  4365. }
  4366. }
  4367. else {
  4368. Log.e(TAG, "The LCD_Sleep_Status is null");
  4369. }
  4370. }
  4371. }
  4372. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  4373. Log.i(TAG, "[Checker handler] ========== JEFF 2 ========== m_LiveMainActivity : " + m_LiveMainActivity);
  4374. if (m_LiveMainActivity > 0) {
  4375. boolean bisScreenOn = false;
  4376. if (getCompareBSPVersion()) {
  4377. bisScreenOn = checkLCDOnByCMD();
  4378. }
  4379. else {
  4380. PowerManager mPowerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
  4381. bisScreenOn = mPowerManager.isScreenOn();
  4382. }
  4383. Log.i(TAG, "[Checker handler] bisScreenOn : " + bisScreenOn);
  4384. if (!bisScreenOn) {
  4385. if (getBlackoutStatus()) {
  4386. Log.i(TAG, "[Checker handler] getBlackoutStatus is true!!!");
  4387. sendBlackoutScreenRunBR();
  4388. }
  4389. else {
  4390. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4391. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4392. if (SettData.StartAutoPictureAPP() == true) {
  4393. Log.d(TAG, "StartAutoPictureAPP is true");
  4394. mIOInterface.ctrlLcdWakeUp();
  4395. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4396. Log.d(TAG, "PowerManager will be set");
  4397. }
  4398. else {
  4399. Log.d(TAG, "StartAutoPictureAPP is false");
  4400. }
  4401. }
  4402. else {
  4403. Log.d(TAG, "DecideAutoPictureAppStartOrNot is false");
  4404. }
  4405. SettData.closeDB();
  4406. }
  4407. }
  4408. }
  4409. }
  4410. if ((nMin == 50) || (nMin == 0)) {
  4411. try {
  4412. checkScheduleReminder();
  4413. } catch (RuntimeException re) {
  4414. LogUtil.errorLogInfo("", TAG, re);
  4415. }
  4416. catch (Exception e) {
  4417. LogUtil.errorLogInfo("", TAG, e);
  4418. }
  4419. // 스케줄 일정 알람 팝업을 띄우도록 한다.
  4420. // Intent intent = new Intent(getApplicationContext(), schedulepopup.class);
  4421. // String SendMSG = doSchedule.get(0).inqmsg;
  4422. // if (doSchedule.size() > 1) SendMSG+=(" 외 "+doSchedule.size()+"건을 알려드립니다.");
  4423. // intent.putExtra("MESSAGE", SendMSG);
  4424. //
  4425. // startActivity(intent);
  4426. }
  4427. if (SCManager != null) SCManager.scheduleCheck();
  4428. //CheckElevator();
  4429. if (MAX_BOOTUP_RETRY_COUNT < bootupretryCNT && SYSTEM_TIME_SET == false) {
  4430. try {
  4431. WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4432. iMAPMethod.ReqGetSet();
  4433. } catch (RuntimeException re) {
  4434. LogUtil.errorLogInfo("", TAG, re);
  4435. }
  4436. catch (Exception e) {
  4437. LogUtil.errorLogInfo("", TAG, e);
  4438. }
  4439. }
  4440. // 중복.... 이게 왜 있는겨....
  4441. // if ( cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY && SYSTEM_TIME_SET && cal.get(Calendar.DAY_OF_MONTH)!=LastTimeSync)
  4442. // {
  4443. // Calendar checktime = GetTimeSyncTime();
  4444. // if (checktime != null)
  4445. // {
  4446. // if (cal.after(checktime))
  4447. // {
  4448. // LastTimeSync = cal.get(Calendar.DAY_OF_MONTH);
  4449. // WallpadStatusData wpd = new WallpadStatusData(getApplicationContext());
  4450. // wpd.SetLastTimeSyncDate(LastTimeSync);
  4451. // wpd.closeDB();
  4452. // WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4453. // iMAPMethod.ReqGetSet();
  4454. // }
  4455. // }
  4456. // }
  4457. //주차정보 관련 20분 마다 얻어오기
  4458. if (bUseofNot_ParkingInfo == true) {
  4459. cGetParkingMin++;
  4460. //테스트
  4461. /*
  4462. bSetMSG_GetParkingInfo = true;
  4463. LoadParkingDataFromServer();
  4464. */
  4465. if (cGetParkingMin >= 20) {
  4466. // 20분으로 고정
  4467. cGetParkingMin = 0;
  4468. //아이콘트롤스 일때도 처리하지 않도록 수정필요
  4469. //넥스파인 경우는 협의후 처리
  4470. switch (nParkingSystemType) {
  4471. case Common.PARKING_SYSTEM_ICONTROLS:
  4472. case Common.PARKING_SYSTEM_NEXPA:
  4473. case Common.PARKING_SYSTEM_UPIS:
  4474. case Common.PARKING_SYSTEM_IES_100:
  4475. break;
  4476. case Common.PARKING_SYSTEM_BASIC:
  4477. case Common.PARKING_SYSTEM_ETC:
  4478. GetParkingInfo_RandomCheckHandler(); //주차 정보 얻어오기
  4479. break;
  4480. default:
  4481. break;
  4482. }
  4483. }
  4484. }
  4485. // 필요없는 코드 삭제 ( yskim 2015.03.31 )
  4486. // String checkDate = String.format("%04d%02d%02d",cal.get(Calendar.YEAR),cal.get(Calendar.MONTH)+1,cal.get(Calendar.DAY_OF_MONTH));
  4487. // WallpadStatusData energyData = new WallpadStatusData(getApplicationContext());
  4488. // String EnergyCheckData = energyData.GetEnergyCheckDate();
  4489. // energyData.closeDB();
  4490. // if (SYSTEM_TIME_SET)
  4491. // {
  4492. // Calendar checktime = GetEnergyDataLoadingTime();
  4493. // if (!checkDate.equals(EnergyCheckData))
  4494. // {
  4495. // if (checktime != null)
  4496. // {
  4497. //
  4498. // if (cal.after(checktime))
  4499. // {
  4500. // WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4501. // iMAPMethod.GetEnergyUsage();
  4502. // WallPadiMAPNotifyAPI iMAPMethod2 = new WallPadiMAPNotifyAPI(getApplicationContext());
  4503. // iMAPMethod2.GetEnergyUsageMonth();
  4504. // }
  4505. // }
  4506. // }
  4507. // }
  4508. }
  4509. // checkMainPage();
  4510. Checker.sendEmptyMessageDelayed(0, 1000);
  4511. }
  4512. };
  4513. /**
  4514. * JEFF, 2019.12.25
  4515. * 매 1초마다 실행되면서 스케쥴 확인하여 각 기능을 동작시킨다 (시간업데이트, 전자액자 등)
  4516. */
  4517. Handler handlerEverySecond = new Handler() {
  4518. public void handleMessage(Message msg) {
  4519. super.handleMessage(msg);
  4520. checkTimeTasks();
  4521. handlerEverySecond.sendEmptyMessageDelayed(0, 1000);
  4522. }
  4523. };
  4524. private void checkTimeTasks() {
  4525. try {
  4526. // Log.d(TAG , "[checkTimeTasks] ===== START =====");
  4527. Calendar cal = new GregorianCalendar();
  4528. if (cal.get(Calendar.DAY_OF_MONTH) != nDay) {
  4529. // 날짜 변경시
  4530. Log.d(TAG , "[checkTimeTasks] day changed!!");
  4531. nDay = cal.get(Calendar.DAY_OF_MONTH);
  4532. if (SCManager != null) {
  4533. if (SYSTEM_TIME_SET) SCManager.refreshSchedule();
  4534. }
  4535. else {
  4536. Log.w(TAG , "[checkTimeTasks] SYSTEM_TIME_SET is null!!");
  4537. }
  4538. // 모바일연동 서비스로 원격검침 데이터를 전송
  4539. // getTelemeteringDataOnRandomTime();
  4540. // // 에너지사용량 알림 초기화
  4541. // ClearEnergyUsage();
  4542. Log.d(TAG , "[checkTimeTasks] Calendar.YEAR = " + cal.get(Calendar.YEAR) );
  4543. if ((bUseofNot_ZeroEnergyHouseInfo == true) && (cal.get(Calendar.YEAR) > 2016) && (SYSTEM_TIME_SET == true)) {
  4544. //어제 시간 재입력
  4545. Log.i(TAG , "[checkTimeTasks] GetZeroEnergyHouseInfo_RandomCheckHandler(true);");
  4546. DayofLastSecond = StringUtil.GetDayofLastSecondTimeString(cal); //하루전 날짜의 마지막 시간 입력
  4547. Log.d(TAG , "[checkTimeTasks] DayofLastSecond : "+ DayofLastSecond);
  4548. }
  4549. }
  4550. if (cal.get(Calendar.HOUR_OF_DAY) != nHour) {
  4551. nHour = cal.get(Calendar.HOUR_OF_DAY);
  4552. // 원격검침 데이터를 서버로부터 가져와 관련 기능모듈에 알린다.
  4553. getTelemeteringDataOnRandomTime();
  4554. DoScheduleHourUnit(cal);
  4555. }
  4556. if (getBlackoutStatus()) {
  4557. Log.i(TAG, "[checkTimeTasks] getBlackoutStatus is true!!!");
  4558. sendBlackoutScreenRunBR();
  4559. }
  4560. if (cal.get(Calendar.MINUTE) != nMin) {
  4561. nMin = cal.get(Calendar.MINUTE);
  4562. /**
  4563. * main app에서 전자액자 실행 여부 확인하여 실행시킴
  4564. * **/
  4565. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  4566. Log.i(TAG, "[checkTimeTasks] m_LiveMainActivity : " + m_LiveMainActivity);
  4567. if (m_LiveMainActivity > 0) {
  4568. boolean bScreenOn = false;
  4569. if (getCompareBSPVersion()) {
  4570. bScreenOn = checkLCDOnByCMD();
  4571. }
  4572. else {
  4573. PowerManager mPowerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
  4574. bScreenOn = mPowerManager.isScreenOn();
  4575. }
  4576. Log.i(TAG, "[checkTimeTasks] bScreenOn : " + bScreenOn);
  4577. if (!bScreenOn && !getBlackoutStatus()) {
  4578. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4579. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4580. if (SettData.StartAutoPictureAPP() == true) {
  4581. Log.d(TAG, "[checkTimeTasks] StartAutoPictureAPP() is true");
  4582. mIOInterface.ctrlLcdWakeUp();
  4583. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4584. Log.d(TAG, "[checkTimeTasks] PowerManager will be set");
  4585. }
  4586. else {
  4587. Log.d(TAG, "[checkTimeTasks] StartAutoPictureAPP() is false");
  4588. }
  4589. }
  4590. else {
  4591. Log.d(TAG, "[checkTimeTasks] DecideAutoPictureAppStartOrNot(...) is false");
  4592. }
  4593. SettData.closeDB();
  4594. }
  4595. }
  4596. }
  4597. if ((nMin == 50) || (nMin == 0)) {
  4598. try {
  4599. checkScheduleReminder();
  4600. } catch (RuntimeException re) {
  4601. LogUtil.errorLogInfo("", TAG, re);
  4602. }
  4603. catch (Exception e) {
  4604. LogUtil.errorLogInfo("", TAG, e);
  4605. }
  4606. }
  4607. if (SCManager != null) SCManager.scheduleCheck();
  4608. if (MAX_BOOTUP_RETRY_COUNT < bootupretryCNT && SYSTEM_TIME_SET == false) {
  4609. try {
  4610. WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4611. iMAPMethod.ReqGetSet();
  4612. } catch (RuntimeException re) {
  4613. LogUtil.errorLogInfo("", TAG, re);
  4614. }
  4615. catch (Exception e) {
  4616. LogUtil.errorLogInfo("", TAG, e);
  4617. }
  4618. }
  4619. //주차정보 관련 20분 마다 얻어오기
  4620. if (bUseofNot_ParkingInfo == true) {
  4621. cGetParkingMin++;
  4622. //테스트
  4623. /*
  4624. bSetMSG_GetParkingInfo = true;
  4625. LoadParkingDataFromServer();
  4626. */
  4627. if (cGetParkingMin >= 20) {
  4628. // 20분으로 고정
  4629. cGetParkingMin = 0;
  4630. //아이콘트롤스 일때도 처리하지 않도록 수정필요
  4631. //넥스파인 경우는 협의후 처리
  4632. switch(nParkingSystemType) {
  4633. case Common.PARKING_SYSTEM_ICONTROLS:
  4634. case Common.PARKING_SYSTEM_NEXPA:
  4635. case Common.PARKING_SYSTEM_UPIS:
  4636. case Common.PARKING_SYSTEM_IES_100:
  4637. break;
  4638. case Common.PARKING_SYSTEM_BASIC:
  4639. case Common.PARKING_SYSTEM_ETC:
  4640. GetParkingInfo_RandomCheckHandler(); //주차 정보 얻어오기
  4641. break;
  4642. default:
  4643. break;
  4644. }
  4645. }
  4646. }
  4647. }
  4648. } catch (RuntimeException re) {
  4649. LogUtil.errorLogInfo("", TAG, re);
  4650. }
  4651. catch (Exception e) {
  4652. Log.e(TAG, "[Exception] checkTimeTasks()");
  4653. LogUtil.errorLogInfo("", TAG, e);
  4654. }
  4655. }
  4656. /**
  4657. * 일정 알림 팝업창 생성하는 함수<br>
  4658. * 김용성 과장님 이곳에서 팝업창 생성해주시기 바랍니다.
  4659. * @param popup_msg 팝업창에 띄울 메시지.
  4660. * **/
  4661. private void MakePopup_Schedule(String popup_msg) {
  4662. try {
  4663. Log.e(TAG, "[MakePopup_Schedule] popup_msg [" + popup_msg + "]");
  4664. DebugLogOutput("===================================");
  4665. DebugLogOutput(popup_msg);
  4666. DebugLogOutput("===================================");
  4667. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  4668. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  4669. boolean soundOut = mWallpadStatusData.GetSoundOutputOfEventAlarm();
  4670. mWallpadStatusData.closeDB();
  4671. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 1 ==========");
  4672. if (AlarmStatus != WallpadStatusData.ALARM_ARISE && AlarmStatus != WallpadStatusData.GUARD_OUT && AlarmStatus != WallpadStatusData.GUARD_OUT_WAIT) {
  4673. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 2 ==========");
  4674. if (!Common.bWallPadCallLive) {
  4675. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 3 ==========");
  4676. Common.SendAppFinishReqBR(getApplicationContext());
  4677. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  4678. Log.d(TAG, "[MakePopup_Schedule] Screen On: " + mPowerManager.isScreenOn());
  4679. if (getCompareBSPVersion()) {
  4680. if (!checkLCDOnByCMD()) {
  4681. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  4682. }
  4683. }
  4684. else {
  4685. if (!mPowerManager.isScreenOn()) {
  4686. Log.d(TAG, "[MakePopup_Schedule] V40Interface LcdWakeUp Call!!");
  4687. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  4688. }
  4689. }
  4690. ((MainActivity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4691. // 알람 소리를 내준다.
  4692. if (soundOut) {
  4693. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 4 ==========");
  4694. Sound().Play(SND.effect.EFFECT1);
  4695. }
  4696. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 5 ==========");
  4697. EnergyAlramPopupMgr.SchedulePopupMsg = popup_msg;
  4698. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 6 ==========");
  4699. StartPopup(ID.POPUPS.POPUP_SCHEDULENOTIFICATION);
  4700. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 7 ==========");
  4701. }
  4702. }
  4703. } catch (RuntimeException re) {
  4704. LogUtil.errorLogInfo("", TAG, re);
  4705. }
  4706. catch (Exception e) {
  4707. Log.e(TAG, "[Exception] MakePopup_Schedule(String popup_msg)");
  4708. LogUtil.errorLogInfo("", TAG, e);
  4709. }
  4710. }
  4711. /**
  4712. * 일정 알림 시간 비교!
  4713. * **/
  4714. private void checkScheduleReminder() {
  4715. try {
  4716. Calendar ScheduleCal = Calendar.getInstance();
  4717. Log.i(TAG, "[checkScheduleReminder] ScheduleCal: " + ScheduleCal.getTime());
  4718. WallpadScheduleData SCData = new WallpadScheduleData(getApplicationContext());
  4719. // List<WallpadScheduleData.ScheduleData> scheduleDataDB = SCData.NewGetScheduleDataForMainActivity(ScheduleCal.get(Calendar.YEAR), ScheduleCal.get(Calendar.MONTH) + 1, ScheduleCal.get(Calendar.DAY_OF_MONTH));
  4720. List<WallpadScheduleData.ScheduleData> scheduleDataDB = SCData.getScheduledInfoforMainActivity();
  4721. SCData.closeDB();
  4722. if (scheduleDataDB != null) {
  4723. Log.i(TAG, "scheduleDataDB.size() [" + scheduleDataDB.size() + "]");
  4724. for (int i = 0; i < scheduleDataDB.size(); i++) {
  4725. DebugLogOutput("[checkScheduleReminder] ===================================");
  4726. DebugLogOutput("[checkScheduleReminder] index [" + i + "], year [" + scheduleDataDB.get(i).inqyear + "], month [" + scheduleDataDB.get(i).inqmonth + "], day [" + scheduleDataDB.get(i).inqday + "], hour [" + scheduleDataDB.get(i).inqhour + "]");
  4727. DebugLogOutput("[checkScheduleReminder] msg [" + scheduleDataDB.get(i).inqmsg + "], seq [" + scheduleDataDB.get(i).seqnum + "]");
  4728. /**
  4729. * inqttype: 음력여부 - {"moon", "sun"}
  4730. * inqctype: 주기 - no:없음 or month:매월주기 or year:매년주기
  4731. * inqatype: 알림 - {"no","intime","min","hour","day"} := {안울림, 정각, 10분전, 1시간전, 하루전}
  4732. * inqitype: 행사 - {"birth","memorial","appoint","trip","first","wedding","tax","meeting","car","ancestor"} := {생일,기념일,약속,여행,돌,결혼,공과금,차량점검,제사}
  4733. */
  4734. DebugLogOutput("[checkScheduleReminder] lunar [" + scheduleDataDB.get(i).inqttype + "], cycle [" + scheduleDataDB.get(i).inqctype + "], remindtime [" + scheduleDataDB.get(i).inqatype + "], event [" + scheduleDataDB.get(i).inqitype + "]");
  4735. DebugLogOutput("[checkScheduleReminder] ===================================\n");
  4736. Calendar alarmCalendar = Calendar.getInstance();
  4737. if(scheduleDataDB.get(i).inqatype.equalsIgnoreCase("no") == true) {
  4738. //알림 사용하지 않음.
  4739. Log.i(TAG, "[checkScheduleReminder] ========== alarm off ==========");
  4740. }
  4741. else {
  4742. Log.i(TAG, "[checkScheduleReminder] ========== alarm on ==========");
  4743. if (scheduleDataDB.get(i).inqctype.equalsIgnoreCase("month")) {
  4744. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month ==========");
  4745. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  4746. //정각인 경우
  4747. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> intime ==========");
  4748. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  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("min")) {
  4765. //10분 전
  4766. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 10 min 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.MINUTE, -10);
  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("hour")) {
  4785. //1시간 전
  4786. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 1 hour 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.HOUR_OF_DAY, -1);
  4789. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4790. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4791. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4792. AlarmScheduleCount++;
  4793. if (bAlarmScheduleString == false) {
  4794. bAlarmScheduleString = true;
  4795. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4796. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4797. }
  4798. else {
  4799. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4800. }
  4801. }
  4802. }
  4803. }
  4804. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  4805. //하루전
  4806. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 1 day before ==========");
  4807. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4808. alarmCalendar.add(Calendar.DATE, -1);
  4809. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  4810. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  4811. // 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));
  4812. // 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));
  4813. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  4814. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4815. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4816. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4817. AlarmScheduleCount++;
  4818. if (bAlarmScheduleString == false) {
  4819. bAlarmScheduleString = true;
  4820. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4821. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4822. }
  4823. else {
  4824. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4825. }
  4826. }
  4827. }
  4828. }
  4829. }
  4830. else if (scheduleDataDB.get(i).inqctype.equalsIgnoreCase("year")) {
  4831. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year ==========");
  4832. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  4833. //정각인 경우
  4834. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> intime ==========");
  4835. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4836. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4837. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4838. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4839. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4840. AlarmScheduleCount++;
  4841. if (bAlarmScheduleString == false) {
  4842. bAlarmScheduleString = true;
  4843. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4844. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4845. }
  4846. else {
  4847. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4848. }
  4849. }
  4850. }
  4851. }
  4852. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("min")) {
  4853. //10분 전
  4854. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 10 min before ==========");
  4855. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4856. alarmCalendar.add(Calendar.MINUTE, -10);
  4857. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4858. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4859. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4860. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4861. {
  4862. AlarmScheduleCount++;
  4863. if (bAlarmScheduleString == false) {
  4864. bAlarmScheduleString = true;
  4865. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4866. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4867. }
  4868. else {
  4869. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4870. }
  4871. }
  4872. }
  4873. }
  4874. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("hour")) {
  4875. //1시간 전
  4876. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 1 hour before ==========");
  4877. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4878. alarmCalendar.add(Calendar.HOUR_OF_DAY, -1);
  4879. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4880. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4881. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4882. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4883. {
  4884. AlarmScheduleCount++;
  4885. if (bAlarmScheduleString == false) {
  4886. bAlarmScheduleString = true;
  4887. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4888. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4889. }
  4890. else {
  4891. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4892. }
  4893. }
  4894. }
  4895. }
  4896. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  4897. //하루전
  4898. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 1 day before ==========");
  4899. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4900. alarmCalendar.add(Calendar.DATE, -1);
  4901. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  4902. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  4903. // 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));
  4904. // 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));
  4905. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  4906. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4907. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4908. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4909. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4910. {
  4911. AlarmScheduleCount++;
  4912. if (bAlarmScheduleString == false) {
  4913. bAlarmScheduleString = true;
  4914. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4915. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4916. }
  4917. else {
  4918. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4919. }
  4920. }
  4921. }
  4922. }
  4923. }
  4924. else {
  4925. //반복 없는경우
  4926. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat ==========");
  4927. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  4928. //정각인 경우
  4929. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> intime ==========");
  4930. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4931. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  4932. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4933. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4934. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4935. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4936. {
  4937. AlarmScheduleCount++;
  4938. if (bAlarmScheduleString == false) {
  4939. bAlarmScheduleString = true;
  4940. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4941. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4942. }
  4943. else {
  4944. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4945. }
  4946. }
  4947. }
  4948. }
  4949. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("min")) {
  4950. //10분 전
  4951. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 10 min before ==========");
  4952. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4953. alarmCalendar.add(Calendar.MINUTE, -10);
  4954. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  4955. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4956. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4957. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4958. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4959. {
  4960. AlarmScheduleCount++;
  4961. if (bAlarmScheduleString == false) {
  4962. bAlarmScheduleString = true;
  4963. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4964. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4965. }
  4966. else {
  4967. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4968. }
  4969. }
  4970. }
  4971. }
  4972. else if(scheduleDataDB.get(i).inqatype.equalsIgnoreCase("hour")) {
  4973. //1시간 전
  4974. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 1 hour before ==========");
  4975. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4976. alarmCalendar.add(Calendar.HOUR_OF_DAY, -1);
  4977. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  4978. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4979. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4980. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4981. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4982. {
  4983. AlarmScheduleCount++;
  4984. if (bAlarmScheduleString == false) {
  4985. bAlarmScheduleString = true;
  4986. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4987. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4988. }
  4989. else {
  4990. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4991. }
  4992. }
  4993. }
  4994. }
  4995. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  4996. //하루전
  4997. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 1 day before ==========");
  4998. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4999. alarmCalendar.add(Calendar.DATE, -1);
  5000. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  5001. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  5002. // 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));
  5003. // 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));
  5004. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  5005. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  5006. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  5007. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5008. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5009. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  5010. {
  5011. AlarmScheduleCount++;
  5012. if (bAlarmScheduleString == false) {
  5013. bAlarmScheduleString = true;
  5014. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5015. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5016. }
  5017. else {
  5018. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5019. }
  5020. }
  5021. }
  5022. }
  5023. else {
  5024. Log.w(TAG, "[checkScheduleReminder] Unsupported alarm type!! -> " + scheduleDataDB.get(i).inqatype);
  5025. }
  5026. }
  5027. }
  5028. }
  5029. Log.i(TAG, "[checkScheduleReminder] bAlarmScheduleString [" + bAlarmScheduleString + "], AlarmScheduleCount [" + AlarmScheduleCount + "]");
  5030. if (bAlarmScheduleString == true) {
  5031. if(AlarmScheduleCount == 1) {
  5032. //일정이 1개인 경우
  5033. AlarmScheduleString += " 일정이 있습니다.\r\n확인 하시겠습니까?";
  5034. }
  5035. else {
  5036. //일정이 1개보다 많은 경우
  5037. AlarmScheduleString += " 일정 외 "+(AlarmScheduleCount-1)+"건이 있습니다.\r\n확인 하시겠습니까?";
  5038. }
  5039. AlarmScheduleCount = 0;
  5040. bAlarmScheduleString = false;
  5041. MakePopup_Schedule(AlarmScheduleString);
  5042. }
  5043. }
  5044. else {
  5045. Log.w(TAG, "[checkScheduleReminder] scheduleDataDB is null!!");
  5046. }
  5047. } catch (RuntimeException re) {
  5048. LogUtil.errorLogInfo("", TAG, re);
  5049. }
  5050. catch (Exception e) {
  5051. Log.e(TAG, "[Exception] checkScheduleReminder(Calendar cal)");
  5052. LogUtil.errorLogInfo("", TAG, e);
  5053. }
  5054. }
  5055. // 프로토콜에 정의된 일정표 이벤트 종류를 변환하여 반환한다.
  5056. private String getScheduleEventType(String strEvent) {
  5057. try {
  5058. Log.i(TAG, "[getScheduleEventType] strEvent [" + strEvent + "]");
  5059. if (strEvent.equalsIgnoreCase("birth")) return "생일";
  5060. else if (strEvent.equalsIgnoreCase("memorial")) return "기념일";
  5061. else if (strEvent.equalsIgnoreCase("appoint")) return "약속";
  5062. else if (strEvent.equalsIgnoreCase("trip")) return "여행";
  5063. else if (strEvent.equalsIgnoreCase("first")) return "돌";
  5064. else if (strEvent.equalsIgnoreCase("wedding")) return "결혼";
  5065. else if (strEvent.equalsIgnoreCase("tax")) return "공과금";
  5066. else if (strEvent.equalsIgnoreCase("meeting")) return "모임";
  5067. else if (strEvent.equalsIgnoreCase("car")) return "생일";
  5068. else if (strEvent.equalsIgnoreCase("ancestor")) return "제사";
  5069. else return "알수없음";
  5070. } catch (RuntimeException re) {
  5071. LogUtil.errorLogInfo("", TAG, re);
  5072. return "알수없음";
  5073. }
  5074. catch (Exception e) {
  5075. Log.e(TAG, "[Exception] getScheduleEventType(String strEvent)");
  5076. LogUtil.errorLogInfo("", TAG, e);
  5077. return "알수없음";
  5078. }
  5079. }
  5080. private void getParkedVehicleLocationSysInfo() {
  5081. try {
  5082. DebugLogOutput("getParkedVehicleLocationSysInfo Init");
  5083. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  5084. String[] ParkingDB = devSet.GetSettingData("주차확인");
  5085. devSet.closeDB();
  5086. if (ParkingDB!=null) {
  5087. try {
  5088. String devInfo = ParkingDB[1];
  5089. devInfo = devInfo.replace('(', '_');
  5090. devInfo = devInfo.replace(':', '_');
  5091. devInfo = devInfo.replace(')', '_');
  5092. String[] ParkingInfo = devInfo.split("_");
  5093. //ParkingInfo[3] -> 사용여부 <사용함 / else>
  5094. //ParkingInfo[5] -> 종류 <기본 / 아이콘트롤스 / NEXPA / UPIS / ETC / 비상벨 / else>
  5095. //ParkingInfo[7] -> IP정보
  5096. //ParkingInfo[8] -> 포트번호
  5097. if (ParkingInfo[3].equalsIgnoreCase("사용함") == true) {
  5098. bUseofNot_ParkingInfo = true;
  5099. }
  5100. if (ParkingInfo[5].equalsIgnoreCase("기본") == true) {
  5101. nParkingSystemType = Common.PARKING_SYSTEM_BASIC;
  5102. }
  5103. else if (ParkingInfo[5].equalsIgnoreCase("아이콘트롤스") == true) {
  5104. nParkingSystemType = Common.PARKING_SYSTEM_ICONTROLS;
  5105. }
  5106. else if (ParkingInfo[5].equalsIgnoreCase("넥스파") == true) {
  5107. nParkingSystemType = Common.PARKING_SYSTEM_NEXPA;
  5108. }
  5109. else if (ParkingInfo[5].equalsIgnoreCase("NEXPA") == true) {
  5110. nParkingSystemType = Common.PARKING_SYSTEM_NEXPA;
  5111. }
  5112. else if (ParkingInfo[5].equalsIgnoreCase("UPIS") == true) {
  5113. nParkingSystemType = Common.PARKING_SYSTEM_UPIS;
  5114. }
  5115. else if (ParkingInfo[5].equalsIgnoreCase("ETC") == true) {
  5116. nParkingSystemType = Common.PARKING_SYSTEM_ETC;
  5117. }
  5118. else if (ParkingInfo[5].equalsIgnoreCase("비상벨") == true) {
  5119. nParkingSystemType = Common.PARKING_SYSTEM_IES_100;
  5120. }
  5121. else if (ParkingInfo[5].equalsIgnoreCase("다람정보") == true) {
  5122. nParkingSystemType = Common.PARKING_SYSTEM_DARAM;
  5123. }
  5124. ParkingServerIP = ParkingInfo[7];
  5125. ParkingServerPort = Integer.parseInt(ParkingInfo[8]);
  5126. DebugLogOutput("[getParkedVehicleLocationSysInfo] bUseofNot_ParkingInfo [" + bUseofNot_ParkingInfo + ", nParkingSystemType ["+ nParkingSystemType + "]");
  5127. DebugLogOutput("[getParkedVehicleLocationSysInfo] ParkingServerIP ["+ParkingServerIP + "], ParkingServerPort [" + ParkingServerPort + "]");
  5128. } catch (RuntimeException re) {
  5129. LogUtil.errorLogInfo("", TAG, re);
  5130. bUseofNot_ParkingInfo = false;
  5131. }
  5132. catch (Exception e) {
  5133. LogUtil.errorLogInfo("", TAG, e);
  5134. bUseofNot_ParkingInfo = false;
  5135. }
  5136. }
  5137. else {
  5138. bUseofNot_ParkingInfo = false;
  5139. DebugLogOutput("[getParkedVehicleLocationSysInfo] bUseofNot_ParkingInfo ["+bUseofNot_ParkingInfo + "]");
  5140. }
  5141. } catch (RuntimeException re) {
  5142. LogUtil.errorLogInfo("", TAG, re);
  5143. }
  5144. catch (Exception e) {
  5145. LogUtil.errorLogInfo("", TAG, e);
  5146. }
  5147. }
  5148. //20분 마다 한번씩 호출되는 주차관련 함수!
  5149. private void GetParkingInfo_RandomCheckHandler() {
  5150. int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  5151. if (DelayTime < 1) {
  5152. return;
  5153. }
  5154. DebugLogOutput("[GetParkingInfo] DelayTime : "+ DelayTime);
  5155. bSetMSG_GetParkingInfo = true;
  5156. mGetParkInfoRandomCheckHandler.sendEmptyMessageDelayed(0, 1000 * DelayTime);
  5157. }
  5158. private Handler mGetParkInfoRandomCheckHandler = new Handler()
  5159. {
  5160. @Override
  5161. public void handleMessage(Message msg)
  5162. {
  5163. if (msg.what == 0) {
  5164. DebugLogOutput("[GetParkingInfo] mGetParkInfoRandomCheckHandler() will be called");
  5165. //얻어오기
  5166. LoadParkingDataFromServer();
  5167. }
  5168. }
  5169. };
  5170. /**
  5171. * @description 주차정보 서버로부터 얻어오기<br>
  5172. * 호출 시에는 bSetMSG_GetParkingInfo = true 하고 호출해야함.
  5173. * **/
  5174. private void LoadParkingDataFromServer() {
  5175. try {
  5176. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5177. final AddressSet addc = SetData.getAddressMGR();
  5178. SetData.closeDB();
  5179. if (bSetMSG_GetParkingInfo == false) {
  5180. return;
  5181. }
  5182. if ((nParkingSystemType == Common.PARKING_SYSTEM_BASIC)
  5183. || (nParkingSystemType == Common.PARKING_SYSTEM_ICONTROLS)
  5184. || (nParkingSystemType == Common.PARKING_SYSTEM_NEXPA)
  5185. || (nParkingSystemType == Common.PARKING_SYSTEM_IES_100))
  5186. {
  5187. iMAPcarParking = new iMAPCarParking(mContext, true);
  5188. iMAPcarParking.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5189. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5190. DebugLogOutput("iMAPcarParking.DoWork()");
  5191. iMAPcarParking.DoWork();
  5192. iMAPcarParking.SetRetCtr(new RetProci(){
  5193. @Override
  5194. public void ProcSuccess() {
  5195. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5196. try {
  5197. iMAPcarParking.SetItem("home_info");
  5198. int home_info_count = Integer.parseInt(iMAPcarParking.GetAttributeVal(0, "count"));
  5199. int park_info_count = iMAPcarParking.SetItem("park_info");
  5200. if (home_info_count != park_info_count) {
  5201. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5202. cGetParkingMin = 0;
  5203. bSetMSG_GetParkingInfo = false;
  5204. return;
  5205. }
  5206. if (park_info_count == 0) {
  5207. DebugLogOutput("park_info_count :" + park_info_count);
  5208. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5209. parkdb.DeleteAllParkInfo();
  5210. parkdb.closeDB();
  5211. cGetParkingMin = 0;
  5212. bSetMSG_GetParkingInfo = false;
  5213. /*
  5214. parkdb = new WallpadParkInfo(getApplicationContext());
  5215. int countRow = parkdb.RowCountCarParking();
  5216. parkdb.closeDB();
  5217. DebugLogOutput("countRow :" + countRow);
  5218. */
  5219. Intent intent = new Intent();
  5220. intent.setAction(define.NOTIFY_ACNAME);
  5221. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5222. getApplicationContext().sendBroadcast(intent);
  5223. return;
  5224. }
  5225. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5226. parkdb.DeleteAllParkInfo();
  5227. parkdb.closeDB();
  5228. for (int i = 0; i < park_info_count; i++) {
  5229. if ((addc.Dong.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "ho")))) {
  5230. parkdb = new WallpadParkInfo(getApplicationContext());
  5231. parkdb.InputParkInfo(
  5232. iMAPcarParking.GetAttributeVal(i, "index"),
  5233. iMAPcarParking.GetAttributeVal(i, "dong"),
  5234. iMAPcarParking.GetAttributeVal(i, "ho"),
  5235. iMAPcarParking.GetAttributeVal(i, "card_num"),
  5236. iMAPcarParking.GetAttributeVal(i, "uid"),
  5237. iMAPcarParking.GetAttributeVal(i, "sn"),
  5238. iMAPcarParking.GetAttributeVal(i, "card_type"),
  5239. iMAPcarParking.GetAttributeVal(i, "time"),
  5240. iMAPcarParking.GetAttributeVal(i, "location_text"),
  5241. iMAPcarParking.GetAttributeVal(i, "location_map"),
  5242. iMAPcarParking.GetAttributeVal(i, "vehicle_info"),
  5243. iMAPcarParking.GetAttributeVal(i, "ftp_path"),
  5244. iMAPcarParking.GetAttributeVal(i, "ftp_info"),
  5245. iMAPcarParking.GetAttributeVal(i, "message"));
  5246. parkdb.closeDB();
  5247. }
  5248. }
  5249. //테스트
  5250. parkdb = new WallpadParkInfo(getApplicationContext());
  5251. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5252. parkdb.closeDB();
  5253. if (carParkingData != null) {
  5254. for (int j = 0; j < carParkingData.length; j++) {
  5255. DebugLogOutput(carParkingData[j].ToDebugString());
  5256. }
  5257. }
  5258. //테스트
  5259. Intent intent = new Intent();
  5260. intent.setAction(define.NOTIFY_ACNAME);
  5261. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5262. getApplicationContext().sendBroadcast(intent);
  5263. } catch (RuntimeException re) {
  5264. LogUtil.errorLogInfo("", TAG, re);
  5265. cGetParkingMin = 0;
  5266. bSetMSG_GetParkingInfo = false;
  5267. }
  5268. catch (Exception e) {
  5269. cGetParkingMin = 0;
  5270. bSetMSG_GetParkingInfo = false;
  5271. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5272. LogUtil.errorLogInfo("", TAG, e);
  5273. }
  5274. cGetParkingMin = 0;
  5275. bSetMSG_GetParkingInfo = false;
  5276. }
  5277. @Override
  5278. public void ProcError() {
  5279. cGetParkingMin = 0;
  5280. bSetMSG_GetParkingInfo = false;
  5281. DebugLogOutput("Load EMData From Server - ProcError");
  5282. }
  5283. @Override
  5284. public void ProcDoing() {
  5285. }
  5286. });
  5287. }
  5288. else if (nParkingSystemType == Common.PARKING_SYSTEM_DARAM) {
  5289. iMAPcarParking = new iMAPCarParking(mContext, false);
  5290. iMAPcarParking.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5291. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5292. DebugLogOutput("iMAPcarParking.DoWork()");
  5293. iMAPcarParking.DoWork();
  5294. iMAPcarParking.SetRetCtr(new RetProci(){
  5295. @Override
  5296. public void ProcSuccess() {
  5297. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5298. try {
  5299. iMAPcarParking.SetItem("home_info");
  5300. int home_info_count = Integer.parseInt(iMAPcarParking.GetAttributeVal(0, "count"));
  5301. int park_info_count = iMAPcarParking.SetItem("park_info");
  5302. if (home_info_count != park_info_count) {
  5303. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5304. cGetParkingMin = 0;
  5305. bSetMSG_GetParkingInfo = false;
  5306. return;
  5307. }
  5308. if (park_info_count == 0) {
  5309. DebugLogOutput("park_info_count :" + park_info_count);
  5310. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5311. parkdb.DeleteAllParkInfo();
  5312. parkdb.closeDB();
  5313. cGetParkingMin = 0;
  5314. bSetMSG_GetParkingInfo = false;
  5315. /*
  5316. parkdb = new WallpadParkInfo(getApplicationContext());
  5317. int countRow = parkdb.RowCountCarParking();
  5318. parkdb.closeDB();
  5319. DebugLogOutput("countRow :" + countRow);
  5320. */
  5321. Intent intent = new Intent();
  5322. intent.setAction(define.NOTIFY_ACNAME);
  5323. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5324. getApplicationContext().sendBroadcast(intent);
  5325. return;
  5326. }
  5327. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5328. parkdb.DeleteAllParkInfo();
  5329. parkdb.closeDB();
  5330. for (int i = 0; i < park_info_count; i++) {
  5331. if ((addc.Dong.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "ho")))) {
  5332. parkdb = new WallpadParkInfo(getApplicationContext());
  5333. parkdb.InputParkInfo(
  5334. iMAPcarParking.GetAttributeVal(i, "index"),
  5335. iMAPcarParking.GetAttributeVal(i, "dong"),
  5336. iMAPcarParking.GetAttributeVal(i, "ho"),
  5337. iMAPcarParking.GetAttributeVal(i, "card_num"),
  5338. iMAPcarParking.GetAttributeVal(i, "uid"),
  5339. iMAPcarParking.GetAttributeVal(i, "sn"),
  5340. iMAPcarParking.GetAttributeVal(i, "card_type"),
  5341. iMAPcarParking.GetAttributeVal(i, "time"),
  5342. iMAPcarParking.GetAttributeVal(i, "location_text"),
  5343. iMAPcarParking.GetAttributeVal(i, "location_map"),
  5344. iMAPcarParking.GetAttributeVal(i, "vehicle_info"),
  5345. iMAPcarParking.GetAttributeVal(i, "ftp_path"),
  5346. iMAPcarParking.GetAttributeVal(i, "ftp_info"),
  5347. iMAPcarParking.GetAttributeVal(i, "message"));
  5348. parkdb.closeDB();
  5349. }
  5350. }
  5351. //테스트
  5352. parkdb = new WallpadParkInfo(getApplicationContext());
  5353. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5354. parkdb.closeDB();
  5355. if (carParkingData != null) {
  5356. for (int j = 0; j < carParkingData.length; j++) {
  5357. DebugLogOutput(carParkingData[j].ToDebugString());
  5358. }
  5359. }
  5360. //테스트
  5361. Intent intent = new Intent();
  5362. intent.setAction(define.NOTIFY_ACNAME);
  5363. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5364. getApplicationContext().sendBroadcast(intent);
  5365. } catch (RuntimeException re) {
  5366. LogUtil.errorLogInfo("", TAG, re);
  5367. cGetParkingMin = 0;
  5368. bSetMSG_GetParkingInfo = false;
  5369. }
  5370. catch (Exception e) {
  5371. cGetParkingMin = 0;
  5372. bSetMSG_GetParkingInfo = false;
  5373. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5374. LogUtil.errorLogInfo("", TAG, e);
  5375. }
  5376. cGetParkingMin = 0;
  5377. bSetMSG_GetParkingInfo = false;
  5378. }
  5379. @Override
  5380. public void ProcError() {
  5381. cGetParkingMin = 0;
  5382. bSetMSG_GetParkingInfo = false;
  5383. DebugLogOutput("Load EMData From Server - ProcError");
  5384. }
  5385. @Override
  5386. public void ProcDoing() {
  5387. }
  5388. });
  5389. }
  5390. else if (nParkingSystemType == Common.PARKING_SYSTEM_UPIS) {
  5391. iMapcarParking_UPIS = new iMAPCarParking_UPIS(mContext, false);
  5392. iMapcarParking_UPIS.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5393. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5394. DebugLogOutput("iMapcarParking_UPIS.DoWork()");
  5395. iMapcarParking_UPIS.DoWork();
  5396. iMapcarParking_UPIS.SetRetCtr(new RetProci(){
  5397. @Override
  5398. public void ProcSuccess() {
  5399. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5400. try {
  5401. iMapcarParking_UPIS.SetItem("home_info");
  5402. int home_info_count = Integer.parseInt(iMapcarParking_UPIS.GetAttributeVal(0, "count"));
  5403. int park_info_count = iMapcarParking_UPIS.SetItem("park_info");
  5404. if (home_info_count != park_info_count) {
  5405. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5406. cGetParkingMin = 0;
  5407. bSetMSG_GetParkingInfo = false;
  5408. return;
  5409. }
  5410. if (park_info_count == 0) {
  5411. DebugLogOutput("park_info_count :" + park_info_count);
  5412. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5413. parkdb.DeleteAllParkInfo();
  5414. parkdb.closeDB();
  5415. cGetParkingMin = 0;
  5416. bSetMSG_GetParkingInfo = false;
  5417. /*
  5418. parkdb = new WallpadParkInfo(getApplicationContext());
  5419. int countRow = parkdb.RowCountCarParking();
  5420. parkdb.closeDB();
  5421. DebugLogOutput("countRow :" + countRow);
  5422. */
  5423. Intent intent = new Intent();
  5424. intent.setAction(define.NOTIFY_ACNAME);
  5425. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5426. getApplicationContext().sendBroadcast(intent);
  5427. return;
  5428. }
  5429. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5430. parkdb.DeleteAllParkInfo();
  5431. parkdb.closeDB();
  5432. for (int i = 0; i < park_info_count; i++) {
  5433. if ((addc.Dong.equalsIgnoreCase(iMapcarParking_UPIS.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMapcarParking_UPIS.GetAttributeVal(i, "ho")))) {
  5434. parkdb = new WallpadParkInfo(getApplicationContext());
  5435. parkdb.InputParkInfo(
  5436. iMapcarParking_UPIS.GetAttributeVal(i, "index"),
  5437. iMapcarParking_UPIS.GetAttributeVal(i, "dong"),
  5438. iMapcarParking_UPIS.GetAttributeVal(i, "ho"),
  5439. "null",
  5440. iMapcarParking_UPIS.GetAttributeVal(i, "uid"),
  5441. iMapcarParking_UPIS.GetAttributeVal(i, "sn"),
  5442. iMapcarParking_UPIS.GetAttributeVal(i, "card_type"),
  5443. iMapcarParking_UPIS.GetAttributeVal(i, "time"),
  5444. iMapcarParking_UPIS.GetAttributeVal(i, "location_2"),
  5445. iMapcarParking_UPIS.GetAttributeVal(i, "location_1"),
  5446. iMapcarParking_UPIS.GetAttributeVal(i, "car_info"),
  5447. "null",
  5448. "null",
  5449. iMapcarParking_UPIS.GetAttributeVal(i, "message"));
  5450. parkdb.closeDB();
  5451. }
  5452. }
  5453. //테스트
  5454. parkdb = new WallpadParkInfo(getApplicationContext());
  5455. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5456. parkdb.closeDB();
  5457. if (carParkingData != null) {
  5458. for (int j = 0; j < carParkingData.length; j++) {
  5459. DebugLogOutput(carParkingData[j].ToDebugString());
  5460. }
  5461. }
  5462. Intent intent = new Intent();
  5463. intent.setAction(define.NOTIFY_ACNAME);
  5464. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5465. getApplicationContext().sendBroadcast(intent);
  5466. } catch (RuntimeException re) {
  5467. LogUtil.errorLogInfo("", TAG, re);
  5468. cGetParkingMin = 0;
  5469. bSetMSG_GetParkingInfo = false;
  5470. }
  5471. catch (Exception e) {
  5472. cGetParkingMin = 0;
  5473. bSetMSG_GetParkingInfo = false;
  5474. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5475. LogUtil.errorLogInfo("", TAG, e);
  5476. }
  5477. cGetParkingMin = 0;
  5478. bSetMSG_GetParkingInfo = false;
  5479. }
  5480. @Override
  5481. public void ProcError() {
  5482. cGetParkingMin = 0;
  5483. bSetMSG_GetParkingInfo = false;
  5484. DebugLogOutput("Load EMData From Server - ProcError");
  5485. }
  5486. @Override
  5487. public void ProcDoing() {
  5488. }
  5489. });
  5490. }
  5491. } catch (RuntimeException re) {
  5492. LogUtil.errorLogInfo("", TAG, re);
  5493. }
  5494. catch (Exception e) {
  5495. Log.e(TAG, "[Exception] LoadParkingDataFromServer()");
  5496. LogUtil.errorLogInfo("", TAG, e);
  5497. }
  5498. }
  5499. // 한시간에 한번식 호출되는 함수임
  5500. private void DoScheduleHourUnit(Calendar cal) {
  5501. nHour = cal.get(Calendar.HOUR_OF_DAY);
  5502. // 매시 7시부터 매시간 정각에 계속해서 알려준다. 사용자가 확인하기 전까지...
  5503. // 사용자가 확인하게 되면 알림을 중지한다.
  5504. // 목표값 팝업 알림에 필요한 DB 정보
  5505. // 각각의 항목에 대한 초기화, 근접알림 발생, 근접알림 확인, 초과 알림 발생 , 초과알림 확인 5단계 구분 필요
  5506. // 달이 넘어가게 되면 초괴하 한다.
  5507. try {
  5508. if (nHour == GetEnergyAlarmTime()) {
  5509. if (GetEnergyAlarm() == true) {
  5510. if (bUseofNot_EnergyServer == true) {
  5511. if (ResultGetIntent == true) {
  5512. ResultGetIntent = false;
  5513. Intent intent = new Intent();
  5514. intent.setAction(define.NOTIFY_ACNAME);
  5515. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_MAIN_ACTIVIVY);
  5516. intent.putExtra("elect_target", elect_target);
  5517. intent.putExtra("elect_used", elect_used);
  5518. intent.putExtra("elect_info", elect_info);
  5519. intent.putExtra("water_target", water_target);
  5520. intent.putExtra("water_used", water_used);
  5521. intent.putExtra("water_info", water_info);
  5522. intent.putExtra("gas_target", gas_target);
  5523. intent.putExtra("gas_used", gas_used);
  5524. intent.putExtra("gas_info", gas_info);
  5525. intent.putExtra("heating_target", heating_target);
  5526. intent.putExtra("heating_used", heating_used);
  5527. intent.putExtra("heating_info", heating_info);
  5528. intent.putExtra("hotwater_target", hotwater_target);
  5529. intent.putExtra("hotwater_used", hotwater_used);
  5530. intent.putExtra("hotwater_info", hotwater_info);
  5531. sendBroadcast(intent);
  5532. }
  5533. }
  5534. else {
  5535. CheckEnergyUsage();
  5536. }
  5537. }
  5538. }
  5539. } catch (RuntimeException re) {
  5540. LogUtil.errorLogInfo("", TAG, re);
  5541. }
  5542. catch (Exception e) {
  5543. LogUtil.errorLogInfo("", TAG, e);
  5544. }
  5545. if (SCManager != null ) SCManager.CheckSysResetData();
  5546. }
  5547. static boolean NeedCheckEnergy = false;
  5548. //에너지 사용량 확인
  5549. public void CheckEnergyUsage() {
  5550. Log.d(TAG, "***********************************************");
  5551. Log.d(TAG, "[CheckEnergyUsage] CheckEnergyUsage Function in");
  5552. Log.d(TAG, "***********************************************");
  5553. try {
  5554. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5555. int alarmstate = SetData.GetAlarmStatus();
  5556. SetData.closeDB();
  5557. if (alarmstate == WallpadStatusData.ALARM_ARISE || alarmstate == WallpadStatusData.GUARD_OUT)
  5558. return;
  5559. String strNear = "";
  5560. String strOver = "";
  5561. if (EnergyAlramPopupMgr.m_Elec_UseValue > 0 && EnergyAlramPopupMgr.m_Elec_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP)) {
  5562. if (EnergyAlramPopupMgr.m_Elec_UseValue >= EnergyAlramPopupMgr.m_Elec_GoalValue) {
  5563. strOver += "전기 ";
  5564. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP);
  5565. }
  5566. else {
  5567. double nNearValue = EnergyAlramPopupMgr.m_Elec_GoalValue * 0.9;
  5568. if (EnergyAlramPopupMgr.m_Elec_UseValue > nNearValue) {
  5569. strNear += "전기 ";
  5570. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP);
  5571. }
  5572. }
  5573. }
  5574. if (EnergyAlramPopupMgr.m_Water_UseValue > 0 && EnergyAlramPopupMgr.m_Water_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP)) {
  5575. if (EnergyAlramPopupMgr.m_Water_UseValue >= EnergyAlramPopupMgr.m_Water_GoalValue) {
  5576. strOver += "수도 ";
  5577. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP);
  5578. }
  5579. else {
  5580. double nNearValue = EnergyAlramPopupMgr.m_Water_GoalValue * 0.9;
  5581. if (EnergyAlramPopupMgr.m_Water_UseValue > nNearValue) {
  5582. strNear += "수도 ";
  5583. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP);
  5584. }
  5585. }
  5586. }
  5587. if (EnergyAlramPopupMgr.m_Gas_UseValue > 0 && EnergyAlramPopupMgr.m_Gas_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP)) {
  5588. if (EnergyAlramPopupMgr.m_Gas_UseValue >= EnergyAlramPopupMgr.m_Gas_GoalValue) {
  5589. strOver += "가스 ";
  5590. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP);
  5591. }
  5592. else {
  5593. double nNearValue = EnergyAlramPopupMgr.m_Gas_GoalValue * 0.9;
  5594. if (EnergyAlramPopupMgr.m_Gas_UseValue > nNearValue) {
  5595. strNear += "가스 ";
  5596. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP);
  5597. }
  5598. }
  5599. }
  5600. if (EnergyAlramPopupMgr.m_HotWater_UseValue > 0 && EnergyAlramPopupMgr.m_HotWater_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP)) {
  5601. if (EnergyAlramPopupMgr.m_HotWater_UseValue >= EnergyAlramPopupMgr.m_HotWater_GoalValue) {
  5602. strOver += "온수 ";
  5603. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP);
  5604. }
  5605. else {
  5606. double nNearValue = EnergyAlramPopupMgr.m_HotWater_GoalValue * 0.9;
  5607. if (EnergyAlramPopupMgr.m_HotWater_UseValue > nNearValue) {
  5608. strNear += "온수 ";
  5609. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP);
  5610. }
  5611. }
  5612. }
  5613. if (EnergyAlramPopupMgr.m_Heating_UseValue > 0 && EnergyAlramPopupMgr.m_Heating_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP)) {
  5614. if (EnergyAlramPopupMgr.m_Heating_UseValue >= EnergyAlramPopupMgr.m_Heating_GoalValue) {
  5615. strOver += "난방 ";
  5616. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP);
  5617. }
  5618. else {
  5619. double nNearValue = EnergyAlramPopupMgr.m_Heating_GoalValue * 0.9;
  5620. if (EnergyAlramPopupMgr.m_Heating_UseValue > nNearValue) {
  5621. strNear += "난방 ";
  5622. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP);
  5623. }
  5624. }
  5625. }
  5626. if (strNear.length() > 8) EnergyAlramPopupMgr.PopupMsg01 = strNear + "사용량이\n목표값에 가까워지고 있습니다.\n확인 하시겠습니까?";
  5627. else if (0 < strNear.length() && strNear.length() <= 8) EnergyAlramPopupMgr.PopupMsg01 = strNear + "사용량이 목표값에 가까워지고 있습니다.\n확인 하시겠습니까?";
  5628. else EnergyAlramPopupMgr.PopupMsg01 = "";
  5629. if (strOver.length() > 10) {
  5630. EnergyAlramPopupMgr.PopupMsg02 = strOver + "사용량이\n목표값을 초과하였습니다.\n확인 하시겠습니까?";
  5631. }
  5632. else if (0 < strOver.length() && strOver.length() <= 10) {
  5633. EnergyAlramPopupMgr.PopupMsg02 = strOver + "사용량이 목표값을 초과하였습니다.\n확인 하시겠습니까?";
  5634. }
  5635. else if(strOver.length() < 0){
  5636. EnergyAlramPopupMgr.PopupMsg02 = "";
  5637. }
  5638. if (EnergyAlramPopupMgr.PopupMsg01.length() > 0 || EnergyAlramPopupMgr.PopupMsg02.length() > 0) {
  5639. mIOInterface.ctrlLcdWakeUp();
  5640. StartPopup(ID.POPUPS.POPUP_ENERGYUSAGEALERT);
  5641. }
  5642. } catch (RuntimeException re) {
  5643. LogUtil.errorLogInfo("", TAG, re);
  5644. }
  5645. catch (Exception e) {
  5646. Log.e(TAG, "[Exception] CheckEnergyUsage()");
  5647. LogUtil.errorLogInfo("", TAG, e);
  5648. }
  5649. }
  5650. //시간 동기화를 위한 getinfo 실행 시간을 구함
  5651. protected Calendar GetTimeSyncTime()
  5652. {
  5653. Calendar retTime = new GregorianCalendar();
  5654. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5655. AddressSet addc = SetData.getAddressMGR();
  5656. SetData.closeDB();
  5657. try {
  5658. int dong = Integer.parseInt(addc.Dong);
  5659. int ho = 101;
  5660. if(addc.UseOrNotRentHouse == true)
  5661. {
  5662. ho = addc.Ho_Integer;
  5663. }
  5664. else
  5665. {
  5666. ho = Integer.parseInt(addc.Ho);
  5667. }
  5668. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  5669. int hour;
  5670. int min;
  5671. int sec;
  5672. if (interval/3600 > 0)
  5673. {
  5674. hour = 3+interval/3600;
  5675. interval=interval%3600;
  5676. }
  5677. else hour = 6;
  5678. if (interval/60 > 0)
  5679. {
  5680. min = interval/60;
  5681. sec = interval%60;
  5682. }
  5683. else
  5684. {
  5685. min = 0;
  5686. sec = interval;
  5687. }
  5688. retTime.set(Calendar.HOUR_OF_DAY, hour);
  5689. retTime.set(Calendar.MINUTE, min);
  5690. retTime.set(Calendar.SECOND, sec);
  5691. }
  5692. catch (RuntimeException re) {
  5693. LogUtil.errorLogInfo("", TAG, re);
  5694. return null;
  5695. }
  5696. catch (Exception e)
  5697. {
  5698. LogUtil.errorLogInfo("", TAG, e);
  5699. return null;
  5700. }
  5701. return retTime;
  5702. }
  5703. //에너지 사용량 확인을 위한 데이터 로딩 시간을 가져옴
  5704. protected Calendar GetEnergyDataLoadingTime()
  5705. {
  5706. Calendar retTime = new GregorianCalendar();
  5707. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5708. AddressSet addc = SetData.getAddressMGR();
  5709. SetData.closeDB();
  5710. try {
  5711. int dong = Integer.parseInt(addc.Dong);
  5712. int ho = 201;
  5713. if(addc.UseOrNotRentHouse == true)
  5714. {
  5715. ho = addc.Ho_Integer;
  5716. }
  5717. else
  5718. {
  5719. ho = Integer.parseInt(addc.Ho);
  5720. }
  5721. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  5722. int hour;
  5723. int min;
  5724. int sec;
  5725. if (interval/3600 > 0)
  5726. {
  5727. hour = 6+interval/3600;
  5728. interval=interval%3600;
  5729. }
  5730. else hour = 6;
  5731. if (interval/60 > 0)
  5732. {
  5733. min = interval/60;
  5734. sec = interval%60;
  5735. }
  5736. else
  5737. {
  5738. min = 0;
  5739. sec = interval;
  5740. }
  5741. retTime.set(Calendar.HOUR_OF_DAY, hour);
  5742. retTime.set(Calendar.MINUTE, min);
  5743. retTime.set(Calendar.SECOND, sec);
  5744. }
  5745. catch (RuntimeException re) {
  5746. LogUtil.errorLogInfo("", TAG, re);
  5747. return null;
  5748. }
  5749. catch (Exception e)
  5750. {
  5751. LogUtil.errorLogInfo("", TAG, e);
  5752. return null;
  5753. }
  5754. return retTime;
  5755. }
  5756. private void setNetworkAddr(int secNum, int thirdNum, int forthNum) {
  5757. try
  5758. {
  5759. String IPAddress = String.format("10.%d.%d.%d", secNum, thirdNum, forthNum);
  5760. String gateWayIPAddress = String.format("10.%d.%d.%d", secNum, Common.DEFAULT_GATEWAY_IP_THIRD, Common.DEFAULT_GATEWAY_IP_FORTH);
  5761. String MacAddr = String.format("00:0A:%02x:%02x:%02x:00", secNum, thirdNum, forthNum);
  5762. String serverIP = Common.DEFAULT_SERVER_IP;
  5763. int serverPort = Common.DEFAULT_SERVER_PORT;
  5764. String managePCIP = Common.DEFAULT_MANAGER_PC_IP;
  5765. int managePCPort = Common.DEFAULT_MANAGER_PC_PORT;
  5766. wallpaddbmgr dbmgr = new wallpaddbmgr(this);
  5767. AddressSet addc = dbmgr.getAddressMGR();
  5768. String mDong = String.format("%d%02d", 1, secNum);
  5769. String mHo = String.format("%d%02d", thirdNum, forthNum);
  5770. addc.setAddress(mDong, mHo);
  5771. addc.setIPAddress(IPAddress);
  5772. dbmgr.closeDB();
  5773. WallpadStatusData wallpadStatusData = new WallpadStatusData(this);
  5774. wallpadStatusData.SetServerIP(serverIP, serverPort);
  5775. wallpadStatusData.SetManagePC(managePCIP, managePCPort);
  5776. wallpadStatusData.closeDB();
  5777. EthernetDevInfo info = new EthernetDevInfo();
  5778. info.setIfName("eth0");
  5779. info.setConnectMode(EthernetDevInfo.ETH_CONN_MODE_MANUAL);
  5780. info.setIpAddress(IPAddress);
  5781. info.setRouteAddr(gateWayIPAddress);
  5782. info.setDnsAddr(Common.DNS_IP);
  5783. info.setNetMask(Common.SUBNET_MASK);
  5784. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  5785. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  5786. mEthManager.UpdateEthDevInfo(info);
  5787. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  5788. WallPadInterface wallPadInterface = new WallPadInterface();;
  5789. wallPadInterface.setMacAddr(MacAddr);
  5790. Log.d("MANAGERSETTING", " IP : "+IPAddress+" Mac : "+ MacAddr);
  5791. writeMacAddress(MacAddr);
  5792. }
  5793. catch (RuntimeException re) {
  5794. LogUtil.errorLogInfo("", TAG, re);
  5795. }
  5796. catch (Exception e)
  5797. {
  5798. LogUtil.errorLogInfo("", TAG, e);
  5799. }
  5800. }
  5801. private final String NETWORK_SETTING = "network_setting";
  5802. private final String MAC_ADDRESS_FILE_PATH = Common.CONTENTS_ROOT + NETWORK_SETTING + ".inc";
  5803. private boolean writeMacAddress(String MacAddr) {
  5804. boolean ret = false;
  5805. String read = null;
  5806. BufferedWriter bufferWriter = null;
  5807. try {
  5808. FileOutputStream fos = new FileOutputStream(MAC_ADDRESS_FILE_PATH, false);
  5809. OutputStreamWriter osr = new OutputStreamWriter(fos, "UTF-8");
  5810. bufferWriter = new BufferedWriter(osr, 1024);
  5811. if ((bufferWriter != null) && (MacAddr != null)) {
  5812. bufferWriter.write(MacAddr, 0, MacAddr.length());
  5813. bufferWriter.newLine();
  5814. bufferWriter.flush();
  5815. ret = true;
  5816. }
  5817. } catch (RuntimeException re) {
  5818. LogUtil.errorLogInfo("", TAG, re);
  5819. }
  5820. catch (Exception e) {
  5821. LogUtil.errorLogInfo("", TAG, e);
  5822. } finally {
  5823. try {
  5824. if (bufferWriter != null) {
  5825. bufferWriter.close();
  5826. }
  5827. } catch (RuntimeException re) {
  5828. LogUtil.errorLogInfo("", TAG, re);
  5829. }
  5830. catch (Exception e) {
  5831. LogUtil.errorLogInfo("", TAG, e);
  5832. }
  5833. }
  5834. Log.d(TAG, "writeMacAddress() path : " + MAC_ADDRESS_FILE_PATH
  5835. + ", MacAddr : " + MacAddr
  5836. + ", ret : " + ret
  5837. );
  5838. return ret;
  5839. }
  5840. private void GetElectricCarInfo() {
  5841. try {
  5842. Log.d(TAG, "[GetElectricCarInfo] ===== START =====");
  5843. int retInt = -1;
  5844. WallpadDeviceSet mWallpadDeviceSet = null;
  5845. mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  5846. retInt = mWallpadDeviceSet.GetDeviceSetted("전기차충전");
  5847. mWallpadDeviceSet.closeDB();
  5848. Log.d(TAG, "[GetElectricCarInfo] retInt = " + retInt);
  5849. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  5850. Log.i(TAG, "[GetElectricCarInfo] Electronic car changing enabled!!");
  5851. GetElectricCarInfo_RandomCheckHandler();
  5852. }
  5853. else Log.i(TAG, "[GetElectricCarInfo] Electronic car changing disabled!!");
  5854. } catch (RuntimeException re) {
  5855. LogUtil.errorLogInfo("", TAG, re);
  5856. }
  5857. catch (Exception e) {
  5858. Log.e(TAG, "[Exception] GetElectricCarInfo()");
  5859. LogUtil.errorLogInfo("", TAG, e);
  5860. }
  5861. }
  5862. private void GetElectricCarInfo_RandomCheckHandler() {
  5863. try {
  5864. Log.d(TAG, "[GetElectricCarInfo_RandomCheckHandler] ===== START =====");
  5865. int nDelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  5866. Log.d(TAG, "[GetElectricCarInfo_RandomCheckHandler] nDelayTime : "+ nDelayTime);
  5867. if (nDelayTime < 1) {
  5868. Log.w(TAG, "[GetElectricCarInfo_RandomCheckHandler] DelayTime error!! -> nDelayTime = " + nDelayTime);
  5869. return;
  5870. }
  5871. mGetElecricCarRandomCheckHandler.sendEmptyMessageDelayed(0, 1000 * nDelayTime);
  5872. } catch (RuntimeException re) {
  5873. LogUtil.errorLogInfo("", TAG, re);
  5874. }
  5875. catch (Exception e) {
  5876. Log.e(TAG, "[Exception] GetElectricCarInfo_RandomCheckHandler()");
  5877. LogUtil.errorLogInfo("", TAG, e);
  5878. }
  5879. }
  5880. private Handler mGetElecricCarRandomCheckHandler = new Handler()
  5881. {
  5882. @Override
  5883. public void handleMessage(Message msg)
  5884. {
  5885. if (msg.what == 0) {
  5886. Log.i(TAG, "[GetElectricCarInfo] mGetElecricCarRandomCheckHandler() will be called!!");
  5887. //얻어오기
  5888. imapElecCarChargingInfo = new iMAPElecCarChargingInfo(getApplicationContext());
  5889. LoadElectricCarDataFromServer();
  5890. }
  5891. }
  5892. };
  5893. void LoadElectricCarDataFromServer() {
  5894. DebugLogOutput("LoadElectricCarDataFromServer");
  5895. imapElecCarChargingInfo.DoWork();
  5896. imapElecCarChargingInfo.SetRetCtr(new RetProci() {
  5897. @Override
  5898. public void ProcSuccess() {
  5899. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcSuccess");
  5900. try {
  5901. int SetItemResult = imapElecCarChargingInfo.SetItem("charging_cnt");
  5902. if(SetItemResult != 1) {
  5903. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - SetItemResult : "+ SetItemResult);
  5904. nElecVehicleChangingCnt = 0;
  5905. return;
  5906. }
  5907. String sChargingCount = imapElecCarChargingInfo.GetItemVal(0);
  5908. int intChargingCount = Integer.parseInt(sChargingCount);
  5909. if (intChargingCount < 1) {
  5910. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - intChargingCount : "+ intChargingCount);
  5911. nElecVehicleChangingCnt = 0;
  5912. return;
  5913. }
  5914. SetItemResult = imapElecCarChargingInfo.SetItem("charger_info");
  5915. if (SetItemResult != intChargingCount) {
  5916. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - SetItemResult : "+ SetItemResult);
  5917. nElecVehicleChangingCnt = 0;
  5918. return;
  5919. }
  5920. if (intChargingCount > 0) {
  5921. nElecVehicleChangingCnt = intChargingCount;
  5922. Intent intent = new Intent();
  5923. intent.setAction(define.NOTIFY_ACNAME);
  5924. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  5925. intent.putExtra("sCard_Num", imapElecCarChargingInfo.GetAttributeVal(0, "card_num"));
  5926. intent.putExtra("sCar_Num", imapElecCarChargingInfo.GetAttributeVal(0, "car_num"));
  5927. intent.putExtra("sCharger_Num", imapElecCarChargingInfo.GetAttributeVal(0, "charger_num"));
  5928. intent.putExtra("sCharger_Loc", imapElecCarChargingInfo.GetAttributeVal(0, "charger_loc"));
  5929. intent.putExtra("sCharging_Status", "charging");
  5930. intent.putExtra("sCharger_sort", imapElecCarChargingInfo.GetAttributeVal(0, "charger_sort"));
  5931. intent.putExtra("sCharging_Ratio", imapElecCarChargingInfo.GetAttributeVal(0, "charging_ratio"));
  5932. intent.putExtra("sStart_Time", imapElecCarChargingInfo.GetAttributeVal(0, "start_time"));
  5933. intent.putExtra("sRemain_Time", imapElecCarChargingInfo.GetAttributeVal(0, "remain_time"));
  5934. intent.putExtra("sMessage", imapElecCarChargingInfo.GetAttributeVal(0, "c_msg"));
  5935. getApplicationContext().sendBroadcast(intent);
  5936. }
  5937. } catch (RuntimeException re) {
  5938. LogUtil.errorLogInfo("", TAG, re);
  5939. }
  5940. catch (Exception e) {
  5941. Log.e(TAG, "[Exception] LoadElectricCarDataFromServer() -> ProcSuccess");
  5942. LogUtil.errorLogInfo("", TAG, e);
  5943. }
  5944. }
  5945. @Override
  5946. public void ProcError()
  5947. {
  5948. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcError");
  5949. }
  5950. @Override
  5951. public void ProcDoing()
  5952. {
  5953. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcDoing");
  5954. }
  5955. });
  5956. }
  5957. /**
  5958. * 대외향 Call 버튼 점멸 및 On Off 처리
  5959. */
  5960. @SuppressLint("HandlerLeak")
  5961. protected Handler mLedFlickerHandler = new Handler()
  5962. {
  5963. boolean Flicker = false;
  5964. @SuppressLint("HandlerLeak")
  5965. @Override
  5966. public void handleMessage(Message msg)
  5967. {
  5968. if(msg.what == 0) // 콜 수신시 또는 발신시 ...
  5969. {
  5970. // 점멸 시작 CallButton LED On
  5971. Flicker = true;
  5972. mLedFlickerHandler.sendEmptyMessageDelayed(1, 500);
  5973. WallPadInterface wpdifc = new WallPadInterface();
  5974. wpdifc.callLEDControll(true);
  5975. }
  5976. else if(msg.what == 1)
  5977. {
  5978. mLedFlickerHandler.sendEmptyMessageDelayed(0, 500);
  5979. WallPadInterface wpdifc = new WallPadInterface();
  5980. wpdifc.callLEDControll(false);
  5981. }
  5982. else if(msg.what == 2) // 통화중
  5983. {
  5984. Flicker = false;
  5985. }
  5986. else if(msg.what == 4) // 통화종료
  5987. {
  5988. Flicker = false;
  5989. }
  5990. }
  5991. };
  5992. public void GetEnergyServerInfo()
  5993. {
  5994. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  5995. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  5996. devSet.closeDB();
  5997. if (MetringDB != null)
  5998. {
  5999. try
  6000. {
  6001. String devInfo = MetringDB[1];
  6002. devInfo = devInfo.replace('(', '_');
  6003. devInfo = devInfo.replace(':', '_');
  6004. devInfo = devInfo.replace(')', '_');
  6005. String[] MetringInfo = devInfo.split("_");
  6006. // MetringInfo[1] -> 회로수
  6007. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  6008. // MetringInfo[4] -> IP
  6009. // MetringInfo[5] -> IP정보
  6010. // MetringInfo[6] -> 검침일사용자설정
  6011. // MetringInfo[7] -> 사용함 또는 사용안함
  6012. if(MetringInfo[3].equals("사용함") == true)
  6013. {
  6014. bUseofNot_EnergyServer = true;
  6015. }
  6016. }
  6017. catch (RuntimeException re) {
  6018. LogUtil.errorLogInfo("", TAG, re);
  6019. }
  6020. catch (Exception e)
  6021. {
  6022. LogUtil.errorLogInfo("", TAG, e);
  6023. }
  6024. }
  6025. else
  6026. {
  6027. }
  6028. Log.d(TAG, "[bUseofNot_EnergyServer] bUseofNot_EnergyServer :"+bUseofNot_EnergyServer);
  6029. }
  6030. /**
  6031. * 카카오 사용 여부 체크
  6032. * @return
  6033. */
  6034. public boolean getKakaoHomeCheck()
  6035. {
  6036. boolean result = false;
  6037. WallpadDeviceSet mWallpadDeviceSet = null;
  6038. mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6039. try {
  6040. result = mWallpadDeviceSet.Get_KakaoUse();
  6041. }
  6042. catch (SQLException e)
  6043. {
  6044. LogUtil.errorLogInfo("", TAG, e);
  6045. }
  6046. return result;
  6047. }
  6048. /**
  6049. * 사용자 설정(카카오를 볼것인지 아닌지를 설정)
  6050. * @return
  6051. */
  6052. public boolean getShowKakaoCheck()
  6053. {
  6054. boolean result = false;
  6055. WallpadDeviceSet mWallpadDeviceSet = null;
  6056. mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6057. try {
  6058. result = mWallpadDeviceSet.Get_KakaoShow();
  6059. }
  6060. catch (SQLException e)
  6061. {
  6062. LogUtil.errorLogInfo("", TAG, e);
  6063. }
  6064. return result;
  6065. }
  6066. public boolean GetEnergyAlarm()
  6067. {
  6068. boolean ret = false;
  6069. WallpadStatusData DBMGR = null;
  6070. DBMGR = new WallpadStatusData(getContext());
  6071. if( DBMGR != null )
  6072. {
  6073. try
  6074. {
  6075. ret = DBMGR.GetRemoteMetering_Alarm();
  6076. }
  6077. catch (RuntimeException re) {
  6078. LogUtil.errorLogInfo("", TAG, re);
  6079. ret = false;
  6080. DBMGR.insertWallPADDB(WallpadStatusData.REMOTE_METERING_ALARM_USE, WallpadStatusData.REMOTE_METERING_ALARM_USE_DEFAULT);
  6081. }
  6082. catch (Exception e)
  6083. {
  6084. LogUtil.errorLogInfo("", TAG, e);
  6085. ret = false;
  6086. DBMGR.insertWallPADDB(WallpadStatusData.REMOTE_METERING_ALARM_USE, WallpadStatusData.REMOTE_METERING_ALARM_USE_DEFAULT);
  6087. }
  6088. DBMGR.closeDB();
  6089. }
  6090. bUseofNot_EnergyAlarm = ret;
  6091. Log.d(TAG, "[bUseofNot_EnergyAlarm] bUseofNot_EnergyAlarm :"+bUseofNot_EnergyAlarm);
  6092. return ret;
  6093. }
  6094. /**
  6095. * @description
  6096. * 에너지 사용량 알림 시간 얻어오기
  6097. * @return int Hour시간 값
  6098. */
  6099. public int GetEnergyAlarmTime()
  6100. {
  6101. int ret = 12;
  6102. WallpadStatusData DBMGR = null;
  6103. DBMGR = new WallpadStatusData(getContext());
  6104. try
  6105. {
  6106. ret = DBMGR.GetRemoteMetering_AlarmTime();
  6107. }
  6108. catch (RuntimeException re) {
  6109. LogUtil.errorLogInfo("", TAG, re);
  6110. }
  6111. catch (Exception e)
  6112. {
  6113. LogUtil.errorLogInfo("", TAG, e);
  6114. }
  6115. DBMGR.closeDB();
  6116. Log.d(TAG, "[GetEnergyAlarmTime] GetEnergyAlarmTime :"+ret);
  6117. return ret;
  6118. }
  6119. public void ClearEnergyUsage()
  6120. {
  6121. ResultGetIntent = false;
  6122. elect_target = "Error";
  6123. elect_used = "Error";
  6124. elect_info = "Error";
  6125. water_target = "Error";
  6126. water_used = "Error";
  6127. water_info = "Error";
  6128. gas_target = "Error";
  6129. gas_used = "Error";
  6130. gas_info = "Error";
  6131. hotwater_target = "Error";
  6132. hotwater_used = "Error";
  6133. hotwater_info = "Error";
  6134. heating_target = "Error";
  6135. heating_used = "Error";
  6136. heating_info = "Error";
  6137. }
  6138. // 신규 통화어플 실행을 위한 코드 (JEFF, 2016.05.23)
  6139. // 통화주체를 다루는 enum
  6140. public enum CALLOWNER {
  6141. NONE,
  6142. WALLPAD,
  6143. MOBILE,
  6144. SUB_WALLPAD,
  6145. KITCHEN_TV,
  6146. BATH_PHONE,
  6147. BATH_TV,
  6148. UNIVERSAL_DEVICE,
  6149. ERROR;
  6150. }
  6151. public enum CALLEVENTTYPE {
  6152. RECEIVE_CALL, // 호출 수신 (호출 수신)
  6153. TRYING_CALL, // 호출 시도중 (호출 발신)
  6154. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  6155. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  6156. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  6157. CONNECT_CALL, // 통화 시작
  6158. TERMINATE_CALL, // 통화 종료
  6159. CANCEL_CALL, // 호출 취소
  6160. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  6161. REJECT_CALL, // 호출수신 거절
  6162. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  6163. FORWARD_CALL, // 착신전환 설정
  6164. CALLERID, // Caller ID_OLD
  6165. TIMEOUT_1STCALL, // 1st Call Timeout
  6166. TIMEOUT_2NDCALL, // 2nd Call Timeout
  6167. TIMEOUT_3RDCALL, // 3rd Call Timeout
  6168. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  6169. DOOR_OPEN, // 문열림 설정
  6170. DETECT_STRANGER, // 거동수상자 발생
  6171. NONE;
  6172. }
  6173. public enum CALLTYPE {
  6174. NONE,
  6175. FRONT,
  6176. RESIDENCE,
  6177. LOBBY,
  6178. GUARD,
  6179. PSTN,
  6180. IHUB,
  6181. HISTORY_CALL,
  6182. HISTORY_VISITORPIC,
  6183. FRONT_RECORD, // 현관_영상녹화
  6184. FRONT_TAKEPIC, // 현관_사진촬영
  6185. ERROR,
  6186. }
  6187. public static class CALLTRIGGER {
  6188. public static String CALLOWNER = "CALLOWNER";
  6189. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  6190. public static String CALLTYPE = "CALLTYPE";
  6191. public enum SOURCE {
  6192. USER,
  6193. CALL_RECEIVE,
  6194. SUBPHONE
  6195. }
  6196. public enum TYPE {
  6197. MENU,
  6198. FRONT,
  6199. LOBBY,
  6200. GUARD,
  6201. RESIDENCE,
  6202. PSTN
  6203. }
  6204. }
  6205. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  6206. public void runWallPadCallAPKByUX(int nScreen) {
  6207. try {
  6208. Log.i(TAG, "[runWallPadCallAPKByUX] nScreen [" + nScreen + "]");
  6209. CALLOWNER eCallOwner = CALLOWNER.NONE;
  6210. CALLEVENTTYPE eEventType = CALLEVENTTYPE.NONE;
  6211. CALLTYPE eCallType = CALLTYPE.GUARD;
  6212. if (nScreen == ID.LINKEDSCREEN.SubCall.Door) {
  6213. if (getIsSubWallpad()) eCallOwner = CALLOWNER.SUB_WALLPAD;
  6214. else eCallOwner = CALLOWNER.WALLPAD;
  6215. eEventType = CALLEVENTTYPE.REQUEST_FRONT_MONITORING;
  6216. eCallType = CALLTYPE.FRONT;
  6217. }
  6218. else if (nScreen == ID.LINKEDSCREEN.SubCall.Door_Record) {
  6219. eCallType = CALLTYPE.FRONT;
  6220. eEventType = CALLEVENTTYPE.DETECT_STRANGER;
  6221. }
  6222. else if (nScreen == ID.LINKEDSCREEN.SubCall.Lobby) eCallType = CALLTYPE.LOBBY;
  6223. else if (nScreen == ID.LINKEDSCREEN.SubCall.Guard) eCallType = CALLTYPE.GUARD;
  6224. else if (nScreen == ID.LINKEDSCREEN.SubCall.Neighboor) eCallType = CALLTYPE.RESIDENCE;
  6225. else if (nScreen == ID.LINKEDSCREEN.SubCall.Pstn) eCallType = CALLTYPE.PSTN;
  6226. else if (nScreen == ID.LINKEDSCREEN.SubCall.CallList) eCallType = CALLTYPE.HISTORY_CALL;
  6227. else if (nScreen == ID.LINKEDSCREEN.SubCall.Visitor) eCallType = CALLTYPE.HISTORY_VISITORPIC;
  6228. else {
  6229. Log.w(TAG, "[runWallPadCallAPKByUX] NOT Supported nScreen!! [" + nScreen + "]");
  6230. }
  6231. Log.i(TAG, "[runWallPadCallAPKByUX] eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6232. if (getIsSubWallpad()) {
  6233. // 서브월패드는 국선 기능을 제공하지 않는다.
  6234. if (eCallType != CALLTYPE.PSTN) runCallMainActivity(eCallOwner, eEventType, eCallType);
  6235. }
  6236. else {
  6237. runCallMainActivity(eCallOwner, eEventType, eCallType);
  6238. }
  6239. } catch (RuntimeException re) {
  6240. LogUtil.errorLogInfo("", TAG, re);
  6241. }
  6242. catch (Exception e) {
  6243. Log.e(TAG, "[Exception] runWallPadCallAPKByUX(int nScreen)");
  6244. LogUtil.errorLogInfo("", TAG, e);
  6245. }
  6246. }
  6247. public void runWallPadCallAPKByUX(int nScreen, int nEmerState) {
  6248. try {
  6249. Log.i(TAG, "[runWallPadCallAPKByUX] nScreen [" + nScreen + "], nEmerState [" + nEmerState + "]");
  6250. CALLOWNER eCallOwner = CALLOWNER.NONE;
  6251. CALLEVENTTYPE eEventType = CALLEVENTTYPE.NONE;
  6252. CALLTYPE eCallType = CALLTYPE.GUARD;
  6253. if (nScreen == ID.LINKEDSCREEN.SubCall.Door) {
  6254. if (getIsSubWallpad()) eCallOwner = CALLOWNER.SUB_WALLPAD;
  6255. else eCallOwner = CALLOWNER.WALLPAD;
  6256. eEventType = CALLEVENTTYPE.REQUEST_FRONT_MONITORING;
  6257. eCallType = CALLTYPE.FRONT;
  6258. }
  6259. else if (nScreen == ID.LINKEDSCREEN.SubCall.Door_Record) {
  6260. eCallType = CALLTYPE.FRONT;
  6261. eEventType = CALLEVENTTYPE.DETECT_STRANGER;
  6262. }
  6263. else if (nScreen == ID.LINKEDSCREEN.SubCall.Lobby) eCallType = CALLTYPE.LOBBY;
  6264. else if (nScreen == ID.LINKEDSCREEN.SubCall.Guard) eCallType = CALLTYPE.GUARD;
  6265. else if (nScreen == ID.LINKEDSCREEN.SubCall.Neighboor) eCallType = CALLTYPE.RESIDENCE;
  6266. else if (nScreen == ID.LINKEDSCREEN.SubCall.Pstn) eCallType = CALLTYPE.PSTN;
  6267. else if (nScreen == ID.LINKEDSCREEN.SubCall.CallList) eCallType = CALLTYPE.HISTORY_CALL;
  6268. else if (nScreen == ID.LINKEDSCREEN.SubCall.Visitor) eCallType = CALLTYPE.HISTORY_VISITORPIC;
  6269. else {
  6270. Log.w(TAG, "[runWallPadCallAPKByUX] NOT Supported nScreen!! [" + nScreen + "]");
  6271. }
  6272. Log.i(TAG, "[runWallPadCallAPKByUX] eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6273. if (getIsSubWallpad()) {
  6274. // 서브월패드는 국선 기능을 제공하지 않는다.
  6275. if (eCallType != CALLTYPE.PSTN) runCallMainActivity(eCallOwner, eEventType, eCallType, nEmerState);
  6276. }
  6277. else {
  6278. runCallMainActivity(eCallOwner, eEventType, eCallType, nEmerState);
  6279. }
  6280. } catch (RuntimeException re) {
  6281. LogUtil.errorLogInfo("", TAG, re);
  6282. }
  6283. catch (Exception e) {
  6284. Log.e(TAG, "[Exception] runWallPadCallAPKByUX(int nScreen, int nEmerState)");
  6285. LogUtil.errorLogInfo("", TAG, e);
  6286. }
  6287. }
  6288. static public Handler CallIntentHandler = new Handler(Looper.getMainLooper()) {
  6289. public void handleMessage(Message msg) {
  6290. if(CallBrList!=null && CallBrList.size() > 0)
  6291. {
  6292. Intent intent = CallBrList.get(0);
  6293. mContext_call.sendBroadcast(intent);
  6294. Log.d(TAG, "jglee - Call Handler Next 호출 > Action : " + MainActivity.CallBrList.get(0).getAction() + ", Extra : " + MainActivity.CallBrList.get(0).getIntExtra(Common.BR_MAIN_NOTI.KIND,0) );
  6295. }
  6296. }
  6297. };
  6298. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  6299. try {
  6300. Log.i(TAG, "[runCallMainActivity] Common.bWallPadCallLive [" + Common.bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6301. if (!Common.bWallPadCallLive) {
  6302. // 통화어플을 실행시킨다.
  6303. sendLCDBacklightStatus(true);
  6304. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  6305. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6306. // mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  6307. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  6308. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  6309. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  6310. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6311. mIntent.setComponent(mComponentName);
  6312. startActivity(mIntent);
  6313. }
  6314. else {
  6315. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  6316. }
  6317. } catch (RuntimeException re) {
  6318. LogUtil.errorLogInfo("", TAG, re);
  6319. }
  6320. catch (Exception e) {
  6321. Log.e(TAG, "[Exception] runCallMainActivity()");
  6322. LogUtil.errorLogInfo("", TAG, e);
  6323. }
  6324. }
  6325. /**
  6326. * Edited by jeff (2020.06.22)
  6327. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  6328. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  6329. * @param bOn
  6330. */
  6331. private void sendLCDBacklightStatus(boolean bOn) {
  6332. try {
  6333. Log.d(TAG,"[sendLCDBacklightStatus] bOn [" + bOn + "]");
  6334. Intent mIntent = new Intent();
  6335. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  6336. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  6337. getApplicationContext().sendBroadcast(mIntent);
  6338. } catch (RuntimeException re) {
  6339. LogUtil.errorLogInfo("", TAG, re);
  6340. }
  6341. catch (Exception e) {
  6342. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  6343. LogUtil.errorLogInfo("", TAG, e);
  6344. }
  6345. }
  6346. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nEmerState) {
  6347. try {
  6348. Log.i(TAG, "[runCallMainActivity] Common.bWallPadCallLive [" + Common.bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "], nEmerState [" + nEmerState + "]");
  6349. if (!Common.bWallPadCallLive) {
  6350. // 통화어플을 실행시킨다.
  6351. sendLCDBacklightStatus(true);
  6352. if (eEventType == CALLEVENTTYPE.DETECT_STRANGER) {
  6353. if (nEmerState >= 0) {
  6354. if (nEmerState != WallpadStatusData.GUARD_OUT)
  6355. Common.SendAppFinishReqBR(getApplicationContext());
  6356. }
  6357. }
  6358. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  6359. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6360. // mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  6361. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  6362. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  6363. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  6364. mIntent.putExtra("EMERGENCY_STATE", nEmerState);
  6365. if (nEmerState != WallpadStatusData.GUARD_OUT) Common.SendAppFinishReqBR(getApplicationContext());
  6366. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6367. mIntent.setComponent(mComponentName);
  6368. startActivity(mIntent);
  6369. }
  6370. else {
  6371. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  6372. }
  6373. } catch (RuntimeException re) {
  6374. LogUtil.errorLogInfo("", TAG, re);
  6375. }
  6376. catch (Exception e) {
  6377. Log.e(TAG, "[Exception] runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nEmerState)");
  6378. LogUtil.errorLogInfo("", TAG, e);
  6379. }
  6380. }
  6381. private String getTopActivity() {
  6382. try {
  6383. ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  6384. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  6385. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  6386. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  6387. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  6388. return mComponentName.getPackageName();
  6389. } catch (RuntimeException re) {
  6390. LogUtil.errorLogInfo("", TAG, re);
  6391. return null;
  6392. }
  6393. catch (Exception e) {
  6394. Log.e(TAG, "[Exception] getTopActivity()");
  6395. LogUtil.errorLogInfo("", TAG, e);
  6396. return null;
  6397. }
  6398. }
  6399. /**
  6400. * 월패드에 설치된 APP들의 패키지 명 및 버전을 저장하는 클래스
  6401. * **/
  6402. class PackageVersionInfo {
  6403. protected String strPackageName;
  6404. protected String strPackageVersion;
  6405. public PackageVersionInfo(String strName, String strVersion) {
  6406. strPackageName = strName;
  6407. strPackageVersion = strVersion;
  6408. }
  6409. public String getPackageName() {
  6410. return strPackageName;
  6411. }
  6412. public String getPackageVersion() {
  6413. return strPackageVersion;
  6414. }
  6415. }
  6416. /**
  6417. * 통화 타임아웃 DB정보 초기화 (무조건 사용함으로 변경)
  6418. * **/
  6419. public void setCallAppTimeoutAsDefault() {
  6420. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6421. try {
  6422. mWallpadDeviceSet.Set_CallAppCallTimeout(true);
  6423. mWallpadDeviceSet.closeDB();
  6424. } catch (RuntimeException re) {
  6425. LogUtil.errorLogInfo("", TAG, re);
  6426. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6427. }
  6428. catch (Exception e) {
  6429. Log.e(TAG, "[Exception] setCallAppTimeoutAsDefault()");
  6430. LogUtil.errorLogInfo("", TAG, e);
  6431. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6432. }
  6433. }
  6434. /**
  6435. * 동호 설정 화면 나오게 처리
  6436. * **/
  6437. private void startManagerSettingSetAddress() {
  6438. try {
  6439. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6440. MAINStatus = MAIN_WAIT_SETIP;
  6441. mIntent.setComponent(new ComponentName("com.artncore.managersetting", "com.artncore.managersetting.ui.activities.SetAddress"));
  6442. mIntent.putExtra("KIND", "SOLO");
  6443. startActivity(mIntent);
  6444. } catch (RuntimeException re) {
  6445. LogUtil.errorLogInfo("", TAG, re);
  6446. }
  6447. catch (Exception e) {
  6448. Log.e(TAG, "[Exception] startManagerSettingSetAddress()");
  6449. LogUtil.errorLogInfo("", TAG, e);
  6450. }
  6451. }
  6452. private Handler mGetCallHistoryCheckHandler = new Handler() {
  6453. @Override
  6454. public void handleMessage(Message msg) {
  6455. if (msg.what == 0) {
  6456. // CheckCallData_CalledCountAndVisitorCount();
  6457. checkEventNotifications();
  6458. }
  6459. }
  6460. };
  6461. /**
  6462. * 음력 데이터를 raw resource에서 wallpaddata폴더 밑으로 복사한다.
  6463. * **/
  6464. private void copyDataBase(String OutputDBPath) throws IOException {
  6465. // Open your local db as the input stream
  6466. //InputStream myInput = this.getAssets().open("luna_db.db");
  6467. InputStream myInput = getResources().openRawResource(R.raw.luna_db);
  6468. // Path to the just created empty db
  6469. String outFileName = OutputDBPath;
  6470. // Open the empty db as the output stream
  6471. OutputStream myOutput = new FileOutputStream(outFileName);
  6472. try {
  6473. // transfer bytes from the inputfile to the outputfile
  6474. byte[] buffer = new byte[1024];
  6475. int length;
  6476. while ((length = myInput.read(buffer)) > 0)
  6477. {
  6478. myOutput.write(buffer, 0, length);
  6479. }
  6480. // Close the streams
  6481. myOutput.flush();
  6482. }
  6483. catch (RuntimeException re) {
  6484. LogUtil.errorLogInfo("", TAG, re);
  6485. }
  6486. catch (Exception e)
  6487. {
  6488. LogUtil.errorLogInfo("", TAG, e);
  6489. }
  6490. finally {
  6491. if(myOutput!=null)
  6492. myOutput.close();
  6493. myOutput = null;
  6494. if(myInput!=null)
  6495. myInput.close();
  6496. myInput = null;
  6497. }
  6498. }
  6499. @SuppressLint("HandlerLeak")
  6500. protected Handler mLCD_SleepHandler = new Handler()
  6501. {
  6502. @SuppressLint("HandlerLeak")
  6503. @Override
  6504. public void handleMessage(Message msg)
  6505. {
  6506. if (msg.what == 0) {
  6507. try {
  6508. if (m_ModelHouseSleepModeRelease == true) {
  6509. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  6510. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  6511. }
  6512. else {
  6513. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  6514. }
  6515. Log.i(TAG, "[SAMPLE SLEEP MODE] Never Sleep Run ~~~");
  6516. }
  6517. } catch (RuntimeException re) {
  6518. LogUtil.errorLogInfo("", TAG, re);
  6519. }
  6520. catch (Exception e) {
  6521. LogUtil.errorLogInfo("", TAG, e);
  6522. }
  6523. }
  6524. }
  6525. };
  6526. public void runIcon(int nIconID) {
  6527. try {
  6528. Log.d(TAG, "[runIcon] nIconID [" + nIconID + "]");
  6529. if (nIconID == ID.ICONS.MENUS.MAIN_ELEVATOR.getID()) {
  6530. // DB를 체크해서 층표시이면 팝업을 띄우고 아니면 바로 호출하도록 한다
  6531. String strElevShortEnabled = Common.getSubDevListItem(this.getContext() ,Common.SETTING_ITEM_SUB_DEVICE_ELEVATOR);
  6532. if(strElevShortEnabled!=null)
  6533. {
  6534. Log.d(TAG, "[runIcon] strElevShortEnabled [" + strElevShortEnabled + "]");
  6535. if (strElevShortEnabled.contains("사용함") && strElevShortEnabled.contains("기본")) {
  6536. Sound().Play(SND.effect.TOUCH_LATCHED);
  6537. Intent intent = new Intent(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  6538. intent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN);
  6539. getContext().sendBroadcast(intent);
  6540. }
  6541. else {
  6542. ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.ElevatorPopupScreen);
  6543. }
  6544. }
  6545. }
  6546. else if (nIconID == ID.ICONS.MENUS.MAIN_LIGHTS_OUT.getID()) {
  6547. ((MainActivity)(getContext())).StartPopup(ID.POPUPS.POPUP_COLLECTIVELIGHTCTRL);
  6548. }
  6549. else if (nIconID == ID.ICONS.MENUS.MAIN_CALRENDAR.getID()) {
  6550. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.TimeSetting);
  6551. }
  6552. else if (nIconID == ID.ICONS.MENUS.MAIN_WEATHER.getID()) {
  6553. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Weather);
  6554. }
  6555. else if (nIconID == ID.ICONS.MENUS.TALK_FRONT.getID()) {
  6556. // Common.command_iGW200( this.getContext(), Common.IGW200_DOOR_MONITERING );
  6557. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Door);
  6558. }
  6559. else if (nIconID == ID.ICONS.MENUS.TALK_LOBBY.getID()) {
  6560. // 로비는 수신시에만 출력되는 화면이므로 해당코드 없음
  6561. }
  6562. else if (nIconID == ID.ICONS.MENUS.TALK_NEIGHBOR.getID()) {
  6563. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Neighboor);
  6564. }
  6565. else if (nIconID == ID.ICONS.MENUS.TALK_GUARD.getID()) {
  6566. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Guard);
  6567. }
  6568. else if (nIconID == ID.ICONS.MENUS.TALK_PHONE.getID()) {
  6569. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Pstn);
  6570. }
  6571. else if (nIconID == ID.ICONS.MENUS.TALK_CALLHISTORY.getID()) {
  6572. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.CallList);
  6573. }
  6574. else if (nIconID == ID.ICONS.MENUS.TALK_VISITORPIC.getID()) {
  6575. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Visitor);
  6576. }
  6577. else if (nIconID == ID.ICONS.MENUS.CTRL_LIGHT.getID()) {
  6578. // 모델별 설정에 따라 구분하여 호출하는 기능 추가해야함
  6579. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  6580. int[] naLightEnable = mWallpadDeviceSet.Get_Light_info(); // 조명설정 확인
  6581. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6582. // for (int i = 0; i < naLightEnable.length; i++) Log.i(TAG, "[runIcon] naLightEnable[" + i + "] = " + naLightEnable[i]);
  6583. if (naLightEnable[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_ADD_BATCHLIGHT_MULTISWITCH) {
  6584. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDCLivingNEach_Lamp);
  6585. }
  6586. else {
  6587. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDC_EachLamp);
  6588. }
  6589. }
  6590. else if (nIconID == ID.ICONS.MENUS.CTRL_HEATING.getID()) {
  6591. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Heating_V1);
  6592. }
  6593. //커튼 추가(전동커튼)
  6594. else if (nIconID == ID.ICONS.MENUS.CTRL_CURTAIN.getID()) {
  6595. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Curtain);
  6596. }
  6597. else if (nIconID == ID.ICONS.MENUS.CTRL_GAS.getID()) {
  6598. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Gas);
  6599. }
  6600. else if (nIconID == ID.ICONS.MENUS.CTRL_DOORLOCK.getID()) {
  6601. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.DoorLockWL);
  6602. }
  6603. else if (nIconID == ID.ICONS.MENUS.CTRL_VENT.getID()) {
  6604. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.ChangAir_Normal);
  6605. }
  6606. else if (nIconID == ID.ICONS.MENUS.CTRL_OUTLET.getID()) {
  6607. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  6608. int[] naLightEnable = mWallpadDeviceSet.Get_Light_info(); // 조명설정 확인
  6609. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6610. if (naLightEnable[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_ADD_BATCHLIGHT_MULTISWITCH) {
  6611. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDCLivingNEach_Concent);
  6612. }
  6613. else {
  6614. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Concent);
  6615. }
  6616. }
  6617. else if (nIconID == ID.ICONS.MENUS.CTRL_LIVINGLIGHT.getID()) {
  6618. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDC_LivingLamp);
  6619. }
  6620. else if (nIconID == ID.ICONS.MENUS.CTRL_AIRQUALTY.getID()) {
  6621. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.AirQualty);
  6622. }
  6623. else if (nIconID == ID.ICONS.MENUS.CTRL_ELECCOOKTOP.getID()) {
  6624. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.ElecCooktop);
  6625. }
  6626. else if (nIconID == ID.ICONS.MENUS.CTRL_COOKTOPOUTLET.getID()) {
  6627. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.CooktopOutlet);
  6628. }
  6629. else if (nIconID == ID.ICONS.MENUS.CTRL_SYSTEMAIRCON.getID()) {
  6630. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.SystemAircon);
  6631. }
  6632. else if (nIconID == ID.ICONS.MENUS.ADD_NOTICE.getID()) {
  6633. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Notice);
  6634. }
  6635. else if (nIconID == ID.ICONS.MENUS.ADD_WEATHER.getID()) {
  6636. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Weather);
  6637. }
  6638. else if (nIconID == ID.ICONS.MENUS.ADD_MEMO.getID()) {
  6639. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Memo);
  6640. }
  6641. else if (nIconID == ID.ICONS.MENUS.ADD_E_FRAME.getID()) {
  6642. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.AutoPicture);
  6643. }
  6644. else if (nIconID == ID.ICONS.MENUS.ADD_SCHEDULE.getID()) {
  6645. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Schedule);
  6646. }
  6647. else if (nIconID == ID.ICONS.MENUS.ADD_CCTV.getID()) {
  6648. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Cctv);
  6649. }
  6650. else if (nIconID == ID.ICONS.MENUS.ADD_PARKING.getID()) {
  6651. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Parking);
  6652. }
  6653. else if (nIconID == ID.ICONS.MENUS.ADD_PARKINGLIST.getID()) {
  6654. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.ParkingList);
  6655. }
  6656. else if (nIconID == ID.ICONS.MENUS.ADD_ELECTRICCAR.getID()) {
  6657. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.ElecCar);
  6658. }
  6659. else if (nIconID == ID.ICONS.MENUS.ADD_INTERLAYERNOISE.getID()) {
  6660. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.InterlayerNoiseHistory);
  6661. }
  6662. else if (nIconID == ID.ICONS.MENUS.ADD_VISITEDVEHICLEREGI.getID()) {
  6663. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.VisitedVehicleRegi);
  6664. }
  6665. else if (nIconID == ID.ICONS.MENUS.ADD_BANDLOCATION.getID()) {
  6666. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.BandLocation);
  6667. }
  6668. else if (nIconID == ID.ICONS.MENUS.ADD_GUARDINGSTREETLAMP.getID()) {
  6669. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.GuardingStreetLamp);
  6670. }
  6671. else if (nIconID == ID.ICONS.MENUS.SECURITY_SETARMED.getID()) {
  6672. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.SecurityMain);
  6673. }
  6674. else if (nIconID == ID.ICONS.MENUS.SECURITY_DEVICELINK.getID()) {
  6675. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.LinkDeviceSet);
  6676. }
  6677. else if (nIconID == ID.ICONS.MENUS.SECURITY_DEVICELINKSLEEP.getID()) {
  6678. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.lnkBedDeviceSet);
  6679. }
  6680. else if (nIconID == ID.ICONS.MENUS.SECURITY_ACCESSHISTORY.getID()) {
  6681. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.AccessHistoryDoor);
  6682. }
  6683. else if (nIconID == ID.ICONS.MENUS.SECURITY_VISITORVIDEO.getID()) {
  6684. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.VisitorVideo);
  6685. }
  6686. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTPANEL.getID()) {
  6687. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartPanel);
  6688. }
  6689. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTLIGHT.getID()) {
  6690. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartLight);
  6691. }
  6692. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTOUTLET.getID()) {
  6693. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartOutlet);
  6694. }
  6695. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYMETER.getID()) {
  6696. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.IEnergy);
  6697. }
  6698. else if (nIconID == ID.ICONS.MENUS.ENERGY_REMOTEMETER.getID()) {
  6699. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.RemoteMeter);
  6700. }
  6701. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYCONSUMPTION.getID()) {
  6702. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.EnergyMgr);
  6703. }
  6704. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYCOSTTABLE.getID()) {
  6705. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.CostTable);
  6706. }
  6707. else if (nIconID == ID.ICONS.MENUS.SETTING_CONFIG.getID()) {
  6708. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.Configuration);
  6709. }
  6710. else if (nIconID == ID.ICONS.MENUS.SETTING_CLREANSCREEN.getID()) {
  6711. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.CleanLcd);
  6712. }
  6713. else if (nIconID == ID.ICONS.MENUS.SETTING_PWCHANGE.getID()) {
  6714. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.PassWordChange);
  6715. }
  6716. else if (nIconID == ID.ICONS.MENUS.SETTING_MORNINGCALL.getID()) {
  6717. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.MoningCall);
  6718. }
  6719. else if (nIconID == ID.ICONS.MENUS.SETTING_SMARTKEY.getID()) {
  6720. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.SmartKey);
  6721. }
  6722. else if (nIconID == ID.ICONS.MENUS.SETTING_SMARTBAND.getID()) {
  6723. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.SmartBand);
  6724. }
  6725. else if (nIconID == ID.ICONS.MENUS.SETTING_ACCESSCARD.getID()) {
  6726. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.RfCard);
  6727. }
  6728. else if (nIconID == ID.ICONS.MENUS.SETTING_CALENDAR.getID()) {
  6729. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.TimeSetting);
  6730. }
  6731. else if (nIconID == ID.ICONS.MENUS.SETTING_REMOTECALLUSER.getID()) {
  6732. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.RemoteCallUser);
  6733. }
  6734. else if (nIconID == ID.ICONS.MENUS.SETTING_REMOTECTRL.getID()) {
  6735. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.MobileDeviceReg);
  6736. }
  6737. else if (nIconID == ID.ICONS.MENUS.SETTING_OCCUPANCYSENSOR.getID()) {
  6738. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.OccupancySensorConfig);
  6739. }
  6740. else {
  6741. Log.w(TAG, "[runShortcut] nIconID is not supported!! [" + nIconID + "]");
  6742. }
  6743. } catch (RuntimeException re) {
  6744. LogUtil.errorLogInfo("", TAG, re);
  6745. }
  6746. catch (Exception e) {
  6747. Log.e(TAG, "[Exception] runShortcut(int nIconID)");
  6748. LogUtil.errorLogInfo("", TAG, e);
  6749. }
  6750. }
  6751. public void runSecurityAPK(int nScreenID) {
  6752. try {
  6753. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  6754. int nSecurityMode = wdb.GetAlarmStatus();
  6755. wdb.closeDB();
  6756. Log.w(TAG, "[runSecurityAPK] nSecurityMode [" + nSecurityMode + "]");
  6757. if (nSecurityMode == WallpadStatusData.GUARD_IN) {
  6758. // 팝업 띄워서 재택모드 해제 유도
  6759. StartPopup(ID.POPUPS.POPUP_RELEASEINMODE);
  6760. // ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.SecurityReleasePopupScreen);
  6761. }
  6762. else if (nSecurityMode == WallpadStatusData.OUT_MODE) {
  6763. // 팝업 띄워서 외출모드 해제 유도
  6764. StartPopup(ID.POPUPS.POPUP_RELEASEOUTMODE);
  6765. // ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.OutModeReleasePopupScreen);
  6766. }
  6767. else if (nSecurityMode == WallpadStatusData.ALARM_STOP) {
  6768. // 알람 화면을 띄우도록 한다.
  6769. runEmergencyAPK(this, getAlarmType(), 2 , "모름");
  6770. }
  6771. else {
  6772. m_CallSubMenuScreen.callStartSecurityAPK(nScreenID);
  6773. }
  6774. } catch (RuntimeException re) {
  6775. LogUtil.errorLogInfo("", TAG, re);
  6776. }
  6777. catch (Exception e) {
  6778. Log.e(TAG, "[Exception] runSecurityAPK(int nScreenID)");
  6779. LogUtil.errorLogInfo("", TAG, e);
  6780. }
  6781. }
  6782. public void runEmergencyAPK(Context context, int nScreenID, int startOption, String detailInfo) {
  6783. try {
  6784. // DB 체크 해서 띄우 도록 한다.
  6785. int [] m_EmerMenuList = new int[4];
  6786. m_EmerMenuList[0] = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  6787. m_EmerMenuList[1] = ID.LINKEDSCREEN.SubEmergency.FIRE_ALARM;
  6788. m_EmerMenuList[2] = ID.LINKEDSCREEN.SubEmergency.BREAKIN_ALARM;
  6789. m_EmerMenuList[3] = ID.LINKEDSCREEN.SubEmergency.LADDER_ALARM;
  6790. Intent intent = new Intent(Intent.ACTION_MAIN);
  6791. intent.putExtra(Common.MENU_ID_LIST, m_EmerMenuList); // KEY : MENU_ID_LIST
  6792. intent.putExtra(Common.MENU_START_ID, nScreenID); // KEY : MENU_START_ID
  6793. intent.putExtra(Common.MENU_START_OPTION, startOption); // KEY : MENU_START_OPTION
  6794. intent.putExtra(Common.MENU_DETAIL_INFO, detailInfo);
  6795. intent.setComponent(new ComponentName(Common.EMER_ALARM_APK, Common.EMER_ALARM_APK + Common.MAIN_ACTIVITY ));
  6796. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6797. context.startActivity(intent);
  6798. } catch (RuntimeException re) {
  6799. LogUtil.errorLogInfo("", TAG, re);
  6800. }
  6801. catch (Exception e) {
  6802. Log.e(TAG, "[Exception] runEmergencyAPK(Context context, int nScreenID, int startOption, String detailInfo)");
  6803. LogUtil.errorLogInfo("", TAG, e);
  6804. }
  6805. }
  6806. public int getAlarmType() {
  6807. WallpadStatusData SetData = new WallpadStatusData(this.getContext());
  6808. int alarmtype = SetData.GetAlarmType();
  6809. SetData.closeDB();
  6810. int Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  6811. switch (alarmtype) {
  6812. case WallpadStatusData.ALARM_ALERT:
  6813. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.FIRE_ALARM;
  6814. break;
  6815. case WallpadStatusData.ALARM_EMM:
  6816. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  6817. break;
  6818. case WallpadStatusData.ALARM_EVAC:
  6819. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.LADDER_ALARM;
  6820. break;
  6821. case WallpadStatusData.ALARM_INVADE:
  6822. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.BREAKIN_ALARM;
  6823. break;
  6824. }
  6825. return Menu_Start_Option;
  6826. }
  6827. public void runGoogleLauncher() {
  6828. try {
  6829. ComponentName mComponentName = new ComponentName("com.android.launcher3", "com.android.launcher3.Launcher");
  6830. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6831. mIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  6832. mIntent.setComponent(mComponentName);
  6833. startActivity(mIntent);
  6834. } catch (RuntimeException re) {
  6835. LogUtil.errorLogInfo("", TAG, re);
  6836. }
  6837. catch (Exception e) {
  6838. Log.e(TAG, "[Exception] runGoogleLauncher()");
  6839. LogUtil.errorLogInfo("", TAG, e);
  6840. }
  6841. }
  6842. public void setCallAppRunning(boolean bRunning) {
  6843. try {
  6844. Log.i(TAG, "[setCallAppRunning] bRunning [" + bRunning + "]");
  6845. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  6846. DBMGR.SetCallAPKStatus(bRunning);
  6847. DBMGR.closeDB();
  6848. } catch (RuntimeException re) {
  6849. LogUtil.errorLogInfo("", TAG, re);
  6850. }
  6851. catch (Exception e) {
  6852. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  6853. LogUtil.errorLogInfo("", TAG, e);
  6854. }
  6855. }
  6856. private void registerMainActivityBR() {
  6857. try {
  6858. IntentFilter filter = new IntentFilter();
  6859. filter.addAction(Common.BR_REQUEST_APK_RUN);
  6860. filter.addAction(ACTION_TIME_TICK);
  6861. filter.addAction(Common.BR_PLAY_SOUND);
  6862. filter.addAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  6863. filter.addAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  6864. mContext.registerReceiver(MainActivityBroadcastReceiver, filter);
  6865. } catch (RuntimeException re) {
  6866. LogUtil.errorLogInfo("", TAG, re);
  6867. }
  6868. catch (Exception e) {
  6869. Log.e(TAG, "[Exception] registerMainActivityBR()");
  6870. LogUtil.errorLogInfo("", TAG, e);
  6871. }
  6872. }
  6873. String strAPKType = "APKType";
  6874. String strMenuType = "MenuType";
  6875. String strSoundID = "SoundID";
  6876. BroadcastReceiver MainActivityBroadcastReceiver = new BroadcastReceiver() {
  6877. @Override
  6878. public void onReceive(Context context, Intent intent) {
  6879. try {
  6880. if (((MainActivity)(getContext())).getMainSubScreenLoadingComplite() == false)
  6881. return;
  6882. String strActionName = intent.getAction();
  6883. Log.d(TAG,"[MainActivityBroadcastReceiver] strActionName [" + strActionName + "]");
  6884. if (strActionName.equals(Common.BR_REQUEST_APK_RUN)) {
  6885. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) BR_REQUEST_APK_RUN");
  6886. int nAPKType = intent.getIntExtra(strAPKType,0);
  6887. int nMenuType = intent.getIntExtra(strMenuType,0);
  6888. int nCardNum = intent.getIntExtra(Common.BR_MAIN_NOTI.CARD_NUM, 0);
  6889. Log.d(TAG, "[MainActivityBroadcastReceiver] nAPKType [" + nAPKType + "], nMenuType [" + nMenuType + "], nCardNum [" + nCardNum + "]");
  6890. if (nAPKType == ID.LINKEDSCREEN.SubCall.BASE) {
  6891. m_CallSubMenuScreen.callStartCallAPK(nMenuType);
  6892. }
  6893. else if (nAPKType == ID.LINKEDSCREEN.SubMenuAddService.BASE) {
  6894. m_CallSubMenuScreen.callStartAddServiceAPK(nMenuType, nCardNum);
  6895. }
  6896. }
  6897. else if (strActionName.equals(ACTION_TIME_TICK)) {
  6898. // checkTimeTasks();
  6899. if (bLCDKeeperUsage) ctrlLCDKeeper();
  6900. }
  6901. else if (strActionName.equals(Common.BR_PLAY_SOUND)) {
  6902. int nSoundID = intent.getIntExtra(strSoundID,0);
  6903. Sound().Play(nSoundID);
  6904. }
  6905. else if (strActionName.equals(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON)) {
  6906. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) NOTIFY_ACNAME_LCD_BACKLIGHT_ON: bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  6907. if (bLCDKeeperUsage) {
  6908. bLCDBacklightPower = true;
  6909. ctrlLCDKeeper();
  6910. }
  6911. }
  6912. else if (strActionName.equals(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF)) {
  6913. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) NOTIFY_ACNAME_LCD_BACKLIGHT_OFF: bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  6914. if (bLCDKeeperUsage) {
  6915. bLCDBacklightPower = false;
  6916. ctrlLCDKeeper();
  6917. }
  6918. }
  6919. else {
  6920. Log.w(TAG,"[MainActivityBroadcastReceiver] Not supported strActionName [" + strActionName + "]");
  6921. }
  6922. } catch (RuntimeException re) {
  6923. LogUtil.errorLogInfo("", TAG, re);
  6924. }
  6925. catch (Exception e) {
  6926. Log.e(TAG, "[Exception] MainActivityBroadcastReceiver()");
  6927. LogUtil.errorLogInfo("", TAG, e);
  6928. }
  6929. }
  6930. };
  6931. public Common.GUI_TYPE checkGUIType(Context context) {
  6932. try {
  6933. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(context);
  6934. String strGUIType = mWallpadDeviceSet.GetMainGUISelect();
  6935. mWallpadDeviceSet.closeDB();
  6936. if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_DEFAULT)) return Common.GUI_TYPE.STANDARD;
  6937. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_METRO)) return Common.GUI_TYPE.METRO;
  6938. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_HYOSUNG)) return Common.GUI_TYPE.HYOSUNG;
  6939. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_HIMCHAN)) return Common.GUI_TYPE.HIMCHAN;
  6940. else return Common.GUI_TYPE.STANDARD;
  6941. } catch (RuntimeException re) {
  6942. LogUtil.errorLogInfo("", TAG, re);
  6943. return Common.GUI_TYPE.STANDARD;
  6944. }
  6945. catch (Exception e) {
  6946. Log.e(TAG, "[Exception] checkGUIType(Context context)");
  6947. LogUtil.errorLogInfo("", TAG, e);
  6948. return Common.GUI_TYPE.STANDARD;
  6949. }
  6950. }
  6951. public void finishActivity() {
  6952. try {
  6953. Log.i(TAG, "[finishActivity]");
  6954. super.finish();
  6955. } catch (RuntimeException re) {
  6956. LogUtil.errorLogInfo("", TAG, re);
  6957. }
  6958. catch (Exception e) {
  6959. Log.e(TAG, "[Exception] finishActivity()");
  6960. LogUtil.errorLogInfo("", TAG, e);
  6961. }
  6962. }
  6963. // MainActivity Handler
  6964. public final class HANDLERMSG {
  6965. public final static int CHECK_FLIPPER_MAINSCREEN_ID = 100;
  6966. public final static int CHECK_WALLPAD_CAMERA_INIT = 200;
  6967. public final static int CHECK_WALLPAD_CAMERA_REMOVE = 300;
  6968. public final static int CHECK_WALLPAD_CAMERA_RESET = 400;
  6969. public final static int CHECK_WALLPAD_CAMERA_CHECK = 500;
  6970. public final static int FINISH_ACTIVITY = 999;
  6971. }
  6972. public Handler MainHandler = new Handler(Looper.getMainLooper()) {
  6973. public void handleMessage(Message msg) {
  6974. Log.d(TAG, "[MainHandler] MainHandler : what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
  6975. switch (msg.what) {
  6976. case HANDLERMSG.CHECK_FLIPPER_MAINSCREEN_ID:
  6977. // checkMainPage();
  6978. break;
  6979. case HANDLERMSG.CHECK_WALLPAD_CAMERA_INIT:
  6980. if (getWallPadCameraUsage()) {
  6981. initMyVideoSurfaceLayout();
  6982. sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_REMOVE, 0, 0, 3000); // 월패드 카메라 영상을 띄우고 5초뒤에 없앤다.
  6983. }
  6984. break;
  6985. case HANDLERMSG.CHECK_WALLPAD_CAMERA_REMOVE:
  6986. if (getWallPadCameraUsage()) removeMyVideoSurfaceLayout();
  6987. break;
  6988. case HANDLERMSG.CHECK_WALLPAD_CAMERA_RESET:
  6989. if (getWallPadCameraUsage()) resetCameraService();
  6990. break;
  6991. case HANDLERMSG.CHECK_WALLPAD_CAMERA_CHECK:
  6992. checkCameraLoading();
  6993. break;
  6994. case HANDLERMSG.FINISH_ACTIVITY:
  6995. finishActivity();
  6996. break;
  6997. default:
  6998. Log.d(TAG, "MainHandler : " + msg.what);
  6999. break;
  7000. }
  7001. }
  7002. };
  7003. public void sendHandlerMsg(int what, int arg1, int arg2) {
  7004. try {
  7005. Log.i(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
  7006. Message HandleMsg = MainHandler.obtainMessage();
  7007. HandleMsg.what = what;
  7008. HandleMsg.arg1 = arg1;
  7009. HandleMsg.arg2 = arg2;
  7010. MainHandler.sendMessage(HandleMsg);
  7011. } catch (RuntimeException re) {
  7012. LogUtil.errorLogInfo("", TAG, re);
  7013. }
  7014. catch (Exception e) {
  7015. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  7016. LogUtil.errorLogInfo("", TAG, e);
  7017. }
  7018. }
  7019. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, long delay) {
  7020. try {
  7021. Log.i(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
  7022. Message HandleMsg = MainHandler.obtainMessage();
  7023. HandleMsg.what = what;
  7024. HandleMsg.arg1 = arg1;
  7025. HandleMsg.arg2 = arg2;
  7026. MainHandler.sendMessageDelayed(HandleMsg, delay);
  7027. } catch (RuntimeException re) {
  7028. LogUtil.errorLogInfo("", TAG, re);
  7029. }
  7030. catch (Exception e) {
  7031. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  7032. LogUtil.errorLogInfo("", TAG, e);
  7033. }
  7034. }
  7035. private boolean savePresetValue(String strPresetValues) {
  7036. try {
  7037. Log.i(TAG, "[savePresetValue] strPresetValues [" + strPresetValues + "]");
  7038. String[] strParse_01 = strPresetValues.split("/");
  7039. int presetid = Integer.parseInt(strParse_01[0]);
  7040. String[] strParse_02 = strParse_01[1].split(":");
  7041. String onoff = strParse_02[0];
  7042. int dim = Integer.parseInt(strParse_02[1]);
  7043. int color = Integer.parseInt(strParse_02[2]);
  7044. WallpadStatusData mWallpadStatusData = new WallpadStatusData(mContext);
  7045. boolean result = mWallpadStatusData.setLivinglightModeCtrlUnitValues(presetid, 0, "on", dim, color);
  7046. mWallpadStatusData.closeDB();
  7047. Log.d(TAG, "[savePresetValue] result [" + result + "], onoff [" + onoff + "], dim [" + dim + "], color [" + color + "]");
  7048. if (result) {
  7049. mLightInfo.mPreset[presetid].mLights[0].ONOFF = onoff;
  7050. mLightInfo.mPreset[presetid].mLights[0].DIM = dim;
  7051. mLightInfo.mPreset[presetid].mLights[0].COLOR = color;
  7052. 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 + "]");
  7053. return true;
  7054. }
  7055. else {
  7056. Log.w(TAG,"[savePresetValue] Fail to save light preset values!!");
  7057. return false;
  7058. }
  7059. } catch (RuntimeException re) {
  7060. LogUtil.errorLogInfo("", TAG, re);
  7061. return false;
  7062. }
  7063. catch (Exception e) {
  7064. Log.e(TAG, "[Exception] savePresetValue(String strPresetValues)");
  7065. LogUtil.errorLogInfo("", TAG, e);
  7066. return false;
  7067. }
  7068. }
  7069. private void initProximitySensor() {
  7070. try {
  7071. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  7072. int nProximitySensorLevel = mWallpadStatusData.GetCloseSensorValue();
  7073. mWallpadStatusData.closeDB();
  7074. Log.i(TAG, "[initProximitySensor] nProximitySensorLevel = " + nProximitySensorLevel);
  7075. if (nProximitySensorLevel < 0 || 5 < nProximitySensorLevel) {
  7076. Log.w(TAG, "[initProximitySensor] nProximitySensorLevel is out of range!!");
  7077. nProximitySensorLevel = 5;
  7078. }
  7079. int nResult = mIOInterface.setProximitySensorLevel(nProximitySensorLevel * 3);
  7080. Log.i(TAG, "[initProximitySensor] nResult = " + nResult);
  7081. } catch (RuntimeException re) {
  7082. LogUtil.errorLogInfo("", TAG, re);
  7083. }
  7084. catch (Exception e) {
  7085. Log.e(TAG, "[Exception] initProximitySensor()");
  7086. LogUtil.errorLogInfo("", TAG, e);
  7087. }
  7088. }
  7089. private boolean checkInterFloorNoiseError() {
  7090. try {
  7091. WallpadStatusData wsd = new WallpadStatusData(getContext());
  7092. String stSensorStatus = wsd.Get_InterlayerSensor_Status();
  7093. wsd.closeDB();
  7094. // 센서 정상 : false, 센서 이상 : true
  7095. Log.i(TAG, "[checkInterFloorNoiseError] stSensorStatus : " + stSensorStatus);
  7096. if (stSensorStatus.equalsIgnoreCase(define.INTERLAYER_NOISE_STATUS_NORMAL)) return false;
  7097. else return true;
  7098. } catch (RuntimeException re) {
  7099. LogUtil.errorLogInfo("", TAG, re);
  7100. return false;
  7101. }
  7102. catch (Exception e) {
  7103. Log.e(TAG, "[Exception] checkInterFloorNoiseError()");
  7104. LogUtil.errorLogInfo("", TAG, e);
  7105. return false;
  7106. }
  7107. }
  7108. private boolean checkInterFloorNoiseFuncUsage() {
  7109. try {
  7110. WallpadStatusData wsd = new WallpadStatusData(getContext());
  7111. boolean bUsage = wsd.GetNoisePopupUse();
  7112. wsd.closeDB();
  7113. return bUsage;
  7114. } catch (RuntimeException re) {
  7115. LogUtil.errorLogInfo("", TAG, re);
  7116. return false;
  7117. }
  7118. catch (Exception e) {
  7119. Log.e(TAG, "[Exception] checkInterFloorNoiseFuncUsage()");
  7120. LogUtil.errorLogInfo("", TAG, e);
  7121. return false;
  7122. }
  7123. }
  7124. /**
  7125. * 현관호출 or 전화호출시 사용되는 keycode - Broadcast 을 송신한다.
  7126. *
  7127. * @param nKeyCode - (int) 송신할 keycode
  7128. * @return (int) - >=0 : 성공, <0 : 실패
  7129. */
  7130. private int sendKeyEventBR(int nKeyCode) {
  7131. try {
  7132. Log.i(TAG, "[sendKeyEventBR] nKeyCode [" + nKeyCode +"] -> EVENT_DEVICE_CONTROL");
  7133. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  7134. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  7135. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  7136. intent.putExtra("keycode",nKeyCode);
  7137. sendBroadcast(intent);
  7138. } catch (RuntimeException re) {
  7139. LogUtil.errorLogInfo("", TAG, re);
  7140. return -100;
  7141. }
  7142. catch (Exception e) {
  7143. Log.e(TAG, "[Exception] sendKeyEventBR(int nKeyCode) [" + nKeyCode + "]");
  7144. LogUtil.errorLogInfo("", TAG, e);
  7145. return -100;
  7146. }
  7147. return 0;
  7148. }
  7149. // 카카오 연동 관련
  7150. public static boolean bKakaoiEnable = false;
  7151. /**
  7152. * 이진규
  7153. * kakaohome 서비스 사용 유무 판단
  7154. */
  7155. protected boolean bKakaoHomeEnable = false;
  7156. // run Kakao i floating button 실행
  7157. private void startKakaoiFloatingBTN() {
  7158. try {
  7159. Log.i(TAG, "[startKakaoiFloatingBTN] ========== Run Kakao i floating button ==========");
  7160. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadglobalbutton", "kr.co.icontrols.wallpadglobalbutton.MainActivity");
  7161. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  7162. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  7163. mIntent.setComponent(mComponentName);
  7164. startActivity(mIntent);
  7165. } catch (RuntimeException re) {
  7166. LogUtil.errorLogInfo("", TAG, re);
  7167. }
  7168. catch (Exception e) {
  7169. Log.e(TAG, "[Exception] startKakaoiFloatingBTN()");
  7170. LogUtil.errorLogInfo("", TAG, e);
  7171. }
  7172. }
  7173. public void Send_NotiSmartSwitch(int nNoticeCnt, int nParcelCnt, int nVisitorPicCnt)
  7174. {
  7175. try
  7176. {
  7177. Intent intentBR = new Intent();
  7178. intentBR.setAction(define.DRIVER_ISD_NOTIINFO);
  7179. //if( m_NoticeCNT > 0 || m_ParcelCNT > 0 || m_InCallCNT > 0 || m_VisitorCNT > 0 )
  7180. {
  7181. // 아이콘 활성화
  7182. if( nNoticeCnt > 0 )
  7183. {
  7184. Log.d(TAG, "LOG : NOTICE CNT INCREASED ++");
  7185. intentBR.putExtra(define.NOTIBR_ISD_NOTICECNT, nNoticeCnt);
  7186. Log.d(TAG, "NoticeCNT BroadCast Added");
  7187. }
  7188. else
  7189. {
  7190. intentBR.putExtra(define.NOTIBR_ISD_NOTICECNT, 0);
  7191. Log.d(TAG, "NoticeCNT ZERO Added");
  7192. }
  7193. if( nParcelCnt > 0 )
  7194. {
  7195. Log.d(TAG, "LOG : Parcel CNT INCREASED ++");
  7196. intentBR.putExtra(define.NOTIBR_ISD_PARCELCNT, nParcelCnt);
  7197. Log.d(TAG, "ParcelCNT BroadCast Added");
  7198. }
  7199. else
  7200. {
  7201. intentBR.putExtra(define.NOTIBR_ISD_PARCELCNT, 0);
  7202. Log.d(TAG, "ParcelCNT ZERO Added");
  7203. }
  7204. if( nVisitorPicCnt > 0 )
  7205. {
  7206. Log.d(TAG, "LOG : VISITOR CNT INCREASED ++");
  7207. intentBR.putExtra(define.NOTIBR_ISD_VISITORCNT, nVisitorPicCnt);
  7208. Log.d(TAG, "VisitorCNT BroadCast Added");
  7209. }
  7210. else
  7211. {
  7212. intentBR.putExtra(define.NOTIBR_ISD_VISITORCNT, nVisitorPicCnt);
  7213. Log.d(TAG, "VisitorCNT ZERO Added");
  7214. }
  7215. // 알림정보 intent BroadCast
  7216. getContext().sendBroadcast(intentBR);
  7217. }
  7218. }
  7219. catch (RuntimeException re) {
  7220. LogUtil.errorLogInfo("", TAG, re);
  7221. }
  7222. catch (Exception e)
  7223. {
  7224. Log.e(TAG, e.toString());
  7225. LogUtil.errorLogInfo("", TAG, e);
  7226. }
  7227. }
  7228. // private void startKakaoiVoiceAgent() {
  7229. // try {
  7230. // Log.i(TAG, "[startKakaoiVoiceAgent] ========== Start Kakao i Voice Agent ==========");
  7231. // Intent mIntent = new Intent("com.kakao.i.agent.START_SERVICE").setPackage("com.kakao.i.test.sandbox");
  7232. // ContextCompat.startForegroundService(this, mIntent);
  7233. // } catch (RuntimeException re) {
  7234. // LogUtil.errorLogInfo("", TAG, re);
  7235. // }
  7236. // catch (Exception e) {
  7237. // Log.e(TAG, "[Exception] startKakaoiVoiceAgent()");
  7238. // e.printStackTrace();
  7239. // }
  7240. // }
  7241. //
  7242. // private void enableKakaoiVoiceAgent() {
  7243. // try {
  7244. // Log.i(TAG, "[enableKakaoiVoiceAgent] ========== Enable Kakao i Voice Agent ==========");
  7245. // Intent mIntent = new Intent("com.kakao.i.agent.ENABLE_KAKAO_I").setPackage("com.kakao.i.test.sandbox");
  7246. // ContextCompat.startForegroundService(this, mIntent);
  7247. // } catch (RuntimeException re) {
  7248. // LogUtil.errorLogInfo("", TAG, re);
  7249. // }
  7250. // catch (Exception e) {
  7251. // Log.e(TAG, "[Exception] enableKakaoiVoiceAgent()");
  7252. // e.printStackTrace();
  7253. // }
  7254. // }
  7255. //
  7256. // private void diableKakaoiVoiceAgent() {
  7257. // try {
  7258. // Log.i(TAG, "[diableKakaoiVoiceAgent] ========== Disable Kakao i Voice Agent ==========");
  7259. // Intent mIntent = new Intent("com.kakao.i.agent.DISABLE_KAKAO_I").setPackage("com.kakao.i.test.sandbox");
  7260. // ContextCompat.startForegroundService(this, mIntent);
  7261. // } catch (RuntimeException re) {
  7262. // LogUtil.errorLogInfo("", TAG, re);
  7263. // }
  7264. // catch (Exception e) {
  7265. // Log.e(TAG, "[Exception] diableKakaoiVoiceAgent()");
  7266. // e.printStackTrace();
  7267. // }
  7268. // }
  7269. /**
  7270. * JEFF, 2019.08.06
  7271. * 동탄현장 월패드 죽는 이슈 원인 분석을 위한 월패드 App 삭제 코드
  7272. * 메인App만 남기고 모두 삭제
  7273. */
  7274. UninstallAPKs mUninstallAPKs = new UninstallAPKs();
  7275. class UninstallAPKs extends Thread {
  7276. @Override
  7277. public void run() {
  7278. super.run();
  7279. try {
  7280. Log.d(TAG, "[UninstallAPKs.run()] Started getting installed package infomation");
  7281. ArrayList<PackageVersionInfo> PackageVersionInfos = new ArrayList<PackageVersionInfo>();
  7282. List<PackageInfo> PackageInfoList = getPackageManager().getInstalledPackages(PackageManager.PERMISSION_GRANTED);
  7283. while (true) {
  7284. Log.d(TAG, "[UninstallAPKs.run()] Get installed packages start!!");
  7285. try {
  7286. for (PackageInfo pack : PackageInfoList) {
  7287. // Log.d(TAG, "[UninstallAPKs.run()] Package Name [" + pack.packageName + "]");
  7288. // Log.d(TAG, "[UninstallAPKs.run()] Version Name [" + pack.versionName + "]");
  7289. if ((pack.packageName.contains("icontrols")) || (pack.packageName.contains("artncore"))) {
  7290. PackageVersionInfos.add(new PackageVersionInfo(pack.packageName, pack.versionName));
  7291. }
  7292. }
  7293. } catch (RuntimeException re) {
  7294. LogUtil.errorLogInfo("", TAG, re);
  7295. break;
  7296. } catch (Exception e) {
  7297. LogUtil.errorLogInfo("", TAG, e);
  7298. break;
  7299. }
  7300. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages end!!");
  7301. break;
  7302. }
  7303. for (int i = 0; i < PackageVersionInfos.size(); i++) {
  7304. Log.d(TAG, "[UninstallAPKs.run()] Package Name [" + PackageVersionInfos.get(i).getPackageName() + "]");
  7305. Log.d(TAG, "[UninstallAPKs.run()] Version Name [" + PackageVersionInfos.get(i).strPackageVersion + "]");
  7306. uninstallWallPadApp(PackageVersionInfos.get(i).getPackageName());
  7307. try {
  7308. Thread.sleep(5000);
  7309. } catch (RuntimeException re) {
  7310. LogUtil.errorLogInfo("", TAG, re);
  7311. } catch (Exception e) {
  7312. LogUtil.errorLogInfo("", TAG, e);
  7313. }
  7314. }
  7315. } catch (RuntimeException re) {
  7316. LogUtil.errorLogInfo("", TAG, re);
  7317. } catch (Exception e) {
  7318. Log.e(TAG, "[Exception] UninstallAPKs.run()");
  7319. LogUtil.errorLogInfo("", TAG, e);
  7320. }
  7321. // try {Thread.sleep(5000);}catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
  7322. }
  7323. }
  7324. private void uninstallWallPadApp(String strAPK) {
  7325. try {
  7326. Log.w(TAG, "[uninstallWallPadApp] strAPK [" + strAPK + "]");
  7327. if (checkAppInstalled(strAPK)) {
  7328. // Intent mIntent = new Intent(Intent.ACTION_DELETE);
  7329. Intent mIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
  7330. mIntent.setData(Uri.parse("package:" + strAPK));
  7331. mIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
  7332. startActivityForResult(mIntent, UNINSTALL_REQUEST_CODE);
  7333. }
  7334. else {
  7335. Log.w(TAG, "[uninstallWallPadApp] Not installed [" + strAPK + "]");
  7336. }
  7337. } catch (RuntimeException re) {
  7338. LogUtil.errorLogInfo("", TAG, re);
  7339. }
  7340. catch (Exception e) {;
  7341. Log.e(TAG, "[Exception] uninstallWallPadApp()");
  7342. LogUtil.errorLogInfo("", TAG, e);
  7343. }
  7344. }
  7345. iMAPRemotemeter miMAPRemotemeter;
  7346. boolean mEMS_Enable;
  7347. int nEnergyTypeCnt;
  7348. private boolean mCostInfo_Enable = false;
  7349. private Calendar nowCal, HourCal, DateCal, MonthCal, YearCal, EnergyDataGetCal;
  7350. int CalendarYear;
  7351. int CalendarMonth;
  7352. int CalendarDate;
  7353. int ShowNowEnergyIndex = 0;
  7354. String[] ShowListEnergyType_String = {
  7355. "전기",
  7356. "수도",
  7357. "가스",
  7358. "온수",
  7359. "난방",
  7360. "탄소"
  7361. };
  7362. // 원격검침 월사용량 데이터 클래스
  7363. MonthTableClass monthTableClass[] = new MonthTableClass[6];
  7364. class MonthTableClass {
  7365. private String Use;
  7366. private String SamePyungUse;
  7367. private String Rank;
  7368. private String Goal;
  7369. private String Price;
  7370. public MonthTableClass (String Use, String SamePyungUse, String Rank, String Goal) {
  7371. this.Use = Use;
  7372. this.SamePyungUse = SamePyungUse;
  7373. this.Rank = Rank;
  7374. this.Goal = Goal;
  7375. }
  7376. public String getUse(){return Use;}
  7377. public String getSamePyungUse(){return SamePyungUse;}
  7378. public String getRank(){return Rank;}
  7379. public String getGoal(){return Goal;}
  7380. public String getPrice(){return Price;}
  7381. }
  7382. public void GetMeteringCount()
  7383. {
  7384. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  7385. String[] MetringDB = devSet.GetSettingData("원격검침");
  7386. devSet.closeDB();
  7387. if (MetringDB != null)
  7388. {
  7389. try
  7390. {
  7391. String devInfo = MetringDB[1];
  7392. devInfo = devInfo.replace('(', '_');
  7393. devInfo = devInfo.replace(':', '_');
  7394. devInfo = devInfo.replace(')', '_');
  7395. String[] MetringInfo = devInfo.split("_");
  7396. // MetringInfo[1] -> 회로수
  7397. // MetringInfo[5] -> EMS 사용여부 사용함 or 사용안함
  7398. if ((Integer.parseInt(MetringInfo[1]) == 2) || (Integer.parseInt(MetringInfo[1]) == 3) || (Integer.parseInt(MetringInfo[1]) == 5) || (Integer.parseInt(MetringInfo[1]) == 6))
  7399. {
  7400. nEnergyTypeCnt = Integer.parseInt(MetringInfo[1]);
  7401. }
  7402. else
  7403. {
  7404. nEnergyTypeCnt = 5;
  7405. }
  7406. if (MetringInfo[5].equals("사용함"))
  7407. {
  7408. mEMS_Enable = true;
  7409. }
  7410. else
  7411. {
  7412. mEMS_Enable = false;
  7413. }
  7414. if(MetringInfo[7].equals("사용함"))
  7415. {
  7416. mCostInfo_Enable = true;
  7417. }
  7418. else
  7419. {
  7420. mCostInfo_Enable = false;
  7421. }
  7422. }
  7423. catch (RuntimeException re) {
  7424. LogUtil.errorLogInfo("", TAG, re);
  7425. nEnergyTypeCnt = 5;
  7426. mEMS_Enable = true;
  7427. }
  7428. catch (Exception e)
  7429. {
  7430. LogUtil.errorLogInfo("", TAG, e);
  7431. nEnergyTypeCnt = 5;
  7432. mEMS_Enable = true;
  7433. }
  7434. }
  7435. else
  7436. {
  7437. nEnergyTypeCnt = 5;
  7438. mEMS_Enable = true;
  7439. }
  7440. }
  7441. /**
  7442. * @description
  7443. * 서버로 부터 데이터를 받아와 분석하고 표현하는 함수<br>
  7444. * @param
  7445. * InputType 0 당월, 1 일별<br>
  7446. * @param
  7447. * //year - 연도<br>
  7448. * @param
  7449. * //month - 월<br>
  7450. * @param
  7451. * //energy - 0 전기, 1 수도, 2 가스, 3 온수, 4 열량, 5 탄소<br>
  7452. */
  7453. private void LoadRemotemeterDataFromServer(int InputType, int Year, int Month, int Energy, final boolean bSendToMobile) {
  7454. final int inputType = InputType;
  7455. final int year = Year;
  7456. final int month = (Month+1);
  7457. try {
  7458. Log.i(TAG, "[LoadRemotemeterDataFromServer] InputType [" + InputType + "], Year [" + Year + "], Month [" + Month + "], Energy [" + Energy + "], bSendToMobile [" + bSendToMobile + "]");
  7459. Log.i(TAG, "[LoadRemotemeterDataFromServer] inputType [" + inputType + "], year [" + year + "], month [" + month + "]");
  7460. miMAPRemotemeter = new iMAPRemotemeter(getApplicationContext());
  7461. switch(inputType) {
  7462. case 0: //당월
  7463. miMAPRemotemeter.DoWork(true, true, true, true, true, true, true, mEMS_Enable, year, month);
  7464. break;
  7465. case 1: //일별
  7466. miMAPRemotemeter.DoWork(false, true, true, true, true, true, false, false, year, month);
  7467. break;
  7468. default:
  7469. break;
  7470. }
  7471. boolean isUseEMS = true;
  7472. WallpadDeviceSet wds = new WallpadDeviceSet(getContext());
  7473. isUseEMS = wds.GetEMSProtocolUse();
  7474. wds.closeDB();
  7475. if(isUseEMS)
  7476. {
  7477. miMAPRemotemeter.SetRetCtr(new RetProci() {
  7478. @Override
  7479. public void ProcSuccess() {
  7480. String TempString = null;
  7481. // DB
  7482. WallpadStatusData StatusDBMGR = null;
  7483. try {
  7484. StatusDBMGR = new WallpadStatusData(getApplicationContext());
  7485. Log.i(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] inputType [" + inputType + "]");
  7486. boolean result = false;
  7487. switch (inputType) {
  7488. case 0: // 당월
  7489. EnergyDataGetCal = Calendar.getInstance();
  7490. int NumberOfValuelist = miMAPRemotemeter.SetItem("valuelist");
  7491. if (NumberOfValuelist != 0) {
  7492. for (int i = 0; i < NumberOfValuelist; i++) {
  7493. //DebugLogOutput("NumberOfValuelist " + Integer.toString(NumberOfValuelist));
  7494. //DebugLogOutput("GetAttributeVal(i, month) " + imapRemotemeter.GetAttributeVal(i, "month"));
  7495. //DebugLogOutput("CalendarMonth " + (CalendarMonth + 1));
  7496. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == (CalendarMonth + 1)) && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == (CalendarYear))) {
  7497. result = true;
  7498. int Temp_mNumberOfEnergy = nEnergyTypeCnt;
  7499. if (Temp_mNumberOfEnergy == 2) {
  7500. Temp_mNumberOfEnergy = 3;
  7501. }
  7502. for (int j = 0; j < Temp_mNumberOfEnergy; j++) {
  7503. switch (j) {
  7504. case 0:
  7505. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7506. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  7507. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000") == true) {
  7508. monthTableClass[j].Use = "0";
  7509. }
  7510. else {
  7511. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  7512. }
  7513. }
  7514. if (miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize") != null) {
  7515. if (miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize").equals("null") == true) {
  7516. monthTableClass[j].SamePyungUse = "0";
  7517. }
  7518. else {
  7519. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize");
  7520. }
  7521. }
  7522. if ((miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7523. if (miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize").equals("null") == true) {
  7524. TempString = "- / ";
  7525. }
  7526. else {
  7527. TempString = miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize") + " / ";
  7528. }
  7529. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7530. TempString = TempString + "-";
  7531. }
  7532. else {
  7533. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7534. }
  7535. monthTableClass[j].Rank = TempString;
  7536. }
  7537. //가격정보
  7538. if (mCostInfo_Enable == true) {
  7539. if (miMAPRemotemeter.GetAttributeVal(i, "elect_price") != null) {
  7540. if (miMAPRemotemeter.GetAttributeVal(i, "elect_price").equals("null") == true) {
  7541. monthTableClass[j].Price = "";
  7542. }
  7543. else {
  7544. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "elect_price");
  7545. }
  7546. }
  7547. }
  7548. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7549. //DebugLogOutput("전기");
  7550. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7551. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7552. break;
  7553. case 1:
  7554. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7555. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  7556. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  7557. monthTableClass[j].Use = "0";
  7558. }
  7559. else {
  7560. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  7561. }
  7562. }
  7563. if (miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize") != null) {
  7564. if (miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize").equals("null") == true) {
  7565. monthTableClass[j].SamePyungUse = "0";
  7566. }
  7567. else {
  7568. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize");
  7569. }
  7570. }
  7571. if ((miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7572. if (miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize").equals("null") == true) {
  7573. TempString = "- / ";
  7574. }
  7575. else {
  7576. TempString = miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize") + " / ";
  7577. }
  7578. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7579. TempString = TempString + "-";
  7580. }
  7581. else {
  7582. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7583. }
  7584. monthTableClass[j].Rank = TempString;
  7585. }
  7586. //가격정보
  7587. if (mCostInfo_Enable == true) {
  7588. if (miMAPRemotemeter.GetAttributeVal(i, "water_price") != null) {
  7589. if (miMAPRemotemeter.GetAttributeVal(i, "water_price").equals("null") == true) {
  7590. monthTableClass[j].Price = "";
  7591. }
  7592. else {
  7593. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "water_price");
  7594. }
  7595. }
  7596. }
  7597. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7598. //DebugLogOutput("수도");
  7599. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7600. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7601. break;
  7602. case 2:
  7603. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7604. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  7605. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  7606. monthTableClass[j].Use = "0";
  7607. }
  7608. else {
  7609. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  7610. }
  7611. }
  7612. if (miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize") != null) {
  7613. if (miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize").equals("null") == true) {
  7614. monthTableClass[j].SamePyungUse = "0";
  7615. }
  7616. else {
  7617. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize");
  7618. }
  7619. }
  7620. if ((miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7621. if (miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize").equals("null") == true) {
  7622. TempString = "- / ";
  7623. }
  7624. else {
  7625. TempString = miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize") + " / ";
  7626. }
  7627. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7628. TempString = TempString + "-";
  7629. }
  7630. else {
  7631. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7632. }
  7633. monthTableClass[j].Rank = TempString;
  7634. }
  7635. //가격정보
  7636. if (mCostInfo_Enable == true) {
  7637. if (miMAPRemotemeter.GetAttributeVal(i, "gas_price") != null) {
  7638. if (miMAPRemotemeter.GetAttributeVal(i, "gas_price").equals("null") == true) {
  7639. monthTableClass[j].Price = "";
  7640. }
  7641. else {
  7642. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "gas_price");
  7643. }
  7644. }
  7645. }
  7646. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7647. //DebugLogOutput("가스");
  7648. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7649. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7650. break;
  7651. case 3:
  7652. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7653. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  7654. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  7655. monthTableClass[j].Use = "0";
  7656. }
  7657. else {
  7658. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  7659. }
  7660. }
  7661. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize") != null) {
  7662. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize").equals("null") == true) {
  7663. monthTableClass[j].SamePyungUse = "0";
  7664. }
  7665. else {
  7666. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize");
  7667. }
  7668. }
  7669. if ((miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7670. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize").equals("null") == true) {
  7671. TempString = "- / ";
  7672. }
  7673. else {
  7674. TempString = miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize") + " / ";
  7675. }
  7676. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7677. TempString = TempString + "-";
  7678. }
  7679. else {
  7680. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7681. }
  7682. monthTableClass[j].Rank = TempString;
  7683. }
  7684. //가격정보
  7685. if (mCostInfo_Enable == true) {
  7686. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_price") != null) {
  7687. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_price").equals("null") == true) {
  7688. monthTableClass[j].Price = "";
  7689. }
  7690. else {
  7691. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "hotwater_price");
  7692. }
  7693. }
  7694. }
  7695. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7696. //DebugLogOutput("온수");
  7697. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7698. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7699. break;
  7700. case 4:
  7701. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7702. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  7703. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  7704. monthTableClass[j].Use = "0";
  7705. }
  7706. else {
  7707. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  7708. }
  7709. }
  7710. if (miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize") != null) {
  7711. if (miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize").equals("null") == true) {
  7712. monthTableClass[j].SamePyungUse = "0";
  7713. }
  7714. else {
  7715. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize");
  7716. }
  7717. }
  7718. if ((miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7719. if (miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize").equals("null") == true) {
  7720. TempString = "- / ";
  7721. }
  7722. else {
  7723. TempString = miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize") + " / ";
  7724. }
  7725. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7726. TempString = TempString + "-";
  7727. }
  7728. else {
  7729. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7730. }
  7731. monthTableClass[j].Rank = TempString;
  7732. }
  7733. //가격정보
  7734. if (mCostInfo_Enable == true) {
  7735. if (miMAPRemotemeter.GetAttributeVal(i, "energy_price") != null) {
  7736. if (miMAPRemotemeter.GetAttributeVal(i, "energy_price").equals("null") == true) {
  7737. monthTableClass[j].Price = "";
  7738. }
  7739. else {
  7740. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "energy_price");
  7741. }
  7742. }
  7743. }
  7744. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7745. //DebugLogOutput("열량");
  7746. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7747. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7748. break;
  7749. case 5:
  7750. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7751. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_used") != null) {
  7752. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_used").equals("1000000") == true) {
  7753. monthTableClass[j].Use = "0";
  7754. }
  7755. else {
  7756. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "carbon_used");
  7757. }
  7758. }
  7759. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize") != null) {
  7760. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize").equals("null") == true) {
  7761. monthTableClass[j].SamePyungUse = "0";
  7762. }
  7763. else {
  7764. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize");
  7765. }
  7766. }
  7767. if ((miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7768. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize").equals("null") == true) {
  7769. TempString = "- / ";
  7770. }
  7771. else {
  7772. TempString = miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize") + " / ";
  7773. }
  7774. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7775. TempString = TempString + "-";
  7776. }
  7777. else {
  7778. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7779. }
  7780. monthTableClass[j].Rank = TempString;
  7781. }
  7782. //가격정보
  7783. if (mCostInfo_Enable == true) {
  7784. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_price") != null) {
  7785. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_price").equals("null") == true) {
  7786. monthTableClass[j].Price = "";
  7787. }
  7788. else {
  7789. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "carbon_price");
  7790. }
  7791. }
  7792. }
  7793. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7794. //DebugLogOutput("탄소");
  7795. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7796. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7797. break;
  7798. default:
  7799. break;
  7800. }
  7801. }
  7802. }
  7803. }
  7804. if (result) {
  7805. if (1 < nEnergyTypeCnt && nEnergyTypeCnt < 6) {
  7806. Intent intent = new Intent();
  7807. intent.setAction(define.NOTIFY_ACNAME);
  7808. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  7809. intent.putExtra("FromWhere", "IcEnergyMgrScreen");
  7810. if (nEnergyTypeCnt == 2) {
  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. }
  7816. else if (nEnergyTypeCnt == 3) {
  7817. elect_target = monthTableClass[0].Goal;
  7818. elect_used = monthTableClass[0].Use;
  7819. water_target = monthTableClass[1].Goal;
  7820. water_used = monthTableClass[1].Use;
  7821. gas_target = monthTableClass[2].Goal;
  7822. gas_used = monthTableClass[2].Use;
  7823. }
  7824. else if (nEnergyTypeCnt == 4) {
  7825. elect_target = monthTableClass[0].Goal;
  7826. elect_used = monthTableClass[0].Use;
  7827. water_target = monthTableClass[1].Goal;
  7828. water_used = monthTableClass[1].Use;
  7829. hotwater_target = monthTableClass[2].Goal;
  7830. hotwater_used = monthTableClass[2].Use;
  7831. heating_target = monthTableClass[3].Goal;
  7832. heating_used = monthTableClass[3].Use;
  7833. }
  7834. else if (nEnergyTypeCnt == 5) {
  7835. elect_target = monthTableClass[0].Goal;
  7836. elect_used = monthTableClass[0].Use;
  7837. water_target = monthTableClass[1].Goal;
  7838. water_used = monthTableClass[1].Use;
  7839. gas_target = monthTableClass[2].Goal;
  7840. gas_used = monthTableClass[2].Use;
  7841. hotwater_target = monthTableClass[3].Goal;
  7842. hotwater_used = monthTableClass[3].Use;
  7843. heating_target = monthTableClass[4].Goal;
  7844. heating_used = monthTableClass[4].Use;
  7845. }
  7846. else {
  7847. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =1 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  7848. return;
  7849. }
  7850. getApplicationContext().sendBroadcast(intent);
  7851. if (bSendToMobile) sendRemotemeterDataToMobile();
  7852. }
  7853. else {
  7854. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =2 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  7855. }
  7856. return;
  7857. }
  7858. else {
  7859. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] result [" + result + "]");
  7860. }
  7861. }
  7862. break;
  7863. default:
  7864. break;
  7865. }
  7866. StatusDBMGR.closeDB();
  7867. } catch (RuntimeException re) {
  7868. if (StatusDBMGR != null) {
  7869. StatusDBMGR.closeDB();
  7870. }
  7871. LogUtil.errorLogInfo("", TAG, re);
  7872. }
  7873. catch (Exception e) {
  7874. if (StatusDBMGR != null) {
  7875. StatusDBMGR.closeDB();
  7876. }
  7877. LogUtil.errorLogInfo("", TAG, e);
  7878. }
  7879. }
  7880. @Override
  7881. public void ProcError() {
  7882. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcError] Error!!!");
  7883. }
  7884. @Override
  7885. public void ProcDoing() {
  7886. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcDoing] Processing!!!");
  7887. }
  7888. });
  7889. }
  7890. else {
  7891. miMAPRemotemeter.SetRetCtr(new RetProci() {
  7892. @Override
  7893. public void ProcSuccess() {
  7894. String TempString = null;
  7895. // DB
  7896. WallpadStatusData StatusDBMGR = null;
  7897. try {
  7898. StatusDBMGR = new WallpadStatusData(getApplicationContext());
  7899. Log.i(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] inputType [" + inputType + "]");
  7900. boolean result = false;
  7901. switch (inputType) {
  7902. case 0: // 당월
  7903. EnergyDataGetCal = Calendar.getInstance();
  7904. int NumberOfValuelist = miMAPRemotemeter.SetItem("valuelist");
  7905. if (NumberOfValuelist != 0) {
  7906. for (int i = 0; i < NumberOfValuelist; i++) {
  7907. //DebugLogOutput("NumberOfValuelist " + Integer.toString(NumberOfValuelist));
  7908. //DebugLogOutput("GetAttributeVal(i, month) " + imapRemotemeter.GetAttributeVal(i, "month"));
  7909. //DebugLogOutput("CalendarMonth " + (CalendarMonth + 1));
  7910. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == (CalendarMonth + 1)) && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == (CalendarYear))) {
  7911. result = true;
  7912. int Temp_mNumberOfEnergy = nEnergyTypeCnt;
  7913. if (Temp_mNumberOfEnergy == 2) {
  7914. Temp_mNumberOfEnergy = 3;
  7915. }
  7916. for (int j = 0; j < Temp_mNumberOfEnergy; j++) {
  7917. switch (j) {
  7918. case 0:
  7919. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7920. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  7921. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000") == true) {
  7922. monthTableClass[j].Use = "0";
  7923. }
  7924. else {
  7925. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  7926. }
  7927. }
  7928. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7929. //DebugLogOutput("전기");
  7930. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7931. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7932. break;
  7933. case 1:
  7934. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7935. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  7936. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  7937. monthTableClass[j].Use = "0";
  7938. }
  7939. else {
  7940. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  7941. }
  7942. }
  7943. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7944. //DebugLogOutput("수도");
  7945. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7946. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7947. break;
  7948. case 2:
  7949. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7950. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  7951. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  7952. monthTableClass[j].Use = "0";
  7953. }
  7954. else {
  7955. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  7956. }
  7957. }
  7958. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7959. //DebugLogOutput("가스");
  7960. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7961. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7962. break;
  7963. case 3:
  7964. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7965. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  7966. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  7967. monthTableClass[j].Use = "0";
  7968. }
  7969. else {
  7970. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  7971. }
  7972. }
  7973. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7974. //DebugLogOutput("온수");
  7975. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7976. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7977. break;
  7978. case 4:
  7979. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7980. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  7981. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  7982. monthTableClass[j].Use = "0";
  7983. }
  7984. else {
  7985. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  7986. }
  7987. }
  7988. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7989. //DebugLogOutput("열량");
  7990. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7991. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7992. break;
  7993. case 5:
  7994. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7995. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7996. //DebugLogOutput("탄소");
  7997. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7998. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7999. break;
  8000. default:
  8001. break;
  8002. }
  8003. }
  8004. }
  8005. }
  8006. if (result) {
  8007. if (1 < nEnergyTypeCnt && nEnergyTypeCnt < 6) {
  8008. Intent intent = new Intent();
  8009. intent.setAction(define.NOTIFY_ACNAME);
  8010. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  8011. intent.putExtra("FromWhere", "IcEnergyMgrScreen");
  8012. if (nEnergyTypeCnt == 2) {
  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. }
  8018. else if (nEnergyTypeCnt == 3) {
  8019. elect_target = monthTableClass[0].Goal;
  8020. elect_used = monthTableClass[0].Use;
  8021. water_target = monthTableClass[1].Goal;
  8022. water_used = monthTableClass[1].Use;
  8023. gas_target = monthTableClass[2].Goal;
  8024. gas_used = monthTableClass[2].Use;
  8025. }
  8026. else if (nEnergyTypeCnt == 4) {
  8027. elect_target = monthTableClass[0].Goal;
  8028. elect_used = monthTableClass[0].Use;
  8029. water_target = monthTableClass[1].Goal;
  8030. water_used = monthTableClass[1].Use;
  8031. hotwater_target = monthTableClass[2].Goal;
  8032. hotwater_used = monthTableClass[2].Use;
  8033. heating_target = monthTableClass[3].Goal;
  8034. heating_used = monthTableClass[3].Use;
  8035. }
  8036. else if (nEnergyTypeCnt == 5) {
  8037. elect_target = monthTableClass[0].Goal;
  8038. elect_used = monthTableClass[0].Use;
  8039. water_target = monthTableClass[1].Goal;
  8040. water_used = monthTableClass[1].Use;
  8041. gas_target = monthTableClass[2].Goal;
  8042. gas_used = monthTableClass[2].Use;
  8043. hotwater_target = monthTableClass[3].Goal;
  8044. hotwater_used = monthTableClass[3].Use;
  8045. heating_target = monthTableClass[4].Goal;
  8046. heating_used = monthTableClass[4].Use;
  8047. }
  8048. else {
  8049. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =1 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  8050. return;
  8051. }
  8052. getApplicationContext().sendBroadcast(intent);
  8053. if (bSendToMobile) sendRemotemeterDataToMobile();
  8054. }
  8055. else {
  8056. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =2 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  8057. }
  8058. return;
  8059. }
  8060. else {
  8061. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] result [" + result + "]");
  8062. }
  8063. }
  8064. break;
  8065. default:
  8066. break;
  8067. }
  8068. StatusDBMGR.closeDB();
  8069. } catch (RuntimeException re) {
  8070. if (StatusDBMGR != null) {
  8071. StatusDBMGR.closeDB();
  8072. }
  8073. LogUtil.errorLogInfo("", TAG, re);
  8074. }
  8075. catch (Exception e) {
  8076. if (StatusDBMGR != null) {
  8077. StatusDBMGR.closeDB();
  8078. }
  8079. LogUtil.errorLogInfo("", TAG, e);
  8080. }
  8081. }
  8082. @Override
  8083. public void ProcError() {
  8084. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcError] Error!!!");
  8085. }
  8086. @Override
  8087. public void ProcDoing() {
  8088. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcDoing] Processing!!!");
  8089. }
  8090. });
  8091. }
  8092. } catch (RuntimeException re) {
  8093. LogUtil.errorLogInfo("", TAG, re);
  8094. }
  8095. catch (Exception e) {
  8096. Log.e(TAG, "[Exception] LoadRemotemeterDataFromServer(int InputType, int Year, int Month, int Energy)");
  8097. LogUtil.errorLogInfo("", TAG, e);
  8098. }
  8099. }
  8100. /**
  8101. * @description
  8102. * 서버로 부터 데이터를 받아와 분석하고 표현하는 함수<br>
  8103. * @param
  8104. * //year - 연도<br>
  8105. * @param
  8106. * //month - 월<br>
  8107. * @param
  8108. * //energy - 0 전기, 1 수도, 2 가스, 3 온수, 4 열량, 5 탄소<br>
  8109. */
  8110. private void getTelemeringDailyUsageData(final int nYear, final int nMonth, final int nDate) {
  8111. try {
  8112. Log.i(TAG, "[getTelemeringDailyUsageData] nYear [" + nYear + "], nMonth [" + nMonth + "], nDate [" + nDate + "]");
  8113. miMAPRemotemeter = new iMAPRemotemeter(getApplicationContext());
  8114. miMAPRemotemeter.DoWork(false, true, true, true, true, true, false, false, nYear, nMonth);
  8115. boolean isUseEMS = true;
  8116. WallpadDeviceSet wds = new WallpadDeviceSet(getContext());
  8117. isUseEMS = wds.GetEMSProtocolUse();
  8118. wds.closeDB();
  8119. if(isUseEMS)
  8120. {
  8121. miMAPRemotemeter.SetRetCtr(new RetProci() {
  8122. @Override
  8123. public void ProcSuccess() {
  8124. String strTempValue = null;
  8125. int nEnergyTypeCnt = 5;
  8126. try {
  8127. boolean bResult = false;
  8128. String strElecUsage = "", strGasUsage = "", strWaterUsage = "", strHotwaterUsage = "", strHeatingUsage = "";
  8129. int nDataCnt = miMAPRemotemeter.SetItem("valuelist");
  8130. if (nDataCnt != 0) {
  8131. Log.i(TAG, "[getTelemeringDailyData] nDataCnt [" + nDataCnt + "]");
  8132. for (int i = 0; i < nDataCnt; i++) {
  8133. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == nYear)
  8134. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == nMonth)
  8135. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "day")) == nDate)) {
  8136. bResult = true;
  8137. Log.i(TAG, "[getTelemeringDailyUsageData] Find!!! nYear [" + nYear + "], nMonth [" + nMonth + "], nDate [" + nDate + "]");
  8138. for (int j = 0; j < nEnergyTypeCnt; j++) {
  8139. if (j == 0) {
  8140. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  8141. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000")) {
  8142. strElecUsage = "0";
  8143. }
  8144. else {
  8145. strElecUsage = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  8146. }
  8147. }
  8148. }
  8149. else if (j == 1) {
  8150. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  8151. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  8152. strWaterUsage = "0";
  8153. }
  8154. else {
  8155. strWaterUsage = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  8156. }
  8157. }
  8158. }
  8159. else if (j == 2) {
  8160. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  8161. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  8162. strGasUsage = "0";
  8163. }
  8164. else {
  8165. strGasUsage = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  8166. }
  8167. }
  8168. }
  8169. else if (j == 3) {
  8170. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  8171. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  8172. strHotwaterUsage = "0";
  8173. }
  8174. else {
  8175. strHotwaterUsage = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  8176. }
  8177. }
  8178. }
  8179. else if (j == 4) {
  8180. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  8181. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  8182. strHeatingUsage = "0";
  8183. }
  8184. else {
  8185. strHeatingUsage = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  8186. }
  8187. }
  8188. }
  8189. }
  8190. }
  8191. }
  8192. if (bResult) {
  8193. Intent mIntent = new Intent();
  8194. mIntent.setAction(define.NOTIFY_ACNAME);
  8195. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_TELEMETERING_DAILY_USAGE);
  8196. mIntent.putExtra("elect_used", strElecUsage);
  8197. mIntent.putExtra("water_used", strWaterUsage);
  8198. mIntent.putExtra("gas_used", strGasUsage);
  8199. mIntent.putExtra("hotwater_used", strHotwaterUsage);
  8200. mIntent.putExtra("heating_used", strHeatingUsage);
  8201. getApplicationContext().sendBroadcast(mIntent);
  8202. }
  8203. else {
  8204. Log.w(TAG, "[getTelemeringDailyUsageData.ProcSuccess] bResult [" + bResult + "]");
  8205. }
  8206. }
  8207. } catch (RuntimeException re) {
  8208. LogUtil.errorLogInfo("", TAG, re);
  8209. }
  8210. catch (Exception e) {
  8211. Log.e(TAG, "[Exception] getTelemeringDailyData.ProcSuccess");
  8212. LogUtil.errorLogInfo("", TAG, e);
  8213. }
  8214. }
  8215. @Override
  8216. public void ProcError() {
  8217. Log.w(TAG, "[getTelemeringDailyData.ProcError] Error!!!");
  8218. }
  8219. @Override
  8220. public void ProcDoing() {
  8221. Log.w(TAG, "[getTelemeringDailyData.ProcDoing] Processing!!!");
  8222. }
  8223. });
  8224. }
  8225. else
  8226. {
  8227. miMAPRemotemeter.SetRetCtr(new RetProci() {
  8228. @Override
  8229. public void ProcSuccess() {
  8230. String strTempValue = null;
  8231. int nEnergyTypeCnt = 5;
  8232. try {
  8233. boolean bResult = false;
  8234. String strElecUsage = "", strGasUsage = "", strWaterUsage = "", strHotwaterUsage = "", strHeatingUsage = "";
  8235. int nDataCnt = miMAPRemotemeter.SetItem("valuelist");
  8236. if (nDataCnt != 0) {
  8237. Log.i(TAG, "[getTelemeringDailyData] nDataCnt [" + nDataCnt + "]");
  8238. for (int i = 0; i < nDataCnt; i++) {
  8239. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == nYear)
  8240. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == nMonth)
  8241. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "day")) == nDate)) {
  8242. bResult = true;
  8243. Log.i(TAG, "[getTelemeringDailyUsageData] Find!!! nYear [" + nYear + "], nMonth [" + nMonth + "], nDate [" + nDate + "]");
  8244. for (int j = 0; j < nEnergyTypeCnt; j++) {
  8245. if (j == 0) {
  8246. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  8247. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000")) {
  8248. strElecUsage = "0";
  8249. }
  8250. else {
  8251. strElecUsage = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  8252. }
  8253. }
  8254. }
  8255. else if (j == 1) {
  8256. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  8257. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  8258. strWaterUsage = "0";
  8259. }
  8260. else {
  8261. strWaterUsage = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  8262. }
  8263. }
  8264. }
  8265. else if (j == 2) {
  8266. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  8267. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  8268. strGasUsage = "0";
  8269. }
  8270. else {
  8271. strGasUsage = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  8272. }
  8273. }
  8274. }
  8275. else if (j == 3) {
  8276. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  8277. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  8278. strHotwaterUsage = "0";
  8279. }
  8280. else {
  8281. strHotwaterUsage = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  8282. }
  8283. }
  8284. }
  8285. else if (j == 4) {
  8286. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  8287. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  8288. strHeatingUsage = "0";
  8289. }
  8290. else {
  8291. strHeatingUsage = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  8292. }
  8293. }
  8294. }
  8295. }
  8296. }
  8297. }
  8298. if (bResult) {
  8299. Intent mIntent = new Intent();
  8300. mIntent.setAction(define.NOTIFY_ACNAME);
  8301. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_TELEMETERING_DAILY_USAGE);
  8302. mIntent.putExtra("elect_used", strElecUsage);
  8303. mIntent.putExtra("water_used", strWaterUsage);
  8304. mIntent.putExtra("gas_used", strGasUsage);
  8305. mIntent.putExtra("hotwater_used", strHotwaterUsage);
  8306. mIntent.putExtra("heating_used", strHeatingUsage);
  8307. getApplicationContext().sendBroadcast(mIntent);
  8308. }
  8309. else {
  8310. Log.w(TAG, "[getTelemeringDailyUsageData.ProcSuccess] bResult [" + bResult + "]");
  8311. }
  8312. }
  8313. } catch (RuntimeException re) {
  8314. LogUtil.errorLogInfo("", TAG, re);
  8315. }
  8316. catch (Exception e) {
  8317. Log.e(TAG, "[Exception] getTelemeringDailyData.ProcSuccess");
  8318. LogUtil.errorLogInfo("", TAG, e);
  8319. }
  8320. }
  8321. @Override
  8322. public void ProcError() {
  8323. Log.w(TAG, "[getTelemeringDailyData.ProcError] Error!!!");
  8324. }
  8325. @Override
  8326. public void ProcDoing() {
  8327. Log.w(TAG, "[getTelemeringDailyData.ProcDoing] Processing!!!");
  8328. }
  8329. });
  8330. }
  8331. } catch (RuntimeException re) {
  8332. LogUtil.errorLogInfo("", TAG, re);
  8333. }
  8334. catch (Exception e) {
  8335. Log.e(TAG, "[Exception] getTelemeringDailyData(int nYear, int nMonth)");
  8336. LogUtil.errorLogInfo("", TAG, e);
  8337. }
  8338. }
  8339. public void sendRemotemeterDataToMobile() {
  8340. try {
  8341. Log.i(TAG, "[sendRemotemeterDataToMobile] ========== START ==========");
  8342. Intent intent = new Intent();
  8343. intent.setAction(define.NOTIFY_ACNAME);
  8344. intent.putExtra("KIND", define.NOTIFY_ENERGY_DATA);
  8345. intent.putExtra(Common.ENERGY_INTENT_ENERGY_COUNT, nEnergyTypeCnt);
  8346. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_YEAR, EnergyDataGetCal.get(Calendar.YEAR));
  8347. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MONTH, (EnergyDataGetCal.get(Calendar.MONTH)+1));
  8348. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_DAY, EnergyDataGetCal.get(Calendar.DATE));
  8349. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_HOUR, EnergyDataGetCal.get(Calendar.HOUR_OF_DAY));
  8350. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MINUTE, EnergyDataGetCal.get(Calendar.MINUTE));
  8351. if (nEnergyTypeCnt == 2) {
  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. }
  8357. else if (nEnergyTypeCnt == 3) {
  8358. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8359. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8360. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8361. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8362. intent.putExtra(Common.ENERGY_INTENT_USE_GAS, gas_used); //가스
  8363. intent.putExtra(Common.ENERGY_INTENT_GOAL_GAS, gas_target);
  8364. }
  8365. else if (nEnergyTypeCnt == 4) {
  8366. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8367. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8368. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8369. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8370. intent.putExtra(Common.ENERGY_INTENT_USE_HOTWATER, hotwater_used); //온수
  8371. intent.putExtra(Common.ENERGY_INTENT_GOAL_HOTWATER, hotwater_target);
  8372. intent.putExtra(Common.ENERGY_INTENT_USE_HEATING, heating_used); //열량
  8373. intent.putExtra(Common.ENERGY_INTENT_GOAL_HEATING, heating_target);
  8374. }
  8375. else if (nEnergyTypeCnt == 5) {
  8376. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8377. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8378. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8379. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8380. intent.putExtra(Common.ENERGY_INTENT_USE_GAS, gas_used); //가스
  8381. intent.putExtra(Common.ENERGY_INTENT_GOAL_GAS, gas_target);
  8382. intent.putExtra(Common.ENERGY_INTENT_USE_HOTWATER, hotwater_used); //온수
  8383. intent.putExtra(Common.ENERGY_INTENT_GOAL_HOTWATER, hotwater_target);
  8384. intent.putExtra(Common.ENERGY_INTENT_USE_HEATING, heating_used); //열량
  8385. intent.putExtra(Common.ENERGY_INTENT_GOAL_HEATING, heating_target);
  8386. }
  8387. getContext().sendBroadcast(intent);
  8388. Log.i(TAG, "[sendRemotemeterDataToMobile] Sent ENERGY_INTENT_ BR "+define.NOTIFY_ENERGY_DATA);
  8389. } catch (RuntimeException re) {
  8390. LogUtil.errorLogInfo("", TAG, re);
  8391. }
  8392. catch (Exception e) {
  8393. Log.e(TAG, "[Exception] sendRemotemeterDataToMobile()");
  8394. LogUtil.errorLogInfo("", TAG, e);
  8395. }
  8396. }
  8397. private void getTelemeteringDataOnRandomTime() {
  8398. try {
  8399. int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  8400. if (DelayTime < 1) {
  8401. return;
  8402. }
  8403. Log.i(TAG, "[getTelemeteringDataOnRandomTime] DelayTime : "+ DelayTime);
  8404. getTelemeteringDataHandler.sendEmptyMessageDelayed(0, 1000 * DelayTime);
  8405. } catch (RuntimeException re) {
  8406. LogUtil.errorLogInfo("", TAG, re);
  8407. return;
  8408. }
  8409. catch (Exception e) {
  8410. Log.e(TAG, "[Exception] getTelemeteringDataOnRandomTime()");
  8411. LogUtil.errorLogInfo("", TAG, e);
  8412. return;
  8413. }
  8414. }
  8415. @SuppressLint("HandlerLeak")
  8416. private Handler getTelemeteringDataHandler = new Handler() {
  8417. @SuppressLint("HandlerLeak")
  8418. @Override
  8419. public void handleMessage(Message msg) {
  8420. if (msg.what == 0) {
  8421. getRemoteMeterDataFromServer(true);
  8422. }
  8423. }
  8424. };
  8425. boolean bTelemeteringToISS = false;
  8426. private void checkISSEnergyType() {
  8427. try {
  8428. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplication());
  8429. int nEnergyKind = mWallpadDeviceSet.Get_SmartSwitchEnergy_Kind();
  8430. mWallpadDeviceSet.closeDB();
  8431. if (nEnergyKind == WallpadDeviceSet.SMARTSWITCH_ENERGY_REMOTE) bTelemeteringToISS = true;
  8432. else bTelemeteringToISS = false;
  8433. } catch (RuntimeException re) {
  8434. LogUtil.errorLogInfo("", TAG, re);
  8435. }
  8436. catch (Exception e) {
  8437. Log.e(TAG, "[Exception] checkISSEnergyType()");
  8438. LogUtil.errorLogInfo("", TAG, e);
  8439. }
  8440. }
  8441. public void getRemoteMeterDataFromServer(boolean bSendToMobile) {
  8442. try {
  8443. nowCal = Calendar.getInstance();
  8444. CalendarYear = nowCal.get(Calendar.YEAR);
  8445. CalendarMonth = nowCal.get(Calendar.MONTH);
  8446. CalendarDate = nowCal.get(Calendar.DATE);
  8447. GetMeteringCount();
  8448. LoadRemotemeterDataFromServer(0, CalendarYear, CalendarMonth, ShowNowEnergyIndex, bSendToMobile);
  8449. if (bTelemeteringToISS) getTelemeringDailyUsageData(CalendarYear, CalendarMonth + 1, CalendarDate);
  8450. } catch (RuntimeException re) {
  8451. LogUtil.errorLogInfo("", TAG, re);
  8452. }
  8453. catch (Exception e) {
  8454. Log.e(TAG, "[Exception] getRemoteMeterDataFromServer()");
  8455. LogUtil.errorLogInfo("", TAG, e);
  8456. }
  8457. }
  8458. private boolean getBlackoutStatus() {
  8459. try {
  8460. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  8461. return mSharedPreferences.getBoolean("status", false);
  8462. } catch (RuntimeException re) {
  8463. LogUtil.errorLogInfo("", TAG, re);
  8464. return false;
  8465. }
  8466. catch (Exception e) {
  8467. Log.e(TAG, "[Exception] getBlackoutStatus()");
  8468. LogUtil.errorLogInfo("", TAG, e);
  8469. return false;
  8470. }
  8471. }
  8472. private void sendBlackoutScreenRunBR() {
  8473. try {
  8474. Log.i(TAG, "[sendBlackoutScreenRunBR] ========== START ==========");
  8475. Intent mIntent = new Intent(Common.BR_BLACKOUT_SCREEN_RUN, null);
  8476. mContext.sendBroadcast(mIntent);
  8477. } catch (RuntimeException re) {
  8478. LogUtil.errorLogInfo("", TAG, re);
  8479. }
  8480. catch (Exception e) {
  8481. Log.e(TAG, "[Exception] sendBlackoutScreenRunBR()");
  8482. LogUtil.errorLogInfo("", TAG, e);
  8483. }
  8484. }
  8485. /**
  8486. * 월패드 타입 판별
  8487. * @return bResult
  8488. * false: 메인월패드
  8489. * true: 서브월패드
  8490. */
  8491. public boolean getIsSubWallpad() {
  8492. boolean bResult = false;
  8493. try {
  8494. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  8495. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  8496. mWallpadDeviceSet.closeDB();
  8497. if (DBinfo == null) bResult = false;
  8498. else {
  8499. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  8500. else bResult = false;
  8501. }
  8502. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  8503. return bResult;
  8504. } catch (RuntimeException re) {
  8505. LogUtil.errorLogInfo("", TAG, re);
  8506. return false;
  8507. }
  8508. catch (Exception e) {
  8509. Log.e(TAG, "[Exception] getIsSubWallpad()");
  8510. LogUtil.errorLogInfo("", TAG, e);
  8511. return false;
  8512. }
  8513. }
  8514. /**
  8515. * JEFF, 2020.01.14
  8516. * 월패드 카메라의 초기화를 위한 코드 삽입
  8517. * 월패드 카메라 preview 실행시, 최초 1회에 한하여 카메라 화면에 녹색이 보이는 증상을 해결하기 위함
  8518. */
  8519. /* ================================================================================================
  8520. * 내 영상
  8521. ================================================================================================ */
  8522. // SurfaceLayout 구성
  8523. RelativeLayout MyVideoLayout; // MoIP 카메라 영상
  8524. SurfaceHolder MyVideoHolder;
  8525. SurfaceView MyVideoSurface;
  8526. RelativeLayout SurfaceLayout; // 영상표시 화면
  8527. public Camera mMyCamera;
  8528. public void toggleMyVideo() {
  8529. try {
  8530. if (MyVideoLayout == null) {
  8531. Log.e(TAG, "[toggleMyVideo] Show My Video!!!");
  8532. initMyVideoSurfaceLayout();
  8533. }
  8534. else {
  8535. Log.e(TAG, "[toggleMyVideo] Remove My Video!!!");
  8536. removeMyVideoSurfaceLayout();
  8537. }
  8538. } catch (RuntimeException re) {
  8539. LogUtil.errorLogInfo("", TAG, re);
  8540. }
  8541. catch (Exception e) {
  8542. Log.e(TAG, "[Exception] toggleMyVideo()");
  8543. LogUtil.errorLogInfo("", TAG, e);
  8544. }
  8545. }
  8546. public void initMyVideoSurfaceLayout() {
  8547. try {
  8548. // LOG_INFO("[initMyVideoSurfaceLayout] MyVideoLayout = " + MyVideoLayout);
  8549. if (MyVideoLayout != null) {
  8550. MyVideoSurface.getHolder().removeCallback(MyVideoCallback);
  8551. MyVideoLayout.removeAllViews();
  8552. MyVideoLayout = null;
  8553. }
  8554. MyVideoLayout = new RelativeLayout(mContext);
  8555. WpadUtil.LayoutRegistration(SurfaceLayout, MyVideoLayout, 1024, 600, 0, 0, ID.MAINACTIVITY.LAYOUT.MYVIDEO);
  8556. MyVideoSurface = new SurfaceView(mContext);
  8557. MyVideoHolder = MyVideoSurface.getHolder();
  8558. WpadRelativeLayoutParams MyVideoParams = new WpadRelativeLayoutParams(320, 240);
  8559. // MyVideoParams.setMargins(10, 10, 0, 0); // 보이게
  8560. MyVideoParams.setMargins(1300, 112, 0, 0); // 안보이게
  8561. MyVideoLayout.addView(MyVideoSurface, MyVideoParams);
  8562. MyVideoSurface.getHolder().addCallback(MyVideoCallback);
  8563. MyVideoSurface.setZOrderOnTop(true);
  8564. } catch (RuntimeException re) {
  8565. LogUtil.errorLogInfo("", TAG, re);
  8566. }
  8567. catch (Exception e) {
  8568. Log.e(TAG, "[Exception] initMyVideoSurfaceLayout()");
  8569. LogUtil.errorLogInfo("", TAG, e);
  8570. }
  8571. }
  8572. public void removeMyVideoSurfaceLayout() {
  8573. try {
  8574. Log.i(TAG, "[removeMyVideoSurfaceLayout] MyVideoLayout = " + MyVideoLayout);
  8575. if (MyVideoLayout != null) {
  8576. MyVideoLayout.removeAllViews();
  8577. MyVideoLayout = null;
  8578. }
  8579. } catch (RuntimeException re) {
  8580. LogUtil.errorLogInfo("", TAG, re);
  8581. }
  8582. catch (Exception e) {
  8583. Log.e(TAG, "[Exception] removeRemoteVideoSurfaceLayout()");
  8584. LogUtil.errorLogInfo("", TAG, e);
  8585. }
  8586. }
  8587. private SurfaceHolder.Callback MyVideoCallback = new SurfaceHolder.Callback() {
  8588. @Override
  8589. public void surfaceCreated(SurfaceHolder holder) {
  8590. try {
  8591. Log.i(TAG, "[MyVideoCallback] surfaceCreated!!");
  8592. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8593. mIOInterface.ctrlWallPadCamPower(true);
  8594. mMyCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  8595. Camera.Parameters params = mMyCamera.getParameters();
  8596. params.setPictureSize(320, 240);
  8597. mMyCamera.setParameters(params);
  8598. mMyCamera.setPreviewDisplay(holder);
  8599. } else {
  8600. Log.w(TAG, "[MyVideoCallback] surfaceCreated!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8601. }
  8602. } catch (RuntimeException re) {
  8603. LogUtil.errorLogInfo("", TAG, re);
  8604. }
  8605. catch (Exception e) {
  8606. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceCreated(SurfaceHolder holder)");
  8607. LogUtil.errorLogInfo("", TAG, e);
  8608. }
  8609. }
  8610. @Override
  8611. public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
  8612. try {
  8613. Log.i(TAG, "[MyVideoCallback] surfaceChanged!!");
  8614. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8615. mMyCamera.startPreview();
  8616. } else {
  8617. Log.w(TAG, "[MyVideoCallback] surfaceChanged!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8618. }
  8619. } catch (RuntimeException re) {
  8620. LogUtil.errorLogInfo("", TAG, re);
  8621. }
  8622. catch (Exception e) {
  8623. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceChanged(SurfaceHolder holder, int format, int width, int height)");
  8624. LogUtil.errorLogInfo("", TAG, e);
  8625. // if (getWallPadCameraUsage()) sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_RESET, 0, 0, 3000); // 3초후 카메라 서비스를 재실행한다.
  8626. }
  8627. }
  8628. @Override
  8629. public void surfaceDestroyed(SurfaceHolder holder) {
  8630. try {
  8631. Log.i(TAG, "[MyVideoCallback] surfaceDestroyed!!");
  8632. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8633. mIOInterface.ctrlWallPadCamPower(false);
  8634. if (mMyCamera != null) {
  8635. mMyCamera.stopPreview();
  8636. mMyCamera.release();
  8637. mMyCamera = null;
  8638. }
  8639. } else {
  8640. Log.w(TAG, "[MyVideoCallback] surfaceDestroyed!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8641. }
  8642. } catch (RuntimeException re) {
  8643. LogUtil.errorLogInfo("", TAG, re);
  8644. }
  8645. catch (Exception e) {
  8646. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceDestroyed(SurfaceHolder holder)");
  8647. LogUtil.errorLogInfo("", TAG, e);
  8648. }
  8649. }
  8650. };
  8651. private boolean getWallPadCameraUsage() {
  8652. boolean bResult = false;
  8653. try {
  8654. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this.getContext());
  8655. int nResult = mWallpadDeviceSet.GetDeviceSetted("월패드카메라");
  8656. mWallpadDeviceSet.closeDB();
  8657. if (nResult == WallpadDeviceSet.DEV_DATA_ENABLE) bResult = true;
  8658. else bResult = false;
  8659. } catch (RuntimeException re) {
  8660. LogUtil.errorLogInfo("", TAG, re);
  8661. }
  8662. catch (Exception e) {
  8663. Log.e(TAG, "[Exception] getWallPadCameraUsage()");
  8664. LogUtil.errorLogInfo("", TAG, e);
  8665. }
  8666. Log.i(TAG, "[getWallPadCameraUsage] bResult [" + bResult + "]");
  8667. return bResult;
  8668. }
  8669. private void forceCtrlStrangerRecordingUserSettingDisable(boolean bEnable) {
  8670. try {
  8671. WallpadStatusData DBMGR = new WallpadStatusData(getContext());
  8672. DBMGR.SetStrangerRecordingOnOff(bEnable);
  8673. DBMGR.closeDB();
  8674. } catch (RuntimeException re) {
  8675. LogUtil.errorLogInfo("", TAG, re);
  8676. }
  8677. catch (Exception e) {
  8678. Log.e(TAG, "[Exception] forceCtrlStrangerRecordingUserSettingDisable(boolean bEnable)");
  8679. LogUtil.errorLogInfo("", TAG, e);
  8680. }
  8681. }
  8682. private void registerLCDKeeper() {
  8683. try {
  8684. Log.i(TAG, "[registerLCDKeeper] ===== START =====");
  8685. if (!bLCDKeeperUsage) {
  8686. Log.w(TAG, "[registerLCDKeeper] bLCDKeeperUsage is false!!!");
  8687. return;
  8688. }
  8689. if (Build.VERSION.SDK_INT < 24) {
  8690. Log.w(TAG, "[registerLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8691. return;
  8692. }
  8693. IMG_LCD_KEEPER = (ImageView) findViewById(R.id.view_lcdkeeper);
  8694. IMG_LCD_KEEPER.bringToFront();
  8695. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8696. Log.i(TAG, "[registerLCDKeeper] ===== END =====");
  8697. } catch (RuntimeException re) {
  8698. LogUtil.errorLogInfo("", TAG, re);
  8699. }
  8700. catch (Exception e) {
  8701. Log.e(TAG, "[Exception] registerLCDKeeper()");
  8702. LogUtil.errorLogInfo("", TAG, e);
  8703. }
  8704. }
  8705. int LCDKEEPER_MODE_NONE = 0; // 동작중 아님
  8706. int LCDKEEPER_MODE_RESTROE = 1; // 복구모드
  8707. int LCDKEEPER_MODE_PROTECT = 2; // 보호모드
  8708. boolean bLCDBacklightPower = true; // LCD backlight on/off 여부 (true: on, false: off)
  8709. int nLCDKeeperRunMode = LCDKEEPER_MODE_NONE; // LCD Keeper 동작 모드 (0: 동작중 아님, 1: 복구모드, 2: 예방모드)
  8710. private void runLCDKeeper(int nKeeperMode) {
  8711. try {
  8712. if (!bLCDKeeperUsage) {
  8713. Log.w(TAG, "[runLCDKeeper] bLCDKeeperUsage is false!!!");
  8714. return;
  8715. }
  8716. Log.i(TAG, "[runLCDKeeper] nKeeperMode [" + nKeeperMode +"], bLCDBacklightPower [" + bLCDBacklightPower +"]");
  8717. if (Build.VERSION.SDK_INT < 24) {
  8718. Log.w(TAG, "[runLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8719. return;
  8720. }
  8721. if (IMG_LCD_KEEPER == null) {
  8722. Log.w(TAG, "[runLCDKeeper] IMG_LCD_KEEPER is null!!");
  8723. return;
  8724. }
  8725. // check run mode
  8726. if (nLCDKeeperRunMode == nKeeperMode) {
  8727. // already run LCDKeeper!!
  8728. Log.w(TAG, "[runLCDKeeper] LCD Keeper mode is same -> Asis [" + nLCDKeeperRunMode + "], Tobe [" + nKeeperMode + "]");
  8729. return;
  8730. }
  8731. nLCDKeeperRunMode = nKeeperMode;
  8732. if (nKeeperMode == LCDKEEPER_MODE_NONE) {
  8733. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8734. }
  8735. else if (nKeeperMode == LCDKEEPER_MODE_RESTROE) {
  8736. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) {
  8737. Glide.with(this).asGif().load(R.drawable.lcd_restore_1280).diskCacheStrategy(DiskCacheStrategy.RESOURCE).into(IMG_LCD_KEEPER);
  8738. }
  8739. else {
  8740. Glide.with(this).asGif().load(R.drawable.lcd_restore_1024).diskCacheStrategy(DiskCacheStrategy.RESOURCE).into(IMG_LCD_KEEPER);
  8741. }
  8742. IMG_LCD_KEEPER.setVisibility(View.VISIBLE);
  8743. }
  8744. else if (nKeeperMode == LCDKEEPER_MODE_PROTECT) {
  8745. IMG_LCD_KEEPER.setImageBitmap(null);
  8746. IMG_LCD_KEEPER.setBackgroundColor(Color.BLACK);
  8747. IMG_LCD_KEEPER.setVisibility(View.VISIBLE);
  8748. }
  8749. else {
  8750. Log.w(TAG, "[runLCDKeeper] Not supported mode!! -> " + nKeeperMode);
  8751. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8752. }
  8753. } catch (RuntimeException re) {
  8754. LogUtil.errorLogInfo("", TAG, re);
  8755. }
  8756. catch (Exception e) {
  8757. Log.e(TAG, "[Exception] runLCDKeeper(int nKeeperMode)");
  8758. LogUtil.errorLogInfo("", TAG, e);
  8759. }
  8760. }
  8761. private void ctrlLCDKeeper() {
  8762. try {
  8763. if (!bLCDKeeperUsage) {
  8764. Log.w(TAG, "[ctrlLCDKeeper] bLCDKeeperUsage is false!!");
  8765. return;
  8766. }
  8767. if (Build.VERSION.SDK_INT < 24) {
  8768. Log.w(TAG, "[ctrlLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8769. return;
  8770. }
  8771. if (IMG_LCD_KEEPER == null) {
  8772. Log.w(TAG, "[ctrlLCDKeeper] IMG_LCD_KEEPER is null!!");
  8773. return;
  8774. }
  8775. Log.i(TAG, "[ctrlLCDKeeper] bLCDBacklightPower [" + bLCDBacklightPower +"]");
  8776. if (bLCDBacklightPower) {
  8777. // backlight on시 lcd keeper를 비활성화 한다.
  8778. runLCDKeeper(LCDKEEPER_MODE_NONE);
  8779. }
  8780. else {
  8781. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT) {
  8782. // LCD backlight off시, LCD protect 화면을 구동한다.
  8783. runLCDKeeper(LCDKEEPER_MODE_PROTECT);
  8784. }
  8785. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER) {
  8786. // LCD backlight off시, LCD restore 화면을 구동한다.
  8787. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8788. }
  8789. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) {
  8790. // 새벽 2:00 ~ 3:59까지 LCD restore 화면을 구동하고, 나머지 시간에는 LCD protect 화면을 구동한다.
  8791. // 화면에 스모그 또는 미러 글라스 적용이 아닌 경우에는 LCD 보호모드(블랙)만 사용을 권장한다. (LCD RGBW rolling시 컬러가 화면에 비침)
  8792. Calendar LCDCal = Calendar.getInstance();
  8793. int nYear = LCDCal.get(Calendar.YEAR);
  8794. int nMonth = LCDCal.get(Calendar.MONTH) + 1;
  8795. int nDay = LCDCal.get(Calendar.DAY_OF_MONTH);
  8796. int nHour = LCDCal.get(Calendar.HOUR_OF_DAY);
  8797. Log.i(TAG, "[ctrlLCDKeeper] nYear [" + nYear +"], nMonth [" + nMonth +"], nDay [" + nDay +"], nHour [" + nHour +"]");
  8798. if (3 >= nHour && nHour >= 2) {
  8799. // 새벽 2:00 ~ 3:59까지 LCD restore 화면을 구동한다.
  8800. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8801. }
  8802. else {
  8803. // 새벽 2:00 ~ 3:59 이외의 시간에는 LCD protect 화면을 구동한다.
  8804. if (nYear == 2020 && ((nMonth < 8 && nDay < 20) || (nMonth < 7))) {
  8805. // 단, 이미 증상이 발생한 현장의 LCD 복구를 위해 2020년 7월 19일까지는 protection 화면 대신 restore 화면을 구동한다.
  8806. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8807. }
  8808. else {
  8809. runLCDKeeper(LCDKEEPER_MODE_PROTECT);
  8810. }
  8811. }
  8812. }
  8813. }
  8814. } catch (RuntimeException re) {
  8815. LogUtil.errorLogInfo("", TAG, re);
  8816. }
  8817. catch (Exception e) {
  8818. Log.e(TAG, "[Exception] ctrlLCDKeeper()");
  8819. LogUtil.errorLogInfo("", TAG, e);
  8820. }
  8821. }
  8822. private boolean checkTranslucentGlassUsage() {
  8823. try {
  8824. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
  8825. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  8826. || Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I
  8827. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  8828. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410
  8829. || Version.getModelType() == MODEL_TYPE.IHN_T1010 || Version.getModelType() == MODEL_TYPE.IHN_T1010_I
  8830. || Version.getModelType() == MODEL_TYPE.IHN_1303_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  8831. return true;
  8832. }
  8833. else return false;
  8834. } catch (RuntimeException re) {
  8835. LogUtil.errorLogInfo("", TAG, re);
  8836. return false;
  8837. }
  8838. catch (Exception e) {
  8839. Log.e(TAG, "[Exception] checkTranslucentGlassUsage()");
  8840. LogUtil.errorLogInfo("", TAG, e);
  8841. return false;
  8842. }
  8843. }
  8844. /**
  8845. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  8846. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  8847. * Jeff, 2020.09.07
  8848. * @return true: LCD backlight On, false: LCD backlight Off
  8849. */
  8850. public boolean checkLCDOnByCMD() {
  8851. try {
  8852. Runtime mRuntime = Runtime.getRuntime();
  8853. Process mProcess;
  8854. String cmd = "getprop persist.sys.lcdcon";
  8855. mProcess = mRuntime.exec(cmd);
  8856. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  8857. String line;
  8858. String strResult = null;
  8859. while ((line = br.readLine()) != null) {
  8860. strResult = line;
  8861. }
  8862. if(strResult!=null)
  8863. {
  8864. if (strResult.equals("0")) {
  8865. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  8866. return true;
  8867. }
  8868. else if (strResult.equals("1")) {
  8869. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  8870. return false;
  8871. }
  8872. else {
  8873. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  8874. return false;
  8875. }
  8876. }
  8877. else return false;
  8878. } catch (RuntimeException re) {
  8879. LogUtil.errorLogInfo("", TAG, re);
  8880. return false;
  8881. }
  8882. catch (Exception e) {
  8883. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  8884. LogUtil.errorLogInfo("", TAG, e);
  8885. return false;
  8886. }
  8887. }
  8888. /**
  8889. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  8890. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  8891. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  8892. */
  8893. public boolean getCompareBSPVersion() {
  8894. try {
  8895. StringBuilder strBSPVersion = new StringBuilder();
  8896. StringBuffer sysInfoBuffer = new StringBuffer();
  8897. sysInfoBuffer.append(Build.DISPLAY);
  8898. strBSPVersion.append(sysInfoBuffer.toString());
  8899. String result = strBSPVersion.toString();
  8900. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  8901. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  8902. Date date = simpleDateFormat.parse(result);
  8903. Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
  8904. if (date.compareTo(standardDate) >= 0) {
  8905. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  8906. return true;
  8907. }
  8908. } catch (RuntimeException re) {
  8909. LogUtil.errorLogInfo("", TAG, re);
  8910. }
  8911. catch (Exception e) {
  8912. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  8913. LogUtil.errorLogInfo("", TAG, e);
  8914. }
  8915. return false;
  8916. }
  8917. /**
  8918. * 월패드 부팅시 카메라서비스 로딩이 실패하는 경우가 생겨 카메라 화면이 안나오는 경우 발생
  8919. * WallPadMain에서 부팅시 카메라를 확인하여 Exception이 발생하는 경우
  8920. * 카메라 서비스를 재실행한다.
  8921. * (Edited by jeff, 2020.09.08)
  8922. */
  8923. public void resetCameraService() {
  8924. try {
  8925. Log.e(TAG, "[resetCameraService] start!!");
  8926. Runtime mRuntime = Runtime.getRuntime();
  8927. String cmd = "setprop persist.sys.fakeactivitydel 1";
  8928. mRuntime.exec(cmd);
  8929. } catch (RuntimeException re) {
  8930. LogUtil.errorLogInfo("", TAG, re);
  8931. }
  8932. catch (Exception e) {
  8933. Log.e(TAG, "[Exception] resetCameraService()");
  8934. LogUtil.errorLogInfo("", TAG, e);
  8935. }
  8936. }
  8937. /**
  8938. * 월패드 부팅시 카메라서비스 로딩이 실패하는 경우가 발생하여
  8939. * 카메라서비스 정상동작 여부를 확인하기위한 함수를 정의한다.
  8940. * 카메라서비스 정상: 정상적으로 카메라가 open되며, camera object가 null이 아니면 카메라를 release한다.
  8941. * 카메라 서비스 비정상: 카메라 open시 Exception이 발생하며 resetCameraService() 함수를 실행하여 카메라서비스를 재실행한다.
  8942. * (Edited by jeff, 2020.09.08)
  8943. */
  8944. public void checkCameraLoading() {
  8945. try {
  8946. Camera checkCamera = Camera.open();
  8947. if (checkCamera != null) {
  8948. Log.e(TAG, "[checkCameraLoading] checkCamera is not null!!");
  8949. checkCamera.release();
  8950. }
  8951. else {
  8952. Log.e(TAG, "[checkCameraLoading] checkCamera is null!!");
  8953. resetCameraService();
  8954. }
  8955. } catch (RuntimeException re) {
  8956. LogUtil.errorLogInfo("", TAG, re);
  8957. resetCameraService();
  8958. }
  8959. catch (Exception e) {
  8960. Log.e(TAG, "[Exception] checkCameraLoading()");
  8961. LogUtil.errorLogInfo("", TAG, e);
  8962. resetCameraService();
  8963. }
  8964. }
  8965. private synchronized void FileDelete(File file)
  8966. {
  8967. if(file!=null && file.exists())
  8968. {
  8969. file.delete();
  8970. }
  8971. }
  8972. public static void ReDirectCall(String ip)
  8973. {
  8974. Intent Intent = new Intent();
  8975. Intent.setAction("CERES_CALL");
  8976. Intent.putExtra("REMOTEINFO", ip);
  8977. mContext_call.sendBroadcast(Intent);
  8978. }
  8979. /**
  8980. * 거동 수상자 녹화 중지(MainActivity -> WallPadCall)
  8981. */
  8982. private void stopStrangerRecord() {
  8983. try {
  8984. Log.d(TAG, "[stopStrangerRecord] bRecordStatus [" + Common.bRecordStatus + "]");
  8985. if (Common.bRecordStatus) {
  8986. Common.bRecordStatus = false;
  8987. // yjyoon. 녹화 중지 브로드캐스트
  8988. Intent iIntent = new Intent();
  8989. iIntent.setAction(Common.BR_REQUEST_RECORD_STOP);
  8990. iIntent.putExtra(define.NOTIBR_KIND, 1);
  8991. getApplicationContext().sendBroadcast(iIntent);
  8992. mediaStopRecord();
  8993. }
  8994. } catch (RuntimeException re) {
  8995. LogUtil.errorLogInfo("", TAG, re);
  8996. } catch (Exception e) {
  8997. Log.e(TAG, "[Exception] stopStrangerRecord(boolean bSave)");
  8998. //e.printStackTrace();
  8999. LogUtil.errorLogInfo("", TAG, e);
  9000. }
  9001. }
  9002. /**
  9003. * 거동 수상자 연속 녹화 방지(10초간 막음)
  9004. */
  9005. private void RecordDelayOn()
  9006. {
  9007. try {
  9008. Log.d(TAG, "[RecordDelay]");
  9009. Common.bRecordDelay = true;
  9010. Message msg = recordDelayHandler.obtainMessage();
  9011. recordDelayHandler.sendMessageDelayed(msg, 10 * 1000); // 녹화 종료 후 10초 동안 녹화를 막는다.
  9012. }
  9013. catch (Exception e)
  9014. {
  9015. }
  9016. }
  9017. /**
  9018. * 거동 수상자 녹화 중지 관련 내부 변수 처리
  9019. */
  9020. private void mediaStopRecord() {
  9021. try {
  9022. Log.d(TAG, "[mediaStopRecord]");
  9023. RecordDelayOn();
  9024. Common.bRecordStatus = false; // 녹화 종료
  9025. } catch (RuntimeException re) {
  9026. LogUtil.errorLogInfo("", TAG, re);
  9027. } catch (Exception e) {
  9028. Log.e(TAG, "[Exception] mediaStopRecord()");
  9029. //e.printStackTrace();
  9030. LogUtil.errorLogInfo("", TAG, e);
  9031. }
  9032. }
  9033. /**
  9034. * 거동 수상자 역속 녹화를 막기 위한 Handler
  9035. */
  9036. Handler recordDelayHandler = new Handler() {
  9037. @Override
  9038. public void handleMessage(Message msg) {
  9039. Common.bRecordDelay = false;
  9040. }
  9041. };
  9042. /**
  9043. * 거동 수상자 관련 BR 등록
  9044. */
  9045. private void registerStrangeRecordBR() {
  9046. try {
  9047. IntentFilter filter = new IntentFilter();
  9048. filter.addAction(Common.BR_RECORD_EXCEPTION);
  9049. filter.addAction(Common.BR_RECORD_STOP);
  9050. filter.addAction(Common.BR_RECORD_DELAY);
  9051. mContext.registerReceiver(StrangeRecordBroadcastReceiver, filter);
  9052. } catch (RuntimeException re) {
  9053. LogUtil.errorLogInfo("", TAG, re);
  9054. }
  9055. catch (Exception e) {
  9056. Log.e(TAG, "[Exception] registerMainActivityBR()");
  9057. LogUtil.errorLogInfo("", TAG, e);
  9058. }
  9059. }
  9060. /**
  9061. * 거동 수상자 관련 BR
  9062. */
  9063. BroadcastReceiver StrangeRecordBroadcastReceiver = new BroadcastReceiver() {
  9064. @Override
  9065. public void onReceive(Context context, Intent intent) {
  9066. if(intent.getAction().equals(Common.BR_RECORD_EXCEPTION))
  9067. {
  9068. Common.bRecordStatus = false;
  9069. }
  9070. else if(intent.getAction().equals(Common.BR_RECORD_STOP))
  9071. {
  9072. stopStrangerRecord();
  9073. }
  9074. else if(intent.getAction().equals(Common.BR_RECORD_DELAY))
  9075. {
  9076. RecordDelayOn();
  9077. }
  9078. }
  9079. };
  9080. }