MainActivity.java 476 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402
  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.SmartKeyRfDoorAPI;
  60. import com.artncore.wallpadapi.WallPadAPI;
  61. import com.artncore.wallpadimap.RetProci;
  62. import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
  63. import com.bumptech.glide.Glide;
  64. import com.bumptech.glide.load.engine.DiskCacheStrategy;
  65. import com.util.LogUtil;
  66. import java.io.BufferedReader;
  67. import java.io.BufferedWriter;
  68. import java.io.File;
  69. import java.io.FileInputStream;
  70. import java.io.FileOutputStream;
  71. import java.io.IOException;
  72. import java.io.InputStream;
  73. import java.io.InputStreamReader;
  74. import java.io.OutputStream;
  75. import java.io.OutputStreamWriter;
  76. import java.net.InetAddress;
  77. import java.net.NetworkInterface;
  78. import java.text.SimpleDateFormat;
  79. import java.util.ArrayList;
  80. import java.util.Calendar;
  81. import java.util.Collections;
  82. import java.util.Date;
  83. import java.util.GregorianCalendar;
  84. import java.util.List;
  85. import java.util.regex.Pattern;
  86. import kr.co.icontrols.v40ioctl.V40IOInterface;
  87. import kr.co.icontrols.wallpadmain.declare.Common;
  88. import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
  89. import kr.co.icontrols.wallpadmain.declare.DataClasses.IconInfoTable;
  90. import kr.co.icontrols.wallpadmain.declare.ID;
  91. import kr.co.icontrols.wallpadmain.declare.ID_OLD;
  92. import kr.co.icontrols.wallpadmain.declare.LayoutDevice;
  93. import kr.co.icontrols.wallpadmain.imap.iMAPAlarmOperation;
  94. import kr.co.icontrols.wallpadmain.imap.iMAPCarParking;
  95. import kr.co.icontrols.wallpadmain.imap.iMAPCarParking_UPIS;
  96. import kr.co.icontrols.wallpadmain.imap.iMAPElecCarChargingInfo;
  97. import kr.co.icontrols.wallpadmain.imap.iMAPEnergyServer_EnergyMeter;
  98. import kr.co.icontrols.wallpadmain.imap.iMAPEnergyServer_EnergyModule;
  99. import kr.co.icontrols.wallpadmain.imap.iMAPEnergyServer_Realmeter;
  100. import kr.co.icontrols.wallpadmain.imap.iMAPRemotemeter;
  101. import kr.co.icontrols.wallpadmain.menu.CallSubMenuScreen;
  102. import kr.co.icontrols.wallpadmain.screen.EASYUI_MAIN;
  103. import kr.co.icontrols.wallpadmain.screen.HYOSUNGUI_MAIN_HA;
  104. import kr.co.icontrols.wallpadmain.screen.HYOSUNGUI_MAIN_HN;
  105. import kr.co.icontrols.wallpadmain.screen.MAIN;
  106. import kr.co.icontrols.wallpadmain.screen.METROUI_MAIN;
  107. import kr.co.icontrols.wallpadmain.screen.METROUI_SUB_01;
  108. import kr.co.icontrols.wallpadmain.screen.METROUI_SUB_02;
  109. import kr.co.icontrols.wallpadmain.screen.METROUI_SUB_GROUP;
  110. import kr.co.icontrols.wallpadmain.screen.SUB_01;
  111. import kr.co.icontrols.wallpadmain.screen.SUB_02;
  112. import kr.co.icontrols.wallpadmain.util.EnergyAlramPopupMgr;
  113. import kr.co.icontrols.wallpadmain.util.IconManager;
  114. import kr.co.icontrols.wallpadmain.util.MobileProcService;
  115. import kr.co.icontrols.wallpadmain.util.StringUtil;
  116. import kr.co.icontrols.wallpadmain.util.iMapServer;
  117. import kr.co.icontrols.wallpadsupport.Version;
  118. import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
  119. import kr.co.icontrols.wallpadsupport.WpadActivity;
  120. import kr.co.icontrols.wallpadsupport.WpadRelativeLayoutParams;
  121. import kr.co.icontrols.wallpadsupport.WpadScale;
  122. import kr.co.icontrols.wallpadsupport.WpadSound;
  123. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  124. import kr.co.icontrols.wallpadsupport.WpadUtil;
  125. import kr.co.icontrols.wallpadmain.imap.iMAPAlarmOperation.EMER_STATE;
  126. import kr.co.icontrols.wallpadmain.imap.iMAPAlarmOperation.EMER_DETAIL_INFO;
  127. import static android.content.Intent.ACTION_TIME_TICK;
  128. import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
  129. import static com.artncore.commons.define.ALBUM_PICTURE_LOCATION;
  130. import static com.artncore.commons.define.BESTIN_LOCATION;
  131. /**
  132. * @description
  133. * 월패드 [설정기능] 메인화면 이다.<br>
  134. * 상단의 Top 메뉴, [홈] [돌아가기]<br>
  135. * 좌측의 Tab 메뉴, [조명] [난방] [가스] ... 등 선택 메뉴<br>
  136. * 를 여기서 처리한다.
  137. */
  138. public class MainActivity extends WpadActivity {
  139. private final static String TAG = "MainActivity";
  140. private void DebugLogOutput(String s) { if(Common.DEBUG_LOG_ON) Log.d(TAG, s); }
  141. // =================================================================================================
  142. // [[ Declaration ]] region
  143. // =================================================================================================
  144. protected Context mContext = null;
  145. static Context mContext_call = null;
  146. public Context getContext() { return mContext; }
  147. private WallPadAPI mWallPadAPI = null;
  148. public static IOInterface mIOInterface = null;
  149. private int DEVICE_OPERATION_MODE = Common.MODE;
  150. boolean bEasyModeUsage = false;
  151. public static boolean bGoodDesign2020 = false;
  152. // Layout
  153. private RelativeLayout MainLayout; // 메인화면
  154. private RelativeLayout MainScreenLayout;
  155. private RelativeLayout SubLayout_01; // 서브 01 화면
  156. private RelativeLayout SubScreenLayout_01;
  157. private RelativeLayout SubLayout_02; // 서브 02 화면
  158. private RelativeLayout SubScreenLayout_02;
  159. private RelativeLayout EasyMainLayout; // 간편모드 메인화면
  160. private RelativeLayout EasyMainScreenLayout;
  161. private ViewFlipper mViewFlipper;
  162. Animation aniSlideIn, aniSlideOut;
  163. public static ImageView IMG_LCD_KEEPER;
  164. // PopupActivityRun
  165. private static boolean PopupActivityRun = false;
  166. public static boolean getPopupActivityRun() { return PopupActivityRun; }
  167. public static void setPopupActivityRun(boolean run) { PopupActivityRun = run; }
  168. // InfoActivityRun
  169. private static boolean InfoActivityRun = false;
  170. public static boolean getInfoActivityRun() {
  171. Log.d(TAG, "[getInfoActivityRun] InfoActivityRun: " + InfoActivityRun);
  172. return InfoActivityRun;
  173. }
  174. public static void setInfoActivityRun(boolean run) {
  175. InfoActivityRun = run;
  176. if (!InfoActivityRun) resetCurrentInfoScreenID();
  177. }
  178. // Menu & TabData
  179. private Menu mMenu = null;
  180. // private TabData mTabData = null;
  181. // CurrentScreenId
  182. private int mCurrentScreenId = -1;
  183. private int mTempCurrentScreenId = -1;
  184. private static int mCurrentInfoScreenId = -1;
  185. // Screen
  186. private MAIN MainScreen = null;
  187. private SUB_01 SUB_01Screen = null;
  188. private SUB_02 SUB_02Screen = null;
  189. private METROUI_MAIN MetroUI_MainScreen = null;
  190. private METROUI_SUB_01 MetroUI_SUB_01Screen = null;
  191. private METROUI_SUB_02 MetroUI_SUB_02Screen = null;
  192. private METROUI_SUB_GROUP MetroUI_SUB_GroupScreen = null;
  193. private HYOSUNGUI_MAIN_HN Hyosung_HN_MainScreen = null;
  194. private HYOSUNGUI_MAIN_HA Hyosung_HA_MainScreen = null;
  195. private EASYUI_MAIN EasyUI_MainScreen = null;
  196. // 메뉴 리스트 처리 및 서브 스크린 호출
  197. public CallSubMenuScreen m_CallSubMenuScreen = null;
  198. ///////////////////////////// AnC 메인어플에서 사용되는 변수 모음
  199. int LastTimeSync = 0;
  200. boolean HomeCTROn = true;
  201. //int PSTNStatus = 0;
  202. int MAINStatus = 0;
  203. public static final int MAIN_NORMAL = 0;
  204. public static final int MAIN_WAIT_SETIP = 1;
  205. static boolean Alert_App_On = false;
  206. byte bootupretryCNT = 0;
  207. static final int MAX_BOOTUP_RETRY_COUNT = 1200;
  208. ScheduleManager SCManager;
  209. boolean SYSTEM_TIME_SET = false;
  210. static boolean CALLSVCSTARTED = false;
  211. public Thread mThread_getAppsVersion = null;
  212. ///////////////////////////// end
  213. // 거실조명 제어드라이버
  214. private IntLightAPI mIntLightAPI = null;
  215. // 에너지미터 제어드라이버
  216. private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null;
  217. private SdbAPI mSdbAPI = null;
  218. // 멀티스위치 제어 드라이버
  219. private MultiSwitchAPI m_MultiSwitch = null;
  220. // 대외향 거실 스위치 드라이버
  221. private LightAPI m_LightCtrl = null;
  222. private boolean m_ModelHouseSleepModeRelease = false;
  223. //주차정보 관련 변수
  224. public static boolean bUseofNot_ParkingInfo = false;
  225. public static int nParkingSystemType = Common.PARKING_SYSTEM_ICONTROLS;
  226. private String ParkingServerIP = null;
  227. private int ParkingServerPort = 10000;
  228. private int cGetParkingMin = 18;
  229. private boolean bSetMSG_GetParkingInfo = false;
  230. iMAPCarParking iMAPcarParking;
  231. iMAPCarParking_UPIS iMapcarParking_UPIS;
  232. //일정 알림 관련 변수
  233. private int AlarmScheduleCount = 0;
  234. private String AlarmScheduleString = null;
  235. private boolean bAlarmScheduleString = false;
  236. //전기차 충전 관련 변수
  237. iMAPElecCarChargingInfo imapElecCarChargingInfo;
  238. //제로 에너지 하우스 관련 변수
  239. private boolean bUseofNot_ZeroEnergyHouseInfo = false;
  240. private int cGetZeroEnergyHouseMin = 12;
  241. iMAPEnergyServer_Realmeter iMAPenergyServer_Realmeter;
  242. iMAPEnergyServer_EnergyMeter iMAPenergyServer_EnergyMeter;
  243. iMAPEnergyServer_EnergyModule iMAPenergyServer_EnergyModule;
  244. String DayofLastSecond = "2000-01-01 00:00:00";
  245. boolean DayofLastBoolean = false;
  246. //에너지관리서버 관련 변수
  247. private boolean bUseofNot_EnergyServer = false;
  248. //에너지 알람 발생 관련 변수
  249. private boolean bUseofNot_EnergyAlarm = false;
  250. private boolean ResultGetIntent = false;
  251. private String elect_target = "Error";
  252. private String elect_used = "Error";
  253. private String elect_info = "Error";
  254. private String water_target = "Error";
  255. private String water_used = "Error";
  256. private String water_info = "Error";
  257. private String gas_target = "Error";
  258. private String gas_used = "Error";
  259. private String gas_info = "Error";
  260. private String hotwater_target = "Error";
  261. private String hotwater_used = "Error";
  262. private String hotwater_info = "Error";
  263. private String heating_target = "Error";
  264. private String heating_used = "Error";
  265. private String heating_info = "Error";
  266. /**
  267. * 월패드 이벤트 알림 관련 변수
  268. */
  269. // 스마트 우편, 전기차 충전 사용 여부
  270. public static boolean bSmartPostUsage = false, bElecVehicleUsage = false;
  271. // 부재중 전화, 방문객 사진, 공지사항, 택배, 스마트 우편, 전기차 충전 이벤트 개수
  272. public static int nMissedCallCnt = 0, nVisitorPicCnt = 0, nNoticeCnt = 0, nParcelCnt = 0, nPostCnt = 0, nElecVehicleChangingCnt = 0;
  273. /**
  274. * 카메라 API
  275. */
  276. SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null;// mWallPadAPI.Get_SmartKeyRfDoorController();
  277. // 끝
  278. //월패드 CallBr 관리하기 위한 List
  279. static public ArrayList<Intent> CallBrList;
  280. IconManager mIconManager;
  281. public IconInfoTable mIconInfoTable;
  282. public static int nShortcutCnt = 0;
  283. public static int nShortcutMax = 12;
  284. public static int nShortcutCnt_HS = 0;
  285. public static int nShortcutMax_HS = 9;
  286. public static int nShortcutCnt_Metro = 0;
  287. public static int nShortcutMax_Metro = 3;
  288. int nIconsOnSubScreen = 24;
  289. public static List<WallpadStatusData.WidgetItem> MainScreenShortcutList;
  290. public static List<WallpadStatusData.WidgetItem> HSScreenShortcutList;
  291. public static List<WallpadStatusData.WidgetItem> MetroScreenShortcutList;
  292. // 조명상태를 관리하기 위한 클래스
  293. public static class LightInfo {
  294. public class Preset {
  295. public class Lights {
  296. public String ONOFF = "none";
  297. public int DIM = 0;
  298. public int COLOR = 0;
  299. public Lights() {
  300. ONOFF = "none";
  301. DIM = 0;
  302. COLOR = 0;
  303. }
  304. }
  305. public Lights[] mLights;
  306. public Preset() {
  307. mLights = new Lights[9]; // 0번지는 프리셋별 그룹제어 설정값 (조명 1~8)
  308. for (int i = 0; i < mLights.length; i++) {
  309. mLights[i] = new Lights();
  310. }
  311. }
  312. }
  313. public Preset[] mPreset;
  314. public int nLightPresetNo;
  315. public LightInfo() {
  316. mPreset = new Preset[9]; // 0번지는 전체제어 설정값 (프리셋 1~8)
  317. for (int i = 0; i < mPreset.length; i++) {
  318. mPreset[i] = new Preset();
  319. }
  320. nLightPresetNo = 0;
  321. }
  322. }
  323. public static LightInfo mLightInfo;
  324. public String BR_CTRL_LIGHT_LIVINGROOM = "kr.co.icontrols.wallpadglobalscreen.BR_CTRL_LIGHT_LIVINGROOM";
  325. public static WpadSound mSound;
  326. public void getLivinglightPreset() {
  327. try {
  328. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  329. String[] strEntireValue = mWallpadStatusData.getLivinglightModeCtrlEntireValue();
  330. mWallpadStatusData.closeDB();
  331. Log.i(TAG, "[getLivinglightPreset] strEntireValue.length = " + strEntireValue.length);
  332. for (int i = 0; i < strEntireValue.length; i++) {
  333. Log.i(TAG, "[getLivinglightPreset] strEntireValue[" + i + "] = " + strEntireValue[i]);
  334. }
  335. } catch (RuntimeException re) {
  336. LogUtil.errorLogInfo("", TAG, re);
  337. }
  338. catch (Exception e) {
  339. Log.e(TAG, "[Exception] getLivinglightPreset()");
  340. LogUtil.errorLogInfo("", TAG, e);
  341. }
  342. }
  343. public void initLivinglightPreset() {
  344. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  345. try {
  346. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  347. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  348. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  349. Log.i(TAG, "[initLivinglightPreset] Initialize preset for IHN-D101");
  350. for (int i = 1; i < 5; i++) {
  351. String strPreset = mWallpadStatusData.getLivinglightModeCtrlUnitValues(i, 0);
  352. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  353. String[] strParse = strPreset.split(":");
  354. if (strParse[1].equalsIgnoreCase("0") || strParse[2].equalsIgnoreCase("0")) {
  355. if (i == 1) {
  356. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  357. mLightInfo.mPreset[i].mLights[0].DIM = 7;
  358. mLightInfo.mPreset[i].mLights[0].COLOR = 5;
  359. }
  360. else if (i == 2) {
  361. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  362. mLightInfo.mPreset[i].mLights[0].DIM = 3;
  363. mLightInfo.mPreset[i].mLights[0].COLOR = 2;
  364. }
  365. else if (i == 3) {
  366. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  367. mLightInfo.mPreset[i].mLights[0].DIM = 1;
  368. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  369. }
  370. mWallpadStatusData.setLivinglightModeCtrlUnitValues(i, 0, mLightInfo.mPreset[i].mLights[0].ONOFF, mLightInfo.mPreset[i].mLights[0].DIM, mLightInfo.mPreset[i].mLights[0].COLOR);
  371. }
  372. else {
  373. mLightInfo.mPreset[i].mLights[0].ONOFF = strParse[0];
  374. mLightInfo.mPreset[i].mLights[0].DIM = Integer.parseInt(strParse[1]);
  375. mLightInfo.mPreset[i].mLights[0].COLOR = Integer.parseInt(strParse[2]);
  376. }
  377. }
  378. }
  379. else if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I
  380. || Version.getModelType() == MODEL_TYPE.IHN_1010_I_2443
  381. ) {
  382. Log.i(TAG, "[initLivinglightPreset] Initialize preset for IHN-1010(-I)");
  383. if (getKCCDimmingCtrl()) {
  384. for (int i = 1; i < 5; i++) {
  385. String strPreset = mWallpadStatusData.getLivinglightModeCtrlUnitValues(i, 0);
  386. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  387. String[] strParse = strPreset.split(":");
  388. if (strParse[1].equalsIgnoreCase("0") || strParse[2].equalsIgnoreCase("0")) {
  389. if (i == 1) {
  390. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  391. mLightInfo.mPreset[i].mLights[0].DIM = 10;
  392. mLightInfo.mPreset[i].mLights[0].COLOR = 5;
  393. }
  394. else if (i == 2) {
  395. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  396. mLightInfo.mPreset[i].mLights[0].DIM = 7;
  397. mLightInfo.mPreset[i].mLights[0].COLOR = 2;
  398. }
  399. else if (i == 3) {
  400. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  401. mLightInfo.mPreset[i].mLights[0].DIM = 5;
  402. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  403. }
  404. else if (i == 4) {
  405. mLightInfo.mPreset[i].mLights[0].ONOFF = "on";
  406. mLightInfo.mPreset[i].mLights[0].DIM = 2;
  407. mLightInfo.mPreset[i].mLights[0].COLOR = 1;
  408. }
  409. mWallpadStatusData.setLivinglightModeCtrlUnitValues(i, 0, mLightInfo.mPreset[i].mLights[0].ONOFF, mLightInfo.mPreset[i].mLights[0].DIM, mLightInfo.mPreset[i].mLights[0].COLOR);
  410. }
  411. else {
  412. Log.i(TAG, "[initLivinglightPreset] i = " + i + ", strPreset = " + strPreset);
  413. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].ONOFF);
  414. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].DIM);
  415. Log.i(TAG, "[initLivinglightPreset] mLightInfo.mPreset[" + i + "].mLights[0].ONOFF = " + mLightInfo.mPreset[i].mLights[0].COLOR);
  416. }
  417. }
  418. }
  419. }
  420. } catch (RuntimeException re) {
  421. LogUtil.errorLogInfo("", TAG, re);
  422. }
  423. catch (Exception e) {
  424. Log.e(TAG, "[Exception] initLivinglightPreset()");
  425. LogUtil.errorLogInfo("", TAG, e);
  426. }
  427. mWallpadStatusData.closeDB();
  428. }
  429. private boolean getKCCDimmingCtrl() {
  430. try {
  431. Log.i(TAG, "[getKCCDimmingCtrl] ========== START ==========");
  432. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  433. int nEnable = mWallpadDeviceSet.GetDeviceSetted("KCC디밍제어기");
  434. mWallpadDeviceSet.closeDB();
  435. Log.i(TAG, "[getKCCDimmingCtrl] nEnable [" + nEnable + "]");
  436. if (nEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
  437. Log.i(TAG, "[getKCCDimmingCtrl] Enabled");
  438. return true;
  439. }
  440. else {
  441. Log.i(TAG, "[getKCCDimmingCtrl] Disabled");
  442. return false;
  443. }
  444. } catch (RuntimeException re) {
  445. LogUtil.errorLogInfo("", TAG, re);
  446. return false;
  447. }
  448. catch (Exception e) {
  449. Log.e(TAG, "[Exception] setKCCDimmingCtrl()");
  450. LogUtil.errorLogInfo("", TAG, e);
  451. return false;
  452. }
  453. }
  454. private void initEscapeLadderDownSend() {
  455. try {
  456. WallpadDeviceSet deviceSet = new WallpadDeviceSet(getContext());
  457. if(deviceSet!=null)
  458. {
  459. int ladderDownSend = deviceSet.getEscapeLadderDownSend();
  460. boolean ladderDownRecv = deviceSet.GetEscapeLadderDownRecv(); // 기존 '피난사다리입하수신' 설정정보 (더이상 사용하지 않음 2021.01.28)\
  461. Log.d(TAG, "[initEscapeLadderDownSend] ladderDownRecv [" + ladderDownRecv + "]");
  462. if (ladderDownRecv) {
  463. if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_NONE) {
  464. Log.d(TAG, "[initEscapeLadderDownSend] ===== first setting =====");
  465. deviceSet.setEscapeLadderDownSend(WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER); // 신규 /'피난사다리전송' 설정정보 '윗집'
  466. } else {
  467. Log.d(TAG, "[initEscapeLadderDownSend] ladderDownSend [" + ladderDownSend + "]");
  468. }
  469. }
  470. deviceSet.closeDB();
  471. }
  472. } catch (RuntimeException re) {
  473. LogUtil.errorLogInfo("", TAG, re);
  474. } catch (Exception e) {
  475. Log.e(TAG, "[Exception] initEscapeLadderDownSend()");
  476. LogUtil.errorLogInfo("", TAG, e);
  477. }
  478. }
  479. public void CallSubMenuScreen(int screenID) {
  480. if (screenID >= ID.LINKEDSCREEN.SubMenuAddService.Notice && screenID <= ID.LINKEDSCREEN.SubMenuAddService.ElecCar) m_CallSubMenuScreen.callStartAddServiceAPK(screenID);
  481. else if (screenID >= ID.LINKEDSCREEN.SubMenuEnergy.RealTimeCheckMeter && screenID <= ID.LINKEDSCREEN.SubMenuEnergy.IEnergy) m_CallSubMenuScreen.callStartEnergyAPK(screenID);
  482. }
  483. private void restoreSystemVolume() {
  484. try {
  485. String strCurrentTopPackage = getTopActivity();
  486. Log.i(TAG, "[restoreSystemVolume] strCurrentTopPackage = " + strCurrentTopPackage);
  487. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  488. int nSavedVolume = wdb.GetWallPadMasterVolume();
  489. wdb.closeDB();
  490. final AudioManager audioManager = (AudioManager)this.getContext().getSystemService(this.getContext().AUDIO_SERVICE);
  491. int nCurrentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
  492. audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume , 0);
  493. Log.i(TAG, "[restoreSystemVolume] #Before# nCurrentVolume = " + nCurrentVolume + ", #After# nSavedVolume = " + nSavedVolume);
  494. } catch (RuntimeException re) {
  495. LogUtil.errorLogInfo("", TAG, re);
  496. }
  497. catch (Exception e) {
  498. Log.e(TAG, "[Exception] restoreSystemVolume()");
  499. LogUtil.errorLogInfo("", TAG, e);
  500. }
  501. }
  502. // =================================================================================================
  503. // [[ Activity Life Cycle ]] region
  504. // =================================================================================================
  505. /**
  506. * Activity Constructors
  507. */
  508. @Override
  509. protected void onCreate(Bundle savedInstanceState) {
  510. super.onCreate(savedInstanceState);
  511. Log.i(TAG, "[onCreate] ========== START ==========");
  512. Log.w(TAG, "[onCreate] Start to check booting status!!!");
  513. Runtime mRuntime = Runtime.getRuntime();
  514. Process mProcess;
  515. int iDelayCount = 0;
  516. while (true) {
  517. try {
  518. String cmd = "getprop dev.bootcomplete";
  519. mProcess = mRuntime.exec(cmd);
  520. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  521. String line;
  522. String strResult = null;
  523. while ((line = br.readLine()) != null) {
  524. strResult = line;
  525. }
  526. if (strResult!=null && strResult.equals("1")) {
  527. File sdcard = new File("/storage/emulated/0");
  528. if(sdcard.exists() == true) {
  529. iDelayCount = 0;
  530. Thread.sleep(1000);
  531. break;
  532. }
  533. }
  534. {
  535. iDelayCount++;
  536. Thread.sleep(100);
  537. }
  538. if (iDelayCount > 400) {
  539. cmd = "setprop persist.sys.reboot 1";
  540. mProcess = mRuntime.exec(cmd);
  541. }
  542. } catch (RuntimeException re) {
  543. LogUtil.errorLogInfo("", TAG, re);
  544. }
  545. catch (Exception e) {
  546. Log.e(TAG, "[Exception] Checking device booting status -> Unable to execute top command");
  547. e.fillInStackTrace();
  548. LogUtil.errorLogInfo("", TAG, e);
  549. }
  550. }
  551. Log.w(TAG, "[onCreate] Device booting completed!!");
  552. Log.i(TAG, "[onCreate] Wallpad model name [" + Version.getModelType() + "]");
  553. if (Common.DIAGNOSTIC_MODE) {
  554. Log.i(TAG, "------------------ [START - DIAGNOSTIC_MODE] -------------------");
  555. setNetworkAddr( 2, 1, 3);
  556. }
  557. // @ AutoScale 설정 - 1.
  558. if (WpadScale.getWidthPixels() == 800 && WpadScale.getHeightPixels() == 480) {
  559. // 800x480 일 경우에만 AutoScale 을 설정한다.
  560. Log.i(TAG, "[onCreate] Wallpad LCD resolution. -> Width [" + WpadScale.getWidthPixels() + "], Height [" + WpadScale.getHeightPixels() + "] -> setAutoScale ON !!!");
  561. WpadScale.setAutoScale(true);
  562. }
  563. else if (WpadScale.getWidthPixels() == 1366 && WpadScale.getHeightPixels() == 768) {
  564. // 800x480 일 경우에만 AutoScale 을 설정한다.
  565. Log.i(TAG, "[onCreate] Wallpad LCD resolution. -> Width [" + WpadScale.getWidthPixels() + "], Height [" + WpadScale.getHeightPixels() + "] -> setAutoScale ON !!!");
  566. WpadScale.setAutoScale(true);
  567. WpadScale.changeAutoScaleValue(1024, 600);
  568. }
  569. // @ AutoScale 설정 - 2. 에너지관리화면을 위한 구분자 설정
  570. if ((WpadScale.getWidthPixels() == 1024) && (WpadScale.getHeightPixels() == 600)) {
  571. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1024x600;
  572. }
  573. else if ((WpadScale.getWidthPixels() == 1280) && (WpadScale.getHeightPixels() == 800)) {
  574. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1280x800;
  575. }
  576. else if ((WpadScale.getWidthPixels() == 800) && (WpadScale.getHeightPixels() == 480)) {
  577. Common.SCREEN_TYPE = Common.SCREEN_TYPE_800x480;
  578. }
  579. else if ((WpadScale.getWidthPixels() == 1366) && (WpadScale.getHeightPixels() == 768)) {
  580. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1024x600;
  581. }
  582. Log.d(TAG, "[onCreate] SCREEN_TYPE: " + Common.SCREEN_TYPE);
  583. super.setFinishBrEnable(false);
  584. super.AppVersionLogOut(); // [APP Version] + [WallPadSupport Lib Version] 을 로그로 출력한다.
  585. LayoutDevice.InitGetScreenSize(this.getWindowManager(), getApplicationContext() );
  586. try {
  587. // 최초 DB 폴더가 생성되어 있지 않으면 폴더를 생성하도록 한다.
  588. File dbhome = new File(wallpaddbmgr.dblocation);
  589. Log.d(TAG, "[Create] - Step0.3 : dbhome path [" + dbhome.getPath() + "]");
  590. if (dbhome.exists() == false) {
  591. dbhome.mkdir();
  592. Log.d(TAG, "[Create] - Step0.3 : Make DB Folder");
  593. }
  594. else {
  595. Log.d(TAG, "[Create] - Step0.3 : DB exists");
  596. }
  597. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  598. if (mWallpadStatusData != null) {
  599. DebugLogOutput("[Create] - Step0.3 : WallpadStatusData Open OK");
  600. mWallpadStatusData.closeDB();
  601. }
  602. else {
  603. DebugLogOutput("[Create] - Step0.3 : WallpadStatusData Open FAIL");
  604. }
  605. } catch (RuntimeException re) {
  606. LogUtil.errorLogInfo("", TAG, re);
  607. }
  608. catch (Exception e) {
  609. LogUtil.errorLogInfo("", TAG, e);
  610. }
  611. DebugLogOutput("[Create] - Step0.5 : WallpadStatusData end");
  612. Log.i("Version", "<><><><> WallPadAPI Version = [" + define.WALLPADAPI_VERSION + "] " + "<><><><>");
  613. checkISSEnergyType();
  614. runDeviceService();
  615. // 1. 변수 초기화
  616. DebugLogOutput("[Create] - Step1 : EMData Create");
  617. PopupActivityRun = false;
  618. InfoActivityRun = false;
  619. mContext = this;
  620. mContext_call = mContext;
  621. setCallAppRunning(false); // 메인앱 초기화시 통화앱 미실행값을 DB에 저장
  622. // 2. 자동 종료 셋팅
  623. DebugLogOutput("[Create] - Step2 : Auto Finish Setting");
  624. // 3. API 호출
  625. DebugLogOutput("[Create] - Step3 : API Call");
  626. // 3.1. mWallPadAPI 생성
  627. try {
  628. mWallPadAPI = new WallPadAPI(this);
  629. } catch (RuntimeException re) {
  630. LogUtil.errorLogInfo("", TAG, re);
  631. }
  632. catch (Exception e) {
  633. Log.e(TAG, "[ExceptionError] - new WallPadAPI : " + e);
  634. LogUtil.errorLogInfo("", TAG, e);
  635. }
  636. initIOInterface(mWallPadAPI);
  637. Common.CurrentBoardType = mIOInterface.getBoardType(Version.getModelType());
  638. DebugLogOutput("[Create] - Step3.5 : API Call end");
  639. if (Common.GetDeviceSampleMode(this)) {
  640. Log.d(TAG, "[Create] OperationMode = MODE_BUSINESS_SAMPLE");
  641. DEVICE_OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE;
  642. }
  643. else {
  644. Log.d(TAG, "[Create] OperationMode = MODE_NOMAL");
  645. DEVICE_OPERATION_MODE = Common.MODE_NOMAL;
  646. }
  647. // 분전반 정보 가져오기
  648. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  649. Common.CurrentDistributionPanelType = mWallpadDeviceSet.Get_DistributionPannelType_Info();
  650. mWallpadDeviceSet.closeDB();
  651. // 4. Layout registration
  652. DebugLogOutput("[Create] - Step4 : Layout registration");
  653. Common.eGUIType = checkGUIType(this.getContext());
  654. Log.i(TAG, "[Create] eGUIType = " + Common.eGUIType);
  655. mIconManager = new IconManager(mContext, mWallPadAPI);
  656. if (mIconManager == null) {
  657. Log.w(TAG, "[Create] mIconManager is null!!");
  658. }
  659. mIconInfoTable = mIconManager.getAvailableIcons();
  660. if (mIconInfoTable == null) {
  661. Log.w(TAG, "[Create] mIconInfoTable is null!!");
  662. }
  663. else {
  664. Log.i(TAG, "[Create] mIconInfoTable.getCnt() = " + mIconInfoTable.getCnt());
  665. }
  666. WallpadDeviceSet deviceSet = new WallpadDeviceSet(mContext);
  667. boolean bSupport = deviceSet.Get_EasyModeUX_Support();
  668. deviceSet.closeDB();
  669. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  670. if (!bSupport) {
  671. mWallpadStatusData.SetEasyModeUxUse(false);
  672. }
  673. bEasyModeUsage = bSupport & mWallpadStatusData.GetEasyModeUxUse();
  674. mWallpadStatusData.closeDB();
  675. // Sound API 등록
  676. mSound = new WpadSound(this);
  677. // 메인화면 레이아웃
  678. MainLayout = new RelativeLayout(this);
  679. RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  680. MainLayout.setLayoutParams(params);
  681. MainLayout.setId(ID_OLD.main.layout.ALL);
  682. super.setAllLayoutRegistration(MainLayout);
  683. // 메인화면 스크린 레이아웃
  684. MainScreenLayout = new RelativeLayout(this);
  685. WpadUtil.LayoutRegistration(MainLayout, MainScreenLayout, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  686. if (getWallPadCameraUsage() && (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT)) {
  687. Log.i(TAG, "[Create] SurfaceLayout Registration!!!");
  688. SurfaceLayout = new RelativeLayout(this);
  689. WpadUtil.LayoutRegistration(MainLayout, SurfaceLayout, WpadScale.getWidthPixels(), WpadScale.getWidthPixels(), 0, 0, ID.MAINACTIVITY.LAYOUT.SURFACE);
  690. }
  691. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) nIconsOnSubScreen = 24;
  692. // else if (eGUIType == GUI_TYPE.METRO) nIconsOnSubScreen = 15;
  693. else nIconsOnSubScreen = 24;
  694. // 서브화면 1 레이아웃
  695. if (mIconInfoTable.getCnt() > 0) {
  696. SubLayout_01 = new RelativeLayout(this);
  697. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  698. SubLayout_01.setLayoutParams(params);
  699. SubLayout_01.setId(ID_OLD.main.layout.ALL);
  700. super.setAllLayoutRegistration(SubLayout_01);
  701. // 서브화면 1 스크린 레이아웃
  702. SubScreenLayout_01 = new RelativeLayout(this);
  703. WpadUtil.LayoutRegistration(SubLayout_01, SubScreenLayout_01, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  704. }
  705. // 서브화면 2 레이아웃
  706. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) {
  707. SubLayout_02 = new RelativeLayout(this);
  708. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  709. SubLayout_02.setLayoutParams(params);
  710. SubLayout_02.setId(ID_OLD.main.layout.ALL);
  711. super.setAllLayoutRegistration(SubLayout_02);
  712. // 서브화면 2 스크린 레이아웃
  713. SubScreenLayout_02 = new RelativeLayout(this);
  714. WpadUtil.LayoutRegistration(SubLayout_02, SubScreenLayout_02, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  715. }
  716. // 간편모드 메인화면 레이아웃
  717. if (bEasyModeUsage) {
  718. EasyMainLayout = new RelativeLayout(this);
  719. params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  720. EasyMainLayout.setLayoutParams(params);
  721. EasyMainLayout.setId(ID_OLD.main.layout.ALL);
  722. super.setAllLayoutRegistration(EasyMainLayout);
  723. // 간편모드 메인화면 스크린 레이아웃
  724. EasyMainScreenLayout = new RelativeLayout(this);
  725. WpadUtil.LayoutRegistration(EasyMainLayout, EasyMainScreenLayout, WpadScale.getWidthPixels(), WpadScale.getHeightPixels(), 0, 0, ID_OLD.main.layout.SCREEN);
  726. }
  727. m_ModelHouseSleepModeRelease= Common.GetModelHouseSleepModeRelease(this);
  728. Log.d(TAG, " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% =====> GetModelHouseSleepModeRelease :" + m_ModelHouseSleepModeRelease);
  729. if (m_ModelHouseSleepModeRelease) {
  730. mLCD_SleepHandler.sendEmptyMessageDelayed(0, (30 * 1000));
  731. }
  732. // 5. Top Menu - ImageView registration
  733. DebugLogOutput("[Create] - Step5 : Top Menu - ImageView registration");
  734. // 6. Tab Menu - ImageView registration
  735. restoreSystemVolume();
  736. initProximitySensor();
  737. // 서브 스크린 호출하기 위한 메뉴 리스트 관리 클래스
  738. m_CallSubMenuScreen = new CallSubMenuScreen( this , mWallPadAPI);
  739. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  740. // 메인화면 3가지 등록으로 인해 변경
  741. MainScreen = new MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  742. // EasyUI_MainScreen = new EASYUI_MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  743. }
  744. else if (Common.eGUIType == Common.GUI_TYPE.METRO) {
  745. MetroUI_MainScreen = new METROUI_MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  746. }
  747. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) {
  748. Hyosung_HN_MainScreen = new HYOSUNGUI_MAIN_HN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  749. }
  750. else {
  751. MainScreen = new MAIN(this, MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  752. }
  753. DebugLogOutput("[Create] - Step6 : Main Screen registration");
  754. // 7. Draw
  755. DebugLogOutput("[Create] - Step7 : setContentView");
  756. try {
  757. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  758. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) setContentView(R.layout.main);
  759. else setContentView(R.layout.main_2);
  760. }
  761. else if (Common.eGUIType == Common.GUI_TYPE.METRO) setContentView(R.layout.main_metro);
  762. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) setContentView(R.layout.main_hyosung);
  763. else {
  764. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) setContentView(R.layout.main);
  765. else setContentView(R.layout.main_2);
  766. }
  767. if (bEasyModeUsage) setContentView(R.layout.main_easy);
  768. // setContentView(R.layout.main);
  769. // 메인화면 3가지로 슬라이딩 방식으로 구현하기 위하여 뷰플리퍼를 사용하여 처리
  770. mViewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);
  771. if (mViewFlipper != null) {
  772. if (MainLayout != null) mViewFlipper.addView(MainLayout);
  773. if (SubLayout_01 != null) mViewFlipper.addView(SubLayout_01);
  774. if (SubLayout_02 != null && Common.eGUIType == Common.GUI_TYPE.STANDARD) mViewFlipper.addView(SubLayout_02);
  775. if (EasyMainLayout != null && bEasyModeUsage) mViewFlipper.addView(EasyMainLayout);
  776. DebugLogOutput("[Create] - Step8 : Add Flipper !!! ");
  777. }
  778. } catch (RuntimeException re) {
  779. LogUtil.errorLogInfo("", TAG, re);
  780. }
  781. catch (Exception e) {
  782. LogUtil.errorLogInfo("", TAG, e);
  783. }
  784. registerBroadcastReceiver();
  785. Check_Upgrade_File();
  786. //앱 버전정보 DB저장
  787. try {
  788. Log.d(TAG, "mThread_getAppsVersion Start!! ");
  789. if (mThread_getAppsVersion== null) {
  790. mThread_getAppsVersion = new getInstalledPackageInfo();
  791. mThread_getAppsVersion.start();
  792. }
  793. else {
  794. Log.w(TAG, "mThread_getAppsVersion is null!!");
  795. }
  796. Log.d(TAG, "mThread_getAppsVersion End!! ");
  797. } catch (RuntimeException re) {
  798. LogUtil.errorLogInfo("", TAG, re);
  799. }
  800. catch (Exception e) {
  801. LogUtil.errorLogInfo("", TAG, e);
  802. }
  803. try {
  804. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  805. AddressSet addc = SetData.getAddressMGR();
  806. AddressSetBackup addc_Backup = SetData.getAddressMGR_Backup();
  807. overridePendingTransition(0, 0);
  808. if (!isSystemIPSet()) {
  809. Log.w(TAG, "[onCreate] The IP Address of OS is not set!");
  810. startManagerSettingSetAddress();
  811. }
  812. else if (addc.Dong.equals("NONE") || addc.Ho.equals("NONE")) {
  813. Log.w(TAG, "[onCreate] The info. of resi. is not set! [primary db]");
  814. if (addc_Backup.Dong.equals("NONE") || addc_Backup.Ho.equals("NONE")) {
  815. Log.w(TAG, "[onCreate] The info. of resi. is not set! [secondary db]");
  816. startManagerSettingSetAddress();
  817. }
  818. else {
  819. addc.setAddress(addc_Backup.Dong, addc_Backup.Ho);
  820. addc.setIPAddress(addc_Backup.IPAddress);
  821. m_IPActivity = true;
  822. if (addc.IPAddress!=null && !addc.IPAddress.equals("NONE")) {
  823. Log.w(TAG, "[onCreate] ========== start iMapServer service ========== [secondary db]");
  824. Intent intent = new Intent(getApplicationContext(), iMapServer.class);
  825. startService(intent);
  826. Intent intentMobile = new Intent(getApplicationContext(), MobileProcService.class);
  827. Log.w(TAG, "[onCreate] ========== start MobileProcServicee ========== [secondary db]");
  828. startService(intentMobile);
  829. }
  830. MAINStatus = MAIN_NORMAL;
  831. }
  832. }
  833. else {
  834. m_IPActivity = true;
  835. if (!addc.IPAddress.equals("NONE")) {
  836. Log.w(TAG, "[onCreate] ========== start iMapServer service ========== [primary db]");
  837. Intent intent = new Intent(this, iMapServer.class);
  838. startService(intent);
  839. Intent intentMobile = new Intent(getApplicationContext(), MobileProcService.class);
  840. Log.w(TAG, "[onCreate] ========== start MobileProcServicee ========== [secondary db]");
  841. startService(intentMobile);
  842. }
  843. MAINStatus = MAIN_NORMAL;
  844. }
  845. SetData.closeDB();
  846. } catch (RuntimeException re) {
  847. LogUtil.errorLogInfo("", TAG, re);
  848. }
  849. catch (Exception e) {
  850. Log.e(TAG, "[Exception] check device addresses(ip, resi. info.)");
  851. LogUtil.errorLogInfo("", TAG, e);
  852. }
  853. //주차정보 사용여부 체크
  854. getParkedVehicleLocationSysInfo();
  855. //전기차 정보 가져오기
  856. GetElectricCarInfo();
  857. //에너지관리서버 사용여부 가져오기
  858. GetEnergyServerInfo();
  859. //에너지 알람 사용여부 가져오기
  860. GetEnergyAlarm();
  861. //통화타임아웃 초기화
  862. setCallAppTimeoutAsDefault();
  863. //카카오홈 사용 여부 체크(카카오홈)
  864. boolean isUseKakao = getKakaoHomeCheck();
  865. if(isUseKakao)
  866. {
  867. Handler mHandler = new Handler();
  868. mHandler.postDelayed(mLaunchTaskKakao, 500);
  869. mHandler = null;
  870. }
  871. try {
  872. mWallPadApiCheckHandler.sendEmptyMessage(0);
  873. // Checker.sendEmptyMessageDelayed(0, 1000);
  874. } catch (RuntimeException re) {
  875. LogUtil.errorLogInfo("", TAG, re);
  876. }
  877. catch (Exception e) {
  878. LogUtil.errorLogInfo("", TAG, e);
  879. }
  880. // sip 서비스 실행 옮김
  881. Log.d(TAG, "[onCreate] startCallService start");
  882. try {
  883. runCallServices startCallService = new runCallServices();
  884. startCallService.start();
  885. } catch (RuntimeException re) {
  886. LogUtil.errorLogInfo("", TAG, re);
  887. }
  888. catch (Exception e) {
  889. LogUtil.errorLogInfo("", TAG, e);
  890. }
  891. Log.d(TAG, "[onCreate] startCallService end");
  892. try {
  893. // 부팅하고 나서 업그레이드 상태를 false 로 해주지 않으면 통화 수신이 안됨
  894. // 꼭 들어가야 함
  895. // 전체 정전시험시 단지서버도 재부팅은 하나 로긴을 하지 않으면 그시간동안 세대기가 보낸 부트업 메세지를 못 받기 때문에....단말기 시간을 재 셋팅해주도록 한다.
  896. Calendar cal = new GregorianCalendar();
  897. 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));
  898. WallpadStatusData wpd = new WallpadStatusData(getApplicationContext());
  899. wpd.SetUpgradeState(false);
  900. wpd.SetLastHeartbeat(timedata);
  901. wpd.closeDB();
  902. } catch (RuntimeException re) {
  903. LogUtil.errorLogInfo("", TAG, re);
  904. }
  905. catch (Exception e) {
  906. LogUtil.errorLogInfo("", TAG, e);
  907. }
  908. try {
  909. Calendar m_CurCalendar = Calendar.getInstance();
  910. //CurYear , CurMonth, CurDate, CurHour, CurMin, CurSecond;
  911. int CurYear = m_CurCalendar.get(Calendar.YEAR);
  912. if (CurYear < 2018) {
  913. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  914. DBMGR.setSystemTime(2018, 8, 1, 13, 0, 0);
  915. DBMGR.closeDB();
  916. }
  917. } catch (RuntimeException re) {
  918. LogUtil.errorLogInfo("", TAG, re);
  919. }
  920. catch (Exception e) {
  921. LogUtil.errorLogInfo("", TAG, e);
  922. }
  923. mLightInfo = new LightInfo();
  924. getLivinglightPreset();
  925. initLivinglightPreset();
  926. getLivinglightPreset();
  927. initEscapeLadderDownSend();
  928. setPageIndicator();
  929. mGetCallHistoryCheckHandler.sendEmptyMessageDelayed(0, 10000);
  930. try {
  931. int getSleepTime = Settings.System.getInt(this.getContext().getContentResolver(), SCREEN_OFF_TIMEOUT);
  932. int mSleepModeTime = (getSleepTime / 1000);
  933. Log.d(TAG, "[Create] mSleepModeTime [" + mSleepModeTime + "]");
  934. if (mSleepModeTime <= 30) {
  935. Log.d(TAG, "[Create] Reset mSleepModeTime ===== [" + mSleepModeTime + "] =====");
  936. Settings.System.putInt(this.getContext().getContentResolver(), SCREEN_OFF_TIMEOUT, 28 * 1000); // 백라이트 off와 앱 종료가 동시에 일어나면 월패드가 비정상 종료되므로 수정 (2021.04.06 메이드인랩 김수진 선임 요청)
  937. }
  938. } catch (Settings.SettingNotFoundException e) {
  939. e.printStackTrace();
  940. }
  941. try {
  942. handlerEverySecond.sendEmptyMessageDelayed(0, 1000);
  943. // BSP 수정으로 인하여 해당 코드 삭제 (2021.02.24, SEULKI)
  944. // // 월패드 카메라 녹색 노이즈 시험 코드 (월패드 부팅시 월패드 카메라 영상을 잠시 띄운후 없앤다. JEFF/2020.01.21.01)
  945. // /**
  946. // * 부팅시 카메라 서비스 정상동작 여부를 확인한다. (Edited by jeff, 2020.09.08)
  947. // */
  948. // sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_CHECK, 0, 0, 0); // 5초후 월패드 카메라를 초기화 한다. (그냥 화면밖에 영상을 잠시 띄우고 5초뒤에 없앤다.)
  949. } catch (RuntimeException re) {
  950. LogUtil.errorLogInfo("", TAG, re);
  951. }
  952. catch (Exception e) {
  953. LogUtil.errorLogInfo("", TAG, e);
  954. }
  955. if (bKakaoiEnable) {
  956. Log.i(TAG, "[onCreate] ========== Kakao function enabled ==========");
  957. startKakaoiFloatingBTN();
  958. }
  959. // forceCtrlStrangerRecordingUserSettingDisable(false);
  960. getLCDKeeperUsage();
  961. Log.i(TAG, "[onCreate] ==================== onCreate end ====================");
  962. }
  963. /**
  964. * 카카오 실행 관련 핸들러
  965. */
  966. private Runnable mLaunchTaskKakao = new Runnable() {
  967. public void run() {
  968. String Packagename = "com.kakao.i.test.real.wallpad";
  969. //Handler를 이용하여 Timer 사용
  970. Intent mainIntent = mContext.getPackageManager().getLaunchIntentForPackage(Packagename);
  971. if (mainIntent != null) {
  972. boolean isShowKakao = getShowKakaoCheck();
  973. if(isShowKakao)
  974. mainIntent.putExtra("ShowKakao", true);
  975. mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  976. startActivity(mainIntent);
  977. };
  978. }
  979. };
  980. private int nLCDKeeperType = WallpadDeviceSet.LCDKEEPER_NONE;
  981. private String getLCDKeeperType(int nLCDKeeperType) {
  982. try {
  983. Log.i(TAG, "[getLCDKeeperUsage] nLCDKeeperType [" + nLCDKeeperType + "]");
  984. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_NONE) return "LCDKEEPER_NONE";
  985. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT) return "LCDKEEPER_PROTECT";
  986. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER) return "LCDKEEPER_RECOVER";
  987. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) return "LCDKEEPER_PROTECT_RECOVER";
  988. else return "UNKNOWN";
  989. } catch (RuntimeException re) {
  990. LogUtil.errorLogInfo("", TAG, re);
  991. return "ERROR";
  992. }
  993. catch (Exception e) {
  994. Log.e(TAG, "[Exception] getLCDKeeperType(int nLCDKeeperType)");
  995. LogUtil.errorLogInfo("", TAG, e);
  996. return "ERROR";
  997. }
  998. }
  999. private boolean bLCDKeeperUsage = false;
  1000. private void getLCDKeeperUsage() {
  1001. try {
  1002. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  1003. nLCDKeeperType = mWallpadDeviceSet.getLCDKeeperUsage();
  1004. mWallpadDeviceSet.closeDB();
  1005. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT || nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER || nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) {
  1006. bLCDKeeperUsage = true;
  1007. }
  1008. Log.i(TAG, "[getLCDKeeperUsage] bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  1009. } catch (RuntimeException re) {
  1010. LogUtil.errorLogInfo("", TAG, re);
  1011. }
  1012. catch (Exception e) {
  1013. Log.e(TAG, "[Exception] getLCDKeeperUsage()");
  1014. LogUtil.errorLogInfo("", TAG, e);
  1015. }
  1016. }
  1017. public boolean isSystemIPSet() {
  1018. try {
  1019. Log.i(TAG, "[isSystemIPSet] START!");
  1020. String strResult = "";
  1021. if (Build.VERSION.SDK_INT > 23) {
  1022. // Android 7
  1023. strResult = getIPAddress();
  1024. }
  1025. else {
  1026. // Android 6
  1027. if(NetworkInterface.getByName("eth0")!=null)
  1028. {
  1029. String strNetInfo = NetworkInterface.getByName("eth0").toString();
  1030. Log.i(TAG, "[isSystemIPSet] strNetInfo : " + strNetInfo + "]");
  1031. strNetInfo.trim();
  1032. String[] Parse_01 = strNetInfo.split("\\]");
  1033. // for (int i = 0; i < Parse_01.length; i++) {
  1034. // LOG_DEBUG("[getDeviceIPAddress] Parse_01[" + i + "] : " + Parse_01[i]);
  1035. // }
  1036. String[] Parse_02 = Parse_01[Parse_01.length - 1].split("\\/");
  1037. // for (int i = 0; i < Parse_02.length; i++) {
  1038. // LOG_DEBUG("[getDeviceIPAddress] Parse_02[" + i + "] : " + Parse_02[i]);
  1039. // }
  1040. strResult = Parse_02[1];
  1041. }
  1042. }
  1043. Log.i(TAG, "[isSystemIPSet] DONE! [IP Address : " + strResult + "]");
  1044. 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])$");
  1045. return mPattern.matcher(strResult).matches();
  1046. } catch (RuntimeException re) {
  1047. LogUtil.errorLogInfo("", TAG, re);
  1048. return false;
  1049. }
  1050. catch (Exception e) {
  1051. Log.e(TAG, "[Exception] isSystemIPSet()");
  1052. LogUtil.errorLogInfo("", TAG, e);
  1053. return false;
  1054. }
  1055. }
  1056. public static String getIPAddress() {
  1057. try {
  1058. List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
  1059. for (NetworkInterface intf : interfaces) {
  1060. List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
  1061. for (InetAddress addr : addrs) {
  1062. if (!addr.isLoopbackAddress()) {
  1063. String sAddr = addr.getHostAddress();
  1064. //boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
  1065. boolean isIPv4 = sAddr.indexOf(':')<0;
  1066. if (isIPv4)
  1067. return sAddr;
  1068. }
  1069. }
  1070. }
  1071. } catch (RuntimeException re) {
  1072. LogUtil.errorLogInfo("", TAG, re);
  1073. }
  1074. catch (Exception e) {
  1075. Log.e(TAG, "[Exception] isSystemIPSet()");
  1076. LogUtil.errorLogInfo("", TAG, e);
  1077. }
  1078. return "";
  1079. }
  1080. public void initIOInterface(WallPadAPI wallpadapi) {
  1081. try {
  1082. mIOInterface = new IOInterface(getContext(), wallpadapi);
  1083. } catch (RuntimeException re) {
  1084. LogUtil.errorLogInfo("", TAG, re);
  1085. }
  1086. catch (Exception e) {
  1087. Log.e(TAG, "[Exception] initIOInterface(WallPadAPI wallpadapi)");
  1088. LogUtil.errorLogInfo("", TAG, e);
  1089. }
  1090. }
  1091. public void checkDongHoSetting() {
  1092. try {
  1093. Log.d(TAG, "[checkDongHoSetting] ========== START ==========");
  1094. boolean IP_ExpansionSettingFlag = false;
  1095. EthernetDevInfo info = new EthernetDevInfo();
  1096. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  1097. AddressSet addc = mWallpadStatusData.getAddressMGR();
  1098. mWallpadStatusData.SetCallAPKStatus(false);
  1099. mWallpadStatusData.closeDB();
  1100. if (addc.Dong!=null && !addc.Dong.equals("NONE") && addc.Ho!=null&& !addc.Ho.equals("NONE") && addc.IPAddress!=null&& !addc.IPAddress.equals("NONE")) {
  1101. if (Version.getModelType() == MODEL_TYPE.IHN_1020GL && Version.getModelType() == MODEL_TYPE.IHN_1020B_A
  1102. && Version.getModelType() == MODEL_TYPE.IHN_1020SA_A && Version.getModelType() == MODEL_TYPE.IHN_750) {
  1103. // LH 게이트웨이 때문에 위치 옮김 제어 서비스 보다 먼저 처리
  1104. if(addc.IPAddress!=null)
  1105. {
  1106. String[] iptbl = addc.IPAddress.split("[.]");
  1107. Log.d(TAG, "[checkDongHoSetting] Mac Set -> IP : " + addc.IPAddress +", Length : " + iptbl.length);
  1108. // BSP에서 초기 이더넷 비활성화시 jni 맥 셋팅시 메인어플 다이~~
  1109. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1110. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1111. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_DISABLED!!!");
  1112. if (IP_ExpansionSettingFlag == true) {
  1113. mEthManager.UpdateEthDevInfo(info);
  1114. }
  1115. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1116. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_ENABLING!!!");
  1117. if (iptbl.length == 4) {
  1118. 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]));
  1119. Log.d(TAG, "[checkDongHoSetting] Mac Set "+macadd);
  1120. try {
  1121. WallPadInterface wpdifc = new WallPadInterface();
  1122. wpdifc.setMacAddr(macadd);
  1123. } catch (RuntimeException re) {
  1124. LogUtil.errorLogInfo("", TAG, re);
  1125. }
  1126. catch (Exception ex) {
  1127. //ex.printStackTrace();
  1128. LogUtil.errorLogInfo("", TAG, ex);
  1129. }
  1130. Log.d(TAG, "[checkDongHoSetting] -----------------------------------MacSet");
  1131. }
  1132. else {
  1133. Log.d(TAG,"[checkDongHoSetting] -----------------------------------Mac iptbl.length fail !!");
  1134. }
  1135. //EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1136. //mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1137. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1138. Log.d(TAG, "[checkDongHoSetting] ETH_STATE_ENABLING!!!");
  1139. }
  1140. }
  1141. }
  1142. } catch (RuntimeException re) {
  1143. LogUtil.errorLogInfo("", TAG, re);
  1144. }
  1145. catch (Exception e) {
  1146. Log.e(TAG, "[Exception] checkDongHoSetting()");
  1147. LogUtil.errorLogInfo("", TAG, e);
  1148. }
  1149. }
  1150. public void registerSubScreen() {
  1151. try {
  1152. if (Common.eGUIType == Common.GUI_TYPE.METRO) {
  1153. if (MetroUI_SUB_GroupScreen == null && SubScreenLayout_01 != null ) MetroUI_SUB_GroupScreen = new METROUI_SUB_GROUP(getContext() , SubScreenLayout_01, mWallPadAPI);
  1154. }
  1155. else if (Common.eGUIType == Common.GUI_TYPE.HYOSUNG) {
  1156. if (MetroUI_SUB_GroupScreen == null && SubScreenLayout_01 != null ) MetroUI_SUB_GroupScreen = new METROUI_SUB_GROUP(getContext() , SubScreenLayout_01, mWallPadAPI);
  1157. }
  1158. else {
  1159. if (mIconInfoTable.getCnt() > 0) {
  1160. if (SUB_01Screen == null && SubScreenLayout_01 != null ) SUB_01Screen = new SUB_01(getContext() , SubScreenLayout_01, mWallPadAPI);
  1161. }
  1162. if (mIconInfoTable.getCnt() > nIconsOnSubScreen) {
  1163. if (SUB_02Screen == null && SubScreenLayout_02 != null ) SUB_02Screen = new SUB_02(getContext() , SubScreenLayout_02, mWallPadAPI);
  1164. }
  1165. if (bEasyModeUsage) {
  1166. if (EasyUI_MainScreen == null && EasyMainScreenLayout != null ) EasyUI_MainScreen = new EASYUI_MAIN(getContext() , EasyMainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  1167. }
  1168. }
  1169. // restoreSystemVolume();
  1170. SCManager = new ScheduleManager();
  1171. } catch (RuntimeException re) {
  1172. LogUtil.errorLogInfo("", TAG, re);
  1173. }
  1174. catch (Exception e) {
  1175. Log.w(TAG, "[registerSubScreen] registerSubScreen()");
  1176. LogUtil.errorLogInfo("", TAG, e);
  1177. }
  1178. }
  1179. public void moveNextPage() {
  1180. try {
  1181. Log.d(TAG, "[moveNextPage] ===== START =====");
  1182. aniSlideIn = AnimationUtils.loadAnimation(getContext(), R.layout.appear_from_right);
  1183. aniSlideOut = AnimationUtils.loadAnimation(getContext(), R.layout.disappear_to_left);
  1184. mViewFlipper.setInAnimation(aniSlideIn);
  1185. mViewFlipper.setOutAnimation(aniSlideOut);
  1186. mViewFlipper.showNext();
  1187. } catch (RuntimeException re) {
  1188. LogUtil.errorLogInfo("", TAG, re);
  1189. }
  1190. catch (Exception e) {
  1191. Log.e(TAG, "[Exception] moveNextPage()");
  1192. LogUtil.errorLogInfo("", TAG, e);
  1193. }
  1194. }
  1195. public void movePreviousPage() {
  1196. try {
  1197. Log.d(TAG, "[movePreviousPage] ===== START =====");
  1198. aniSlideIn = AnimationUtils.loadAnimation(getContext(), R.layout.appear_from_left);
  1199. aniSlideOut = AnimationUtils.loadAnimation(getContext(), R.layout.disappear_to_right);
  1200. mViewFlipper.setInAnimation(aniSlideIn);
  1201. mViewFlipper.setOutAnimation(aniSlideOut);
  1202. mViewFlipper.showPrevious();
  1203. } catch (RuntimeException re) {
  1204. LogUtil.errorLogInfo("", TAG, re);
  1205. }
  1206. catch (Exception e) {
  1207. Log.e(TAG, "[Exception] moveNextPage()");
  1208. LogUtil.errorLogInfo("", TAG, e);
  1209. }
  1210. }
  1211. boolean bScreenCheck = false;
  1212. int nSubScreenTimeout = 20, SCREENTIMEOUT = 20;
  1213. public void checkMainPage() {
  1214. try {
  1215. if (!bScreenCheck) {
  1216. nSubScreenTimeout = SCREENTIMEOUT;
  1217. return;
  1218. }
  1219. int nViewFlipperIndex = mViewFlipper.getDisplayedChild();
  1220. if (nViewFlipperIndex != 0) {
  1221. if (nSubScreenTimeout > 0) {
  1222. nSubScreenTimeout--;
  1223. }
  1224. else {
  1225. nSubScreenTimeout = SCREENTIMEOUT;
  1226. mViewFlipper.setDisplayedChild(0);
  1227. }
  1228. Log.i(TAG, "[checkMainPage] nViewFlipperIndex [" + nViewFlipperIndex + "], nSubScreenTimeout [" + nSubScreenTimeout + "]");
  1229. }
  1230. else {
  1231. if (nSubScreenTimeout <= 0) {
  1232. nSubScreenTimeout = SCREENTIMEOUT;
  1233. Log.i(TAG, "[checkMainPage] nViewFlipperIndex [" + nViewFlipperIndex + "], nSubScreenTimeout [" + nSubScreenTimeout + "]");
  1234. }
  1235. }
  1236. } catch (RuntimeException re) {
  1237. LogUtil.errorLogInfo("", TAG, re);
  1238. }
  1239. catch (Exception e) {
  1240. Log.e(TAG, "[Exception] checkMainPage()");
  1241. LogUtil.errorLogInfo("", TAG, e);
  1242. }
  1243. }
  1244. String strWallPadMainPakageName = "kr.co.icontrols.wallpadmain";
  1245. private boolean isPackageTop(String strPackageName) {
  1246. try {
  1247. ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  1248. Log.i(TAG, "[isPackageTop] Build.VERSION.SDK_INT [" + Build.VERSION.SDK_INT + "]");
  1249. if (Build.VERSION.SDK_INT > 23) {
  1250. // Android 7
  1251. List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses();
  1252. for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) {
  1253. if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
  1254. for (String activeProcess : processInfo.pkgList) {
  1255. if (activeProcess.equals(strPackageName)) {
  1256. Log.i(TAG, "[isPackageTop] The top package is [" + strPackageName + "]");
  1257. return true;
  1258. }
  1259. }
  1260. }
  1261. }
  1262. }
  1263. else {
  1264. // Android 6
  1265. List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  1266. ComponentName componentInfo = taskInfo.get(0).topActivity;
  1267. if (componentInfo.getPackageName().equals(strPackageName)) {
  1268. Log.i(TAG, "[isPackageTop] The top package is [" + strPackageName + "]");
  1269. return true;
  1270. }
  1271. }
  1272. } catch (RuntimeException re) {
  1273. LogUtil.errorLogInfo("", TAG, re);
  1274. }
  1275. catch (Exception e) {
  1276. Log.e(TAG, "[Exception] isPackageTop(String strPackageName)");
  1277. LogUtil.errorLogInfo("", TAG, e);
  1278. }
  1279. return false;
  1280. }
  1281. // 부팅시에는 최초 DB에서 값을 읽어와서 변경하도록 한다.
  1282. private boolean m_SetBookMarkMainScreen = false;
  1283. private int m_CheckBookMarkReturnCount = 0 ;
  1284. private final int BOOKMARK_SCREEN_RETURN_CHECK_TIME = 30;
  1285. private boolean m_thisAcitivityRusume = false;
  1286. // 즐겨찾기 메인화면을 항상 고정해서 쓸것인지 설정하는 함수
  1287. public void SetBookMarkMainScreen(boolean Set)
  1288. {
  1289. m_SetBookMarkMainScreen = Set;
  1290. try
  1291. {
  1292. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  1293. if( wdb != null )
  1294. {
  1295. if( Set == true )
  1296. {
  1297. wdb.SetSelectedMainScreen( WallpadStatusData.MAIN_BOOKMARK_SCREEN);
  1298. }
  1299. else
  1300. {
  1301. wdb.SetSelectedMainScreen( WallpadStatusData.MAIN_DEFAULT_SCREEN);
  1302. }
  1303. wdb.closeDB();
  1304. }
  1305. }
  1306. catch (RuntimeException re) {
  1307. LogUtil.errorLogInfo("", TAG, re);
  1308. }
  1309. catch (Exception e )
  1310. {
  1311. LogUtil.errorLogInfo("", TAG, e);
  1312. }
  1313. }
  1314. public boolean CheckCurrentEnergyScreen()
  1315. {
  1316. int currentView = mViewFlipper.getDisplayedChild();
  1317. Log.d(TAG, "-------> currentView : " + currentView);
  1318. if( currentView == 1)
  1319. return true;
  1320. else
  1321. return false;
  1322. }
  1323. private int nTouchDownPosX = 0;
  1324. private int nTouchUpPosX = 0;
  1325. @Override
  1326. public boolean dispatchTouchEvent(MotionEvent ev) {
  1327. boolean bReturn = false;
  1328. //Log.d("Move" , "dispatchTouchEvent-----------1");
  1329. try {
  1330. if (ev.getAction() == MotionEvent.ACTION_DOWN) {
  1331. nTouchDownPosX = (int)ev.getX();
  1332. }
  1333. else if (ev.getAction() == MotionEvent.ACTION_UP) {
  1334. nTouchUpPosX = (int)ev.getX();
  1335. Log.d(TAG, "[dispatchTouchEvent] nTouchDownPosX [" + nTouchDownPosX + "], nTouchUpPosX [" + nTouchUpPosX + "]");
  1336. if (nTouchUpPosX < nTouchDownPosX - 50) {
  1337. moveNextPage();
  1338. setPageIndicator();
  1339. }
  1340. else if (nTouchUpPosX > nTouchDownPosX + 50) {
  1341. movePreviousPage();
  1342. setPageIndicator();
  1343. }
  1344. nTouchDownPosX = nTouchUpPosX;
  1345. }
  1346. } catch (RuntimeException re) {
  1347. LogUtil.errorLogInfo("", TAG, re);
  1348. }
  1349. catch (Exception e) {
  1350. Log.e(TAG, "[Exception] dispatchTouchEvent(MotionEvent ev)");
  1351. LogUtil.errorLogInfo("", TAG, e);
  1352. }
  1353. bReturn = super.dispatchTouchEvent(ev);
  1354. return bReturn;
  1355. }
  1356. private void setPageIndicator() {
  1357. try {
  1358. int nViewFlipperIndex = mViewFlipper.getDisplayedChild();
  1359. int nChildCnt = mViewFlipper.getChildCount();
  1360. Log.d(TAG, "[setPageIndicator] nViewFlipperIndex [" + nViewFlipperIndex + "], nChildCnt [" + nChildCnt + "]");
  1361. if (Common.eGUIType == Common.GUI_TYPE.STANDARD) {
  1362. Log.d(TAG, "[setPageIndicator] eGUIType == GUI_TYPE.STANDARD");
  1363. ImageView[] IMG_INDICATOR;
  1364. 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) };
  1365. else IMG_INDICATOR = new ImageView[] { (ImageView) findViewById(R.id.pageindex_main), (ImageView) findViewById(R.id.pageindex_sub1), (ImageView) findViewById(R.id.pageindex_sub2) };
  1366. for (int i = 0; i < nChildCnt; i++) {
  1367. if (i == nViewFlipperIndex) {
  1368. if (i == 0) IMG_INDICATOR[i].setSelected(true);
  1369. else IMG_INDICATOR[i].setSelected(true);
  1370. }
  1371. else {
  1372. if (i == 0) IMG_INDICATOR[i].setSelected(false);
  1373. else IMG_INDICATOR[i].setSelected(false);
  1374. }
  1375. }
  1376. }
  1377. // else if (eGUIType == GUI_TYPE.METRO) {
  1378. // ImageView[] IMG_INDICATOR = { (ImageView) findViewById(R.id.pageindex_sub1), (ImageView) findViewById(R.id.pageindex_sub2) };
  1379. // if (nViewFlipperIndex == 0) {
  1380. // for (int i = 0; i < nChildCnt; i++) {
  1381. // if (i != 0) IMG_INDICATOR[i - 1].setVisibility(View.INVISIBLE);
  1382. // }
  1383. // }
  1384. // else {
  1385. // for (int i = 0; i < nChildCnt; i++) {
  1386. // if (i != 0) {
  1387. // IMG_INDICATOR[i - 1].setVisibility(View.VISIBLE);
  1388. // if (i == nViewFlipperIndex) IMG_INDICATOR[i - 1].setSelected(true);
  1389. // else IMG_INDICATOR[i - 1].setSelected(false);
  1390. // }
  1391. // }
  1392. // }
  1393. // }
  1394. } catch (RuntimeException re) {
  1395. LogUtil.errorLogInfo("", TAG, re);
  1396. }
  1397. catch (Exception e) {
  1398. Log.e(TAG, "[Exception] setPageIndicator()");
  1399. LogUtil.errorLogInfo("", TAG, e);
  1400. }
  1401. }
  1402. /**
  1403. * (임시코드) WallPadAPI 초기생성시 Connect 에 시간이 걸리며, <br>
  1404. * WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에, <br>
  1405. * 본 딜레이 코드를 임시로 적용한다.
  1406. */
  1407. @SuppressLint("HandlerLeak")
  1408. protected Handler mWallPadApiCheckHandler = new Handler()
  1409. {
  1410. @SuppressLint("HandlerLeak")
  1411. @Override
  1412. public void handleMessage(Message msg)
  1413. {
  1414. if (msg.what == 0) {
  1415. if (mWallPadAPI != null) {
  1416. if (mWallPadAPI.Check_Connect()) mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10);
  1417. else mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  1418. }
  1419. }
  1420. else if (msg.what == 1) {
  1421. // 현산향
  1422. AutoIGALStatusReleaseSinario();
  1423. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  1424. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  1425. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  1426. mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
  1427. mSdbAPI = mWallPadAPI.Get_SdbController();
  1428. if (mSdb_LivingRoomLightAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_Sdb_LivingRoomLightAPI Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1429. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_Sdb_LivingRoomLightAPI Success !");
  1430. if (mSdbAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_SdbController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1431. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_SdbController Success !");
  1432. // ChangeLEDButtonLevel();
  1433. }
  1434. else if (Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  1435. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410) {
  1436. mIntLightAPI = mWallPadAPI.Get_IntLightController();
  1437. if (mIntLightAPI == null) Log.d(TAG , "[mWallPadApiCheckHandler] Get_IntLightController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1438. else Log.d(TAG , "[mWallPadApiCheckHandler] Get_IntLightController Success !");
  1439. // ChangeLEDButtonLevel();
  1440. }
  1441. else {
  1442. // 대외향
  1443. WallpadDeviceSet devDB = new WallpadDeviceSet( getApplicationContext() );
  1444. int[] retArray = devDB.Get_Light_info();
  1445. devDB.closeDB();
  1446. if (retArray!= null && retArray[0] == 1) {
  1447. if (retArray[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  1448. // 거실 스위치
  1449. m_LightCtrl = mWallPadAPI.Get_LightController();
  1450. if (m_LightCtrl == null) Log.d(TAG , "Get_LightController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1451. else Log.d(TAG , "Get_LightController Success !");
  1452. }
  1453. else {
  1454. // 멀티스위치
  1455. m_MultiSwitch = mWallPadAPI.Get_MultiSwitchController();
  1456. if (m_MultiSwitch == null) Log.d(TAG , "Get_MultiSwitchController Fail %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  1457. else Log.d(TAG , "Get_MultiSwitchController Success !");
  1458. }
  1459. }
  1460. }
  1461. }
  1462. else if (msg.what == 10) {
  1463. // 부트업 실패시 5초 간격으로 보내도록 수정
  1464. Log.d(TAG , "NOTIFY_SENDBOOTUP_FAIL Retry!!!!");
  1465. Intent Newintent = new Intent();
  1466. Newintent.setAction(define.NOTIFY_ACNAME);
  1467. Newintent.putExtra(define.NOTIBR_KIND,Common.DEVICE_BOOTUP_RETRY);
  1468. sendBroadcast(Newintent);
  1469. }
  1470. }
  1471. };
  1472. private void ChangeLEDButtonLevel()
  1473. {
  1474. if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL )
  1475. {
  1476. try
  1477. {
  1478. String filename = "/sdcard/led_button_reset.txt";
  1479. File savefile = new File(filename);
  1480. Log.d(TAG, "8888888888888888888888 savefile : " + savefile.exists());
  1481. if(savefile.exists())
  1482. {
  1483. Log.d(TAG, "try file is exist... ");
  1484. if( mIntLightAPI != null)
  1485. {
  1486. int ret = mIntLightAPI.LedBrightCtrl((byte)0x01);
  1487. if( ret >= 0 )
  1488. {
  1489. WallpadStatusData wd = new WallpadStatusData( getApplicationContext());
  1490. wd.SetLEDButtonBrightnessLevel(1); // DB 저장이 실패하게 되면 초기값을 2로 셋팅하기 때문에 다시 한번 셋팅해준다.
  1491. int level = wd.GetLEDButtonBrightnessLevel();
  1492. wd.closeDB();
  1493. Log.d(TAG, "88888888 button brightness Level 1 == " + level);
  1494. WallpadStatusData wd1 = new WallpadStatusData( getApplicationContext());
  1495. wd1.SetLEDButtonBrightnessLevel(1);
  1496. level = wd1.GetLEDButtonBrightnessLevel();
  1497. wd1.closeDB();
  1498. FileDelete(savefile);//.delete();
  1499. // 생산 기술팀 요청사항
  1500. // LED 버튼 보디 교체로 레벨이 너무 밝아 디폴트값 변경을 요청함 ,,
  1501. Log.d(TAG, "8888888888888888888888 button brightness Level 1 == " + level);
  1502. }
  1503. }
  1504. }
  1505. }
  1506. catch (RuntimeException re) {
  1507. LogUtil.errorLogInfo("", TAG, re);
  1508. }
  1509. catch (Exception e )
  1510. {
  1511. LogUtil.errorLogInfo("", TAG, e);
  1512. }
  1513. }
  1514. }
  1515. private void AutoIGALStatusReleaseSinario()
  1516. {
  1517. // 에너지미터 설정에 따라 조명 상태 변경시 일괄소등 해제 처리 시나리오를 설정하도록 한다.
  1518. // 일괄소등 해제 시나리오 적용시...
  1519. try
  1520. {
  1521. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  1522. int setIparkEnergy = devset.Get_Energy_Devices_Info();
  1523. Log.d(TAG , "Get_IPark_Energy_Info bSet: setIparkEnergy : " + setIparkEnergy);
  1524. if( setIparkEnergy == 1 )
  1525. {
  1526. mWallPadAPI.SetAutoIGALStatusClear(true);
  1527. Log.d(TAG , "AutoIGALStatusReleaseSinario bSet: true");
  1528. }
  1529. devset.closeDB();
  1530. }
  1531. catch (RuntimeException re) {
  1532. LogUtil.errorLogInfo("", TAG, re);
  1533. }
  1534. catch (Exception e )
  1535. {
  1536. Log.e(TAG, e.toString());
  1537. LogUtil.errorLogInfo("", TAG, e);
  1538. }
  1539. }
  1540. /**
  1541. * onDestroy
  1542. */
  1543. @Override
  1544. protected void onDestroy() {
  1545. // 이걸 왜 넣었지?
  1546. setChangeScreen(mCurrentScreenId, true, false);
  1547. unregisterBroadcastReceiver();
  1548. super.setFinishTimerDestroy();
  1549. Log.i(TAG, "*************************************************************");
  1550. Log.i(TAG, "****************** [END - MainActivity] *******************");
  1551. Log.i(TAG, "*************************************************************");
  1552. super.onDestroy();
  1553. }
  1554. boolean cv_bStrangerVideoRecordUsage;
  1555. boolean cv_bStrangerUserVideoRecordUsage;
  1556. /**
  1557. * onResume
  1558. */
  1559. @Override
  1560. protected void onResume() {
  1561. super.onResume();
  1562. m_thisAcitivityRusume = true;
  1563. if (mWallPadAPI != null) {
  1564. if (mWallPadAPI.Check_Connect()) Log.w(TAG, "[onResume] mWallPadAPI.Check_Connect() = true!!!");
  1565. else Log.w(TAG, "[onResume] mWallPadAPI.Check_Connect() = false!!!");
  1566. mWallPadAPI.Resume();
  1567. }
  1568. //CallDataChecker();
  1569. try {
  1570. if (m_ModelHouseSleepModeRelease) {
  1571. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  1572. // pm.userActivity(1, true);
  1573. // pm.userActivity(2, true);1qn
  1574. // LCD 항상 ON
  1575. ((Activity)this.getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  1576. }
  1577. } catch (RuntimeException re) {
  1578. LogUtil.errorLogInfo("", TAG, re);
  1579. }
  1580. catch (Exception e) {
  1581. LogUtil.errorLogInfo("", TAG, e);
  1582. }
  1583. if (MAINStatus == MAIN_WAIT_SETIP) {
  1584. try {
  1585. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  1586. AddressSet addc = SetData.getAddressMGR();
  1587. SetData.closeDB();
  1588. Log.i("MAINSCREEN", "onResume MAIN_WAIT_SETIP "+addc.IPAddress);
  1589. if (addc.IPAddress!=null && !addc.IPAddress.equals("NONE")) {
  1590. Log.i("MAINSCREEN", "onResume Start Server");
  1591. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  1592. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  1593. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  1594. Intent intent = new Intent(getApplicationContext(), iMapServer.class);
  1595. Log.w("MAINSCREEN", "Call Start iMapServer");
  1596. startService(intent);
  1597. WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
  1598. String[] sitecode = devSet.GetSettingData("site_code");
  1599. try {
  1600. if (sitecode != null) {
  1601. Intent sipServiceLauncher = new Intent ("cm.sip.hns.SIPStun.StartService");
  1602. getApplicationContext().startService(sipServiceLauncher);
  1603. }
  1604. } catch (RuntimeException re) {
  1605. LogUtil.errorLogInfo("", TAG, re);
  1606. }
  1607. catch (Exception e) {
  1608. Common.DebugLog("SIP StartServerice Error!!!!!!!!!!!!!!");
  1609. }
  1610. devSet.closeDB();
  1611. MAINStatus = MAIN_NORMAL;
  1612. }
  1613. } catch (RuntimeException re) {
  1614. LogUtil.errorLogInfo("", TAG, re);
  1615. }
  1616. catch (Exception e ) {
  1617. LogUtil.errorLogInfo("", TAG, e);
  1618. }
  1619. }
  1620. //CheckMainScreen();
  1621. //refreshUserCtr();
  1622. //reloadData();
  1623. try {
  1624. WallPadInterface wpdifc = new WallPadInterface();
  1625. AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
  1626. amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
  1627. wpdifc.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
  1628. Intent intent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
  1629. getContext().sendBroadcast(intent);
  1630. mGetCallHistoryCheckHandler.sendEmptyMessageDelayed(0, 1000);
  1631. } catch (RuntimeException re) {
  1632. LogUtil.errorLogInfo("", TAG, re);
  1633. }
  1634. catch (Exception e) {
  1635. LogUtil.errorLogInfo("", TAG, e);
  1636. }
  1637. bScreenCheck = true;
  1638. //jglee - 거동 수상자 관련 flag 정보를 resume에서 받아오는것으로 수정
  1639. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  1640. cv_bStrangerVideoRecordUsage = mWallpadDeviceSet.Get_Stranger_RecordUse(); // 거동수상자 녹화설정 (관리자 설정)
  1641. mWallpadDeviceSet.closeDB();
  1642. WallpadStatusData DBMGR = new WallpadStatusData(this);
  1643. try {
  1644. cv_bStrangerUserVideoRecordUsage = DBMGR.GetStrangerRecordingOnOff();
  1645. DBMGR.closeDB();
  1646. Log.d(TAG, "[getStrangerRecordingUserSetting] bResult [" + cv_bStrangerUserVideoRecordUsage + "]");
  1647. } catch (RuntimeException re) {
  1648. LogUtil.errorLogInfo("", TAG, re);
  1649. DBMGR.closeDB();
  1650. cv_bStrangerUserVideoRecordUsage = false;
  1651. } catch (Exception e) {
  1652. DBMGR.closeDB();
  1653. Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
  1654. //e.printStackTrace();
  1655. LogUtil.errorLogInfo("", TAG, e);
  1656. cv_bStrangerUserVideoRecordUsage = false;
  1657. }
  1658. DebugLogOutput("@@@@@@@@ [onResume] @@@@@@@@");
  1659. }
  1660. protected String getForegroundAPK() {
  1661. try {
  1662. ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  1663. List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
  1664. ComponentName topActivity=taskInfo.get(0).topActivity;
  1665. String str=topActivity.getPackageName();
  1666. return str;
  1667. } catch (RuntimeException re) {
  1668. LogUtil.errorLogInfo("", TAG, re);
  1669. return " ";
  1670. }
  1671. catch (Exception e) {
  1672. LogUtil.errorLogInfo("", TAG, e);
  1673. return " ";
  1674. }
  1675. }
  1676. /**
  1677. * onPause
  1678. */
  1679. @Override
  1680. protected void onPause() {
  1681. m_thisAcitivityRusume = false;
  1682. if(mWallPadAPI != null) mWallPadAPI.Pause();
  1683. bScreenCheck = false;
  1684. DebugLogOutput("@@@@@@@@ [onPause] @@@@@@@@");
  1685. super.onPause();
  1686. }
  1687. /* ================================================================================================
  1688. * [BroadcastReceiver] Section
  1689. ================================================================================================ */
  1690. /**
  1691. * BroadcastReceiver.onReceive for [WpadActivity]
  1692. */
  1693. @Override
  1694. protected void onBrReceive(Intent intent) {
  1695. try {
  1696. String strAction = intent.getAction();
  1697. Log.i(TAG, "[onBrReceive] Action [" + strAction + "]");
  1698. if (strAction.equals(BR_CTRL_LIGHT_LIVINGROOM)) {
  1699. Log.d(TAG, "[onBrReceive] (BR) BR_CTRL_LIGHT_LIVINGROOM");
  1700. mLightInfo.nLightPresetNo = 0;
  1701. }
  1702. } catch (RuntimeException re) {
  1703. LogUtil.errorLogInfo("", TAG, re);
  1704. }
  1705. catch (Exception e) {
  1706. Log.e(TAG, "[Exception] onBrReceive(Intent intent)");
  1707. LogUtil.errorLogInfo("", TAG, e);
  1708. }
  1709. super.onBrReceive(intent);
  1710. }
  1711. /* ================================================================================================
  1712. * [Touch & Key Event] Section
  1713. ================================================================================================ */
  1714. /**
  1715. * TouchEvent for [WpadActivity]
  1716. */
  1717. @Override
  1718. protected void onTouchEvent(View v, MotionEvent event) {
  1719. super.onTouchEvent(v, event);
  1720. int TargetId = v.getId();
  1721. int MoveEvent = event.getAction();
  1722. Log.i(TAG, "[onTouchEvent] TargetId [" + TargetId + "], MoveEvent [" + MoveEvent + "]");
  1723. if (MoveEvent == MotionEvent.ACTION_UP) {
  1724. }
  1725. }
  1726. /**
  1727. * H/W Key Event
  1728. */
  1729. @Override
  1730. public boolean onKeyDown(int keyCode, KeyEvent event) {
  1731. Log.i(TAG, "[onKeyDown] keyCode : " + keyCode + ", Action : " + event.getAction());
  1732. // sendKeyEventBR(keyCode);
  1733. return super.onKeyDown(keyCode, event);
  1734. }
  1735. @Override
  1736. public boolean onKeyUp(int keyCode, KeyEvent event) {
  1737. // TODO Auto-generated method stub
  1738. Log.i(TAG, "[onKeyUp] keyCode : " + keyCode + ", Action : " + event.getAction());
  1739. return super.onKeyUp(keyCode, event);
  1740. }
  1741. @Override
  1742. public boolean onKeyLongPress(int keyCode, KeyEvent event) {
  1743. // TODO Auto-generated method stub
  1744. DebugLogOutput("onKeyLongPress - " + " / keyCode : " + keyCode + " / Action : " + event.getAction());
  1745. return super.onKeyLongPress(keyCode, event);
  1746. }
  1747. /* ================================================================================================
  1748. * [Popup Activity] Section
  1749. ================================================================================================ */
  1750. /**
  1751. * Popup Activity 를 시작시킨다.
  1752. *
  1753. * @param ScreenId - 팝업시작시 Screen ID_OLD
  1754. * @return (boolean) true : 성공, false : 실패
  1755. */
  1756. public boolean StartPopup(int ScreenId){
  1757. try {
  1758. if (ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED <= ScreenId && ScreenId <= ID.POPUPS.POPUP_POSTRECEIVED) { // 알림 팝업에 한하여
  1759. if (Common.bWallPadCallLive) {
  1760. Log.w(TAG, "[StartPopup] StartPopup denied!!! === WallPadCall is running!! ScreenId [" + ScreenId + "]");
  1761. return false; // 통화 앱이 실행되어 있는 경우, 팝업 출력 안함
  1762. }
  1763. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  1764. int AlarmStatus = WsDB.GetAlarmStatus();
  1765. WsDB.closeDB();
  1766. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1767. Log.w(TAG, "[StartPopup] StartPopup denied!!! === AlarmStatus [" + AlarmStatus + "]");
  1768. return false; // 방범모드 실행중인 경우, 팝업 출력 안함
  1769. }
  1770. }
  1771. if (getPopupActivityRun()) {
  1772. if (ScreenId == ID.POPUPS.POPUP_NOTICESTRANGER) return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId);
  1773. else return false;
  1774. }
  1775. else {
  1776. setPopupActivityRun(true);
  1777. Intent intent = new Intent(mContext, PopupActivity.class);
  1778. intent.putExtra("ScreenId", ScreenId);
  1779. overridePendingTransition(0, 0);
  1780. startActivityForResult(intent, 0);
  1781. return true;
  1782. }
  1783. } catch (RuntimeException re) {
  1784. LogUtil.errorLogInfo("", TAG, re);
  1785. return false;
  1786. }
  1787. catch (Exception e) {
  1788. Log.e(TAG, "[Exception] StartPopup(int ScreenId)");
  1789. LogUtil.errorLogInfo("", TAG, e);
  1790. return false;
  1791. }
  1792. }
  1793. /**
  1794. * Popup Activity 를 시작시킨다. (시작시 Intent Type 데이터를 전달한다)
  1795. *
  1796. * @param ScreenId - 팝업시작시 Screen ID_OLD
  1797. * @param data - 전달할 데이터
  1798. * @return (boolean) true : 성공, false : 실패
  1799. */
  1800. public boolean StartPopup(int ScreenId, Intent data) {
  1801. try {
  1802. if (ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED <= ScreenId && ScreenId <= ID.POPUPS.POPUP_POSTRECEIVED) { // 알림 팝업에 한하여
  1803. if (Common.bWallPadCallLive) {
  1804. Log.w(TAG, "[StartPopup] StartPopup denied!!! === WallPadCall is running!! ScreenId [" + ScreenId + "]");
  1805. return false; // 통화 앱이 실행되어 있는 경우, 팝업 출력 안함
  1806. }
  1807. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  1808. int AlarmStatus = WsDB.GetAlarmStatus();
  1809. WsDB.closeDB();
  1810. if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
  1811. Log.w(TAG, "[StartPopup] StartPopup denied!!! === AlarmStatus [" + AlarmStatus + "]");
  1812. return false; // 방범모드 실행중인 경우, 팝업 출력 안함
  1813. }
  1814. }
  1815. if (getPopupActivityRun()) {
  1816. if (ScreenId == ID.POPUPS.POPUP_NOTICESTRANGER) return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId);
  1817. else return false;
  1818. }
  1819. else {
  1820. setPopupActivityRun(true);
  1821. Intent intent = new Intent(mContext, PopupActivity.class);
  1822. intent.putExtra("ScreenId", ScreenId);
  1823. intent.putExtra("PopupScreenDataIntent", data);
  1824. overridePendingTransition(0, 0);
  1825. startActivityForResult(intent, 0);
  1826. return true;
  1827. }
  1828. } catch (RuntimeException re) {
  1829. LogUtil.errorLogInfo("", TAG, re);
  1830. return false;
  1831. }
  1832. catch (Exception e) {
  1833. Log.e(TAG, "[Exception] StartPopup(int ScreenId, Intent data)");
  1834. LogUtil.errorLogInfo("", TAG, e);
  1835. return false;
  1836. }
  1837. }
  1838. /**
  1839. * Activity Result Reception
  1840. */
  1841. @Override
  1842. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  1843. super.onActivityResult(requestCode, resultCode, data);
  1844. try {
  1845. Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@");
  1846. // int screenId = data.getIntExtra("SCREENS", -1);
  1847. // Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@ screenId : " + screenId );
  1848. //if( mViewFlipper)
  1849. if (requestCode == UNINSTALL_REQUEST_CODE) {
  1850. if (resultCode == RESULT_OK) {
  1851. Log.w(TAG, "[onActivityResult] user accepted the uninstall");
  1852. } else if (resultCode == RESULT_CANCELED) {
  1853. Log.w(TAG, "[onActivityResult] user canceled the uninstall");
  1854. } else if (resultCode == RESULT_FIRST_USER) {
  1855. Log.w(TAG, "[onActivityResult] failed to uninstall");
  1856. }
  1857. }
  1858. else {
  1859. if (data != null) {
  1860. int nSenderScreenID = data.getIntExtra(Common.BR_SENDER_SCREEN, -1);
  1861. int nReceiveScreenID = data.getIntExtra(Common.BR_RECEIVE_SCREEN, -1);
  1862. int nCallSubMenuScreen = data.getIntExtra(Common.CALL_SUBMAIN_SCREEN, -1);
  1863. if (nCallSubMenuScreen > 0) {
  1864. CallSubMenuScreen(nCallSubMenuScreen);
  1865. }
  1866. else {
  1867. Log.d(TAG, "[onActivityResult] nSenderScreenID : " + nSenderScreenID + " , nReceiveScreenID : " + nReceiveScreenID );
  1868. if (nSenderScreenID == ID.POPUPS.POPUP_DELETESHORTCUT) {
  1869. if (nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  1870. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  1871. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  1872. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  1873. MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  1874. return;
  1875. }
  1876. else if (nReceiveScreenID == ID.SCREENS.SCREEN_HYOSUNGUI_MAIN_HN) {
  1877. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  1878. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  1879. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  1880. Hyosung_HN_MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  1881. return;
  1882. }
  1883. else if (nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_MAIN) {
  1884. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_DELETE, false);
  1885. int nDeleteShortcutID = data.getIntExtra(Common.BR_DELETE_WIDGET_ID, -1);
  1886. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nDeleteShortcutID : " + nDeleteShortcutID);
  1887. MetroUI_MainScreen.procDeleteShortcutPopupResult(bResult, nDeleteShortcutID);
  1888. return;
  1889. }
  1890. }
  1891. else if (nSenderScreenID == ID.POPUPS.POPUP_ADDSHORTCUT) {
  1892. if (nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  1893. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  1894. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  1895. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  1896. MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  1897. return;
  1898. }
  1899. else if (nReceiveScreenID == ID.SCREENS.SCREEN_HYOSUNGUI_MAIN_HN) {
  1900. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  1901. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  1902. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  1903. Hyosung_HN_MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  1904. return;
  1905. }
  1906. else if (nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_MAIN) {
  1907. boolean bResult = data.getBooleanExtra(Common.BR_WIDGET_INSERT, false);
  1908. int nAddShortcutID = data.getIntExtra(Common.BR_INSERT_WIDGET_ID, -1);
  1909. Log.d(TAG, "[onActivityResult] bResult : " + bResult + ", nAddShortcutID : " + nAddShortcutID);
  1910. MetroUI_MainScreen.procAddShortcutPopupResult(bResult, nAddShortcutID);
  1911. return;
  1912. }
  1913. }
  1914. else if (nSenderScreenID == ID.POPUPS.POPUP_CONFIGUREPRESET && nReceiveScreenID == ID.SCREENS.SCREEN_MAIN) {
  1915. String strLivinglightPresetInfo = data.getStringExtra(Common.BR_LIVINGLIGHT_PRESET_INFO);
  1916. Log.d(TAG, "[onActivityResult] strLivinglightPresetInfo [" + strLivinglightPresetInfo + "]");
  1917. savePresetValue(strLivinglightPresetInfo);
  1918. return;
  1919. }
  1920. else if ((ID.POPUPS.POPUP_GROUP_CTRL <= nSenderScreenID && nSenderScreenID <= ID.POPUPS.POPUP_GROUP_SETTING) && nReceiveScreenID == ID.SCREENS.SCREEN_METROUI_GROUP) {
  1921. boolean bRun = data.getBooleanExtra(Common.BR_RUN_WIDGET, false);
  1922. int nIconID = data.getIntExtra(Common.BR_RUN_WIDGET_ID, 0);
  1923. Log.d(TAG, "[onPopupResult] bRun [" + bRun + "], nIconID [" + nIconID + "]") ;
  1924. if (bRun) runIcon(nIconID);
  1925. }
  1926. }
  1927. }
  1928. if (resultCode == RESULT_OK) {
  1929. // // 팝업을 종료하고 다른 팝업을 띄울경우가 있다.
  1930. // int screenIdCode = data.getExtras().getInt("CHANGE_POPUP" );
  1931. // int popupKind = data.getExtras().getInt("POPUP_KIND");
  1932. //
  1933. // Log.d(TAG, "@@@ CHANGE_POPUP : " + screenIdCode + " , popupKind : " +popupKind);
  1934. // if( screenIdCode > 0 )
  1935. // {
  1936. // setPopupActivityRun(false);
  1937. // Intent intent = new Intent();
  1938. // intent.putExtra("POPUP_KIND", popupKind );
  1939. // StartPopup(screenIdCode , intent);
  1940. // }
  1941. }
  1942. }
  1943. }
  1944. catch (RuntimeException re) {
  1945. LogUtil.errorLogInfo("", TAG, re);
  1946. }
  1947. catch (Exception e )
  1948. {
  1949. Log.e(TAG, e.toString());
  1950. LogUtil.errorLogInfo("", TAG, e);
  1951. }
  1952. }
  1953. /* ================================================================================================
  1954. * [Info Activity] Section
  1955. ================================================================================================ */
  1956. public static ManualActivity mManualActivity;
  1957. /**
  1958. * Info Activity를 시작시킨다.
  1959. *
  1960. * @param screenId - 매뉴얼 시작시 Screen ID_OLD
  1961. * @return (boolean) true : 성공, false : 실패
  1962. */
  1963. public boolean startManualPopup(int screenId) {
  1964. Log.d(TAG, "[startManualPopup] ScreenId [" + screenId +"], mCurrentInfoScreenId [" + mCurrentInfoScreenId + "]" );
  1965. if (getInfoActivityRun() == true) {
  1966. mCurrentInfoScreenId = screenId;
  1967. return ((WpadActivity)(ManualActivity.getContext())).ChangeScreen(screenId);
  1968. } else {
  1969. if (mCurrentInfoScreenId == screenId) return false;
  1970. mCurrentInfoScreenId = screenId;
  1971. setInfoActivityRun(true);
  1972. Intent intent = new Intent(mContext, ManualActivity.class);
  1973. intent.putExtra("ScreenId", screenId);
  1974. overridePendingTransition(0, 0);
  1975. startActivityForResult(intent, 0);
  1976. return true;
  1977. }
  1978. }
  1979. public static void resetCurrentInfoScreenID() {
  1980. try {
  1981. mCurrentInfoScreenId = -1;
  1982. } catch (RuntimeException re) {
  1983. LogUtil.errorLogInfo("", TAG, re);
  1984. }
  1985. catch (Exception e) {
  1986. Log.e(TAG, "[Exception] resetCurrentInfoScreenID()");
  1987. LogUtil.errorLogInfo("", TAG, e);
  1988. }
  1989. }
  1990. /**
  1991. * 매뉴얼 버튼 사용 유무
  1992. *
  1993. * @return boolean 타입 - true:사용, false:미사용
  1994. */
  1995. public boolean GetManualUse() {
  1996. WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
  1997. String[] DBinfo = devSet.GetSettingData("매뉴얼");
  1998. devSet.closeDB();
  1999. if (DBinfo != null) {
  2000. if (DBinfo[1].indexOf("사용함") > 0) {
  2001. Log.d(TAG, "[GetManualUse] Use Manual");
  2002. return true;
  2003. }
  2004. else {
  2005. // 미사용
  2006. Log.d(TAG, "[GetManualUse] Not Use Manual");
  2007. return false;
  2008. }
  2009. }
  2010. else {
  2011. //미사용
  2012. return false;
  2013. }
  2014. }
  2015. /* ================================================================================================
  2016. * [Screen] Section
  2017. ================================================================================================ */
  2018. /**
  2019. * Screen 에서 Screen 변경을 요청할 경우 호출된다.<br>
  2020. * Override 사용하여 Screen 변경을 처리한다.<br>
  2021. *
  2022. * @param nScreenId - 변경할 Screen ID_OLD
  2023. * @return (boolean) true : 성공, false : 실패
  2024. */
  2025. @Override
  2026. protected boolean onChangeScreen(int nScreenId) {
  2027. super.onChangeScreen(nScreenId);
  2028. return setChangeScreen(nScreenId, false, false);
  2029. }
  2030. /**
  2031. * Screen 등록자<br>
  2032. * MainScreenLayout 에 현재 Screen 을 삭제하고, 새로운 Screen 을 등록시킨다.
  2033. *
  2034. * @param nScreenId - 변경할 Screen ID_OLD
  2035. * @param OnlyRemove - 현재 Screen 을 삭제만 할 경우 (onDestroy 에서 사용)
  2036. * @return (boolean) true : 성공, false : 실패
  2037. */
  2038. private boolean setChangeScreen(int nScreenId, boolean OnlyRemove, boolean setAnimation) {
  2039. DebugLogOutput("setChangeScreen - " + "CurrentSelectDeviceId : " + mCurrentScreenId + " / NextLayoutId : " + nScreenId + " / OnlyRemove : " + OnlyRemove);
  2040. // 1. 현재 Layout 삭제
  2041. boolean remove = false;
  2042. if (mCurrentScreenId > 0) {
  2043. remove = true;
  2044. MainScreenLayout.removeAllViews();
  2045. super.setCurrentScreen(null);
  2046. }
  2047. if (OnlyRemove) return true;
  2048. mCurrentScreenId = nScreenId;
  2049. // 2. 새로운 Layout 표시
  2050. try {
  2051. switch (nScreenId) {
  2052. case ID.SCREENS.SCREEN_MAIN:
  2053. MainScreen = new MAIN(getContext(), MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen, DEVICE_OPERATION_MODE);
  2054. super.setCurrentScreen(MainScreen);
  2055. break;
  2056. case ID.SCREENS.SCREEN_SUB_01:
  2057. SUB_01Screen = new SUB_01(getContext(), MainScreenLayout, mWallPadAPI);
  2058. super.setCurrentScreen(SUB_01Screen);
  2059. break;
  2060. case ID.SCREENS.SCREEN_SUB_02:
  2061. SUB_02Screen = new SUB_02(getContext(), MainScreenLayout, mWallPadAPI);
  2062. super.setCurrentScreen(SUB_02Screen);
  2063. break;
  2064. case ID.SCREENS.SCREEN_METROUI_MAIN:
  2065. MetroUI_MainScreen = new METROUI_MAIN(getContext(), MainScreenLayout, mWallPadAPI, m_CallSubMenuScreen);
  2066. super.setCurrentScreen(MetroUI_MainScreen);
  2067. break;
  2068. case ID.SCREENS.SCREEN_METROUI_SUB_01:
  2069. MetroUI_SUB_01Screen = new METROUI_SUB_01(getContext(), MainScreenLayout, mWallPadAPI);
  2070. super.setCurrentScreen(MetroUI_SUB_01Screen);
  2071. break;
  2072. case ID.SCREENS.SCREEN_METROUI_SUB_02:
  2073. MetroUI_SUB_02Screen = new METROUI_SUB_02(getContext(), MainScreenLayout, mWallPadAPI);
  2074. super.setCurrentScreen(MetroUI_SUB_02Screen);
  2075. break;
  2076. default:
  2077. Log.e(TAG, "[Error] setChangeScreen - nScreenId Not found!!! (" + mCurrentScreenId + ")");
  2078. mCurrentScreenId = -1;
  2079. return false;
  2080. }
  2081. } catch (RuntimeException re) {
  2082. LogUtil.errorLogInfo("", TAG, re);
  2083. return false;
  2084. }
  2085. catch (Exception e) {
  2086. Log.e(TAG, "[ExceptionError] - setChangeScreen->Screen Create : " + e);
  2087. return false;
  2088. }
  2089. return true;
  2090. }
  2091. /////////////////////////////////////////////////////////////////////////////////
  2092. private void runDeviceService() {
  2093. try {
  2094. Log.i(TAG, "[runDeviceService] ===== START =====");
  2095. /* 2018.01.30 속초 아이파크 RF현관카메라 연동으로 인하여 수정
  2096. // 우선 제어기기 연동 기능이 없음
  2097. if( Version.getModelType() == Version.MODEL_TYPE.IHN_750 )
  2098. return;
  2099. */
  2100. if (!getIsSubWallpad()) {
  2101. ActivityManager mActivityManager = (ActivityManager)getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
  2102. List<ActivityManager.RunningAppProcessInfo> RunningAppList = mActivityManager.getRunningAppProcesses();
  2103. Common.DebugLog("[runDeviceService] -----> RunningAppProcessInfo : " + RunningAppList.size() + " +++ Version : " + this.getAppVersion());
  2104. for (int i = 0; i < RunningAppList.size(); i++) {
  2105. ActivityManager.RunningAppProcessInfo RunningAppListInfo = RunningAppList.get(i);
  2106. Common.DebugLog("[runDeviceService] -----> RunningAppListInfo.processName : " + RunningAppListInfo.processName);
  2107. if (RunningAppListInfo.processName.equals("com.artncore.deviceservice")) {
  2108. Log.w(TAG, "[runDeviceService] DevService is already running");
  2109. return;
  2110. }
  2111. }
  2112. Log.i(TAG, "[runDeviceService] Start DevService!!");
  2113. Intent mIntent = new Intent("wallpaddevservice.ServiceMain");
  2114. startService(mIntent);
  2115. }
  2116. else {
  2117. Log.w(TAG, "[runDeviceService] This wallpad is sub-wallpad. not need DevService!!!");
  2118. }
  2119. } catch (RuntimeException re) {
  2120. LogUtil.errorLogInfo("", TAG, re);
  2121. }
  2122. catch (Exception e) {
  2123. Log.e(TAG, "[Exception] runDeviceService()");
  2124. LogUtil.errorLogInfo("", TAG, e);
  2125. }
  2126. }
  2127. // 통신으로 들어오는 비상버튼 스킵하기 위한 딜레이 체크 변수
  2128. private long EmerCommDelayTime = 0;
  2129. public static String WALLPAD_ALERT = "WALLPAD_ALERT";
  2130. BroadcastReceiver mWallPadAlertBR = new BroadcastReceiver() {
  2131. @Override
  2132. public void onReceive(Context context, Intent intent) {
  2133. Log.i(TAG, "[mWallPadAlertBR] Receive alert BR");
  2134. String strAction = intent.getAction();
  2135. Log.d(TAG, "[mWallPadAlertBR] strAction [" + strAction + "]");
  2136. if (strAction.equalsIgnoreCase(WALLPAD_ALERT)) {
  2137. int kind = intent.getIntExtra("KIND",0);
  2138. Log.i(TAG, "[mWallPadAlertBR] " + String.format("Receive alert BR [%d][tag:%s]", kind,String.valueOf(Alert_App_On)));
  2139. // 제주 아이파크 스위트현장의 비상발생 증상을 디버깅하기 위한 코드 (JEFF, 2019.09.26)
  2140. // if (kind == 4) {
  2141. // try {
  2142. // byte hFrom = intent.getByteExtra("FROM", (byte) 0xFF);
  2143. // if (hFrom != (byte) 0xFF) {
  2144. // if (hFrom % 10 == 3) {
  2145. // Log.w(TAG, "[mWallPadAlertBR] Emergency from BathPhone!!!");
  2146. // int nDstPort = 10000;
  2147. // sendAlarmOperationToMainServer("10.0.1.1", nDstPort, EMER_STATE.FIRE, EMER_DETAIL_INFO.EMERGENCY_COMM);
  2148. // return;
  2149. // }
  2150. // }
  2151. // } catch (RuntimeException re) {
  2152. // LogUtil.errorLogInfo("", TAG, re);
  2153. // }
  2154. // catch (Exception e) {
  2155. // Log.e(TAG, "[Exception] mWallPadAlertBR - 1");
  2156. // e.printStackTrace();
  2157. // }
  2158. // }
  2159. if (kind == 30) Alert_App_On = true;
  2160. else if (kind == 40) Alert_App_On = false;
  2161. else {
  2162. WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
  2163. int alarmState = wdb.GetAlarmStatus();
  2164. wdb.closeDB();
  2165. if (alarmState == WallpadStatusData.ALARM_ARISE || alarmState == WallpadStatusData.ALARM_STOP) {
  2166. // 알람화면이 현재 실행중이면 스킵
  2167. Log.d(TAG, "Skip BR ==> Current Alarm state : "+ alarmState );
  2168. return;
  2169. }
  2170. if (kind == 4 && ( Math.abs(System.currentTimeMillis()-EmerCommDelayTime) < 1000)) {
  2171. // 통신 비상알람의 경우 중복으로 날라오는 경우가 있어서 필터링
  2172. Log.d(TAG, "Skip BR ==> deleayTime :" + String.valueOf( Math.abs(System.currentTimeMillis()-EmerCommDelayTime)));
  2173. return;
  2174. }
  2175. EmerCommDelayTime = System.currentTimeMillis();
  2176. SendAppFinishReqBR();
  2177. Log.i(TAG, "[mWallPadAlertBR] before Call Alert App");
  2178. int base = 7000;
  2179. int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41, base+51};
  2180. int Menu_Start_Id = base+21;
  2181. int Menu_Start_Option = 1;
  2182. String Cause = "none";
  2183. if (kind == 1) Cause = "gas";
  2184. else if (kind == 2) Cause = "fire";
  2185. else if (kind == 4) Cause = "emergency_Comm";
  2186. else if (kind == 5) {
  2187. Cause = "heating_Leak";
  2188. Menu_Start_Id = base + 51;
  2189. }
  2190. else {
  2191. Cause = "unknown(" + kind + ")";
  2192. }
  2193. Intent newintent = new Intent(Intent.ACTION_MAIN);
  2194. newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2195. newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  2196. newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2197. newintent.putExtra("MENU_DETAIL_INFO", Cause);
  2198. newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
  2199. newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  2200. startActivity(newintent);
  2201. }
  2202. }
  2203. }
  2204. };
  2205. private void sendAlarmOperationToMainServer(String DstIP, int DstPort, EMER_STATE alarm_mode, EMER_DETAIL_INFO cause) {
  2206. Log.d(TAG, "[sendAlarmOperationToMainServer] DstIP [" + DstIP + "], DstPort [" + DstPort + "], alarm_mode [" + EMER_STATE.GetXMLData(alarm_mode) + "], cause [" + EMER_DETAIL_INFO.GetXMLData(cause) + "]");
  2207. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  2208. AddressSet addc = wdb.getAddressMGR(); //DB에서 동호 정보 받아옴
  2209. wdb.closeDB();
  2210. final iMAPAlarmOperation imapAlarmOperation = new iMAPAlarmOperation(getContext() , addc);
  2211. imapAlarmOperation.SetServerIPcfg(DstIP, DstPort);
  2212. imapAlarmOperation.DoWork(alarm_mode, cause);
  2213. imapAlarmOperation.SetRetCtr(new RetProci(){
  2214. @Override
  2215. public void ProcSuccess() {
  2216. // TODO Auto-generated method stub
  2217. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcSuccess()");
  2218. String result = imapAlarmOperation.GetAttributeVal(0, "result");
  2219. Log.i(TAG, "[sendAlarmOperationToMainServer] result [" + result +"]");
  2220. if (result.equalsIgnoreCase("ok")) {
  2221. Log.i(TAG, "[sendAlarmOperationToMainServer] result [" + result +"]");
  2222. }
  2223. }
  2224. @Override
  2225. public void ProcError() {
  2226. // TODO Auto-generated method stub
  2227. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcError() -> " + APIErrorCode.GetLogPrefix());
  2228. }
  2229. @Override
  2230. public void ProcDoing() {
  2231. // TODO Auto-generated method stub
  2232. Log.i(TAG, "[sendAlarmOperationToMainServer] ProcDoing()");
  2233. }
  2234. });
  2235. }
  2236. private String getMainVersion() {
  2237. return this.getAppVersion();
  2238. }
  2239. private int m_LiveImapServer = 0;
  2240. private int m_LiveMainActivity = 0;
  2241. private boolean m_IPActivity = false;
  2242. BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
  2243. @Override
  2244. public void onReceive(Context context, Intent intent) {
  2245. String strAction = intent.getAction();
  2246. int item = 0;
  2247. Log.i(TAG, "[mWallPadNotifyBR] strAction [" + strAction + "]");
  2248. if (strAction.equals(define.NOTIFY_ACNAME)) {
  2249. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND,0);
  2250. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACNAME -> kind : " + kind);
  2251. switch (kind) {
  2252. case define.NOTIFY_GET_ELEC_CHARGE:
  2253. String strState = intent.getStringExtra("sCharging_Status");
  2254. String strCarNum = intent.getStringExtra("sCar_Num");
  2255. if (strState.equals("start")) {
  2256. try {
  2257. WallpadStatusData SetData = new WallpadStatusData(getContext());
  2258. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2259. SetData.closeDB();
  2260. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  2261. } catch (RuntimeException re) {
  2262. LogUtil.errorLogInfo("", TAG, re);
  2263. }
  2264. catch (Exception e) {
  2265. LogUtil.errorLogInfo("", TAG, e);
  2266. }
  2267. // 충전시작
  2268. Intent data = new Intent();
  2269. data.putExtra("CarNum", strCarNum); // KEY : MENU_ID_LIST
  2270. data.putExtra("Msg", "충전을 시작합니다.");
  2271. mIOInterface.ctrlLcdWakeUp();
  2272. StartPopup(ID.POPUPS.POPUP_CHARGINGELECTRICVEHICLE, data);
  2273. }
  2274. else if (strState.equals("stop")) {
  2275. try {
  2276. WallpadStatusData SetData = new WallpadStatusData(getContext());
  2277. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2278. SetData.closeDB();
  2279. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  2280. } catch (RuntimeException re) {
  2281. LogUtil.errorLogInfo("", TAG, re);
  2282. }
  2283. catch (Exception e) {
  2284. LogUtil.errorLogInfo("", TAG, e);
  2285. }
  2286. // 충전 종료
  2287. Intent data = new Intent();
  2288. data.putExtra("CarNum", strCarNum); // KEY : MENU_ID_LIST
  2289. data.putExtra("Msg", "충전이 종료되었습니다.");
  2290. mIOInterface.ctrlLcdWakeUp();
  2291. StartPopup(ID.POPUPS.POPUP_CHARGINGELECTRICVEHICLE, data);
  2292. }
  2293. break;
  2294. case define.NOTIFY_INTERLAYTER_NOISE_ALARM:
  2295. if (checkInterFloorNoiseFuncUsage()) {
  2296. mIOInterface.ctrlLcdWakeUp();
  2297. StartPopup(ID.POPUPS.POPUP_INTERFLOORNOISEOCCURED);
  2298. }
  2299. break;
  2300. case define.NOTIFY_INTERLAYTER_SENSOR_STATUS_CHANGE :
  2301. if (checkInterFloorNoiseFuncUsage() && checkInterFloorNoiseError()) {
  2302. mIOInterface.ctrlLcdWakeUp();
  2303. StartPopup(ID.POPUPS.POPUP_INTERFLOORNOISEERROR);
  2304. }
  2305. break;
  2306. case define.NOTIFY_AUTOPICTURE_FINISH:
  2307. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_AUTOPICTURE_FINISH");
  2308. // 전자액자 종료 BR 수신시 LCD ON Flag 제거
  2309. ctrlLCDOnOff(false);
  2310. break;
  2311. case define.NOTIFY_ALARM_CHANGE:
  2312. Log.d(TAG, "[mWallPadNotifyBR] define.NOTIFY_ALARM_CHANGE");
  2313. // WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2314. // int nAlarmStatus = SetData.GetAlarmStatus();
  2315. // SetData.closeDB();
  2316. //
  2317. // Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus = " + nAlarmStatus);
  2318. // if (nAlarmStatus == WallpadStatusData.GUARD_IN) {
  2319. // mSound.PlayMent(SND.mode.INMODE_SETTING);
  2320. // }
  2321. // else if (nAlarmStatus == WallpadStatusData.GUARD_OUT) {
  2322. // mSound.PlayMent(SND.mode.OUTMODE_SETTING);
  2323. // }
  2324. // else if (nAlarmStatus == WallpadStatusData.ALARM_NONE) {
  2325. // mSound.PlayMent(SND.mode.NORMALMODE_COMEBACK);
  2326. // }
  2327. break;
  2328. case define.NOTIFY_PLAYMENT:
  2329. int sndidx = intent.getIntExtra(define.NOTIBR_CONTENT,0);
  2330. Sound().PlayMent(sndidx);
  2331. case define.NOTIFY_DEVICE_INIT_COMPLETION:
  2332. Log.i(TAG, "[mWallPadNotifyBR] NOTIFY_DEVICE_INIT_COMPLETION: bLCDKeeperUsage [" + bLCDKeeperUsage +"]");
  2333. if (bLCDKeeperUsage) registerLCDKeeper();
  2334. break;
  2335. default:
  2336. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  2337. break;
  2338. }
  2339. }
  2340. else if (strAction.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
  2341. Log.d(TAG, "[mWallPadNotifyBR] Common.BR_ACK_WALLPADCALL_LIVE");
  2342. return;
  2343. }
  2344. else if (strAction.equals(define.DRIVER_VENTIL_BR)) {
  2345. Log.d(TAG, "[mWallPadNotifyBR] define.DRIVER_VENTIL_BR");
  2346. return;
  2347. }
  2348. else if (strAction.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
  2349. try {
  2350. int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND,0);
  2351. Log.d(TAG, "[mWallPadNotifyBR] ACNAME_MAIN_NOTI -> kind : " + kind);
  2352. switch (kind) {
  2353. case Common.BR_MAIN_NOTI.ARRIVED_CAR:
  2354. StartPopup(ID.POPUPS.POPUP_VEHICLEARRIVED, intent);
  2355. // StartPopup(ID_OLD.SCREENS.ArrivedCarPopupScreen);
  2356. break;
  2357. case Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL:
  2358. StartPopup(ID.POPUPS.POPUP_PARCELRECEIVED);
  2359. // StartPopup(ID_OLD.SCREENS.DeliveryBox);
  2360. break;
  2361. case Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR:
  2362. StartPopup(ID.POPUPS.POPUP_SMARTKEYEMERGENCY, intent);
  2363. // StartPopup(ID_OLD.SCREENS.SmartKeyAlarmPopupScreen, intent);
  2364. break;
  2365. case Common.BR_MAIN_NOTI.UI_BANDLOCATION_ALARM:
  2366. ctrlLCDOnOff(true);
  2367. int nCardNum = intent.getIntExtra(Common.BR_MAIN_NOTI.CARD_NUM,0);
  2368. Intent mIntent = new Intent();
  2369. mIntent.putExtra(Common.BR_MAIN_NOTI.CARD_NUM, nCardNum);
  2370. StartPopup(ID.POPUPS.POPUP_BANDLOCATIONALARM, mIntent);
  2371. break;
  2372. case Common.BR_MAIN_NOTI.UI_UPDATE_POST:
  2373. ctrlLCDOnOff(true);
  2374. StartPopup(ID.POPUPS.POPUP_POSTRECEIVED);
  2375. break;
  2376. case Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER:
  2377. // 알람 상태 확인
  2378. int doorCamType = intent.getIntExtra("DOORCAM_TYPE", -1);
  2379. Intent data = new Intent();
  2380. data.putExtra("DOORCAM_TYPE", doorCamType);
  2381. mIOInterface.ctrlLcdWakeUp();
  2382. // StartPopup(ID.POPUPS.POPUP_NOTICESTRANGER, data); // 시나리오 변경: 거동수상자 알림 팝업 삭제 (바로 녹화 시작)
  2383. WallpadStatusData SetData = new WallpadStatusData(mContext);
  2384. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2385. SetData.closeDB();
  2386. if (soundOut) Sound().Play(SND.effect.EFFECT1);
  2387. // 메인 앱으로 BR 전송
  2388. Intent notiIntent = new Intent();
  2389. notiIntent.setAction(define.NOTIFY_ACNAME);
  2390. notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ACCEPT_RECORD_STRANGER);
  2391. mContext.sendBroadcast(notiIntent);
  2392. break;
  2393. case Common.BR_MAIN_NOTI.ACCEPT_RECORDING:
  2394. int nEmerState = intent.getIntExtra("EMERGENCY_STATE", -1);
  2395. //여기서 거동 수상자 녹화 시작 여부 확인
  2396. Common.bRecordStatus = true;
  2397. boolean bFromCall = intent.getBooleanExtra("FROMCALL", false);
  2398. if (!bFromCall) {
  2399. // yjyoon. 2443에서는 Call 앱에서 녹화 수행
  2400. // 여기서 해당하는 br 정보를 저장 해야 함
  2401. //jglee - 여기서 BR들을 관리하기 위하여
  2402. if(CallBrList == null)
  2403. CallBrList = new ArrayList<Intent>();
  2404. Intent brListIntent = new Intent();
  2405. brListIntent.setAction(define.NOTIFY_ACNAME);
  2406. brListIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SMART_DCAM_DETECT);
  2407. if(CallBrList.size() > 1)
  2408. {
  2409. if(CallBrList.get(0) != brListIntent)
  2410. {
  2411. CallBrList.add(brListIntent);
  2412. Log.d(TAG, "jglee - Call 인텐트 추가 > size : " + CallBrList.size() + ", Action : " + CallBrList.get(0).getAction());
  2413. }
  2414. }
  2415. else {
  2416. CallBrList.add(brListIntent);
  2417. Log.d(TAG, "jglee - Call 인텐트 추가 > size : " + CallBrList.size() + ", Action : " + CallBrList.get(0).getAction());
  2418. }
  2419. //여기서 BrList에 남아 있는 갯수를 확인
  2420. if(CallBrList!=null && CallBrList.size() > 1)
  2421. {
  2422. return;
  2423. }
  2424. Log.d(TAG, "jglee - Call Record");
  2425. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Door_Record, nEmerState);
  2426. }
  2427. break;
  2428. case Common.BR_MAIN_NOTI.STOP_RECORDING:
  2429. // yjyoon. 거동수상자 녹화중지 시 상태값 변경.
  2430. Log.v("yjyoon", "Common.BR_MAIN_NOTI.STOP_RECORDING Common.bWallPadRecoder = false");
  2431. //Common.bWallPadRecoder = false;
  2432. Common.bRecordStatus = false;
  2433. mediaStopRecord();
  2434. break;
  2435. default:
  2436. Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
  2437. break;
  2438. }
  2439. } catch (RuntimeException re) {
  2440. LogUtil.errorLogInfo("", TAG, re);
  2441. }
  2442. catch (Exception e) {
  2443. e.toString();
  2444. }
  2445. return;
  2446. }
  2447. else if(strAction.equals(BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER )) {
  2448. int kind = intent.getIntExtra(BR_MAIN_LIVE_CHECKER.KIND,0);
  2449. Log.d(TAG, "[mWallPadNotifyBR] BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER -> kind : " + kind + ", m_LiveImapServer [" + m_LiveImapServer + "], m_LiveMainActivity [" + m_LiveMainActivity + "]");
  2450. if (kind == BR_MAIN_LIVE_CHECKER.IMAP_SERVER) {
  2451. Log.d(TAG, "[mWallPadNotifyBR] received Imap Server Live !");
  2452. m_LiveImapServer++;
  2453. }
  2454. else if( kind == BR_MAIN_LIVE_CHECKER.MAIN_ACTIVITY) {
  2455. Log.d(TAG, "[mWallPadNotifyBR] received Main Activity Live !");
  2456. m_LiveMainActivity++;
  2457. if (m_IPActivity == false) {
  2458. Log.d(TAG, "[mWallPadNotifyBR] IP is not set");
  2459. m_LiveImapServer++;
  2460. }
  2461. }
  2462. Log.d(TAG, "[mWallPadNotifyBR] m_LiveImapServer [" + m_LiveImapServer + "], m_LiveMainActivity [" + m_LiveMainActivity +"]");
  2463. return;
  2464. }
  2465. int kind = intent.getIntExtra("KIND",0);
  2466. Log.d(TAG, "MainActivity mWallPadNotifyBR Receive Notify BR "+kind+" "/*+electr.isActive()*/);
  2467. switch (kind) {
  2468. case define.NOTIFY_ELE_MOVE:
  2469. // if (electr!= null /*&& electr.isActive()*/)
  2470. // {
  2471. // Log.i("MAINSCREEN", "Receive NOTIFY_ELE_MOVE");
  2472. // electr.updateUI(intent.getStringExtra("FLOOR"), intent.getByteExtra("UPDOWN",(byte)-1));
  2473. // }
  2474. break;
  2475. case define.NOTIFY_ELE_ARRIVAL_UP:
  2476. Log.i("AIDLTEST", "Receive NOTIFY_ELE_ARRIVAL_UP");
  2477. Sound().Play(SND.elevator.UP_ARRIVED);
  2478. break;
  2479. case define.NOTIFY_ELE_ARRIVAL_DOWN:
  2480. try {
  2481. WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
  2482. int eleinfo = devset.Get_Elevator_Info();
  2483. devset.closeDB();
  2484. if (WallpadDeviceSet.ELEVATOR_SIMPLE == eleinfo) Sound().Play(SND.elevator.ORG_ARRIVED);
  2485. else if (WallpadDeviceSet.ELEVATOR_FLOOR == eleinfo) Sound().Play(SND.elevator.DN_ARRIVED);
  2486. } catch (RuntimeException re) {
  2487. LogUtil.errorLogInfo("", TAG, re);
  2488. }
  2489. catch (Exception e) {
  2490. LogUtil.errorLogInfo("", TAG, e);
  2491. }
  2492. break;
  2493. case define.NOTIFY_UPDATE_START:
  2494. try {
  2495. String updateFile = intent.getStringExtra("PATH");
  2496. Log.i("WALLPADAPI","Call Update App :" + updateFile);
  2497. if (updateFile==null) return;
  2498. ComponentName cn = new ComponentName("com.telechips.android.systemupdater","com.telechips.android.systemupdater.SystemUpdate");
  2499. Intent Uintent = new Intent(Intent.ACTION_MAIN);
  2500. Uintent.addCategory(Intent.CATEGORY_LAUNCHER);
  2501. Uintent.putExtra("updatefile",updateFile);
  2502. Uintent.setComponent(cn);
  2503. startActivity(Uintent);
  2504. } catch (RuntimeException re) {
  2505. LogUtil.errorLogInfo("", TAG, re);
  2506. }
  2507. catch (Exception e) {
  2508. LogUtil.errorLogInfo("", TAG, e);
  2509. }
  2510. break;
  2511. case define.NOTIFY_DEVSERVICE_START:
  2512. mWallPadAPI = new WallPadAPI(getApplicationContext());
  2513. break;
  2514. case define.NOTIFY_DEVICECONNECTED:
  2515. //DevLockCtr.ReleaseLock(define.DEVICE_LOCK_SVC_INIT);
  2516. break;
  2517. case define.NOTIFY_SENDBOOTUP_FAIL:
  2518. // 부트업 실패시 5초 간격으로 다시 시도하도록 수정.
  2519. mWallPadApiCheckHandler.sendEmptyMessageDelayed(10, 10000);
  2520. break;
  2521. case define.NOTIFY_IMAPSERVER_START:
  2522. case Common.DEVICE_BOOTUP_RETRY:
  2523. Log.i(TAG, "Try Send Boot up MSG kind : " + kind );
  2524. bootupretryCNT++;
  2525. if (bootupretryCNT > MAX_BOOTUP_RETRY_COUNT) break;
  2526. try {
  2527. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2528. if (SetData != null) {
  2529. // AnC 기존 코드는 네트워크 연결이 안된경우 DB Close를 50회를 안 하도록 되어있어서 수정함.
  2530. String strServerIP = SetData.GetServerIP();
  2531. int nServerPort = SetData.GetServerPort();
  2532. String svrVersion = SetData.GetServerVer();
  2533. Log.d(TAG, "DB Server Version : " + svrVersion );
  2534. if (svrVersion == null) svrVersion = "1.0";
  2535. //설정정보 버전 가져오기
  2536. StringBuilder result = new StringBuilder();
  2537. result.append(SetData.GetSettingVer());
  2538. SetData.closeDB();
  2539. String Setting_Version = result.toString();
  2540. Log.i(TAG, "Setting's Version :"+Setting_Version);
  2541. boolean mNewDanjiServer = false;
  2542. try {
  2543. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  2544. //mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
  2545. int danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
  2546. if(danjiserverType == 1)
  2547. {
  2548. mNewDanjiServer = false;
  2549. }
  2550. else if(danjiserverType == 2)
  2551. {
  2552. mNewDanjiServer = true;
  2553. }
  2554. else
  2555. {
  2556. mNewDanjiServer = true;
  2557. }
  2558. wallpadDeviceSet.closeDB();
  2559. } catch (RuntimeException re) {
  2560. LogUtil.errorLogInfo("", TAG, re);
  2561. mNewDanjiServer = false;
  2562. }
  2563. catch (Exception e) {
  2564. Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
  2565. LogUtil.errorLogInfo("", TAG, e);
  2566. mNewDanjiServer = false;
  2567. }
  2568. if (mNewDanjiServer == true) {
  2569. // DB 값하고 , 신형단지서버 사용 설정이 동일 하다면 DB값을 전달한다.
  2570. // 나중에 2.X 이상 버전이 갱신될 경우를 위해서
  2571. }
  2572. else {
  2573. svrVersion = "1.0";
  2574. }
  2575. //Main App 버전정보 가져오기
  2576. WallPadiMAPNotifyAPI notify = new WallPadiMAPNotifyAPI(getApplicationContext());
  2577. notify.SetSocketWaitCount(3000);
  2578. notify.SetServerIPcfg(strServerIP, nServerPort);
  2579. notify.Send_Device_BootUP(getMainVersion(), Setting_Version , svrVersion );
  2580. }
  2581. } catch (RuntimeException re) {
  2582. LogUtil.errorLogInfo("", TAG, re);
  2583. Intent Newintent = new Intent();
  2584. Newintent.setAction(define.NOTIFY_ACNAME);
  2585. Newintent.putExtra(define.NOTIBR_KIND,define.NOTIFY_SENDBOOTUP_FAIL);
  2586. sendBroadcast(Newintent);
  2587. }
  2588. catch (Exception e) {
  2589. LogUtil.errorLogInfo("", TAG, e);
  2590. Intent Newintent = new Intent();
  2591. Newintent.setAction(define.NOTIFY_ACNAME);
  2592. Newintent.putExtra(define.NOTIBR_KIND,define.NOTIFY_SENDBOOTUP_FAIL);
  2593. sendBroadcast(Newintent);
  2594. }
  2595. break;
  2596. case define.NOTIFY_SUBDEVCALLBUSY:
  2597. /*
  2598. callbtn = (Button)findViewById(R.id.Callbtn);
  2599. callbtn.setBackgroundResource(R.drawable.but_call_on);
  2600. MAIN_CALL_LOCK = true;
  2601. */
  2602. break;
  2603. case define.NOTIFY_SUBDEVCALLEND:
  2604. /*
  2605. callbtn = (Button)findViewById(R.id.Callbtn);
  2606. callbtn.setBackgroundResource(R.drawable.but_call);
  2607. MAIN_CALL_LOCK = false;
  2608. */
  2609. break;
  2610. case define.NOTIFY_UPDATECALLDATA:
  2611. try{
  2612. String[] UpdateCallData = intent.getStringExtra(define.NOTIBR_CONTENT).split(define.DEVCTR_CMD_SPLITER);
  2613. Log.i(APIErrorCode.GetLogPrefix(),"Receive NOTIFY_UPDATECALLDATA "+UpdateCallData[0]+";"+UpdateCallData[1]);
  2614. int IncallCnt = 0;
  2615. int VisitorCNT = 0;
  2616. try {
  2617. IncallCnt = Integer.parseInt(UpdateCallData[0]);
  2618. VisitorCNT = Integer.parseInt(UpdateCallData[1]);
  2619. } catch (RuntimeException re) {
  2620. LogUtil.errorLogInfo("", TAG, re);
  2621. }
  2622. catch (Exception e) {
  2623. LogUtil.errorLogInfo("", TAG, e);
  2624. }
  2625. } catch (RuntimeException re) {
  2626. LogUtil.errorLogInfo("", TAG, re);
  2627. }
  2628. catch (Exception e) {
  2629. LogUtil.errorLogInfo("", TAG, e);
  2630. }
  2631. break;
  2632. case define.NOTIFY_UPDATENOTICE:
  2633. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATENOTICE ");
  2634. try {
  2635. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2636. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2637. SetData.closeDB();
  2638. if (soundOut) {
  2639. Sound().PlayMent(SND.effect.EFFECT1);
  2640. }
  2641. mIOInterface.ctrlLcdWakeUp();
  2642. } catch (RuntimeException re) {
  2643. LogUtil.errorLogInfo("", TAG, re);
  2644. }
  2645. catch (Exception e) { LogUtil.errorLogInfo("", TAG, e);
  2646. }
  2647. break;
  2648. case define.NOTIFY_UPDATEPARCEL:
  2649. try {
  2650. String type = intent.getStringExtra(define.NOTIBR_CONTENT);
  2651. int itemcnt = intent.getIntExtra("ITEM",-1);
  2652. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2653. boolean soundOut = SetData.GetSoundOutputOfEventAlarm();
  2654. if (itemcnt !=-1) SetData.SetParcelCNT(itemcnt);
  2655. SetData.closeDB();
  2656. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPARCEL itemcnt : " + itemcnt);
  2657. // if (soundOut) {
  2658. // if (type.equals("parcel_in")) {
  2659. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2660. // pm.userActivity(1, true);
  2661. // Sound().PlayMent(SND.mode.BOX_ARRIVED);
  2662. // }
  2663. // }
  2664. Log.d(TAG, "Send BR --> Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL");
  2665. Intent Newintent = new Intent();
  2666. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2667. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.UI_UPDATE_PARCEL);
  2668. getApplicationContext().sendBroadcast(Newintent);
  2669. //NoticeIconOnoff(true);
  2670. } catch (RuntimeException re) {
  2671. LogUtil.errorLogInfo("", TAG, re);
  2672. }
  2673. catch (Exception e) {
  2674. LogUtil.errorLogInfo("", TAG, e);
  2675. }
  2676. // if (type.equals("parcel_in"))
  2677. // {
  2678. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2679. // pm.userActivity(1, true);
  2680. // PlayNotiSound(WpadSound.SND.mode.BOX_ARRIVED);
  2681. // }
  2682. //
  2683. // if (itemcnt!=-1){
  2684. // if (itemcnt > 0)
  2685. // ParcelIconOnoff(true);
  2686. // else
  2687. // ParcelIconOnoff(false);
  2688. // WallpadStatusData ParData = new WallpadStatusData(getApplicationContext());
  2689. // ParData.SetParcelCNT(itemcnt);
  2690. // ParData.closeDB();
  2691. // if (ParcelMGR!=null) ParcelMGR.updateParcel();
  2692. // }
  2693. break;
  2694. case define.NOTIFY_UPDATEPOST:
  2695. try {
  2696. int nItemCnt = intent.getIntExtra("ITEM",-1);
  2697. Log.d(TAG, "[UI_UPDATE_POST] nItemCnt [" + nItemCnt + "]");
  2698. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  2699. if (nItemCnt != -1) SetData.SetPostCNT(nItemCnt);
  2700. SetData.closeDB();
  2701. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPOST nItemCnt : " + nItemCnt);
  2702. Log.d(TAG, "Send BR --> Common.BR_MAIN_NOTI.UI_UPDATE_POST");
  2703. Intent Newintent = new Intent();
  2704. Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
  2705. Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.UI_UPDATE_POST);
  2706. getApplicationContext().sendBroadcast(Newintent);
  2707. } catch (RuntimeException re) {
  2708. LogUtil.errorLogInfo("", TAG, re);
  2709. }
  2710. catch (Exception e) {
  2711. Log.e(TAG, "[Exception] mWallPadNotifyBR.onReceive()");
  2712. LogUtil.errorLogInfo("", TAG, e);
  2713. }
  2714. break;
  2715. case define.NOTIFY_UPDATEPARKING:
  2716. Common.DebugLog("Main Activity Receive Br=== . define.NOTIFY_UPDATEPARKING ");
  2717. /*
  2718. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  2719. List<String[]> parkList = parkdb.GetParkInfo();
  2720. if(parkList != null)
  2721. {
  2722. for(int j= 0; j<parkList.size(); j++)
  2723. {
  2724. for(int i = 0; i<4; i++)
  2725. {
  2726. Common.DebugLog("parkList.get("+j+")["+i+"]:"+ parkList.get(j)[i]);
  2727. }
  2728. }
  2729. }
  2730. parkdb.closeDB();
  2731. */
  2732. break;
  2733. case define.NOTIFY_DEVICEREBOOT:
  2734. try {
  2735. //[Model]
  2736. // if (Version.getPlatformType() == Version.PLATFORM_TYPE.A20) {
  2737. // // A20
  2738. // PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
  2739. // pm.userActivity(8, true);
  2740. // }
  2741. // else if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  2742. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  2743. // V40
  2744. V40IOInterface mV40IOInterface = new V40IOInterface();
  2745. mV40IOInterface.setV40Reboot(5);
  2746. }
  2747. else {
  2748. // TCC8935
  2749. SendAppFinishReqBR();
  2750. ComponentName cnA = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  2751. intent = new Intent(Intent.ACTION_MAIN);
  2752. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  2753. intent.putExtra("updatesystem", "no");
  2754. intent.putExtra("updateapp", " no ");
  2755. intent.putExtra("rebootcmd", "reboot");
  2756. intent.setComponent(cnA);
  2757. startActivity(intent);
  2758. }
  2759. } catch (RuntimeException re) {
  2760. LogUtil.errorLogInfo("", TAG, re);
  2761. }
  2762. catch (Exception e) {
  2763. LogUtil.errorLogInfo("", TAG, e);
  2764. }
  2765. break;
  2766. case define.NOTIFY_DEVICEDEEPSLEEP:
  2767. try {
  2768. Log.d(TAG, "[mWallPadAlertBR] NOTIFY_DEVICEDEEPSLEEP");
  2769. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  2770. String[] getstate = sdb.GetSystemUpdateStatus();
  2771. for (int i = 0; i < getstate.length; i++) {
  2772. Log.d(TAG, "[mWallPadAlertBR] getstate[" + i + "] = " + getstate[i]);
  2773. }
  2774. if (getstate[0].equalsIgnoreCase("SET")) {
  2775. sdb.SetSystemUpdate(null, null);
  2776. sdb.SetUpgradeState(true);
  2777. ComponentName cnn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  2778. intent = new Intent(Intent.ACTION_MAIN);
  2779. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  2780. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  2781. intent.putExtra("updatesystem", getstate[1]);
  2782. intent.putExtra("updateapp", getstate[2]);
  2783. intent.setComponent(cnn);
  2784. Log.e("MAINSCREEN","Call Upgrade Request BSP : "+getstate[1]+" APP : "+getstate[2]);
  2785. startActivity(intent);
  2786. }
  2787. sdb.closeDB();
  2788. } catch (RuntimeException re) {
  2789. LogUtil.errorLogInfo("", TAG, re);
  2790. }
  2791. catch (Exception e) {
  2792. LogUtil.errorLogInfo("", TAG, e);
  2793. }
  2794. break;
  2795. case define.NOTIFY_SYSTEMTIMESETTED:
  2796. try {
  2797. Common.DebugLog("MainActivity ---------- > define.NOTIFY_SYSTEMTIMESETTED");
  2798. Calendar caldata = new GregorianCalendar();
  2799. // refreshdate(caldata);
  2800. // refreshclock(caldata);
  2801. if (SYSTEM_TIME_SET == false) {
  2802. SYSTEM_TIME_SET = true;
  2803. if (SCManager != null) {
  2804. if (SCManager.isSetted != true) SCManager.refreshSchedule();
  2805. }
  2806. }
  2807. } catch (RuntimeException re) {
  2808. LogUtil.errorLogInfo("", TAG, re);
  2809. }
  2810. catch (Exception e) {
  2811. LogUtil.errorLogInfo("", TAG, e);
  2812. }
  2813. break;
  2814. case define.NOTIFY_SCHEDULEUPDATED:
  2815. // item = intent.getIntExtra("ITEM",0);
  2816. // if (item == ScheduleManager.SCHEDULE_TYPE_SCHEDULER && SYSTEM_TIME_SET)
  2817. // SCManager.refreshSchedulerData();
  2818. // else if (item == ScheduleManager.SCHEDULE_TYPE_SYSRESET && SYSTEM_TIME_SET)
  2819. // SCManager.refreshsysreset();
  2820. // else if (item == ScheduleManager.SCHEDULE_TYPE_MORNINGCALL && SYSTEM_TIME_SET)
  2821. // SCManager.refreshMorningCall();
  2822. // break;
  2823. case define.NOTIFY_ALARMSTAUSCHANGED:
  2824. try {
  2825. item = intent.getIntExtra("ITEM",0);
  2826. if (item == WallpadStatusData.GUARD_OUT) {
  2827. int base = 8000;
  2828. int [] Menu_Id_List = { base+11};
  2829. int Menu_Start_Id = base+11;
  2830. int Menu_Start_Option = -1;
  2831. Intent iintent = new Intent(Intent.ACTION_MAIN);
  2832. iintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
  2833. iintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
  2834. iintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
  2835. iintent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun","kr.co.icontrols.wallpadoutmoderun.MainActivity"));
  2836. startActivity(iintent);
  2837. }
  2838. else if (item == WallpadStatusData.GUARD_IN) {
  2839. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  2840. // Button callBtn = (Button)findViewById(R.id.GuardBtn);
  2841. // callBtn.setBackgroundResource((SettData.GetAlarmStatus() == WallpadStatusData.GUARD_IN)?R.drawable.but_guard_on:R.drawable.but_guard);
  2842. SettData.closeDB();
  2843. }
  2844. } catch (RuntimeException re) {
  2845. LogUtil.errorLogInfo("", TAG, re);
  2846. }
  2847. catch (Exception e) {
  2848. LogUtil.errorLogInfo("", TAG, e);
  2849. }
  2850. break;
  2851. case define.NOTIFY_ENERGYUPDATE:
  2852. try
  2853. {
  2854. Calendar caldata = new GregorianCalendar();
  2855. String[] getData = intent.getStringExtra(define.NOTIBR_CONTENT).split(define.DEVCTR_CMD_SPLITER);
  2856. String checkDate = String.format("%04d%02d%02d",caldata.get(Calendar.YEAR),caldata.get(Calendar.MONTH)+1,caldata.get(Calendar.DAY_OF_MONTH));
  2857. WallpadStatusData energyData = new WallpadStatusData(getApplicationContext());
  2858. energyData.SetEnergyData(intent.getStringExtra(define.NOTIBR_CONTENT));
  2859. energyData.SetEnergyCheckDate(checkDate);
  2860. energyData.closeDB();
  2861. //if (NeedCheckEnergy)
  2862. // CheckEnergyUsage(getData);
  2863. // if (EnergyMGR!=null)
  2864. // EnergyMGR.UpdateData(getData);
  2865. }
  2866. catch (RuntimeException re) {
  2867. LogUtil.errorLogInfo("", TAG, re);
  2868. }
  2869. catch (Exception e )
  2870. {
  2871. LogUtil.errorLogInfo("", TAG, e);
  2872. }
  2873. break;
  2874. case define.NOTIFY_STARTEFRAME:
  2875. try
  2876. {
  2877. Log.w("MAINSCREEN"," Receive NOTIFY_STARTEFRAME Start StartAutoPictureAPP ");
  2878. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  2879. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar()))
  2880. {
  2881. if (!SettData.StartAutoPictureAPP())
  2882. {
  2883. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2884. // pm.userActivity(3, true);
  2885. }
  2886. }
  2887. else
  2888. {
  2889. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  2890. // pm.userActivity(3, true);
  2891. }
  2892. SettData.closeDB();
  2893. }
  2894. catch (RuntimeException re) {
  2895. LogUtil.errorLogInfo("", TAG, re);
  2896. }
  2897. catch (Exception e )
  2898. {
  2899. LogUtil.errorLogInfo("", TAG, e);
  2900. }
  2901. break;
  2902. case define.NOTIFY_ADDDEVICELOCK:
  2903. Log.w("MAINSCREEN"," Receive NOTIFY_ADDDEVICELOCK Start ");
  2904. //DevLockCtr.AddLock(intent.getIntExtra(define.NOTIBR_CONTENT, 0));
  2905. break;
  2906. case define.NOTIFY_RELEASEDEVICELOCK:
  2907. Log.w("MAINSCREEN"," Receive NOTIFY_RELEASEDEVICELOCK Start ");
  2908. //DevLockCtr.ReleaseLock(intent.getIntExtra(define.NOTIBR_CONTENT, 0));
  2909. break;
  2910. case define.NOTIFY_PLAYMENT:
  2911. {
  2912. int sndidx = intent.getIntExtra(define.NOTIBR_CONTENT,0);
  2913. Sound().PlayMent(sndidx);
  2914. if (sndidx == WpadSound.SND.elevator.CALL) {
  2915. byte floorInfo = intent.getByteExtra(define.NOTIBR_FLOOR,(byte)0);
  2916. Log.e("MANUAL_MAIN", " PLAY MENT Get Ele Call : "+floorInfo);
  2917. }
  2918. }
  2919. break;
  2920. case define.NOTIFY_ENERGY_DATA:
  2921. {
  2922. try
  2923. {
  2924. Log.w("MAINSCREEN"," Receive NOTIFY_ENERGY DATA Start ");
  2925. //에너지 데이터 개수 - 3종 또는 5종
  2926. EnergyAlramPopupMgr.m_EnergyInfoCount = intent.getIntExtra(Common.ENERGY_INTENT_ENERGY_COUNT, -1);
  2927. Log.w("MAINSCREEN"," ENERGY_INTENT_ENERGY_COUNT :"+ EnergyAlramPopupMgr.m_EnergyInfoCount);
  2928. //에너지 단지서버에서 받아온 시간
  2929. EnergyAlramPopupMgr.m_ReceiveYear = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_YEAR, -1);
  2930. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_YEAR :"+ EnergyAlramPopupMgr.m_ReceiveYear);
  2931. EnergyAlramPopupMgr.m_ReceiveMonth = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_MONTH, -1);
  2932. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_MONTH :"+ EnergyAlramPopupMgr.m_ReceiveMonth);
  2933. EnergyAlramPopupMgr.m_ReceiveDay = intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_DAY, -1);
  2934. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_DAY :"+ EnergyAlramPopupMgr.m_ReceiveDay );
  2935. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_HOUR :"+ intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_HOUR, -1));
  2936. Log.w("MAINSCREEN"," ENERGY_INTENT_GETDATA_TIME_MINUTE :"+ intent.getIntExtra(Common.ENERGY_INTENT_GETDATA_TIME_MINUTE, -1));
  2937. //전기 에너지 정보
  2938. String Vaule = "";
  2939. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_ELECTRIC);
  2940. if( Vaule != null && Vaule.length() > 0 )
  2941. EnergyAlramPopupMgr.m_Elec_UseValue = Double.parseDouble(Vaule);
  2942. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC);
  2943. if( Vaule != null && Vaule.length() > 0 )
  2944. EnergyAlramPopupMgr.m_Elec_GoalValue = Double.parseDouble(Vaule);
  2945. //수도 에너지 정보
  2946. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_WATER);
  2947. if( Vaule != null && Vaule.length() > 0 )
  2948. EnergyAlramPopupMgr.m_Water_UseValue = Double.parseDouble(Vaule);
  2949. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_WATER);
  2950. if( Vaule != null && Vaule.length() > 0 )
  2951. EnergyAlramPopupMgr.m_Water_GoalValue = Double.parseDouble(Vaule);
  2952. //가스 에너지 정보
  2953. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_GAS);
  2954. if( Vaule != null && Vaule.length() > 0 )
  2955. EnergyAlramPopupMgr.m_Gas_UseValue = Double.parseDouble(Vaule);
  2956. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_GAS);
  2957. if( Vaule != null && Vaule.length() > 0 )
  2958. EnergyAlramPopupMgr.m_Gas_GoalValue = Double.parseDouble(Vaule);
  2959. //온수 에너지 정보
  2960. if( EnergyAlramPopupMgr.m_EnergyInfoCount >= 5 )
  2961. {
  2962. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_HOTWATER);
  2963. if( Vaule != null && Vaule.length() > 0 )
  2964. EnergyAlramPopupMgr.m_HotWater_UseValue = Double.parseDouble(Vaule);
  2965. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_HOTWATER);
  2966. if( Vaule != null && Vaule.length() > 0 )
  2967. EnergyAlramPopupMgr.m_HotWater_GoalValue = Double.parseDouble(Vaule);
  2968. //난방 에너지 정보
  2969. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_USE_HEATING);
  2970. if( Vaule != null && Vaule.length() > 0 )
  2971. EnergyAlramPopupMgr.m_Heating_UseValue = Double.parseDouble(Vaule);
  2972. Vaule = intent.getStringExtra(Common.ENERGY_INTENT_GOAL_HEATING);
  2973. if( Vaule != null && Vaule.length() > 0 )
  2974. EnergyAlramPopupMgr.m_Heating_GoalValue = Double.parseDouble(Vaule);
  2975. }
  2976. }
  2977. catch (RuntimeException re) {
  2978. LogUtil.errorLogInfo("", TAG, re);
  2979. }
  2980. catch (Exception e )
  2981. {
  2982. LogUtil.errorLogInfo("", TAG, e);
  2983. }
  2984. }
  2985. break;
  2986. case define.NOTIFY_GET_CAR_PARKING:
  2987. try
  2988. {
  2989. if(bUseofNot_ParkingInfo == true)
  2990. {
  2991. bSetMSG_GetParkingInfo = true;
  2992. LoadParkingDataFromServer();
  2993. }
  2994. else
  2995. {
  2996. DebugLogOutput("bUseofNot_ParkingInfo == false");
  2997. }
  2998. }
  2999. catch (RuntimeException re) {
  3000. LogUtil.errorLogInfo("", TAG, re);
  3001. }
  3002. catch (Exception e )
  3003. {
  3004. LogUtil.errorLogInfo("", TAG, e);
  3005. }
  3006. break;
  3007. case define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER:
  3008. String tempFromWhere = intent.getStringExtra("FromWhere");
  3009. if(tempFromWhere == null)
  3010. {
  3011. ResultGetIntent = true;
  3012. }
  3013. String tempElect_target = intent.getStringExtra("elect_target");
  3014. if(tempElect_target != null)
  3015. {
  3016. elect_target = tempElect_target;
  3017. }
  3018. String tempElect_used = intent.getStringExtra("elect_used");
  3019. if(tempElect_used != null)
  3020. {
  3021. elect_used = tempElect_used;
  3022. }
  3023. String tempElect_info = intent.getStringExtra("elect_info");
  3024. if(tempElect_info != null)
  3025. {
  3026. elect_info = tempElect_info;
  3027. }
  3028. String tempWater_target = intent.getStringExtra("water_target");
  3029. if(tempWater_target != null)
  3030. {
  3031. water_target = tempWater_target;
  3032. }
  3033. String tempWater_used = intent.getStringExtra("water_used");
  3034. if(tempWater_used != null)
  3035. {
  3036. water_used = tempWater_used;
  3037. }
  3038. String tempWater_info = intent.getStringExtra("water_info");
  3039. if(tempWater_info != null)
  3040. {
  3041. water_info = tempWater_info;
  3042. }
  3043. String tempGas_target = intent.getStringExtra("gas_target");
  3044. if(tempGas_target != null)
  3045. {
  3046. gas_target = tempGas_target;
  3047. }
  3048. String tempGas_used = intent.getStringExtra("gas_used");
  3049. if(tempGas_used != null)
  3050. {
  3051. gas_used = tempGas_used;
  3052. }
  3053. String tempGas_info = intent.getStringExtra("gas_info");
  3054. if(tempGas_info != null)
  3055. {
  3056. gas_info = tempGas_info;
  3057. }
  3058. String tempHotwater_target = intent.getStringExtra("hotwater_target");
  3059. if(tempHotwater_target != null)
  3060. {
  3061. hotwater_target = tempHotwater_target;
  3062. }
  3063. String tempHotwater_used = intent.getStringExtra("hotwater_used");
  3064. if(tempHotwater_used != null)
  3065. {
  3066. hotwater_used = tempHotwater_used;
  3067. }
  3068. String tempHotwater_info = intent.getStringExtra("hotwater_info");
  3069. if(tempHotwater_info != null)
  3070. {
  3071. hotwater_info = tempHotwater_info;
  3072. }
  3073. String tempHeating_target = intent.getStringExtra("heating_target");
  3074. if(tempHeating_target != null)
  3075. {
  3076. heating_target = tempHeating_target;
  3077. }
  3078. String tempHeating_used = intent.getStringExtra("heating_used");
  3079. if(tempHeating_used != null)
  3080. {
  3081. heating_used = tempHeating_used;
  3082. }
  3083. String tempHeatin_info = intent.getStringExtra("heating_info");
  3084. if(tempHeatin_info != null)
  3085. {
  3086. heating_info = tempHeatin_info;
  3087. }
  3088. break;
  3089. }
  3090. }
  3091. };
  3092. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3093. private void ctrlLCDOnOff(boolean bOn) {
  3094. try {
  3095. if (bOn) {
  3096. PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  3097. Log.d(TAG, "[ctrlLCDOnOff] Screen On: " + pm.isScreenOn());
  3098. if (getCompareBSPVersion()) {
  3099. if (!checkLCDOnByCMD()) {
  3100. Log.d(TAG, "[ctrlLCDOnOff] V40Interface LcdWakeUp Call!!");
  3101. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  3102. }
  3103. }
  3104. else {
  3105. if (!pm.isScreenOn()) {
  3106. Log.d(TAG, "[ctrlLCDOnOff] V40Interface LcdWakeUp Call!!");
  3107. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  3108. }
  3109. }
  3110. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3111. } else
  3112. getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3113. } catch (RuntimeException re) {
  3114. LogUtil.errorLogInfo("", TAG, re);
  3115. }
  3116. catch (Exception e) {
  3117. Log.e(TAG, "[Exception] ctrlLCDOnOff(boolean bOn)");
  3118. LogUtil.errorLogInfo("", TAG, e);
  3119. }
  3120. }
  3121. protected void refreshUserCtr() {
  3122. Intent intent = new Intent();
  3123. intent.setAction(define.DRIVER_LIGHT_BR);
  3124. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_LIGHT_BR);
  3125. sendBroadcast(intent);
  3126. intent = new Intent();
  3127. intent.setAction(define.DRIVER_BATCHLIGHT_BR);
  3128. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_BATCHLIGHT_BR);
  3129. sendBroadcast(intent);
  3130. intent = new Intent();
  3131. intent.setAction(define.DRIVER_VENTIL_BR);
  3132. Log.i("HIGH","StatusChanged BR Send "+define.DRIVER_VENTIL_BR);
  3133. sendBroadcast(intent);
  3134. // intent = new Intent();
  3135. // intent.setAction(HEATERBR);
  3136. // Log.i("HIGH","StatusChanged BR Send "+HEATERBR);
  3137. // sendBroadcast(intent);
  3138. }
  3139. private void Check_Upgrade_File() {
  3140. try {
  3141. WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
  3142. String[] getstate = sdb.GetSystemUpdateStatus();
  3143. if (getstate[0].equalsIgnoreCase("SET")) {
  3144. for (int i = 1; i < 3; i++) {
  3145. if (!getstate[i].equals("no")) {
  3146. String filePath = "/sdcard/"+getstate[i];
  3147. File updradef = new File(filePath);
  3148. if (updradef.exists()) FileDelete(updradef);//.delete();
  3149. }
  3150. }
  3151. sdb.SetSystemUpdate(null, null);
  3152. }
  3153. sdb.closeDB();
  3154. } catch (RuntimeException re) {
  3155. LogUtil.errorLogInfo("", TAG, re);
  3156. }
  3157. catch (Exception e) {
  3158. Log.e(TAG, "[Exception] Check_Upgrade_File()");
  3159. LogUtil.errorLogInfo("", TAG, e);
  3160. }
  3161. }
  3162. protected void SendAppFinishReqBR() {
  3163. try {
  3164. Log.e("MANUAL_MAIN", "Send Finish BR");
  3165. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  3166. // pm.userActivity(1, true);
  3167. // LCD Always ON
  3168. getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  3169. Intent notiIntent = new Intent();
  3170. notiIntent.setAction(define.BR_APP_FINISH);
  3171. getApplicationContext().sendBroadcast(notiIntent);
  3172. } catch (RuntimeException re) {
  3173. LogUtil.errorLogInfo("", TAG, re);
  3174. }
  3175. catch (Exception e) {
  3176. Log.e(TAG, "[Exception] SendAppFinishReqBR()");
  3177. LogUtil.errorLogInfo("", TAG, e);
  3178. }
  3179. }
  3180. private void registerBroadcastReceiver() {
  3181. try {
  3182. IntentFilter mIntentFilter = new IntentFilter();
  3183. mIntentFilter.addAction("WALLPAD_ALERT");
  3184. registerReceiver(mWallPadAlertBR, mIntentFilter);
  3185. mIntentFilter = new IntentFilter();
  3186. mIntentFilter.addAction("WALLPAD_NOTIFY");
  3187. mIntentFilter.addAction(define.DRIVER_VENTIL_BR);
  3188. mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI); // ACC 꺼와 구분되는 Noti 추가
  3189. mIntentFilter.addAction(BR_MAIN_LIVE_CHECKER.ACNAME_MAIN_LIVE_CHECKER);
  3190. mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
  3191. registerReceiver(mWallPadNotifyBR, mIntentFilter);
  3192. registerMainActivityBR();
  3193. registerStrangeRecordBR();
  3194. } catch (RuntimeException re) {
  3195. LogUtil.errorLogInfo("", TAG, re);
  3196. }
  3197. catch (Exception e) {
  3198. Log.e(TAG, "[Exception] registerBroadcastReceiver()");
  3199. LogUtil.errorLogInfo("", TAG, e);
  3200. }
  3201. }
  3202. private void unregisterBroadcastReceiver() {
  3203. try {
  3204. unregisterReceiver(mWallPadAlertBR);
  3205. unregisterReceiver(mWallPadNotifyBR);
  3206. unregisterReceiver(MainActivityBroadcastReceiver);
  3207. //거동수상자 관련 리시버 해제
  3208. unregisterReceiver(StrangeRecordBroadcastReceiver);
  3209. } catch (RuntimeException re) {
  3210. LogUtil.errorLogInfo("", TAG, re);
  3211. }
  3212. catch (Exception e) {
  3213. Log.e(TAG, "[Exception] unregisterBroadcastReceiver()");
  3214. LogUtil.errorLogInfo("", TAG, e);
  3215. }
  3216. }
  3217. private void MainScrLog(String msg) {
  3218. Log.e("MAINSCREEN",APIErrorCode.GetLogPrefix()+msg);
  3219. }
  3220. protected void CheckEnv() {
  3221. try {
  3222. File dnDIC = new File(BESTIN_LOCATION);
  3223. if (!dnDIC.exists()) dnDIC.mkdir();
  3224. dnDIC = new File(ALBUM_PICTURE_LOCATION);
  3225. if (!dnDIC.exists()) dnDIC.mkdir();
  3226. } catch (RuntimeException re) {
  3227. LogUtil.errorLogInfo("", TAG, re);
  3228. }
  3229. catch (Exception e) {
  3230. Log.e(TAG, "[Exception] CheckEnv()");
  3231. LogUtil.errorLogInfo("", TAG, e);
  3232. }
  3233. }
  3234. public void FileCopy(String Target, String Source) {
  3235. FileInputStream input = null;
  3236. FileOutputStream output = null;
  3237. try {
  3238. input = new FileInputStream(Source);
  3239. long size = input.available();
  3240. byte buff[] = new byte[(int)size];
  3241. input.read(buff);
  3242. output = new FileOutputStream(Target);
  3243. output.write(buff);
  3244. output.flush();
  3245. } catch (RuntimeException re) {
  3246. LogUtil.errorLogInfo("", TAG, re);
  3247. }
  3248. catch (Exception e ) {
  3249. Log.e(TAG, "[Exception] FileCopy(String Target, String Source)");
  3250. LogUtil.errorLogInfo("", TAG, e);
  3251. }
  3252. finally {
  3253. if(input!=null) {
  3254. try {
  3255. input.close( );
  3256. } catch (IOException e) {
  3257. LogUtil.errorLogInfo("", TAG, e);
  3258. }
  3259. }
  3260. input = null;
  3261. if(output!=null) {
  3262. try {
  3263. output.close();
  3264. } catch (IOException e) {
  3265. LogUtil.errorLogInfo("", TAG, e);
  3266. }
  3267. }
  3268. output = null;
  3269. }
  3270. }
  3271. public void checkEventNotifications() {
  3272. try {
  3273. Log.d(TAG,"[checkEventNotifications] ========== START ==========)");
  3274. // 스마트우편함, 전기차충전 연동 여부 확인
  3275. int nRetElecVehicle = -1;
  3276. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this.getContext());
  3277. bSmartPostUsage = mWallpadDeviceSet.Get_SmartPostUse();
  3278. nRetElecVehicle = mWallpadDeviceSet.GetDeviceSetted("전기차충전");
  3279. mWallpadDeviceSet.closeDB();
  3280. if (nRetElecVehicle == WallpadDeviceSet.DEV_DATA_ENABLE) bElecVehicleUsage = true;
  3281. else bElecVehicleUsage = false;
  3282. Log.d(TAG, "[checkEventNotifications] bSmartPostUsage [" + bSmartPostUsage + "], nRetElecVehicle [" + nRetElecVehicle + "], bElecVehicleUsage [" + bElecVehicleUsage + "]");
  3283. // 부재중 통화
  3284. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3285. try {
  3286. nMissedCallCnt = mWallpadCallHistoryData.RowCallHistoryCountData();
  3287. } catch (RuntimeException re) {
  3288. LogUtil.errorLogInfo("", TAG, re);
  3289. }
  3290. catch (Exception e) {
  3291. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadCallHistoryData");
  3292. LogUtil.errorLogInfo("", TAG, e);
  3293. }
  3294. mWallpadCallHistoryData.closeDB();
  3295. // 방문자 사진
  3296. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3297. try {
  3298. nVisitorPicCnt = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3299. } catch (RuntimeException re) {
  3300. LogUtil.errorLogInfo("", TAG, re);
  3301. }
  3302. catch (Exception e) {
  3303. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadVisitorPicData_A20");
  3304. LogUtil.errorLogInfo("", TAG, e);
  3305. }
  3306. mWallpadVisitorPicData_A20.closeDB();
  3307. // 공지사항, 택배, 스마트 우편
  3308. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  3309. try {
  3310. nNoticeCnt = mWallpadStatusData.GetNoticeCNT();
  3311. nParcelCnt = mWallpadStatusData.GetParcelCNT();
  3312. nPostCnt = mWallpadStatusData.GetPostCNT();
  3313. } catch (RuntimeException re) {
  3314. LogUtil.errorLogInfo("", TAG, re);
  3315. }
  3316. catch (Exception e) {
  3317. Log.e(TAG, "[Exception] checkEventNotifications() -> mWallpadStatusData");
  3318. LogUtil.errorLogInfo("", TAG, e);
  3319. }
  3320. mWallpadStatusData.closeDB();
  3321. if (0 > nMissedCallCnt) {
  3322. Log.w(TAG,"[checkEventNotifications] out of range!! nMissedCallCnt [" + nMissedCallCnt + "]");
  3323. nMissedCallCnt = 0;
  3324. }
  3325. if (0 > nVisitorPicCnt) {
  3326. Log.w(TAG,"[checkEventNotifications] out of range!! nVisitorPicCnt [" + nVisitorPicCnt + "]");
  3327. nVisitorPicCnt = 0;
  3328. }
  3329. if (0 > nNoticeCnt) {
  3330. Log.w(TAG,"[checkEventNotifications] out of range!! nNoticeCnt [" + nNoticeCnt + "]");
  3331. nNoticeCnt = 0;
  3332. }
  3333. if (0 > nParcelCnt) {
  3334. Log.w(TAG,"[checkEventNotifications] out of range!! nParcelCnt [" + nParcelCnt + "]");
  3335. nParcelCnt = 0;
  3336. }
  3337. if (0 > nPostCnt) {
  3338. Log.w(TAG,"[checkEventNotifications] out of range!! nPostCnt [" + nPostCnt + "]");
  3339. nPostCnt = 0;
  3340. }
  3341. if (0 > nElecVehicleChangingCnt) {
  3342. Log.w(TAG,"[checkEventNotifications] out of range!! nElecVehicleChangingCnt [" + nElecVehicleChangingCnt + "]");
  3343. nElecVehicleChangingCnt = 0;
  3344. }
  3345. if (!bSmartPostUsage) {
  3346. Log.w(TAG,"[checkEventNotifications] bSmartPostUsage is not supported!! -> bSmartPostUsage [" + bSmartPostUsage + "]");
  3347. nPostCnt = 0;
  3348. }
  3349. if (!bElecVehicleUsage) {
  3350. Log.w(TAG,"[checkEventNotifications] bElecVehicleUsage is not supported!! -> bElecVehicleUsage [" + bElecVehicleUsage + "]");
  3351. nElecVehicleChangingCnt = 0;
  3352. }
  3353. Log.d(TAG,"[checkEventNotifications] nMissedCallCnt [" + nMissedCallCnt + "], nVisitorPicCnt [" + nVisitorPicCnt + "], nNoticeCnt [" + nNoticeCnt + "], nParcelCnt [" + nParcelCnt + "], nPostCnt [" + nPostCnt + "], nElecVehicleChangingCnt [" + nElecVehicleChangingCnt + "]");
  3354. sendEventNotiBR(nMissedCallCnt, nVisitorPicCnt, nNoticeCnt, nParcelCnt, nPostCnt, nElecVehicleChangingCnt);
  3355. Send_NotiSmartSwitch(MainActivity.nNoticeCnt, MainActivity.nParcelCnt, MainActivity.nVisitorPicCnt);
  3356. } catch (RuntimeException re) {
  3357. LogUtil.errorLogInfo("", TAG, re);
  3358. }
  3359. catch (Exception e) {
  3360. Log.e(TAG, "[Exception] checkEventNotifications()");
  3361. LogUtil.errorLogInfo("", TAG, e);
  3362. }
  3363. }
  3364. public String getEventNotificationInfo() {
  3365. try {
  3366. Log.d(TAG,"[getEventNotificationInfo] ========== START ==========)");
  3367. // 부재중 통화, 방문자 사진, 공지사항, 택배
  3368. int nMissedCallCnt = 0, nVisitorPicCnt = 0, nNoticeCnt = 0, nParcelCnt = 0, nPostCnt = 0;
  3369. // 부재중 통화
  3370. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3371. try {
  3372. nMissedCallCnt = mWallpadCallHistoryData.RowCallHistoryCountData();
  3373. } catch (RuntimeException re) {
  3374. LogUtil.errorLogInfo("", TAG, re);
  3375. }
  3376. catch (Exception e) {
  3377. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadCallHistoryData");
  3378. LogUtil.errorLogInfo("", TAG, e);
  3379. }
  3380. mWallpadCallHistoryData.closeDB();
  3381. // 방문자 사진
  3382. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3383. try {
  3384. nVisitorPicCnt = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3385. } catch (RuntimeException re) {
  3386. LogUtil.errorLogInfo("", TAG, re);
  3387. }
  3388. catch (Exception e) {
  3389. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadVisitorPicData_A20");
  3390. LogUtil.errorLogInfo("", TAG, e);
  3391. }
  3392. mWallpadVisitorPicData_A20.closeDB();
  3393. // 공지사항, 택배
  3394. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this.getContext());
  3395. try {
  3396. nNoticeCnt = mWallpadStatusData.GetNoticeCNT();
  3397. nParcelCnt = mWallpadStatusData.GetParcelCNT();
  3398. nPostCnt = mWallpadStatusData.GetPostCNT();
  3399. } catch (RuntimeException re) {
  3400. LogUtil.errorLogInfo("", TAG, re);
  3401. }
  3402. catch (Exception e) {
  3403. Log.e(TAG, "[Exception] getEventNotificationInfo() -> mWallpadStatusData");
  3404. LogUtil.errorLogInfo("", TAG, e);
  3405. }
  3406. mWallpadStatusData.closeDB();
  3407. if (0 > nMissedCallCnt) {
  3408. Log.w(TAG,"[getEventNotificationInfo] out of range!! nMissedCallCnt [" + nMissedCallCnt + "]");
  3409. nMissedCallCnt = 0;
  3410. }
  3411. if (0 > nVisitorPicCnt) {
  3412. Log.w(TAG,"[getEventNotificationInfo] out of range!! nVisitorPicCnt [" + nVisitorPicCnt + "]");
  3413. nVisitorPicCnt = 0;
  3414. }
  3415. if (0 > nNoticeCnt) {
  3416. Log.w(TAG,"[getEventNotificationInfo] out of range!! nNoticeCnt [" + nNoticeCnt + "]");
  3417. nNoticeCnt = 0;
  3418. }
  3419. if (0 > nParcelCnt) {
  3420. Log.w(TAG,"[getEventNotificationInfo] out of range!! nParcelCnt [" + nParcelCnt + "]");
  3421. nParcelCnt = 0;
  3422. }
  3423. if (0 > nPostCnt) {
  3424. Log.w(TAG,"[getEventNotificationInfo] out of range!! nPostCnt [" + nPostCnt + "]");
  3425. nPostCnt = 0;
  3426. }
  3427. Log.d(TAG,"[getEventNotificationInfo] nMissedCallCnt [" + nMissedCallCnt + "], nVisitorPicCnt [" + nVisitorPicCnt + "], nNoticeCnt [" + nNoticeCnt + "], nParcelCnt [" + nParcelCnt + "], nPostCnt [" + nPostCnt + "]");
  3428. if (bSmartPostUsage) return nMissedCallCnt + define.DEVCTR_CMD_SPLITER + nVisitorPicCnt + define.DEVCTR_CMD_SPLITER + nNoticeCnt + define.DEVCTR_CMD_SPLITER + nParcelCnt + define.DEVCTR_CMD_SPLITER + nPostCnt;
  3429. else return nMissedCallCnt + define.DEVCTR_CMD_SPLITER + nVisitorPicCnt + define.DEVCTR_CMD_SPLITER + nNoticeCnt + define.DEVCTR_CMD_SPLITER + nParcelCnt;
  3430. } catch (RuntimeException re) {
  3431. LogUtil.errorLogInfo("", TAG, re);
  3432. return null;
  3433. }
  3434. catch (Exception e) {
  3435. Log.e(TAG, "[Exception] getEventNotificationInfo()");
  3436. LogUtil.errorLogInfo("", TAG, e);
  3437. return null;
  3438. }
  3439. }
  3440. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel) {
  3441. try {
  3442. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "]");
  3443. 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);
  3444. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3445. Intent mIntent = new Intent();
  3446. mIntent.setAction(define.NOTIFY_ACNAME);
  3447. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3448. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3449. getApplicationContext().sendBroadcast(mIntent);
  3450. } catch (RuntimeException re) {
  3451. LogUtil.errorLogInfo("", TAG, re);
  3452. }
  3453. catch (Exception e) {
  3454. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel)");
  3455. LogUtil.errorLogInfo("", TAG, e);
  3456. }
  3457. }
  3458. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post) {
  3459. try {
  3460. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "], post [" + post + "]");
  3461. 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);
  3462. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3463. Intent mIntent = new Intent();
  3464. mIntent.setAction(define.NOTIFY_ACNAME);
  3465. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3466. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3467. getApplicationContext().sendBroadcast(mIntent);
  3468. } catch (RuntimeException re) {
  3469. LogUtil.errorLogInfo("", TAG, re);
  3470. }
  3471. catch (Exception e) {
  3472. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post)");
  3473. LogUtil.errorLogInfo("", TAG, e);
  3474. }
  3475. }
  3476. private void sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post, int elecvehiclecharging) {
  3477. try {
  3478. Log.d(TAG,"[sendEventNotiBR] missedcall [" + missedcall + "], visitorpic [" + visitorpic + "], notice [" + notice + "], parcel [" + parcel + "], post [" + post + "], elecvehiclecharging [" + elecvehiclecharging +"]");
  3479. String strResult = String.valueOf(missedcall) + define.DEVCTR_CMD_SPLITER + String.valueOf(visitorpic) + define.DEVCTR_CMD_SPLITER + String.valueOf(notice)
  3480. + define.DEVCTR_CMD_SPLITER + String.valueOf(parcel) + define.DEVCTR_CMD_SPLITER + String.valueOf(post) + define.DEVCTR_CMD_SPLITER + String.valueOf(elecvehiclecharging);
  3481. Log.d(TAG,"[sendEventNotiBR] strResult [" + strResult + "]");
  3482. Intent mIntent = new Intent();
  3483. mIntent.setAction(define.NOTIFY_ACNAME);
  3484. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3485. mIntent.putExtra(define.NOTIBR_CONTENT, strResult);
  3486. getApplicationContext().sendBroadcast(mIntent);
  3487. } catch (RuntimeException re) {
  3488. LogUtil.errorLogInfo("", TAG, re);
  3489. }
  3490. catch (Exception e) {
  3491. Log.e(TAG, "[Exception] sendEventNotiBR(int missedcall, int visitorpic, int notice, int parcel, int post, int elecvehiclecharging)");
  3492. LogUtil.errorLogInfo("", TAG, e);
  3493. }
  3494. }
  3495. private void CheckCallData_CalledCountAndVisitorCount() {
  3496. try {
  3497. int Vcount = 0;
  3498. int Ccount = 0;
  3499. try {
  3500. //DB정보 읽어서 처리
  3501. Log.d(TAG,"CheckCallData_CalledCountAndVisitorCount Start");
  3502. WallpadCallHistoryData mWallpadCallHistoryData = new WallpadCallHistoryData(getContext());
  3503. int TempCcount = mWallpadCallHistoryData.RowCallHistoryCountData();
  3504. mWallpadCallHistoryData.closeDB();
  3505. Log.d(TAG,"RowCallHistoryCountData() :" + TempCcount);
  3506. if (TempCcount != -999) {
  3507. Ccount = TempCcount;
  3508. }
  3509. WallpadVisitorPicData_A20 mWallpadVisitorPicData_A20 = new WallpadVisitorPicData_A20(getContext());
  3510. int TempVcount = mWallpadVisitorPicData_A20.RowVisitorPictureCountData();
  3511. mWallpadVisitorPicData_A20.closeDB();
  3512. Log.d(TAG,"RowVisitorPictureCountData() :" + TempVcount);
  3513. if (TempVcount != -999) {
  3514. Vcount = TempVcount;
  3515. }
  3516. } catch (RuntimeException re) {
  3517. LogUtil.errorLogInfo("", TAG, re);
  3518. }
  3519. catch (Exception e) {
  3520. LogUtil.errorLogInfo("", TAG, e);
  3521. }
  3522. Log.d(TAG," Call Count Check Receive Ccount :" + Ccount + " , Photo Count : " + Vcount );
  3523. String Retdata = String.valueOf(Ccount)+define.DEVCTR_CMD_SPLITER+String.valueOf(Vcount);
  3524. Intent intent = new Intent();
  3525. intent.setAction(define.NOTIFY_ACNAME);
  3526. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATECALLDATA);
  3527. intent.putExtra(define.NOTIBR_CONTENT, Retdata);
  3528. getApplicationContext().sendBroadcast(intent);
  3529. } catch (RuntimeException re) {
  3530. LogUtil.errorLogInfo("", TAG, re);
  3531. }
  3532. catch (Exception e) {
  3533. Log.e(TAG, "[Exception] CheckCallData_CalledCountAndVisitorCount()");
  3534. LogUtil.errorLogInfo("", TAG, e);
  3535. }
  3536. }
  3537. class ScheduleManager {
  3538. public static final int SCHEDULE_TYPE_GETINFO = 5000;
  3539. public static final int SCHEDULE_TYPE_MORNINGCALL = 5001;
  3540. public static final int SCHEDULE_TYPE_SCHEDULER = 5002;
  3541. public static final int SCHEDULE_TYPE_SYSRESET = 5003;
  3542. public static final int SCHEDULE_TYPE_NONE = 5004;
  3543. public boolean isSetted = false;
  3544. List<TimeScheduleUnit> SchedulerData = new ArrayList<TimeScheduleUnit>();
  3545. List<TimeScheduleUnit> GeneralData = new ArrayList<TimeScheduleUnit>();
  3546. public ScheduleManager() {
  3547. }
  3548. public class TimeScheduleUnit {
  3549. int type;
  3550. Calendar TimeSet;
  3551. String message;
  3552. TimeScheduleUnit(int sctype, Calendar target) {
  3553. type = sctype;
  3554. TimeSet = target;
  3555. }
  3556. TimeScheduleUnit(int sctype, Calendar target, String msg) {
  3557. Log.i("MAINSCREEN","TimeScheduleUnit Create "+sctype+" : MSG : "+msg);
  3558. type = sctype;
  3559. TimeSet = target;
  3560. message = msg;
  3561. }
  3562. public boolean isOver() {
  3563. Calendar cal_now = new GregorianCalendar();
  3564. if (cal_now.after(TimeSet)) {
  3565. return true;
  3566. }
  3567. return false;
  3568. }
  3569. }
  3570. private void CheckSysResetData() {
  3571. try {
  3572. Calendar today = new GregorianCalendar();
  3573. Log.i("MAINSCREEN","CheckSysResetData Schedule");
  3574. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3575. String[] ResetData = WsDB.GetResetSchedule();
  3576. if (!ResetData[0].equals("NONE")) {
  3577. int type = Integer.parseInt(ResetData[0]);
  3578. Log.i("MAINSCREEN","CheckSysResetData Schedule check typr : "+type + " Week : "+today.get(Calendar.DAY_OF_WEEK)+" Set Week : "+ResetData[1]);
  3579. if ((type == WallpadStatusData.RESET_MONTH && today.get(Calendar.DAY_OF_MONTH)+1 == Integer.parseInt(ResetData[1])) ||
  3580. (type == WallpadStatusData.RESET_WEEK && today.get(Calendar.DAY_OF_WEEK) == (Integer.parseInt(ResetData[1]))+1) )
  3581. {
  3582. if (today.get(Calendar.HOUR_OF_DAY) == Integer.parseInt(ResetData[2]) && today.get(Calendar.MINUTE) < 2) {
  3583. SendAppFinishReqBR();
  3584. ComponentName cn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  3585. Intent intent = new Intent(Intent.ACTION_MAIN);
  3586. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  3587. intent.putExtra("updatesystem", "no");
  3588. intent.putExtra("updateapp", " no ");
  3589. intent.putExtra("rebootcmd", "reboot");
  3590. intent.setComponent(cn);
  3591. startActivity(intent);
  3592. }
  3593. }
  3594. }
  3595. WsDB.closeDB();
  3596. } catch (RuntimeException re) {
  3597. LogUtil.errorLogInfo("", TAG, re);
  3598. }
  3599. catch (Exception e) {
  3600. Log.e(TAG, "[Exception] CheckSysResetData()");
  3601. LogUtil.errorLogInfo("", TAG, e);
  3602. }
  3603. }
  3604. private boolean checkMorningCall() {
  3605. try {
  3606. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3607. int AlarmStatus = WsDB.GetAlarmStatus();
  3608. if (AlarmStatus != WallpadStatusData.ALARM_NONE && AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.ALARM_STOP) {
  3609. WsDB.closeDB();
  3610. return false;
  3611. }
  3612. Calendar today = new GregorianCalendar();
  3613. int MCStatus = WsDB.GetMorningCallStatus();
  3614. Log.i(TAG,"[checkMorningCall] GetMorningCallStatus : "+MCStatus);
  3615. if (MCStatus==WallpadStatusData.MORNINGCALL_ON) {
  3616. int MCPer = WsDB.GetMorningCallPeriod();
  3617. Log.i(TAG,"[checkMorningCall] GetMorningCallPeriod : "+MCPer);
  3618. int TodatofWeek = today.get(Calendar.DAY_OF_WEEK);
  3619. if ((MCPer == WallpadStatusData.MORNINGCALL_EWORKDAY && TodatofWeek != Calendar.SUNDAY) ||
  3620. (MCPer == WallpadStatusData.MORNINGCALL_WORKDAY && TodatofWeek!=Calendar.SUNDAY && TodatofWeek != Calendar.SATURDAY) ||
  3621. (MCPer == WallpadStatusData.MORNINGCALL_ONCE || MCPer == WallpadStatusData.MORNINGCALL_EVERYDAY )) {
  3622. Log.i(TAG,"[checkMorningCall] "+today.get(Calendar.HOUR_OF_DAY)+";"+WsDB.MorningHour + " -- " +today.get(Calendar.MINUTE)+":"+WsDB.MorningMin);
  3623. if (today.get(Calendar.HOUR_OF_DAY) == WsDB.MorningHour && today.get(Calendar.MINUTE) == WsDB.MorningMin) {
  3624. SendAppFinishReqBR();
  3625. mIOInterface.ctrlLcdWakeUp();
  3626. StartPopup(ID.POPUPS.POPUP_MORNINGCALL);
  3627. int[] MC_Doing = WsDB.GetMorningCallReserve();
  3628. if (MC_Doing != null && MC_Doing.length > 0) {
  3629. for (int k=0;k<MC_Doing.length;k++) {
  3630. switch (MC_Doing[k]) {
  3631. case WallpadStatusData.MCALLR_VENTIL_ON:
  3632. mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
  3633. break;
  3634. case WallpadStatusData.MCALLR_LIGHT_ON:
  3635. //에너지 미터인 경우 안방 조명을 켜도록 하고
  3636. //에너지 미터가 안 달린 경우 거실 조명을 켜도록 한다
  3637. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
  3638. || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
  3639. || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  3640. // 안방조명에 1번 조명만 제어하도록 한다
  3641. // 모닝콜이 울리면 일괄소등시나리오에 의해 일괄소등이 해제가 되겠네 ? 음.....이건 아닌데
  3642. // 모닝콜이 울리는 동안만 켜고 끄자 일괄소등 시나리오를 해제할까나? 그러면 팝업 화면에서 제어처리를?
  3643. Log.d(TAG, "[checkMorningCall] mSdbAPI Room 2 - Lamp 1 On");
  3644. if (mSdbAPI != null) {
  3645. int nResult = mSdbAPI.SetLightOnOff((byte) 0x01, (byte) 0x00, true);
  3646. Log.d(TAG, "[checkMorningCall] mSdbAPI nResult = " + nResult);
  3647. }
  3648. }
  3649. else if (Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  3650. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410) {
  3651. Log.d(TAG, "[checkMorningCall] mIntLightAPI Living Room - Lamp 1 On");
  3652. if (mIntLightAPI != null) {
  3653. int nResult = mIntLightAPI.LightControl((byte) 0x01, true);
  3654. Log.d(TAG, "[checkMorningCall] mIntLightAPI nResult = " + nResult);
  3655. }
  3656. }
  3657. else {
  3658. // 대외향 구분하여 처리
  3659. WallpadDeviceSet devDB = new WallpadDeviceSet( getApplicationContext() );
  3660. int[] retArray = devDB.Get_Light_info();
  3661. devDB.closeDB();
  3662. if (retArray!= null && retArray[0] == 1) {
  3663. if (retArray[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
  3664. // 거실 스위치
  3665. if (m_LightCtrl != null) {
  3666. m_LightCtrl.Refresh(false);
  3667. m_LightCtrl.SetLightOnOff((byte)0x01, true);
  3668. }
  3669. }
  3670. else {
  3671. // 멀티 스위치
  3672. if (m_MultiSwitch != null) {
  3673. m_MultiSwitch.Refresh((byte)0x00, false);
  3674. if (m_MultiSwitch.data.DeviceCnt > 1) {
  3675. m_MultiSwitch.SetLightOnOff((byte)0x01 ,(byte)0x00 , true);
  3676. }
  3677. else if(m_MultiSwitch.data.DeviceCnt == 1) {
  3678. m_MultiSwitch.SetLightOnOff((byte)0x00 ,(byte)0x00 , true);
  3679. }
  3680. }
  3681. }
  3682. }
  3683. }
  3684. break;
  3685. case WallpadStatusData.MCALLR_CURTAIN_OPEN: //fill lather
  3686. break;
  3687. }
  3688. }
  3689. }
  3690. if (MCPer == WallpadStatusData.MORNINGCALL_ONCE) {
  3691. // Button morning = (Button)findViewById(R.id.top_alarm);
  3692. // morning.setVisibility(View.INVISIBLE);
  3693. WsDB.SetMorningCall(WallpadStatusData.MORNINGCALL_OFF, WsDB.MorningHour, WsDB.MorningMin);
  3694. }
  3695. }
  3696. }
  3697. }
  3698. WsDB.closeDB();
  3699. } catch (RuntimeException re) {
  3700. LogUtil.errorLogInfo("", TAG, re);
  3701. }
  3702. catch (Exception e) {
  3703. LogUtil.errorLogInfo("", TAG, e);
  3704. }
  3705. return false;
  3706. }
  3707. private void scheduleCheck()
  3708. {
  3709. try
  3710. {
  3711. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++");
  3712. Log.d("scheduleCheck", "Enter scheduleCheck "+GeneralData.size()+" : "+SchedulerData.size());
  3713. checkMorningCall();
  3714. if (GeneralData.size() > 0)
  3715. {
  3716. for (int i = 0;i < GeneralData.size(); i++)
  3717. {
  3718. TimeScheduleUnit scUnit = GeneralData.get(i);
  3719. if (scUnit.isOver())
  3720. {
  3721. switch (scUnit.type)
  3722. {
  3723. case SCHEDULE_TYPE_SYSRESET:
  3724. GeneralData.remove(scUnit);
  3725. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++ SCHEDULE_TYPE_SYSRESET");
  3726. SendAppFinishReqBR();
  3727. ComponentName cn = new ComponentName("com.artncore.updater","com.artncore.updater.MainActivity");
  3728. Intent intent = new Intent(Intent.ACTION_MAIN);
  3729. intent.addCategory(Intent.CATEGORY_LAUNCHER);
  3730. intent.putExtra("updatesystem", "no");
  3731. intent.putExtra("updateapp", "no");
  3732. intent.putExtra("rebootcmd", "reboot");
  3733. intent.setComponent(cn);
  3734. startActivity(intent);
  3735. break;
  3736. case SCHEDULE_TYPE_GETINFO:
  3737. GeneralData.remove(scUnit);
  3738. Log.d("scheduleCheck", "++++++++++++++++++++++++++++++++++++++++ SCHEDULE_TYPE_GETINFO");
  3739. WallPadiMAPNotifyAPI notifyAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
  3740. notifyAPI.ReqGetSet();
  3741. break;
  3742. }
  3743. }
  3744. }
  3745. Log.d("scheduleCheck", "after scheduleCheck "+GeneralData.size() );
  3746. }
  3747. }
  3748. catch (RuntimeException re) {
  3749. LogUtil.errorLogInfo("", TAG, re);
  3750. }
  3751. catch (Exception e)
  3752. {
  3753. LogUtil.errorLogInfo("", TAG, e);
  3754. }
  3755. }
  3756. public void doSchedule(String mess, int cnt)
  3757. {
  3758. // SendAppFinishReqBR();
  3759. // Intent intent = new Intent(getApplicationContext(), schedulepopup.class);
  3760. // String SendMSG = mess;
  3761. // if (cnt > 1) SendMSG+=(" 외 "+cnt+"건을 알려드립니다.");
  3762. // intent.putExtra("MESSAGE", SendMSG);
  3763. // Log.i("MAINSCREEN","Call Schedule POPUP");
  3764. // startActivity(intent);
  3765. }
  3766. public void refreshSchedulerData()
  3767. {
  3768. try
  3769. {
  3770. SchedulerData.clear();
  3771. WallpadScheduleData schedata = new WallpadScheduleData(getApplicationContext());
  3772. List<WallpadScheduleData.ScheduleData> scheduledata = schedata.GetTodaySchedule();
  3773. Log.i("MAINSCREEN","refreshSchedulerData "+scheduledata.size());
  3774. for(int i=0;i<scheduledata.size();i++)
  3775. {
  3776. WallpadScheduleData.ScheduleData ScUnit = scheduledata.get(i);
  3777. int hour;
  3778. int min;
  3779. Log.i("MAINSCREEN","refreshSchedulerData "+ScUnit.inqatype+" : "+ScUnit.inqhour+" : ");
  3780. if (ScUnit.inqatype.equals("no")) continue;
  3781. else if (ScUnit.inqatype.equals("intime")||ScUnit.inqatype.equals("day"))
  3782. {
  3783. hour = ScUnit.inqhour;
  3784. min = 0;
  3785. }
  3786. else if (ScUnit.inqatype.equals("hour"))
  3787. {
  3788. hour = ScUnit.inqhour-1;
  3789. if (hour < 0) continue;
  3790. min = 0;
  3791. }
  3792. else if (ScUnit.inqatype.equals("min"))
  3793. {
  3794. hour = ScUnit.inqhour-1;
  3795. if (hour < 0) continue;
  3796. min = 50;
  3797. }
  3798. else
  3799. continue;
  3800. Calendar today = new GregorianCalendar();
  3801. int MoonM = 0;
  3802. int MoonD = 0;
  3803. try
  3804. {
  3805. String Moon = schedata.GetLunarDate(String.format("%04d%02d%02d", today.get(Calendar.YEAR),today.get(Calendar.MONTH)+1,today.get(Calendar.DAY_OF_MONTH) ));
  3806. if(Moon!=null)
  3807. {
  3808. MoonM = Integer.parseInt(Moon.substring(4, 6));
  3809. MoonD = Integer.parseInt(Moon.substring(6, 8));
  3810. Log.i("MAINSCREEN", " Get Lunar Date "+Moon+" : "+MoonM+"/"+MoonD);
  3811. }
  3812. }
  3813. catch (RuntimeException re) {
  3814. LogUtil.errorLogInfo("", TAG, re);
  3815. }
  3816. catch (Exception e)
  3817. {
  3818. LogUtil.errorLogInfo("", TAG, e);
  3819. MoonM = 0;
  3820. MoonD = 0;
  3821. }
  3822. today.set(Calendar.HOUR_OF_DAY, hour);
  3823. today.set(Calendar.MINUTE, min);
  3824. 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;
  3825. Log.i("MAINSCREEN","refreshSchedulerData add "+ScUnit.inqatype+" : "+ScUnit.inqhour+" : "+Mesg);
  3826. TimeScheduleUnit newUnit = new TimeScheduleUnit(SCHEDULE_TYPE_SCHEDULER, today, Mesg);
  3827. isSetted = true;
  3828. SchedulerData.add(newUnit);
  3829. }
  3830. schedata.closeDB();
  3831. }
  3832. catch (RuntimeException re) {
  3833. LogUtil.errorLogInfo("", TAG, re);
  3834. }
  3835. catch (Exception e)
  3836. {
  3837. LogUtil.errorLogInfo("", TAG, e);
  3838. }
  3839. }
  3840. public void refreshMorningCall()
  3841. {
  3842. try
  3843. {
  3844. for (int i = 0; i < GeneralData.size(); i++)
  3845. {
  3846. TimeScheduleUnit scUnit = SchedulerData.get(i);
  3847. if (scUnit.type == SCHEDULE_TYPE_MORNINGCALL)
  3848. {
  3849. SchedulerData.remove(i);
  3850. break;
  3851. }
  3852. }
  3853. SetMorningCallData();
  3854. }
  3855. catch (RuntimeException re) {
  3856. LogUtil.errorLogInfo("", TAG, re);
  3857. }
  3858. catch (Exception e)
  3859. {
  3860. LogUtil.errorLogInfo("", TAG, e);
  3861. }
  3862. }
  3863. private void SetMorningCallData()
  3864. {
  3865. try
  3866. {
  3867. Log.i("MAINSCREEN","SetMorningCallData Schedule");
  3868. Calendar today = new GregorianCalendar();
  3869. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3870. int MCStatus = WsDB.GetMorningCallStatus();
  3871. if (MCStatus==WallpadStatusData.MORNINGCALL_ON)
  3872. {
  3873. int MCPer = WsDB.GetMorningCallPeriod();
  3874. int TodatofWeek = today.get(Calendar.DAY_OF_WEEK);
  3875. if ((MCPer == WallpadStatusData.MORNINGCALL_EWORKDAY && TodatofWeek != Calendar.SUNDAY) &&
  3876. (MCPer == WallpadStatusData.MORNINGCALL_WORKDAY && TodatofWeek!=Calendar.SUNDAY && TodatofWeek != Calendar.SATURDAY) &&
  3877. (MCPer == WallpadStatusData.MORNINGCALL_ONCE || MCPer == WallpadStatusData.MORNINGCALL_EVERYDAY ))
  3878. {
  3879. today.set(Calendar.HOUR_OF_DAY, WsDB.MorningHour);
  3880. today.set(Calendar.MINUTE, WsDB.MorningMin);
  3881. today.set(Calendar.SECOND, 0);
  3882. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_MORNINGCALL, today);
  3883. if (!scUnit.isOver())
  3884. {
  3885. isSetted = true;
  3886. // Button morning = (Button)findViewById(R.id.top_alarm);
  3887. // morning.setVisibility(View.VISIBLE);
  3888. GeneralData.add(scUnit);
  3889. }
  3890. else
  3891. {
  3892. // Button morning = (Button)findViewById(R.id.top_alarm);
  3893. // morning.setVisibility(View.INVISIBLE);
  3894. }
  3895. }
  3896. }
  3897. WsDB.closeDB();
  3898. }
  3899. catch (RuntimeException re) {
  3900. LogUtil.errorLogInfo("", TAG, re);
  3901. }
  3902. catch (Exception e)
  3903. {
  3904. LogUtil.errorLogInfo("", TAG, e);
  3905. }
  3906. }
  3907. public void refreshsysreset()
  3908. {
  3909. try
  3910. {
  3911. Log.i("MAINSCREEN","refreshsysreset Schedule");
  3912. for (int i = 0; i < GeneralData.size(); i++)
  3913. {
  3914. TimeScheduleUnit scUnit = SchedulerData.get(i);
  3915. if (scUnit.type == SCHEDULE_TYPE_SYSRESET)
  3916. {
  3917. SchedulerData.remove(i);
  3918. break;
  3919. }
  3920. }
  3921. SetSysResetData();
  3922. }
  3923. catch (RuntimeException re) {
  3924. LogUtil.errorLogInfo("", TAG, re);
  3925. }
  3926. catch (Exception e)
  3927. {
  3928. LogUtil.errorLogInfo("", TAG, e);
  3929. }
  3930. }
  3931. private void SetSysResetData()
  3932. {
  3933. try
  3934. {
  3935. Calendar today = new GregorianCalendar();
  3936. Log.i("MAINSCREEN","SetSysResetData Schedule");
  3937. WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
  3938. String[] ResetData = WsDB.GetResetSchedule();
  3939. if (!ResetData[0].equals("NONE"))
  3940. {
  3941. int type = Integer.parseInt(ResetData[0]);
  3942. if ((type == WallpadStatusData.RESET_MONTH && today.get(Calendar.DAY_OF_MONTH) == Integer.parseInt(ResetData[1])) ||
  3943. (type == WallpadStatusData.RESET_WEEK && today.get(Calendar.DAY_OF_WEEK) == Integer.parseInt(ResetData[1])) )
  3944. {
  3945. Log.i("MAINSCREEN","SetSysResetData Setted");
  3946. today.set(Calendar.HOUR_OF_DAY, Integer.parseInt(ResetData[2]));
  3947. today.set(Calendar.MINUTE, 0);
  3948. today.set(Calendar.SECOND, 0);
  3949. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_SYSRESET, today);
  3950. if (!scUnit.isOver())
  3951. {
  3952. isSetted = true;
  3953. GeneralData.add(scUnit);
  3954. }
  3955. }
  3956. }
  3957. WsDB.closeDB();
  3958. }
  3959. catch (RuntimeException re) {
  3960. LogUtil.errorLogInfo("", TAG, re);
  3961. }
  3962. catch (Exception e)
  3963. {
  3964. LogUtil.errorLogInfo("", TAG, e);
  3965. }
  3966. }
  3967. public void refreshSchedule()
  3968. {
  3969. try
  3970. {
  3971. Log.i("MAINSCREEN","Refresh Schedule");
  3972. GeneralData.clear();
  3973. Calendar today = new GregorianCalendar();
  3974. // 하루에 한번 가져오는 걸로 변경함
  3975. //if (today.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY)
  3976. {
  3977. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  3978. AddressSet addc = SetData.getAddressMGR();
  3979. SetData.closeDB();
  3980. int dong = Integer.parseInt(addc.Dong);
  3981. int ho = 101;
  3982. if(addc.UseOrNotRentHouse == true)
  3983. {
  3984. ho = addc.Ho_Integer;
  3985. }
  3986. else
  3987. {
  3988. ho = Integer.parseInt(addc.Ho);
  3989. }
  3990. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  3991. int hour;
  3992. int min;
  3993. int sec;
  3994. if (interval/3600 > 0)
  3995. {
  3996. hour = 3+interval/3600;
  3997. interval=interval%3600;
  3998. }
  3999. else hour = 3;
  4000. if (interval/60 > 0)
  4001. {
  4002. min = interval/60;
  4003. sec = interval%60;
  4004. }
  4005. else
  4006. {
  4007. min = 0;
  4008. sec = interval;
  4009. }
  4010. today.set(Calendar.HOUR_OF_DAY, hour);
  4011. today.set(Calendar.MINUTE, min);
  4012. today.set(Calendar.SECOND, sec);
  4013. TimeScheduleUnit scUnit = new TimeScheduleUnit(SCHEDULE_TYPE_GETINFO, today);
  4014. if (!scUnit.isOver())
  4015. GeneralData.add(scUnit);
  4016. }
  4017. SetMorningCallData();
  4018. SetSysResetData();
  4019. refreshSchedulerData();
  4020. }
  4021. catch (RuntimeException re) {
  4022. LogUtil.errorLogInfo("", TAG, re);
  4023. }
  4024. catch (Exception e)
  4025. {
  4026. LogUtil.errorLogInfo("", TAG, e);
  4027. }
  4028. }
  4029. }
  4030. class runCallServices extends Thread {
  4031. public runCallServices() {
  4032. super();
  4033. }
  4034. public void run() {
  4035. try {
  4036. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  4037. if (getIsSubWallpad()) {
  4038. Log.w(TAG, "[runCallServices.run()] ############### This wallpad is set as a sub-wallpad ###############");
  4039. Intent SubWallpadServiceLauncher = new Intent ("kr.co.icontrols.callengine.subwallpad.SubWallPadSerialManager.StartService");
  4040. getApplicationContext().startService(SubWallpadServiceLauncher);
  4041. }
  4042. else {
  4043. Log.w(TAG, "[runCallServices.run()] ############### This wallpad is set as a main-wallpad ###############");
  4044. // SIP/Subphone 서비스 실행
  4045. Intent SIPServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  4046. getApplicationContext().startService(SIPServiceLauncher);
  4047. Intent SubPhoneServiceLauncher = new Intent ("kr.co.icontrols.callengine.subphone.SubPhoneSerialManager.StartService");
  4048. getApplicationContext().startService(SubPhoneServiceLauncher);
  4049. if (GetRemoteCallUseInfo()) {
  4050. Intent remoteCallServiceLauncher = new Intent ("kr.co.icontrols.callengine.remotecall.RemoteCallManager.StartService");
  4051. getApplicationContext().startService(remoteCallServiceLauncher);
  4052. }
  4053. }
  4054. }
  4055. else {
  4056. int nModelType = Version.getModelType();
  4057. if (nModelType == MODEL_TYPE.IHN_750) {
  4058. // SIP 서비스만 실행
  4059. Intent sipServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  4060. getApplicationContext().startService(sipServiceLauncher);
  4061. }
  4062. else {
  4063. // SIP/PSTN/Subphone 서비스 실행
  4064. Intent sipServiceLauncher = new Intent ("kr.co.icontrols.callengine.sip.SIPStun.StartService");
  4065. getApplicationContext().startService(sipServiceLauncher);
  4066. Intent PSTNServiceLauncher = new Intent ("kr.co.icontrols.callengine.pstn.PSTNSerialManager.StartService");
  4067. getApplicationContext().startService(PSTNServiceLauncher);
  4068. Intent SubPhoneServiceLauncher = new Intent ("kr.co.icontrols.callengine.subphone.SubPhoneSerialManager.StartService");
  4069. getApplicationContext().startService(SubPhoneServiceLauncher);
  4070. }
  4071. }
  4072. } catch (RuntimeException re) {
  4073. LogUtil.errorLogInfo("", TAG, re);
  4074. }
  4075. catch (Exception e) {
  4076. Log.e(TAG, "[Exception] runCallServices().run()");
  4077. LogUtil.errorLogInfo("", TAG, e);
  4078. }
  4079. }
  4080. }
  4081. // 방문객원격통화 솔루션 사용여부 판별
  4082. private boolean GetRemoteCallUseInfo() {
  4083. try {
  4084. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  4085. if (mWallpadDeviceSet != null) {
  4086. String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
  4087. if (astrRemoteCall != null) {
  4088. if (astrRemoteCall[1].contains("사용함"))
  4089. return true;
  4090. } else {
  4091. Log.d(TAG, "[GetRemoteCallUseInfo] astrRemoteCall is null!!");
  4092. }
  4093. }
  4094. mWallpadDeviceSet.closeDB();
  4095. } catch (RuntimeException re) {
  4096. LogUtil.errorLogInfo("", TAG, re);
  4097. }
  4098. catch (Exception e) {
  4099. Log.e(TAG, "[Exception] GetRemoteCallUseInfo()");
  4100. LogUtil.errorLogInfo("", TAG, e);
  4101. }
  4102. return false;
  4103. }
  4104. int UNINSTALL_REQUEST_CODE = 1;
  4105. private void uninstallAnCCallApp(String strAPK) {
  4106. try {
  4107. Log.w(TAG, "[uninstallAnCCallApp] strAPK [" + strAPK + "]");
  4108. if (checkAppInstalled(strAPK)) {
  4109. // Intent mIntent = new Intent(Intent.ACTION_DELETE);
  4110. Intent mIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
  4111. mIntent.setData(Uri.parse("package:" + strAPK));
  4112. mIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
  4113. startActivityForResult(mIntent, UNINSTALL_REQUEST_CODE);
  4114. }
  4115. else {
  4116. Log.w(TAG, "[uninstallAnCCallApp] Not installed [" + strAPK + "]");
  4117. }
  4118. } catch (RuntimeException re) {
  4119. LogUtil.errorLogInfo("", TAG, re);
  4120. }
  4121. catch (Exception e) {;
  4122. Log.e(TAG, "[Exception] uninstallAnCCallApp()");
  4123. LogUtil.errorLogInfo("", TAG, e);
  4124. }
  4125. }
  4126. private boolean checkAppInstalled(String strAPK) {
  4127. try {
  4128. PackageManager mPackageManager = getPackageManager();
  4129. try {
  4130. mPackageManager.getPackageInfo(strAPK, PackageManager.GET_ACTIVITIES);
  4131. return true;
  4132. } catch (PackageManager.NameNotFoundException pne) {
  4133. Log.w(TAG, "[checkAppInstalled] No Package [" + strAPK + "]");
  4134. }
  4135. return false;
  4136. } catch (RuntimeException re) {
  4137. LogUtil.errorLogInfo("", TAG, re);
  4138. return false;
  4139. }
  4140. catch (Exception e) {
  4141. Log.e(TAG, "[Exception] checkAppInstalled(String strAPK)");
  4142. LogUtil.errorLogInfo("", TAG, e);
  4143. return false;
  4144. }
  4145. }
  4146. private boolean MainSubScreenLoadingComplite = false;
  4147. public boolean getMainSubScreenLoadingComplite() {
  4148. return MainSubScreenLoadingComplite;
  4149. }
  4150. /**
  4151. * 설치된 모든 어플의 이름/버전정보 Version DB에 저장하는 쓰레드. <br>
  4152. * main Activity 생성 시 최초 1회 실행 후 die
  4153. */
  4154. class getInstalledPackageInfo extends Thread {
  4155. @Override
  4156. public void run() {
  4157. super.run();
  4158. try {
  4159. Log.d(TAG, "[getInstalledPackageInfo] Started getting installed package infomation");
  4160. ArrayList<PackageVersionInfo> PackageVersionInfos = new ArrayList<PackageVersionInfo>();
  4161. List<PackageInfo> PackageInfoList = getPackageManager().getInstalledPackages(PackageManager.PERMISSION_GRANTED);
  4162. while (true) {
  4163. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages start!!");
  4164. try {
  4165. for (PackageInfo pack : PackageInfoList) {
  4166. Log.d(TAG, "# PackageName : " + pack.packageName);
  4167. Log.d(TAG, "# VersionName : " + pack.versionName);
  4168. if ((pack.packageName.contains("icontrols")) || (pack.packageName.contains("artncore")) || (pack.packageName.contains("dadam"))) {
  4169. PackageVersionInfos.add(new PackageVersionInfo(pack.packageName, pack.versionName));
  4170. }
  4171. }
  4172. } catch (RuntimeException re) {
  4173. LogUtil.errorLogInfo("", TAG, re);
  4174. break;
  4175. }
  4176. catch (Exception e) {
  4177. LogUtil.errorLogInfo("", TAG, e);
  4178. break;
  4179. }
  4180. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages end!!");
  4181. break;
  4182. }
  4183. Log.d(TAG, "[getInstalledPackageInfo.run()] Save installed packages start!!");
  4184. wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  4185. if (PackageVersionInfos != null) {
  4186. for (int i = 0; i < PackageVersionInfos.size(); i++) {
  4187. WallpadDBMGR.UpdateVersionData(PackageVersionInfos.get(i).getPackageName(), PackageVersionInfos.get(i).getPackageVersion());
  4188. }
  4189. }
  4190. WallpadDBMGR.closeDB();
  4191. Log.d(TAG, "[getInstalledPackageInfo.run()] Save installed packages end!!");
  4192. try {
  4193. Thread.sleep(1500);
  4194. } catch (RuntimeException re) {
  4195. LogUtil.errorLogInfo("", TAG, re);
  4196. }
  4197. catch (Exception e) {
  4198. LogUtil.errorLogInfo("", TAG, e);
  4199. }
  4200. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
  4201. try {
  4202. Thread.sleep(1000);
  4203. } catch (RuntimeException re) {
  4204. LogUtil.errorLogInfo("", TAG, re);
  4205. }
  4206. catch (Exception e) {
  4207. LogUtil.errorLogInfo("", TAG, e);
  4208. }
  4209. }
  4210. runOnUiThread(new Runnable() {
  4211. @Override
  4212. public void run() {
  4213. registerSubScreen();
  4214. }
  4215. });
  4216. try
  4217. {
  4218. WallpadScheduleData schedb = new WallpadScheduleData(getApplicationContext());
  4219. boolean bLunarTableExist = schedb.CheckLunarTable();
  4220. schedb.closeDB();
  4221. if (!bLunarTableExist) {
  4222. try {
  4223. Log.d(TAG, "DB File Copy Start");
  4224. copyDataBase(wallpaddbmgr.dblocation + "/" + wallpaddbmgr.Schedule_LunaDB);
  4225. Log.d(TAG, "DB File Copy End");
  4226. } catch (IOException e) {
  4227. LogUtil.errorLogInfo("", TAG, e);
  4228. }
  4229. }
  4230. } catch (RuntimeException re) {
  4231. LogUtil.errorLogInfo("", TAG, re);
  4232. }
  4233. catch (Exception e) {
  4234. LogUtil.errorLogInfo("", TAG, e);
  4235. }
  4236. // if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) checkDongHoSetting();
  4237. checkDongHoSetting();
  4238. if (Common.GetElevatorSampleMode(getApplicationContext())) {
  4239. int retCount = EnergyAlramPopupMgr.get_WallPadRebootingCount( getApplicationContext()) + 1;
  4240. EnergyAlramPopupMgr.set_WallPadRebootingCount(getApplicationContext(), retCount);
  4241. Log.d(TAG, "################################# rebooting Count : " + retCount );
  4242. }
  4243. // 하드웨어 키 샘플 모드 동작 여부 설정
  4244. WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
  4245. int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
  4246. sdata.closeDB();
  4247. WallPadInterface wpdifc = new WallPadInterface();
  4248. if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
  4249. wpdifc.DoControl(WallPadInterface.IOCTL_KEY_ONOFF_SET, 0);
  4250. CheckEnv();
  4251. }
  4252. catch (RuntimeException re) {
  4253. LogUtil.errorLogInfo("", TAG, re);
  4254. }
  4255. catch (Exception e)
  4256. {
  4257. LogUtil.errorLogInfo("", TAG, e);
  4258. }
  4259. try {Thread.sleep(5000);}
  4260. catch (RuntimeException re) {
  4261. LogUtil.errorLogInfo("", TAG, re);
  4262. MainSubScreenLoadingComplite = true;
  4263. }
  4264. catch (Exception e){LogUtil.errorLogInfo("", TAG, e);}
  4265. MainSubScreenLoadingComplite = true;
  4266. }
  4267. }
  4268. public static String DB_WALLPAD_WIDGET_INIT = "DB_WALLPAD_WIDGET_INIT";
  4269. public void set_WallPadWidgetInit(Context context) {
  4270. try {
  4271. wallpaddbmgr mgr = new wallpaddbmgr(context);
  4272. boolean bRet = mgr.UpdateWallPADData(DB_WALLPAD_WIDGET_INIT, String.valueOf(1));
  4273. if (bRet == false ) {
  4274. Log.d(TAG, "----- DB_WALLPAD_WIDGET_INIT insert ==> false ");
  4275. mgr.insertWallPADDB(DB_WALLPAD_WIDGET_INIT, "1");
  4276. }
  4277. mgr.closeDB();
  4278. } catch (RuntimeException re) {
  4279. LogUtil.errorLogInfo("", TAG, re);
  4280. }
  4281. catch (Exception e) {
  4282. LogUtil.errorLogInfo("", TAG, e);
  4283. }
  4284. }
  4285. public int get_WallPadWidgetInit(Context context) {
  4286. int ret = 0;
  4287. try {
  4288. wallpaddbmgr mgr = new wallpaddbmgr(context);
  4289. String strRet = mgr.GetWallPADData(DB_WALLPAD_WIDGET_INIT);
  4290. if (strRet == null) {
  4291. Log.d(TAG, "----- get_WallPadRebootingCount strRet == null && insert ==> false ");
  4292. mgr.insertWallPADDB(DB_WALLPAD_WIDGET_INIT, "0");
  4293. return 0;
  4294. }
  4295. ret = Integer.parseInt(strRet);
  4296. mgr.closeDB();
  4297. } catch (RuntimeException re) {
  4298. LogUtil.errorLogInfo("", TAG, re);
  4299. }
  4300. catch (Exception e) {
  4301. LogUtil.errorLogInfo("", TAG, e);
  4302. }
  4303. return ret;
  4304. }
  4305. /**
  4306. * 스케줄 관련 처리 핸들러 추가
  4307. * 모닝콜, 일정관리, 엘리베이터 호출상태, 에너지 사용량 확인
  4308. * 현재는 사용하지 않음. checkTimeTasks()로 대체
  4309. */
  4310. private int nDay, nHour, nMin;
  4311. Handler Checker = new Handler() {
  4312. public void handleMessage(Message msg) {
  4313. super.handleMessage(msg);
  4314. Calendar cal = new GregorianCalendar();
  4315. if (cal.get(Calendar.DAY_OF_MONTH) != nDay) {
  4316. // 날짜가 바뀌었을때...
  4317. nDay = cal.get(Calendar.DAY_OF_MONTH);
  4318. Log.d(TAG , "-----------------day change repeat");
  4319. if (SCManager != null) {
  4320. if (SYSTEM_TIME_SET)SCManager.refreshSchedule();
  4321. }
  4322. //
  4323. // Intent intent = new Intent();
  4324. // intent.setAction(define.NOTIFY_ACNAME);
  4325. // intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DAYCHANGED);
  4326. // getApplicationContext().sendBroadcast(intent);
  4327. //에너지사용량 알림 초기화
  4328. ClearEnergyUsage();
  4329. Log.d(TAG , "cal.get(Calendar.YEAR) :" + cal.get(Calendar.YEAR) );
  4330. if ((bUseofNot_ZeroEnergyHouseInfo == true) && (cal.get(Calendar.YEAR) > 2016) && (SYSTEM_TIME_SET == true)) {
  4331. //어제 시간 재입력
  4332. Log.d(TAG , "/**********************************************/");
  4333. Log.d(TAG , "GetZeroEnergyHouseInfo_RandomCheckHandler(true);");
  4334. Log.d(TAG , "/**********************************************/");
  4335. DayofLastSecond = StringUtil.GetDayofLastSecondTimeString(cal); //하루전 날짜의 마지막 시간 입력
  4336. Log.d(TAG , "DayofLastSecond : "+ DayofLastSecond);
  4337. }
  4338. }
  4339. if (cal.get(Calendar.HOUR_OF_DAY) != nHour) {
  4340. nHour = cal.get(Calendar.HOUR_OF_DAY);
  4341. DoScheduleHourUnit(cal);
  4342. }
  4343. if (cal.get(Calendar.MINUTE) != nMin) {
  4344. nMin = cal.get(Calendar.MINUTE);
  4345. /**
  4346. * A20월패드 BSP는 전자액자 실행을 시키지 않기때문에 main app에서 전자액자 실행 여부 확인하여
  4347. * 실행시킴
  4348. * **/
  4349. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A20) {
  4350. Log.i(TAG, "[Checker handler] ========== JEFF 1 ========== m_LiveMainActivity : " + m_LiveMainActivity);
  4351. if (m_LiveMainActivity > 0) {
  4352. String LCD_Sleep_Status = null;
  4353. Runtime runtime = Runtime.getRuntime();
  4354. Process process;
  4355. try {
  4356. String cmd = "getprop persist.sys.display.lcdoff";
  4357. process = runtime.exec(cmd);
  4358. BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
  4359. String line;
  4360. while ((line = br.readLine()) != null) {
  4361. LCD_Sleep_Status = line;
  4362. }
  4363. } catch (RuntimeException re) {
  4364. LogUtil.errorLogInfo("", TAG, re);
  4365. }
  4366. catch (Exception e) {
  4367. e.fillInStackTrace();
  4368. Log.e("Process Manager", "Unable to execute top command");
  4369. }
  4370. if (LCD_Sleep_Status != null) {
  4371. Log.d(TAG, "The LCD_Sleep_Status : " + LCD_Sleep_Status);
  4372. if (LCD_Sleep_Status.equals("1") == true) {
  4373. // LCD 꺼져있음
  4374. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4375. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4376. if (SettData.StartAutoPictureAPP() == true) {
  4377. Log.d(TAG, "StartAutoPictureAPP is true");
  4378. // PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  4379. // pm.userActivity(2, true);
  4380. // LCD backlight normal
  4381. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4382. Log.d(TAG, "PowerManager will be set");
  4383. }
  4384. else {
  4385. Log.d(TAG, "StartAutoPictureAPP is false");
  4386. }
  4387. }
  4388. else {
  4389. Log.d(TAG, "DecideAutoPictureAppStartOrNot is false");
  4390. }
  4391. SettData.closeDB();
  4392. }
  4393. }
  4394. else {
  4395. Log.e(TAG, "The LCD_Sleep_Status is null");
  4396. }
  4397. }
  4398. }
  4399. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  4400. Log.i(TAG, "[Checker handler] ========== JEFF 2 ========== m_LiveMainActivity : " + m_LiveMainActivity);
  4401. if (m_LiveMainActivity > 0) {
  4402. boolean bisScreenOn = false;
  4403. if (getCompareBSPVersion()) {
  4404. bisScreenOn = checkLCDOnByCMD();
  4405. }
  4406. else {
  4407. PowerManager mPowerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
  4408. bisScreenOn = mPowerManager.isScreenOn();
  4409. }
  4410. Log.i(TAG, "[Checker handler] bisScreenOn : " + bisScreenOn);
  4411. if (!bisScreenOn) {
  4412. if (getBlackoutStatus()) {
  4413. Log.i(TAG, "[Checker handler] getBlackoutStatus is true!!!");
  4414. sendBlackoutScreenRunBR();
  4415. }
  4416. else {
  4417. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4418. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4419. if (SettData.StartAutoPictureAPP() == true) {
  4420. Log.d(TAG, "StartAutoPictureAPP is true");
  4421. mIOInterface.ctrlLcdWakeUp();
  4422. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4423. Log.d(TAG, "PowerManager will be set");
  4424. }
  4425. else {
  4426. Log.d(TAG, "StartAutoPictureAPP is false");
  4427. }
  4428. }
  4429. else {
  4430. Log.d(TAG, "DecideAutoPictureAppStartOrNot is false");
  4431. }
  4432. SettData.closeDB();
  4433. }
  4434. }
  4435. }
  4436. }
  4437. if ((nMin == 50) || (nMin == 0)) {
  4438. try {
  4439. checkScheduleReminder();
  4440. } catch (RuntimeException re) {
  4441. LogUtil.errorLogInfo("", TAG, re);
  4442. }
  4443. catch (Exception e) {
  4444. LogUtil.errorLogInfo("", TAG, e);
  4445. }
  4446. // 스케줄 일정 알람 팝업을 띄우도록 한다.
  4447. // Intent intent = new Intent(getApplicationContext(), schedulepopup.class);
  4448. // String SendMSG = doSchedule.get(0).inqmsg;
  4449. // if (doSchedule.size() > 1) SendMSG+=(" 외 "+doSchedule.size()+"건을 알려드립니다.");
  4450. // intent.putExtra("MESSAGE", SendMSG);
  4451. //
  4452. // startActivity(intent);
  4453. }
  4454. if (SCManager != null) SCManager.scheduleCheck();
  4455. //CheckElevator();
  4456. if (MAX_BOOTUP_RETRY_COUNT < bootupretryCNT && SYSTEM_TIME_SET == false) {
  4457. try {
  4458. WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4459. iMAPMethod.ReqGetSet();
  4460. } catch (RuntimeException re) {
  4461. LogUtil.errorLogInfo("", TAG, re);
  4462. }
  4463. catch (Exception e) {
  4464. LogUtil.errorLogInfo("", TAG, e);
  4465. }
  4466. }
  4467. // 중복.... 이게 왜 있는겨....
  4468. // if ( cal.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY && SYSTEM_TIME_SET && cal.get(Calendar.DAY_OF_MONTH)!=LastTimeSync)
  4469. // {
  4470. // Calendar checktime = GetTimeSyncTime();
  4471. // if (checktime != null)
  4472. // {
  4473. // if (cal.after(checktime))
  4474. // {
  4475. // LastTimeSync = cal.get(Calendar.DAY_OF_MONTH);
  4476. // WallpadStatusData wpd = new WallpadStatusData(getApplicationContext());
  4477. // wpd.SetLastTimeSyncDate(LastTimeSync);
  4478. // wpd.closeDB();
  4479. // WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4480. // iMAPMethod.ReqGetSet();
  4481. // }
  4482. // }
  4483. // }
  4484. //주차정보 관련 20분 마다 얻어오기
  4485. if (bUseofNot_ParkingInfo == true) {
  4486. cGetParkingMin++;
  4487. //테스트
  4488. /*
  4489. bSetMSG_GetParkingInfo = true;
  4490. LoadParkingDataFromServer();
  4491. */
  4492. if (cGetParkingMin >= 20) {
  4493. // 20분으로 고정
  4494. cGetParkingMin = 0;
  4495. //아이콘트롤스 일때도 처리하지 않도록 수정필요
  4496. //넥스파인 경우는 협의후 처리
  4497. switch (nParkingSystemType) {
  4498. case Common.PARKING_SYSTEM_ICONTROLS:
  4499. case Common.PARKING_SYSTEM_NEXPA:
  4500. case Common.PARKING_SYSTEM_UPIS:
  4501. case Common.PARKING_SYSTEM_IES_100:
  4502. break;
  4503. case Common.PARKING_SYSTEM_BASIC:
  4504. case Common.PARKING_SYSTEM_ETC:
  4505. GetParkingInfo_RandomCheckHandler(); //주차 정보 얻어오기
  4506. break;
  4507. default:
  4508. break;
  4509. }
  4510. }
  4511. }
  4512. // 필요없는 코드 삭제 ( yskim 2015.03.31 )
  4513. // String checkDate = String.format("%04d%02d%02d",cal.get(Calendar.YEAR),cal.get(Calendar.MONTH)+1,cal.get(Calendar.DAY_OF_MONTH));
  4514. // WallpadStatusData energyData = new WallpadStatusData(getApplicationContext());
  4515. // String EnergyCheckData = energyData.GetEnergyCheckDate();
  4516. // energyData.closeDB();
  4517. // if (SYSTEM_TIME_SET)
  4518. // {
  4519. // Calendar checktime = GetEnergyDataLoadingTime();
  4520. // if (!checkDate.equals(EnergyCheckData))
  4521. // {
  4522. // if (checktime != null)
  4523. // {
  4524. //
  4525. // if (cal.after(checktime))
  4526. // {
  4527. // WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4528. // iMAPMethod.GetEnergyUsage();
  4529. // WallPadiMAPNotifyAPI iMAPMethod2 = new WallPadiMAPNotifyAPI(getApplicationContext());
  4530. // iMAPMethod2.GetEnergyUsageMonth();
  4531. // }
  4532. // }
  4533. // }
  4534. // }
  4535. }
  4536. // checkMainPage();
  4537. Checker.sendEmptyMessageDelayed(0, 1000);
  4538. }
  4539. };
  4540. /**
  4541. * JEFF, 2019.12.25
  4542. * 매 1초마다 실행되면서 스케쥴 확인하여 각 기능을 동작시킨다 (시간업데이트, 전자액자 등)
  4543. */
  4544. Handler handlerEverySecond = new Handler() {
  4545. public void handleMessage(Message msg) {
  4546. super.handleMessage(msg);
  4547. checkTimeTasks();
  4548. handlerEverySecond.sendEmptyMessageDelayed(0, 1000);
  4549. }
  4550. };
  4551. private void checkTimeTasks() {
  4552. try {
  4553. // Log.d(TAG , "[checkTimeTasks] ===== START =====");
  4554. Calendar cal = new GregorianCalendar();
  4555. if (cal.get(Calendar.DAY_OF_MONTH) != nDay) {
  4556. // 날짜 변경시
  4557. Log.d(TAG , "[checkTimeTasks] day changed!!");
  4558. nDay = cal.get(Calendar.DAY_OF_MONTH);
  4559. if (SCManager != null) {
  4560. if (SYSTEM_TIME_SET) SCManager.refreshSchedule();
  4561. }
  4562. else {
  4563. Log.w(TAG , "[checkTimeTasks] SYSTEM_TIME_SET is null!!");
  4564. }
  4565. // 모바일연동 서비스로 원격검침 데이터를 전송
  4566. // getTelemeteringDataOnRandomTime();
  4567. // // 에너지사용량 알림 초기화
  4568. // ClearEnergyUsage();
  4569. Log.d(TAG , "[checkTimeTasks] Calendar.YEAR = " + cal.get(Calendar.YEAR) );
  4570. if ((bUseofNot_ZeroEnergyHouseInfo == true) && (cal.get(Calendar.YEAR) > 2016) && (SYSTEM_TIME_SET == true)) {
  4571. //어제 시간 재입력
  4572. Log.i(TAG , "[checkTimeTasks] GetZeroEnergyHouseInfo_RandomCheckHandler(true);");
  4573. DayofLastSecond = StringUtil.GetDayofLastSecondTimeString(cal); //하루전 날짜의 마지막 시간 입력
  4574. Log.d(TAG , "[checkTimeTasks] DayofLastSecond : "+ DayofLastSecond);
  4575. }
  4576. }
  4577. if (cal.get(Calendar.HOUR_OF_DAY) != nHour) {
  4578. nHour = cal.get(Calendar.HOUR_OF_DAY);
  4579. // 원격검침 데이터를 서버로부터 가져와 관련 기능모듈에 알린다.
  4580. getTelemeteringDataOnRandomTime();
  4581. DoScheduleHourUnit(cal);
  4582. }
  4583. if (getBlackoutStatus()) {
  4584. Log.i(TAG, "[checkTimeTasks] getBlackoutStatus is true!!!");
  4585. sendBlackoutScreenRunBR();
  4586. }
  4587. if (cal.get(Calendar.MINUTE) != nMin) {
  4588. nMin = cal.get(Calendar.MINUTE);
  4589. /**
  4590. * main app에서 전자액자 실행 여부 확인하여 실행시킴
  4591. * **/
  4592. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  4593. Log.i(TAG, "[checkTimeTasks] m_LiveMainActivity : " + m_LiveMainActivity);
  4594. if (m_LiveMainActivity > 0) {
  4595. boolean bScreenOn = false;
  4596. if (getCompareBSPVersion()) {
  4597. bScreenOn = checkLCDOnByCMD();
  4598. }
  4599. else {
  4600. PowerManager mPowerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
  4601. bScreenOn = mPowerManager.isScreenOn();
  4602. }
  4603. Log.i(TAG, "[checkTimeTasks] bScreenOn : " + bScreenOn);
  4604. if (!bScreenOn && !getBlackoutStatus()) {
  4605. WallpadStatusData SettData = new WallpadStatusData(getApplicationContext());
  4606. if (SettData.DecideAutoPictureAppStartOrNot(new GregorianCalendar())) {
  4607. if (SettData.StartAutoPictureAPP() == true) {
  4608. Log.d(TAG, "[checkTimeTasks] StartAutoPictureAPP() is true");
  4609. mIOInterface.ctrlLcdWakeUp();
  4610. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4611. Log.d(TAG, "[checkTimeTasks] PowerManager will be set");
  4612. }
  4613. else {
  4614. Log.d(TAG, "[checkTimeTasks] StartAutoPictureAPP() is false");
  4615. }
  4616. }
  4617. else {
  4618. Log.d(TAG, "[checkTimeTasks] DecideAutoPictureAppStartOrNot(...) is false");
  4619. }
  4620. SettData.closeDB();
  4621. }
  4622. }
  4623. }
  4624. if ((nMin == 50) || (nMin == 0)) {
  4625. try {
  4626. checkScheduleReminder();
  4627. } catch (RuntimeException re) {
  4628. LogUtil.errorLogInfo("", TAG, re);
  4629. }
  4630. catch (Exception e) {
  4631. LogUtil.errorLogInfo("", TAG, e);
  4632. }
  4633. }
  4634. if (SCManager != null) SCManager.scheduleCheck();
  4635. if (MAX_BOOTUP_RETRY_COUNT < bootupretryCNT && SYSTEM_TIME_SET == false) {
  4636. try {
  4637. WallPadiMAPNotifyAPI iMAPMethod = new WallPadiMAPNotifyAPI(getApplicationContext());
  4638. iMAPMethod.ReqGetSet();
  4639. } catch (RuntimeException re) {
  4640. LogUtil.errorLogInfo("", TAG, re);
  4641. }
  4642. catch (Exception e) {
  4643. LogUtil.errorLogInfo("", TAG, e);
  4644. }
  4645. }
  4646. //주차정보 관련 20분 마다 얻어오기
  4647. if (bUseofNot_ParkingInfo == true) {
  4648. cGetParkingMin++;
  4649. //테스트
  4650. /*
  4651. bSetMSG_GetParkingInfo = true;
  4652. LoadParkingDataFromServer();
  4653. */
  4654. if (cGetParkingMin >= 20) {
  4655. // 20분으로 고정
  4656. cGetParkingMin = 0;
  4657. //아이콘트롤스 일때도 처리하지 않도록 수정필요
  4658. //넥스파인 경우는 협의후 처리
  4659. switch(nParkingSystemType) {
  4660. case Common.PARKING_SYSTEM_ICONTROLS:
  4661. case Common.PARKING_SYSTEM_NEXPA:
  4662. case Common.PARKING_SYSTEM_UPIS:
  4663. case Common.PARKING_SYSTEM_IES_100:
  4664. break;
  4665. case Common.PARKING_SYSTEM_BASIC:
  4666. case Common.PARKING_SYSTEM_ETC:
  4667. GetParkingInfo_RandomCheckHandler(); //주차 정보 얻어오기
  4668. break;
  4669. default:
  4670. break;
  4671. }
  4672. }
  4673. }
  4674. }
  4675. } catch (RuntimeException re) {
  4676. LogUtil.errorLogInfo("", TAG, re);
  4677. }
  4678. catch (Exception e) {
  4679. Log.e(TAG, "[Exception] checkTimeTasks()");
  4680. LogUtil.errorLogInfo("", TAG, e);
  4681. }
  4682. }
  4683. /**
  4684. * 일정 알림 팝업창 생성하는 함수<br>
  4685. * 김용성 과장님 이곳에서 팝업창 생성해주시기 바랍니다.
  4686. * @param popup_msg 팝업창에 띄울 메시지.
  4687. * **/
  4688. private void MakePopup_Schedule(String popup_msg) {
  4689. try {
  4690. Log.e(TAG, "[MakePopup_Schedule] popup_msg [" + popup_msg + "]");
  4691. DebugLogOutput("===================================");
  4692. DebugLogOutput(popup_msg);
  4693. DebugLogOutput("===================================");
  4694. WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
  4695. int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
  4696. boolean soundOut = mWallpadStatusData.GetSoundOutputOfEventAlarm();
  4697. mWallpadStatusData.closeDB();
  4698. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 1 ==========");
  4699. if (AlarmStatus != WallpadStatusData.ALARM_ARISE && AlarmStatus != WallpadStatusData.GUARD_OUT && AlarmStatus != WallpadStatusData.GUARD_OUT_WAIT) {
  4700. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 2 ==========");
  4701. if (!Common.bWallPadCallLive) {
  4702. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 3 ==========");
  4703. Common.SendAppFinishReqBR(getApplicationContext());
  4704. PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
  4705. Log.d(TAG, "[MakePopup_Schedule] Screen On: " + mPowerManager.isScreenOn());
  4706. if (getCompareBSPVersion()) {
  4707. if (!checkLCDOnByCMD()) {
  4708. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  4709. }
  4710. }
  4711. else {
  4712. if (!mPowerManager.isScreenOn()) {
  4713. Log.d(TAG, "[MakePopup_Schedule] V40Interface LcdWakeUp Call!!");
  4714. mIOInterface.ctrlLcdWakeUp(); // 절전상태일 경우, jni LcdWakeUp 먼저 호출
  4715. }
  4716. }
  4717. ((MainActivity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  4718. // 알람 소리를 내준다.
  4719. if (soundOut) {
  4720. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 4 ==========");
  4721. Sound().Play(SND.effect.EFFECT1);
  4722. }
  4723. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 5 ==========");
  4724. EnergyAlramPopupMgr.SchedulePopupMsg = popup_msg;
  4725. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 6 ==========");
  4726. StartPopup(ID.POPUPS.POPUP_SCHEDULENOTIFICATION);
  4727. Log.e(TAG, "[MakePopup_Schedule] ========== JEFF 7 ==========");
  4728. }
  4729. }
  4730. } catch (RuntimeException re) {
  4731. LogUtil.errorLogInfo("", TAG, re);
  4732. }
  4733. catch (Exception e) {
  4734. Log.e(TAG, "[Exception] MakePopup_Schedule(String popup_msg)");
  4735. LogUtil.errorLogInfo("", TAG, e);
  4736. }
  4737. }
  4738. /**
  4739. * 일정 알림 시간 비교!
  4740. * **/
  4741. private void checkScheduleReminder() {
  4742. try {
  4743. Calendar ScheduleCal = Calendar.getInstance();
  4744. Log.i(TAG, "[checkScheduleReminder] ScheduleCal: " + ScheduleCal.getTime());
  4745. WallpadScheduleData SCData = new WallpadScheduleData(getApplicationContext());
  4746. // List<WallpadScheduleData.ScheduleData> scheduleDataDB = SCData.NewGetScheduleDataForMainActivity(ScheduleCal.get(Calendar.YEAR), ScheduleCal.get(Calendar.MONTH) + 1, ScheduleCal.get(Calendar.DAY_OF_MONTH));
  4747. List<WallpadScheduleData.ScheduleData> scheduleDataDB = SCData.getScheduledInfoforMainActivity();
  4748. SCData.closeDB();
  4749. if (scheduleDataDB != null) {
  4750. Log.i(TAG, "scheduleDataDB.size() [" + scheduleDataDB.size() + "]");
  4751. for (int i = 0; i < scheduleDataDB.size(); i++) {
  4752. DebugLogOutput("[checkScheduleReminder] ===================================");
  4753. DebugLogOutput("[checkScheduleReminder] index [" + i + "], year [" + scheduleDataDB.get(i).inqyear + "], month [" + scheduleDataDB.get(i).inqmonth + "], day [" + scheduleDataDB.get(i).inqday + "], hour [" + scheduleDataDB.get(i).inqhour + "]");
  4754. DebugLogOutput("[checkScheduleReminder] msg [" + scheduleDataDB.get(i).inqmsg + "], seq [" + scheduleDataDB.get(i).seqnum + "]");
  4755. /**
  4756. * inqttype: 음력여부 - {"moon", "sun"}
  4757. * inqctype: 주기 - no:없음 or month:매월주기 or year:매년주기
  4758. * inqatype: 알림 - {"no","intime","min","hour","day"} := {안울림, 정각, 10분전, 1시간전, 하루전}
  4759. * inqitype: 행사 - {"birth","memorial","appoint","trip","first","wedding","tax","meeting","car","ancestor"} := {생일,기념일,약속,여행,돌,결혼,공과금,차량점검,제사}
  4760. */
  4761. DebugLogOutput("[checkScheduleReminder] lunar [" + scheduleDataDB.get(i).inqttype + "], cycle [" + scheduleDataDB.get(i).inqctype + "], remindtime [" + scheduleDataDB.get(i).inqatype + "], event [" + scheduleDataDB.get(i).inqitype + "]");
  4762. DebugLogOutput("[checkScheduleReminder] ===================================\n");
  4763. Calendar alarmCalendar = Calendar.getInstance();
  4764. if(scheduleDataDB.get(i).inqatype.equalsIgnoreCase("no") == true) {
  4765. //알림 사용하지 않음.
  4766. Log.i(TAG, "[checkScheduleReminder] ========== alarm off ==========");
  4767. }
  4768. else {
  4769. Log.i(TAG, "[checkScheduleReminder] ========== alarm on ==========");
  4770. if (scheduleDataDB.get(i).inqctype.equalsIgnoreCase("month")) {
  4771. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month ==========");
  4772. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  4773. //정각인 경우
  4774. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> intime ==========");
  4775. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4776. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4777. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4778. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4779. AlarmScheduleCount++;
  4780. if (bAlarmScheduleString == false) {
  4781. bAlarmScheduleString = true;
  4782. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4783. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4784. }
  4785. else {
  4786. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4787. }
  4788. }
  4789. }
  4790. }
  4791. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("min")) {
  4792. //10분 전
  4793. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 10 min before ==========");
  4794. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4795. alarmCalendar.add(Calendar.MINUTE, -10);
  4796. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4797. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4798. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4799. AlarmScheduleCount++;
  4800. if (bAlarmScheduleString == false) {
  4801. bAlarmScheduleString = true;
  4802. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4803. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4804. }
  4805. else {
  4806. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4807. }
  4808. }
  4809. }
  4810. }
  4811. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("hour")) {
  4812. //1시간 전
  4813. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 1 hour before ==========");
  4814. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4815. alarmCalendar.add(Calendar.HOUR_OF_DAY, -1);
  4816. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4817. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4818. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4819. AlarmScheduleCount++;
  4820. if (bAlarmScheduleString == false) {
  4821. bAlarmScheduleString = true;
  4822. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4823. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4824. }
  4825. else {
  4826. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4827. }
  4828. }
  4829. }
  4830. }
  4831. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  4832. //하루전
  4833. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> month -> 1 day before ==========");
  4834. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4835. alarmCalendar.add(Calendar.DATE, -1);
  4836. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  4837. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  4838. // 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));
  4839. // 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));
  4840. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  4841. if ((ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4842. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4843. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4844. AlarmScheduleCount++;
  4845. if (bAlarmScheduleString == false) {
  4846. bAlarmScheduleString = true;
  4847. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4848. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4849. }
  4850. else {
  4851. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4852. }
  4853. }
  4854. }
  4855. }
  4856. }
  4857. else if (scheduleDataDB.get(i).inqctype.equalsIgnoreCase("year")) {
  4858. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year ==========");
  4859. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  4860. //정각인 경우
  4861. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> intime ==========");
  4862. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4863. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4864. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4865. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4866. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE))) {
  4867. AlarmScheduleCount++;
  4868. if (bAlarmScheduleString == false) {
  4869. bAlarmScheduleString = true;
  4870. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4871. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4872. }
  4873. else {
  4874. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4875. }
  4876. }
  4877. }
  4878. }
  4879. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("min")) {
  4880. //10분 전
  4881. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 10 min before ==========");
  4882. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4883. alarmCalendar.add(Calendar.MINUTE, -10);
  4884. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4885. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4886. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4887. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4888. {
  4889. AlarmScheduleCount++;
  4890. if (bAlarmScheduleString == false) {
  4891. bAlarmScheduleString = true;
  4892. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4893. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4894. }
  4895. else {
  4896. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4897. }
  4898. }
  4899. }
  4900. }
  4901. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("hour")) {
  4902. //1시간 전
  4903. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 1 hour before ==========");
  4904. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4905. alarmCalendar.add(Calendar.HOUR_OF_DAY, -1);
  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. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  4924. //하루전
  4925. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> year -> 1 day before ==========");
  4926. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4927. alarmCalendar.add(Calendar.DATE, -1);
  4928. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  4929. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  4930. // 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));
  4931. // 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));
  4932. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  4933. if ((ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4934. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4935. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4936. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4937. {
  4938. AlarmScheduleCount++;
  4939. if (bAlarmScheduleString == false) {
  4940. bAlarmScheduleString = true;
  4941. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4942. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4943. }
  4944. else {
  4945. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4946. }
  4947. }
  4948. }
  4949. }
  4950. }
  4951. else {
  4952. //반복 없는경우
  4953. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat ==========");
  4954. if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("intime")) {
  4955. //정각인 경우
  4956. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> intime ==========");
  4957. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4958. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  4959. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4960. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4961. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4962. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4963. {
  4964. AlarmScheduleCount++;
  4965. if (bAlarmScheduleString == false) {
  4966. bAlarmScheduleString = true;
  4967. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4968. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4969. }
  4970. else {
  4971. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4972. }
  4973. }
  4974. }
  4975. }
  4976. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("min")) {
  4977. //10분 전
  4978. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 10 min before ==========");
  4979. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  4980. alarmCalendar.add(Calendar.MINUTE, -10);
  4981. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  4982. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  4983. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  4984. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  4985. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  4986. {
  4987. AlarmScheduleCount++;
  4988. if (bAlarmScheduleString == false) {
  4989. bAlarmScheduleString = true;
  4990. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  4991. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4992. }
  4993. else {
  4994. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  4995. }
  4996. }
  4997. }
  4998. }
  4999. else if(scheduleDataDB.get(i).inqatype.equalsIgnoreCase("hour")) {
  5000. //1시간 전
  5001. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 1 hour before ==========");
  5002. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  5003. alarmCalendar.add(Calendar.HOUR_OF_DAY, -1);
  5004. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  5005. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  5006. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5007. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5008. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  5009. {
  5010. AlarmScheduleCount++;
  5011. if (bAlarmScheduleString == false) {
  5012. bAlarmScheduleString = true;
  5013. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5014. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5015. }
  5016. else {
  5017. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5018. }
  5019. }
  5020. }
  5021. }
  5022. else if (scheduleDataDB.get(i).inqatype.equalsIgnoreCase("day")) {
  5023. //하루전
  5024. Log.i(TAG, "[checkScheduleReminder] ========== alarm on -> no repeat -> 1 day before ==========");
  5025. alarmCalendar.set(scheduleDataDB.get(i).inqyear, scheduleDataDB.get(i).inqmonth - 1, scheduleDataDB.get(i).inqday, scheduleDataDB.get(i).inqhour, 0);
  5026. alarmCalendar.add(Calendar.DATE, -1);
  5027. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.YEAR): " + ScheduleCal.get(Calendar.YEAR) + ", alarmCalendar.get(Calendar.YEAR): " + alarmCalendar.get(Calendar.YEAR));
  5028. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MONTH): " + ScheduleCal.get(Calendar.MONTH) + ", alarmCalendar.get(Calendar.MONTH): " + alarmCalendar.get(Calendar.MONTH));
  5029. // 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));
  5030. // 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));
  5031. // Log.i(TAG, "[checkScheduleReminder] cal.get(Calendar.MINUTE): " + ScheduleCal.get(Calendar.MINUTE) + ", alarmCalendar.get(Calendar.MINUTE): " + alarmCalendar.get(Calendar.MINUTE));
  5032. if ((ScheduleCal.get(Calendar.YEAR) == alarmCalendar.get(Calendar.YEAR))
  5033. && (ScheduleCal.get(Calendar.MONTH) == alarmCalendar.get(Calendar.MONTH))
  5034. && (ScheduleCal.get(Calendar.DAY_OF_MONTH) == alarmCalendar.get(Calendar.DAY_OF_MONTH))
  5035. && (ScheduleCal.get(Calendar.HOUR_OF_DAY) == alarmCalendar.get(Calendar.HOUR_OF_DAY))
  5036. && (ScheduleCal.get(Calendar.MINUTE) == alarmCalendar.get(Calendar.MINUTE)))
  5037. {
  5038. AlarmScheduleCount++;
  5039. if (bAlarmScheduleString == false) {
  5040. bAlarmScheduleString = true;
  5041. if (scheduleDataDB.get(i).inqttype.equalsIgnoreCase("moon")) {
  5042. AlarmScheduleString = "[음력] "+ getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5043. }
  5044. else {
  5045. AlarmScheduleString = getScheduleEventType(scheduleDataDB.get(i).inqitype);
  5046. }
  5047. }
  5048. }
  5049. }
  5050. else {
  5051. Log.w(TAG, "[checkScheduleReminder] Unsupported alarm type!! -> " + scheduleDataDB.get(i).inqatype);
  5052. }
  5053. }
  5054. }
  5055. }
  5056. Log.i(TAG, "[checkScheduleReminder] bAlarmScheduleString [" + bAlarmScheduleString + "], AlarmScheduleCount [" + AlarmScheduleCount + "]");
  5057. if (bAlarmScheduleString == true) {
  5058. if(AlarmScheduleCount == 1) {
  5059. //일정이 1개인 경우
  5060. AlarmScheduleString += " 일정이 있습니다.\r\n확인 하시겠습니까?";
  5061. }
  5062. else {
  5063. //일정이 1개보다 많은 경우
  5064. AlarmScheduleString += " 일정 외 "+(AlarmScheduleCount-1)+"건이 있습니다.\r\n확인 하시겠습니까?";
  5065. }
  5066. AlarmScheduleCount = 0;
  5067. bAlarmScheduleString = false;
  5068. MakePopup_Schedule(AlarmScheduleString);
  5069. }
  5070. }
  5071. else {
  5072. Log.w(TAG, "[checkScheduleReminder] scheduleDataDB is null!!");
  5073. }
  5074. } catch (RuntimeException re) {
  5075. LogUtil.errorLogInfo("", TAG, re);
  5076. }
  5077. catch (Exception e) {
  5078. Log.e(TAG, "[Exception] checkScheduleReminder(Calendar cal)");
  5079. LogUtil.errorLogInfo("", TAG, e);
  5080. }
  5081. }
  5082. // 프로토콜에 정의된 일정표 이벤트 종류를 변환하여 반환한다.
  5083. private String getScheduleEventType(String strEvent) {
  5084. try {
  5085. Log.i(TAG, "[getScheduleEventType] strEvent [" + strEvent + "]");
  5086. if (strEvent.equalsIgnoreCase("birth")) return "생일";
  5087. else if (strEvent.equalsIgnoreCase("memorial")) return "기념일";
  5088. else if (strEvent.equalsIgnoreCase("appoint")) return "약속";
  5089. else if (strEvent.equalsIgnoreCase("trip")) return "여행";
  5090. else if (strEvent.equalsIgnoreCase("first")) return "돌";
  5091. else if (strEvent.equalsIgnoreCase("wedding")) return "결혼";
  5092. else if (strEvent.equalsIgnoreCase("tax")) return "공과금";
  5093. else if (strEvent.equalsIgnoreCase("meeting")) return "모임";
  5094. else if (strEvent.equalsIgnoreCase("car")) return "생일";
  5095. else if (strEvent.equalsIgnoreCase("ancestor")) return "제사";
  5096. else return "알수없음";
  5097. } catch (RuntimeException re) {
  5098. LogUtil.errorLogInfo("", TAG, re);
  5099. return "알수없음";
  5100. }
  5101. catch (Exception e) {
  5102. Log.e(TAG, "[Exception] getScheduleEventType(String strEvent)");
  5103. LogUtil.errorLogInfo("", TAG, e);
  5104. return "알수없음";
  5105. }
  5106. }
  5107. private void getParkedVehicleLocationSysInfo() {
  5108. try {
  5109. DebugLogOutput("getParkedVehicleLocationSysInfo Init");
  5110. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  5111. String[] ParkingDB = devSet.GetSettingData("주차확인");
  5112. devSet.closeDB();
  5113. if (ParkingDB!=null) {
  5114. try {
  5115. String devInfo = ParkingDB[1];
  5116. devInfo = devInfo.replace('(', '_');
  5117. devInfo = devInfo.replace(':', '_');
  5118. devInfo = devInfo.replace(')', '_');
  5119. String[] ParkingInfo = devInfo.split("_");
  5120. //ParkingInfo[3] -> 사용여부 <사용함 / else>
  5121. //ParkingInfo[5] -> 종류 <기본 / 아이콘트롤스 / NEXPA / UPIS / ETC / 비상벨 / else>
  5122. //ParkingInfo[7] -> IP정보
  5123. //ParkingInfo[8] -> 포트번호
  5124. if (ParkingInfo[3].equalsIgnoreCase("사용함") == true) {
  5125. bUseofNot_ParkingInfo = true;
  5126. }
  5127. if (ParkingInfo[5].equalsIgnoreCase("기본") == true) {
  5128. nParkingSystemType = Common.PARKING_SYSTEM_BASIC;
  5129. }
  5130. else if (ParkingInfo[5].equalsIgnoreCase("아이콘트롤스") == true) {
  5131. nParkingSystemType = Common.PARKING_SYSTEM_ICONTROLS;
  5132. }
  5133. else if (ParkingInfo[5].equalsIgnoreCase("넥스파") == true) {
  5134. nParkingSystemType = Common.PARKING_SYSTEM_NEXPA;
  5135. }
  5136. else if (ParkingInfo[5].equalsIgnoreCase("NEXPA") == true) {
  5137. nParkingSystemType = Common.PARKING_SYSTEM_NEXPA;
  5138. }
  5139. else if (ParkingInfo[5].equalsIgnoreCase("UPIS") == true) {
  5140. nParkingSystemType = Common.PARKING_SYSTEM_UPIS;
  5141. }
  5142. else if (ParkingInfo[5].equalsIgnoreCase("ETC") == true) {
  5143. nParkingSystemType = Common.PARKING_SYSTEM_ETC;
  5144. }
  5145. else if (ParkingInfo[5].equalsIgnoreCase("비상벨") == true) {
  5146. nParkingSystemType = Common.PARKING_SYSTEM_IES_100;
  5147. }
  5148. else if (ParkingInfo[5].equalsIgnoreCase("다람정보") == true) {
  5149. nParkingSystemType = Common.PARKING_SYSTEM_DARAM;
  5150. }
  5151. ParkingServerIP = ParkingInfo[7];
  5152. ParkingServerPort = Integer.parseInt(ParkingInfo[8]);
  5153. DebugLogOutput("[getParkedVehicleLocationSysInfo] bUseofNot_ParkingInfo [" + bUseofNot_ParkingInfo + ", nParkingSystemType ["+ nParkingSystemType + "]");
  5154. DebugLogOutput("[getParkedVehicleLocationSysInfo] ParkingServerIP ["+ParkingServerIP + "], ParkingServerPort [" + ParkingServerPort + "]");
  5155. } catch (RuntimeException re) {
  5156. LogUtil.errorLogInfo("", TAG, re);
  5157. bUseofNot_ParkingInfo = false;
  5158. }
  5159. catch (Exception e) {
  5160. LogUtil.errorLogInfo("", TAG, e);
  5161. bUseofNot_ParkingInfo = false;
  5162. }
  5163. }
  5164. else {
  5165. bUseofNot_ParkingInfo = false;
  5166. DebugLogOutput("[getParkedVehicleLocationSysInfo] bUseofNot_ParkingInfo ["+bUseofNot_ParkingInfo + "]");
  5167. }
  5168. } catch (RuntimeException re) {
  5169. LogUtil.errorLogInfo("", TAG, re);
  5170. }
  5171. catch (Exception e) {
  5172. LogUtil.errorLogInfo("", TAG, e);
  5173. }
  5174. }
  5175. //20분 마다 한번씩 호출되는 주차관련 함수!
  5176. private void GetParkingInfo_RandomCheckHandler() {
  5177. int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  5178. if (DelayTime < 1) {
  5179. return;
  5180. }
  5181. DebugLogOutput("[GetParkingInfo] DelayTime : "+ DelayTime);
  5182. bSetMSG_GetParkingInfo = true;
  5183. mGetParkInfoRandomCheckHandler.sendEmptyMessageDelayed(0, 1000 * DelayTime);
  5184. }
  5185. private Handler mGetParkInfoRandomCheckHandler = new Handler()
  5186. {
  5187. @Override
  5188. public void handleMessage(Message msg)
  5189. {
  5190. if (msg.what == 0) {
  5191. DebugLogOutput("[GetParkingInfo] mGetParkInfoRandomCheckHandler() will be called");
  5192. //얻어오기
  5193. LoadParkingDataFromServer();
  5194. }
  5195. }
  5196. };
  5197. /**
  5198. * @description 주차정보 서버로부터 얻어오기<br>
  5199. * 호출 시에는 bSetMSG_GetParkingInfo = true 하고 호출해야함.
  5200. * **/
  5201. private void LoadParkingDataFromServer() {
  5202. try {
  5203. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5204. final AddressSet addc = SetData.getAddressMGR();
  5205. SetData.closeDB();
  5206. if (bSetMSG_GetParkingInfo == false) {
  5207. return;
  5208. }
  5209. if ((nParkingSystemType == Common.PARKING_SYSTEM_BASIC)
  5210. || (nParkingSystemType == Common.PARKING_SYSTEM_ICONTROLS)
  5211. || (nParkingSystemType == Common.PARKING_SYSTEM_NEXPA)
  5212. || (nParkingSystemType == Common.PARKING_SYSTEM_IES_100))
  5213. {
  5214. iMAPcarParking = new iMAPCarParking(mContext, true);
  5215. iMAPcarParking.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5216. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5217. DebugLogOutput("iMAPcarParking.DoWork()");
  5218. iMAPcarParking.DoWork();
  5219. iMAPcarParking.SetRetCtr(new RetProci(){
  5220. @Override
  5221. public void ProcSuccess() {
  5222. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5223. try {
  5224. iMAPcarParking.SetItem("home_info");
  5225. int home_info_count = Integer.parseInt(iMAPcarParking.GetAttributeVal(0, "count"));
  5226. int park_info_count = iMAPcarParking.SetItem("park_info");
  5227. if (home_info_count != park_info_count) {
  5228. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5229. cGetParkingMin = 0;
  5230. bSetMSG_GetParkingInfo = false;
  5231. return;
  5232. }
  5233. if (park_info_count == 0) {
  5234. DebugLogOutput("park_info_count :" + park_info_count);
  5235. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5236. parkdb.DeleteAllParkInfo();
  5237. parkdb.closeDB();
  5238. cGetParkingMin = 0;
  5239. bSetMSG_GetParkingInfo = false;
  5240. /*
  5241. parkdb = new WallpadParkInfo(getApplicationContext());
  5242. int countRow = parkdb.RowCountCarParking();
  5243. parkdb.closeDB();
  5244. DebugLogOutput("countRow :" + countRow);
  5245. */
  5246. Intent intent = new Intent();
  5247. intent.setAction(define.NOTIFY_ACNAME);
  5248. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5249. getApplicationContext().sendBroadcast(intent);
  5250. return;
  5251. }
  5252. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5253. parkdb.DeleteAllParkInfo();
  5254. parkdb.closeDB();
  5255. for (int i = 0; i < park_info_count; i++) {
  5256. if ((addc.Dong.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "ho")))) {
  5257. parkdb = new WallpadParkInfo(getApplicationContext());
  5258. parkdb.InputParkInfo(
  5259. iMAPcarParking.GetAttributeVal(i, "index"),
  5260. iMAPcarParking.GetAttributeVal(i, "dong"),
  5261. iMAPcarParking.GetAttributeVal(i, "ho"),
  5262. iMAPcarParking.GetAttributeVal(i, "card_num"),
  5263. iMAPcarParking.GetAttributeVal(i, "uid"),
  5264. iMAPcarParking.GetAttributeVal(i, "sn"),
  5265. iMAPcarParking.GetAttributeVal(i, "card_type"),
  5266. iMAPcarParking.GetAttributeVal(i, "time"),
  5267. iMAPcarParking.GetAttributeVal(i, "location_text"),
  5268. iMAPcarParking.GetAttributeVal(i, "location_map"),
  5269. iMAPcarParking.GetAttributeVal(i, "vehicle_info"),
  5270. iMAPcarParking.GetAttributeVal(i, "ftp_path"),
  5271. iMAPcarParking.GetAttributeVal(i, "ftp_info"),
  5272. iMAPcarParking.GetAttributeVal(i, "message"));
  5273. parkdb.closeDB();
  5274. }
  5275. }
  5276. //테스트
  5277. parkdb = new WallpadParkInfo(getApplicationContext());
  5278. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5279. parkdb.closeDB();
  5280. if (carParkingData != null) {
  5281. for (int j = 0; j < carParkingData.length; j++) {
  5282. DebugLogOutput(carParkingData[j].ToDebugString());
  5283. }
  5284. }
  5285. //테스트
  5286. Intent intent = new Intent();
  5287. intent.setAction(define.NOTIFY_ACNAME);
  5288. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5289. getApplicationContext().sendBroadcast(intent);
  5290. } catch (RuntimeException re) {
  5291. LogUtil.errorLogInfo("", TAG, re);
  5292. cGetParkingMin = 0;
  5293. bSetMSG_GetParkingInfo = false;
  5294. }
  5295. catch (Exception e) {
  5296. cGetParkingMin = 0;
  5297. bSetMSG_GetParkingInfo = false;
  5298. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5299. LogUtil.errorLogInfo("", TAG, e);
  5300. }
  5301. cGetParkingMin = 0;
  5302. bSetMSG_GetParkingInfo = false;
  5303. }
  5304. @Override
  5305. public void ProcError() {
  5306. cGetParkingMin = 0;
  5307. bSetMSG_GetParkingInfo = false;
  5308. DebugLogOutput("Load EMData From Server - ProcError");
  5309. }
  5310. @Override
  5311. public void ProcDoing() {
  5312. }
  5313. });
  5314. }
  5315. else if (nParkingSystemType == Common.PARKING_SYSTEM_DARAM) {
  5316. iMAPcarParking = new iMAPCarParking(mContext, false);
  5317. iMAPcarParking.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5318. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5319. DebugLogOutput("iMAPcarParking.DoWork()");
  5320. iMAPcarParking.DoWork();
  5321. iMAPcarParking.SetRetCtr(new RetProci(){
  5322. @Override
  5323. public void ProcSuccess() {
  5324. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5325. try {
  5326. iMAPcarParking.SetItem("home_info");
  5327. int home_info_count = Integer.parseInt(iMAPcarParking.GetAttributeVal(0, "count"));
  5328. int park_info_count = iMAPcarParking.SetItem("park_info");
  5329. if (home_info_count != park_info_count) {
  5330. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5331. cGetParkingMin = 0;
  5332. bSetMSG_GetParkingInfo = false;
  5333. return;
  5334. }
  5335. if (park_info_count == 0) {
  5336. DebugLogOutput("park_info_count :" + park_info_count);
  5337. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5338. parkdb.DeleteAllParkInfo();
  5339. parkdb.closeDB();
  5340. cGetParkingMin = 0;
  5341. bSetMSG_GetParkingInfo = false;
  5342. /*
  5343. parkdb = new WallpadParkInfo(getApplicationContext());
  5344. int countRow = parkdb.RowCountCarParking();
  5345. parkdb.closeDB();
  5346. DebugLogOutput("countRow :" + countRow);
  5347. */
  5348. Intent intent = new Intent();
  5349. intent.setAction(define.NOTIFY_ACNAME);
  5350. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5351. getApplicationContext().sendBroadcast(intent);
  5352. return;
  5353. }
  5354. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5355. parkdb.DeleteAllParkInfo();
  5356. parkdb.closeDB();
  5357. for (int i = 0; i < park_info_count; i++) {
  5358. if ((addc.Dong.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMAPcarParking.GetAttributeVal(i, "ho")))) {
  5359. parkdb = new WallpadParkInfo(getApplicationContext());
  5360. parkdb.InputParkInfo(
  5361. iMAPcarParking.GetAttributeVal(i, "index"),
  5362. iMAPcarParking.GetAttributeVal(i, "dong"),
  5363. iMAPcarParking.GetAttributeVal(i, "ho"),
  5364. iMAPcarParking.GetAttributeVal(i, "card_num"),
  5365. iMAPcarParking.GetAttributeVal(i, "uid"),
  5366. iMAPcarParking.GetAttributeVal(i, "sn"),
  5367. iMAPcarParking.GetAttributeVal(i, "card_type"),
  5368. iMAPcarParking.GetAttributeVal(i, "time"),
  5369. iMAPcarParking.GetAttributeVal(i, "location_text"),
  5370. iMAPcarParking.GetAttributeVal(i, "location_map"),
  5371. iMAPcarParking.GetAttributeVal(i, "vehicle_info"),
  5372. iMAPcarParking.GetAttributeVal(i, "ftp_path"),
  5373. iMAPcarParking.GetAttributeVal(i, "ftp_info"),
  5374. iMAPcarParking.GetAttributeVal(i, "message"));
  5375. parkdb.closeDB();
  5376. }
  5377. }
  5378. //테스트
  5379. parkdb = new WallpadParkInfo(getApplicationContext());
  5380. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5381. parkdb.closeDB();
  5382. if (carParkingData != null) {
  5383. for (int j = 0; j < carParkingData.length; j++) {
  5384. DebugLogOutput(carParkingData[j].ToDebugString());
  5385. }
  5386. }
  5387. //테스트
  5388. Intent intent = new Intent();
  5389. intent.setAction(define.NOTIFY_ACNAME);
  5390. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5391. getApplicationContext().sendBroadcast(intent);
  5392. } catch (RuntimeException re) {
  5393. LogUtil.errorLogInfo("", TAG, re);
  5394. cGetParkingMin = 0;
  5395. bSetMSG_GetParkingInfo = false;
  5396. }
  5397. catch (Exception e) {
  5398. cGetParkingMin = 0;
  5399. bSetMSG_GetParkingInfo = false;
  5400. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5401. LogUtil.errorLogInfo("", TAG, e);
  5402. }
  5403. cGetParkingMin = 0;
  5404. bSetMSG_GetParkingInfo = false;
  5405. }
  5406. @Override
  5407. public void ProcError() {
  5408. cGetParkingMin = 0;
  5409. bSetMSG_GetParkingInfo = false;
  5410. DebugLogOutput("Load EMData From Server - ProcError");
  5411. }
  5412. @Override
  5413. public void ProcDoing() {
  5414. }
  5415. });
  5416. }
  5417. else if (nParkingSystemType == Common.PARKING_SYSTEM_UPIS) {
  5418. iMapcarParking_UPIS = new iMAPCarParking_UPIS(mContext, false);
  5419. iMapcarParking_UPIS.SetServerIPcfg(ParkingServerIP, ParkingServerPort);
  5420. DebugLogOutput("ParkingServerIP :"+ParkingServerIP+", ParkingServerPort : "+ParkingServerPort);
  5421. DebugLogOutput("iMapcarParking_UPIS.DoWork()");
  5422. iMapcarParking_UPIS.DoWork();
  5423. iMapcarParking_UPIS.SetRetCtr(new RetProci(){
  5424. @Override
  5425. public void ProcSuccess() {
  5426. DebugLogOutput("Load EMData From Server - ProcSuccess");
  5427. try {
  5428. iMapcarParking_UPIS.SetItem("home_info");
  5429. int home_info_count = Integer.parseInt(iMapcarParking_UPIS.GetAttributeVal(0, "count"));
  5430. int park_info_count = iMapcarParking_UPIS.SetItem("park_info");
  5431. if (home_info_count != park_info_count) {
  5432. DebugLogOutput("home_info_count != park_info_count -->"+ home_info_count+" != "+ park_info_count);
  5433. cGetParkingMin = 0;
  5434. bSetMSG_GetParkingInfo = false;
  5435. return;
  5436. }
  5437. if (park_info_count == 0) {
  5438. DebugLogOutput("park_info_count :" + park_info_count);
  5439. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5440. parkdb.DeleteAllParkInfo();
  5441. parkdb.closeDB();
  5442. cGetParkingMin = 0;
  5443. bSetMSG_GetParkingInfo = false;
  5444. /*
  5445. parkdb = new WallpadParkInfo(getApplicationContext());
  5446. int countRow = parkdb.RowCountCarParking();
  5447. parkdb.closeDB();
  5448. DebugLogOutput("countRow :" + countRow);
  5449. */
  5450. Intent intent = new Intent();
  5451. intent.setAction(define.NOTIFY_ACNAME);
  5452. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5453. getApplicationContext().sendBroadcast(intent);
  5454. return;
  5455. }
  5456. WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
  5457. parkdb.DeleteAllParkInfo();
  5458. parkdb.closeDB();
  5459. for (int i = 0; i < park_info_count; i++) {
  5460. if ((addc.Dong.equalsIgnoreCase(iMapcarParking_UPIS.GetAttributeVal(i, "dong"))) && (addc.Ho.equalsIgnoreCase(iMapcarParking_UPIS.GetAttributeVal(i, "ho")))) {
  5461. parkdb = new WallpadParkInfo(getApplicationContext());
  5462. parkdb.InputParkInfo(
  5463. iMapcarParking_UPIS.GetAttributeVal(i, "index"),
  5464. iMapcarParking_UPIS.GetAttributeVal(i, "dong"),
  5465. iMapcarParking_UPIS.GetAttributeVal(i, "ho"),
  5466. "null",
  5467. iMapcarParking_UPIS.GetAttributeVal(i, "uid"),
  5468. iMapcarParking_UPIS.GetAttributeVal(i, "sn"),
  5469. iMapcarParking_UPIS.GetAttributeVal(i, "card_type"),
  5470. iMapcarParking_UPIS.GetAttributeVal(i, "time"),
  5471. iMapcarParking_UPIS.GetAttributeVal(i, "location_2"),
  5472. iMapcarParking_UPIS.GetAttributeVal(i, "location_1"),
  5473. iMapcarParking_UPIS.GetAttributeVal(i, "car_info"),
  5474. "null",
  5475. "null",
  5476. iMapcarParking_UPIS.GetAttributeVal(i, "message"));
  5477. parkdb.closeDB();
  5478. }
  5479. }
  5480. //테스트
  5481. parkdb = new WallpadParkInfo(getApplicationContext());
  5482. CarParkingData carParkingData[] = parkdb.getCarParkingData();
  5483. parkdb.closeDB();
  5484. if (carParkingData != null) {
  5485. for (int j = 0; j < carParkingData.length; j++) {
  5486. DebugLogOutput(carParkingData[j].ToDebugString());
  5487. }
  5488. }
  5489. Intent intent = new Intent();
  5490. intent.setAction(define.NOTIFY_ACNAME);
  5491. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
  5492. getApplicationContext().sendBroadcast(intent);
  5493. } catch (RuntimeException re) {
  5494. LogUtil.errorLogInfo("", TAG, re);
  5495. cGetParkingMin = 0;
  5496. bSetMSG_GetParkingInfo = false;
  5497. }
  5498. catch (Exception e) {
  5499. cGetParkingMin = 0;
  5500. bSetMSG_GetParkingInfo = false;
  5501. Log.e(TAG, "[Exception] iMAPcarParking.ProcSuccess()");
  5502. LogUtil.errorLogInfo("", TAG, e);
  5503. }
  5504. cGetParkingMin = 0;
  5505. bSetMSG_GetParkingInfo = false;
  5506. }
  5507. @Override
  5508. public void ProcError() {
  5509. cGetParkingMin = 0;
  5510. bSetMSG_GetParkingInfo = false;
  5511. DebugLogOutput("Load EMData From Server - ProcError");
  5512. }
  5513. @Override
  5514. public void ProcDoing() {
  5515. }
  5516. });
  5517. }
  5518. } catch (RuntimeException re) {
  5519. LogUtil.errorLogInfo("", TAG, re);
  5520. }
  5521. catch (Exception e) {
  5522. Log.e(TAG, "[Exception] LoadParkingDataFromServer()");
  5523. LogUtil.errorLogInfo("", TAG, e);
  5524. }
  5525. }
  5526. // 한시간에 한번식 호출되는 함수임
  5527. private void DoScheduleHourUnit(Calendar cal) {
  5528. nHour = cal.get(Calendar.HOUR_OF_DAY);
  5529. // 매시 7시부터 매시간 정각에 계속해서 알려준다. 사용자가 확인하기 전까지...
  5530. // 사용자가 확인하게 되면 알림을 중지한다.
  5531. // 목표값 팝업 알림에 필요한 DB 정보
  5532. // 각각의 항목에 대한 초기화, 근접알림 발생, 근접알림 확인, 초과 알림 발생 , 초과알림 확인 5단계 구분 필요
  5533. // 달이 넘어가게 되면 초괴하 한다.
  5534. try {
  5535. if (nHour == GetEnergyAlarmTime()) {
  5536. if (GetEnergyAlarm() == true) {
  5537. if (bUseofNot_EnergyServer == true) {
  5538. if (ResultGetIntent == true) {
  5539. ResultGetIntent = false;
  5540. Intent intent = new Intent();
  5541. intent.setAction(define.NOTIFY_ACNAME);
  5542. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_MAIN_ACTIVIVY);
  5543. intent.putExtra("elect_target", elect_target);
  5544. intent.putExtra("elect_used", elect_used);
  5545. intent.putExtra("elect_info", elect_info);
  5546. intent.putExtra("water_target", water_target);
  5547. intent.putExtra("water_used", water_used);
  5548. intent.putExtra("water_info", water_info);
  5549. intent.putExtra("gas_target", gas_target);
  5550. intent.putExtra("gas_used", gas_used);
  5551. intent.putExtra("gas_info", gas_info);
  5552. intent.putExtra("heating_target", heating_target);
  5553. intent.putExtra("heating_used", heating_used);
  5554. intent.putExtra("heating_info", heating_info);
  5555. intent.putExtra("hotwater_target", hotwater_target);
  5556. intent.putExtra("hotwater_used", hotwater_used);
  5557. intent.putExtra("hotwater_info", hotwater_info);
  5558. sendBroadcast(intent);
  5559. }
  5560. }
  5561. else {
  5562. CheckEnergyUsage();
  5563. }
  5564. }
  5565. }
  5566. } catch (RuntimeException re) {
  5567. LogUtil.errorLogInfo("", TAG, re);
  5568. }
  5569. catch (Exception e) {
  5570. LogUtil.errorLogInfo("", TAG, e);
  5571. }
  5572. if (SCManager != null ) SCManager.CheckSysResetData();
  5573. }
  5574. static boolean NeedCheckEnergy = false;
  5575. //에너지 사용량 확인
  5576. public void CheckEnergyUsage() {
  5577. Log.d(TAG, "***********************************************");
  5578. Log.d(TAG, "[CheckEnergyUsage] CheckEnergyUsage Function in");
  5579. Log.d(TAG, "***********************************************");
  5580. try {
  5581. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5582. int alarmstate = SetData.GetAlarmStatus();
  5583. SetData.closeDB();
  5584. if (alarmstate == WallpadStatusData.ALARM_ARISE || alarmstate == WallpadStatusData.GUARD_OUT)
  5585. return;
  5586. String strNear = "";
  5587. String strOver = "";
  5588. if (EnergyAlramPopupMgr.m_Elec_UseValue > 0 && EnergyAlramPopupMgr.m_Elec_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP)) {
  5589. if (EnergyAlramPopupMgr.m_Elec_UseValue >= EnergyAlramPopupMgr.m_Elec_GoalValue) {
  5590. strOver += "전기 ";
  5591. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP);
  5592. }
  5593. else {
  5594. double nNearValue = EnergyAlramPopupMgr.m_Elec_GoalValue * 0.9;
  5595. if (EnergyAlramPopupMgr.m_Elec_UseValue > nNearValue) {
  5596. strNear += "전기 ";
  5597. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_ELEC_ALAM_POPUP_STEP);
  5598. }
  5599. }
  5600. }
  5601. if (EnergyAlramPopupMgr.m_Water_UseValue > 0 && EnergyAlramPopupMgr.m_Water_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP)) {
  5602. if (EnergyAlramPopupMgr.m_Water_UseValue >= EnergyAlramPopupMgr.m_Water_GoalValue) {
  5603. strOver += "수도 ";
  5604. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP);
  5605. }
  5606. else {
  5607. double nNearValue = EnergyAlramPopupMgr.m_Water_GoalValue * 0.9;
  5608. if (EnergyAlramPopupMgr.m_Water_UseValue > nNearValue) {
  5609. strNear += "수도 ";
  5610. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_WATER_ALAM_POPUP_STEP);
  5611. }
  5612. }
  5613. }
  5614. if (EnergyAlramPopupMgr.m_Gas_UseValue > 0 && EnergyAlramPopupMgr.m_Gas_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP)) {
  5615. if (EnergyAlramPopupMgr.m_Gas_UseValue >= EnergyAlramPopupMgr.m_Gas_GoalValue) {
  5616. strOver += "가스 ";
  5617. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP);
  5618. }
  5619. else {
  5620. double nNearValue = EnergyAlramPopupMgr.m_Gas_GoalValue * 0.9;
  5621. if (EnergyAlramPopupMgr.m_Gas_UseValue > nNearValue) {
  5622. strNear += "가스 ";
  5623. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_GAS_ALAM_POPUP_STEP);
  5624. }
  5625. }
  5626. }
  5627. if (EnergyAlramPopupMgr.m_HotWater_UseValue > 0 && EnergyAlramPopupMgr.m_HotWater_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP)) {
  5628. if (EnergyAlramPopupMgr.m_HotWater_UseValue >= EnergyAlramPopupMgr.m_HotWater_GoalValue) {
  5629. strOver += "온수 ";
  5630. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP);
  5631. }
  5632. else {
  5633. double nNearValue = EnergyAlramPopupMgr.m_HotWater_GoalValue * 0.9;
  5634. if (EnergyAlramPopupMgr.m_HotWater_UseValue > nNearValue) {
  5635. strNear += "온수 ";
  5636. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_HOTWATER_ALAM_POPUP_STEP);
  5637. }
  5638. }
  5639. }
  5640. if (EnergyAlramPopupMgr.m_Heating_UseValue > 0 && EnergyAlramPopupMgr.m_Heating_GoalValue > 0 && EnergyAlramPopupMgr.CheckAlramPopupCreate( getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP)) {
  5641. if (EnergyAlramPopupMgr.m_Heating_UseValue >= EnergyAlramPopupMgr.m_Heating_GoalValue) {
  5642. strOver += "난방 ";
  5643. EnergyAlramPopupMgr.setAlramOverStep(getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP);
  5644. }
  5645. else {
  5646. double nNearValue = EnergyAlramPopupMgr.m_Heating_GoalValue * 0.9;
  5647. if (EnergyAlramPopupMgr.m_Heating_UseValue > nNearValue) {
  5648. strNear += "난방 ";
  5649. EnergyAlramPopupMgr.setAlramNearStep(getContext(), EnergyAlramPopupMgr.DB_HEATING_ALAM_POPUP_STEP);
  5650. }
  5651. }
  5652. }
  5653. if (strNear.length() > 8) EnergyAlramPopupMgr.PopupMsg01 = strNear + "사용량이\n목표값에 가까워지고 있습니다.\n확인 하시겠습니까?";
  5654. else if (0 < strNear.length() && strNear.length() <= 8) EnergyAlramPopupMgr.PopupMsg01 = strNear + "사용량이 목표값에 가까워지고 있습니다.\n확인 하시겠습니까?";
  5655. else EnergyAlramPopupMgr.PopupMsg01 = "";
  5656. if (strOver.length() > 10) {
  5657. EnergyAlramPopupMgr.PopupMsg02 = strOver + "사용량이\n목표값을 초과하였습니다.\n확인 하시겠습니까?";
  5658. }
  5659. else if (0 < strOver.length() && strOver.length() <= 10) {
  5660. EnergyAlramPopupMgr.PopupMsg02 = strOver + "사용량이 목표값을 초과하였습니다.\n확인 하시겠습니까?";
  5661. }
  5662. else if(strOver.length() < 0){
  5663. EnergyAlramPopupMgr.PopupMsg02 = "";
  5664. }
  5665. if (EnergyAlramPopupMgr.PopupMsg01.length() > 0 || EnergyAlramPopupMgr.PopupMsg02.length() > 0) {
  5666. mIOInterface.ctrlLcdWakeUp();
  5667. StartPopup(ID.POPUPS.POPUP_ENERGYUSAGEALERT);
  5668. }
  5669. } catch (RuntimeException re) {
  5670. LogUtil.errorLogInfo("", TAG, re);
  5671. }
  5672. catch (Exception e) {
  5673. Log.e(TAG, "[Exception] CheckEnergyUsage()");
  5674. LogUtil.errorLogInfo("", TAG, e);
  5675. }
  5676. }
  5677. //시간 동기화를 위한 getinfo 실행 시간을 구함
  5678. protected Calendar GetTimeSyncTime()
  5679. {
  5680. Calendar retTime = new GregorianCalendar();
  5681. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5682. AddressSet addc = SetData.getAddressMGR();
  5683. SetData.closeDB();
  5684. try {
  5685. int dong = Integer.parseInt(addc.Dong);
  5686. int ho = 101;
  5687. if(addc.UseOrNotRentHouse == true)
  5688. {
  5689. ho = addc.Ho_Integer;
  5690. }
  5691. else
  5692. {
  5693. ho = Integer.parseInt(addc.Ho);
  5694. }
  5695. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  5696. int hour;
  5697. int min;
  5698. int sec;
  5699. if (interval/3600 > 0)
  5700. {
  5701. hour = 3+interval/3600;
  5702. interval=interval%3600;
  5703. }
  5704. else hour = 6;
  5705. if (interval/60 > 0)
  5706. {
  5707. min = interval/60;
  5708. sec = interval%60;
  5709. }
  5710. else
  5711. {
  5712. min = 0;
  5713. sec = interval;
  5714. }
  5715. retTime.set(Calendar.HOUR_OF_DAY, hour);
  5716. retTime.set(Calendar.MINUTE, min);
  5717. retTime.set(Calendar.SECOND, sec);
  5718. }
  5719. catch (RuntimeException re) {
  5720. LogUtil.errorLogInfo("", TAG, re);
  5721. return null;
  5722. }
  5723. catch (Exception e)
  5724. {
  5725. LogUtil.errorLogInfo("", TAG, e);
  5726. return null;
  5727. }
  5728. return retTime;
  5729. }
  5730. //에너지 사용량 확인을 위한 데이터 로딩 시간을 가져옴
  5731. protected Calendar GetEnergyDataLoadingTime()
  5732. {
  5733. Calendar retTime = new GregorianCalendar();
  5734. WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
  5735. AddressSet addc = SetData.getAddressMGR();
  5736. SetData.closeDB();
  5737. try {
  5738. int dong = Integer.parseInt(addc.Dong);
  5739. int ho = 201;
  5740. if(addc.UseOrNotRentHouse == true)
  5741. {
  5742. ho = addc.Ho_Integer;
  5743. }
  5744. else
  5745. {
  5746. ho = Integer.parseInt(addc.Ho);
  5747. }
  5748. int interval = (dong-(dong/100)*100) * 100 + ho/100;
  5749. int hour;
  5750. int min;
  5751. int sec;
  5752. if (interval/3600 > 0)
  5753. {
  5754. hour = 6+interval/3600;
  5755. interval=interval%3600;
  5756. }
  5757. else hour = 6;
  5758. if (interval/60 > 0)
  5759. {
  5760. min = interval/60;
  5761. sec = interval%60;
  5762. }
  5763. else
  5764. {
  5765. min = 0;
  5766. sec = interval;
  5767. }
  5768. retTime.set(Calendar.HOUR_OF_DAY, hour);
  5769. retTime.set(Calendar.MINUTE, min);
  5770. retTime.set(Calendar.SECOND, sec);
  5771. }
  5772. catch (RuntimeException re) {
  5773. LogUtil.errorLogInfo("", TAG, re);
  5774. return null;
  5775. }
  5776. catch (Exception e)
  5777. {
  5778. LogUtil.errorLogInfo("", TAG, e);
  5779. return null;
  5780. }
  5781. return retTime;
  5782. }
  5783. private void setNetworkAddr(int secNum, int thirdNum, int forthNum) {
  5784. try
  5785. {
  5786. String IPAddress = String.format("10.%d.%d.%d", secNum, thirdNum, forthNum);
  5787. String gateWayIPAddress = String.format("10.%d.%d.%d", secNum, Common.DEFAULT_GATEWAY_IP_THIRD, Common.DEFAULT_GATEWAY_IP_FORTH);
  5788. String MacAddr = String.format("00:0A:%02x:%02x:%02x:00", secNum, thirdNum, forthNum);
  5789. String serverIP = Common.DEFAULT_SERVER_IP;
  5790. int serverPort = Common.DEFAULT_SERVER_PORT;
  5791. String managePCIP = Common.DEFAULT_MANAGER_PC_IP;
  5792. int managePCPort = Common.DEFAULT_MANAGER_PC_PORT;
  5793. wallpaddbmgr dbmgr = new wallpaddbmgr(this);
  5794. AddressSet addc = dbmgr.getAddressMGR();
  5795. String mDong = String.format("%d%02d", 1, secNum);
  5796. String mHo = String.format("%d%02d", thirdNum, forthNum);
  5797. addc.setAddress(mDong, mHo);
  5798. addc.setIPAddress(IPAddress);
  5799. dbmgr.closeDB();
  5800. WallpadStatusData wallpadStatusData = new WallpadStatusData(this);
  5801. wallpadStatusData.SetServerIP(serverIP, serverPort);
  5802. wallpadStatusData.SetManagePC(managePCIP, managePCPort);
  5803. wallpadStatusData.closeDB();
  5804. EthernetDevInfo info = new EthernetDevInfo();
  5805. info.setIfName("eth0");
  5806. info.setConnectMode(EthernetDevInfo.ETH_CONN_MODE_MANUAL);
  5807. info.setIpAddress(IPAddress);
  5808. info.setRouteAddr(gateWayIPAddress);
  5809. info.setDnsAddr(Common.DNS_IP);
  5810. info.setNetMask(Common.SUBNET_MASK);
  5811. EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
  5812. mEthManager.setEthernetState(EthernetManager.ETH_STATE_DISABLED);
  5813. mEthManager.UpdateEthDevInfo(info);
  5814. mEthManager.setEthernetState(EthernetManager.ETH_STATE_ENABLING);
  5815. WallPadInterface wallPadInterface = new WallPadInterface();;
  5816. wallPadInterface.setMacAddr(MacAddr);
  5817. Log.d("MANAGERSETTING", " IP : "+IPAddress+" Mac : "+ MacAddr);
  5818. writeMacAddress(MacAddr);
  5819. }
  5820. catch (RuntimeException re) {
  5821. LogUtil.errorLogInfo("", TAG, re);
  5822. }
  5823. catch (Exception e)
  5824. {
  5825. LogUtil.errorLogInfo("", TAG, e);
  5826. }
  5827. }
  5828. private final String NETWORK_SETTING = "network_setting";
  5829. private final String MAC_ADDRESS_FILE_PATH = Common.CONTENTS_ROOT + NETWORK_SETTING + ".inc";
  5830. private boolean writeMacAddress(String MacAddr) {
  5831. boolean ret = false;
  5832. String read = null;
  5833. BufferedWriter bufferWriter = null;
  5834. try {
  5835. FileOutputStream fos = new FileOutputStream(MAC_ADDRESS_FILE_PATH, false);
  5836. OutputStreamWriter osr = new OutputStreamWriter(fos, "UTF-8");
  5837. bufferWriter = new BufferedWriter(osr, 1024);
  5838. if ((bufferWriter != null) && (MacAddr != null)) {
  5839. bufferWriter.write(MacAddr, 0, MacAddr.length());
  5840. bufferWriter.newLine();
  5841. bufferWriter.flush();
  5842. ret = true;
  5843. }
  5844. } catch (RuntimeException re) {
  5845. LogUtil.errorLogInfo("", TAG, re);
  5846. }
  5847. catch (Exception e) {
  5848. LogUtil.errorLogInfo("", TAG, e);
  5849. } finally {
  5850. try {
  5851. if (bufferWriter != null) {
  5852. bufferWriter.close();
  5853. }
  5854. } catch (RuntimeException re) {
  5855. LogUtil.errorLogInfo("", TAG, re);
  5856. }
  5857. catch (Exception e) {
  5858. LogUtil.errorLogInfo("", TAG, e);
  5859. }
  5860. }
  5861. Log.d(TAG, "writeMacAddress() path : " + MAC_ADDRESS_FILE_PATH
  5862. + ", MacAddr : " + MacAddr
  5863. + ", ret : " + ret
  5864. );
  5865. return ret;
  5866. }
  5867. private void GetElectricCarInfo() {
  5868. try {
  5869. Log.d(TAG, "[GetElectricCarInfo] ===== START =====");
  5870. int retInt = -1;
  5871. WallpadDeviceSet mWallpadDeviceSet = null;
  5872. mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
  5873. retInt = mWallpadDeviceSet.GetDeviceSetted("전기차충전");
  5874. mWallpadDeviceSet.closeDB();
  5875. Log.d(TAG, "[GetElectricCarInfo] retInt = " + retInt);
  5876. if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
  5877. Log.i(TAG, "[GetElectricCarInfo] Electronic car changing enabled!!");
  5878. GetElectricCarInfo_RandomCheckHandler();
  5879. }
  5880. else Log.i(TAG, "[GetElectricCarInfo] Electronic car changing disabled!!");
  5881. } catch (RuntimeException re) {
  5882. LogUtil.errorLogInfo("", TAG, re);
  5883. }
  5884. catch (Exception e) {
  5885. Log.e(TAG, "[Exception] GetElectricCarInfo()");
  5886. LogUtil.errorLogInfo("", TAG, e);
  5887. }
  5888. }
  5889. private void GetElectricCarInfo_RandomCheckHandler() {
  5890. try {
  5891. Log.d(TAG, "[GetElectricCarInfo_RandomCheckHandler] ===== START =====");
  5892. int nDelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  5893. Log.d(TAG, "[GetElectricCarInfo_RandomCheckHandler] nDelayTime : "+ nDelayTime);
  5894. if (nDelayTime < 1) {
  5895. Log.w(TAG, "[GetElectricCarInfo_RandomCheckHandler] DelayTime error!! -> nDelayTime = " + nDelayTime);
  5896. return;
  5897. }
  5898. mGetElecricCarRandomCheckHandler.sendEmptyMessageDelayed(0, 1000 * nDelayTime);
  5899. } catch (RuntimeException re) {
  5900. LogUtil.errorLogInfo("", TAG, re);
  5901. }
  5902. catch (Exception e) {
  5903. Log.e(TAG, "[Exception] GetElectricCarInfo_RandomCheckHandler()");
  5904. LogUtil.errorLogInfo("", TAG, e);
  5905. }
  5906. }
  5907. private Handler mGetElecricCarRandomCheckHandler = new Handler()
  5908. {
  5909. @Override
  5910. public void handleMessage(Message msg)
  5911. {
  5912. if (msg.what == 0) {
  5913. Log.i(TAG, "[GetElectricCarInfo] mGetElecricCarRandomCheckHandler() will be called!!");
  5914. //얻어오기
  5915. imapElecCarChargingInfo = new iMAPElecCarChargingInfo(getApplicationContext());
  5916. LoadElectricCarDataFromServer();
  5917. }
  5918. }
  5919. };
  5920. void LoadElectricCarDataFromServer() {
  5921. DebugLogOutput("LoadElectricCarDataFromServer");
  5922. imapElecCarChargingInfo.DoWork();
  5923. imapElecCarChargingInfo.SetRetCtr(new RetProci() {
  5924. @Override
  5925. public void ProcSuccess() {
  5926. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcSuccess");
  5927. try {
  5928. int SetItemResult = imapElecCarChargingInfo.SetItem("charging_cnt");
  5929. if(SetItemResult != 1) {
  5930. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - SetItemResult : "+ SetItemResult);
  5931. nElecVehicleChangingCnt = 0;
  5932. return;
  5933. }
  5934. String sChargingCount = imapElecCarChargingInfo.GetItemVal(0);
  5935. int intChargingCount = Integer.parseInt(sChargingCount);
  5936. if (intChargingCount < 1) {
  5937. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - intChargingCount : "+ intChargingCount);
  5938. nElecVehicleChangingCnt = 0;
  5939. return;
  5940. }
  5941. SetItemResult = imapElecCarChargingInfo.SetItem("charger_info");
  5942. if (SetItemResult != intChargingCount) {
  5943. Log.w(TAG, "[LoadElectricCarDataFromServer.ProcSuccess()] Error1 - SetItemResult : "+ SetItemResult);
  5944. nElecVehicleChangingCnt = 0;
  5945. return;
  5946. }
  5947. if (intChargingCount > 0) {
  5948. nElecVehicleChangingCnt = intChargingCount;
  5949. Intent intent = new Intent();
  5950. intent.setAction(define.NOTIFY_ACNAME);
  5951. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
  5952. intent.putExtra("sCard_Num", imapElecCarChargingInfo.GetAttributeVal(0, "card_num"));
  5953. intent.putExtra("sCar_Num", imapElecCarChargingInfo.GetAttributeVal(0, "car_num"));
  5954. intent.putExtra("sCharger_Num", imapElecCarChargingInfo.GetAttributeVal(0, "charger_num"));
  5955. intent.putExtra("sCharger_Loc", imapElecCarChargingInfo.GetAttributeVal(0, "charger_loc"));
  5956. intent.putExtra("sCharging_Status", "charging");
  5957. intent.putExtra("sCharger_sort", imapElecCarChargingInfo.GetAttributeVal(0, "charger_sort"));
  5958. intent.putExtra("sCharging_Ratio", imapElecCarChargingInfo.GetAttributeVal(0, "charging_ratio"));
  5959. intent.putExtra("sStart_Time", imapElecCarChargingInfo.GetAttributeVal(0, "start_time"));
  5960. intent.putExtra("sRemain_Time", imapElecCarChargingInfo.GetAttributeVal(0, "remain_time"));
  5961. intent.putExtra("sMessage", imapElecCarChargingInfo.GetAttributeVal(0, "c_msg"));
  5962. getApplicationContext().sendBroadcast(intent);
  5963. }
  5964. } catch (RuntimeException re) {
  5965. LogUtil.errorLogInfo("", TAG, re);
  5966. }
  5967. catch (Exception e) {
  5968. Log.e(TAG, "[Exception] LoadElectricCarDataFromServer() -> ProcSuccess");
  5969. LogUtil.errorLogInfo("", TAG, e);
  5970. }
  5971. }
  5972. @Override
  5973. public void ProcError()
  5974. {
  5975. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcError");
  5976. }
  5977. @Override
  5978. public void ProcDoing()
  5979. {
  5980. Log.i(TAG, "[LoadElectricCarDataFromServer] ProcDoing");
  5981. }
  5982. });
  5983. }
  5984. /**
  5985. * 대외향 Call 버튼 점멸 및 On Off 처리
  5986. */
  5987. @SuppressLint("HandlerLeak")
  5988. protected Handler mLedFlickerHandler = new Handler()
  5989. {
  5990. boolean Flicker = false;
  5991. @SuppressLint("HandlerLeak")
  5992. @Override
  5993. public void handleMessage(Message msg)
  5994. {
  5995. if(msg.what == 0) // 콜 수신시 또는 발신시 ...
  5996. {
  5997. // 점멸 시작 CallButton LED On
  5998. Flicker = true;
  5999. mLedFlickerHandler.sendEmptyMessageDelayed(1, 500);
  6000. WallPadInterface wpdifc = new WallPadInterface();
  6001. wpdifc.callLEDControll(true);
  6002. }
  6003. else if(msg.what == 1)
  6004. {
  6005. mLedFlickerHandler.sendEmptyMessageDelayed(0, 500);
  6006. WallPadInterface wpdifc = new WallPadInterface();
  6007. wpdifc.callLEDControll(false);
  6008. }
  6009. else if(msg.what == 2) // 통화중
  6010. {
  6011. Flicker = false;
  6012. }
  6013. else if(msg.what == 4) // 통화종료
  6014. {
  6015. Flicker = false;
  6016. }
  6017. }
  6018. };
  6019. public void GetEnergyServerInfo()
  6020. {
  6021. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  6022. String[] MetringDB = devSet.GetSettingData("에너지관리서버");
  6023. devSet.closeDB();
  6024. if (MetringDB != null)
  6025. {
  6026. try
  6027. {
  6028. String devInfo = MetringDB[1];
  6029. devInfo = devInfo.replace('(', '_');
  6030. devInfo = devInfo.replace(':', '_');
  6031. devInfo = devInfo.replace(')', '_');
  6032. String[] MetringInfo = devInfo.split("_");
  6033. // MetringInfo[1] -> 회로수
  6034. // MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
  6035. // MetringInfo[4] -> IP
  6036. // MetringInfo[5] -> IP정보
  6037. // MetringInfo[6] -> 검침일사용자설정
  6038. // MetringInfo[7] -> 사용함 또는 사용안함
  6039. if(MetringInfo[3].equals("사용함") == true)
  6040. {
  6041. bUseofNot_EnergyServer = true;
  6042. }
  6043. }
  6044. catch (RuntimeException re) {
  6045. LogUtil.errorLogInfo("", TAG, re);
  6046. }
  6047. catch (Exception e)
  6048. {
  6049. LogUtil.errorLogInfo("", TAG, e);
  6050. }
  6051. }
  6052. else
  6053. {
  6054. }
  6055. Log.d(TAG, "[bUseofNot_EnergyServer] bUseofNot_EnergyServer :"+bUseofNot_EnergyServer);
  6056. }
  6057. /**
  6058. * 카카오 사용 여부 체크
  6059. * @return
  6060. */
  6061. public boolean getKakaoHomeCheck()
  6062. {
  6063. boolean result = false;
  6064. WallpadDeviceSet mWallpadDeviceSet = null;
  6065. mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6066. try {
  6067. result = mWallpadDeviceSet.Get_KakaoUse();
  6068. }
  6069. catch (SQLException e)
  6070. {
  6071. LogUtil.errorLogInfo("", TAG, e);
  6072. }
  6073. return result;
  6074. }
  6075. /**
  6076. * 사용자 설정(카카오를 볼것인지 아닌지를 설정)
  6077. * @return
  6078. */
  6079. public boolean getShowKakaoCheck()
  6080. {
  6081. boolean result = false;
  6082. WallpadDeviceSet mWallpadDeviceSet = null;
  6083. mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6084. try {
  6085. result = mWallpadDeviceSet.Get_KakaoShow();
  6086. }
  6087. catch (SQLException e)
  6088. {
  6089. LogUtil.errorLogInfo("", TAG, e);
  6090. }
  6091. return result;
  6092. }
  6093. public boolean GetEnergyAlarm()
  6094. {
  6095. boolean ret = false;
  6096. WallpadStatusData DBMGR = null;
  6097. DBMGR = new WallpadStatusData(getContext());
  6098. if( DBMGR != null )
  6099. {
  6100. try
  6101. {
  6102. ret = DBMGR.GetRemoteMetering_Alarm();
  6103. }
  6104. catch (RuntimeException re) {
  6105. LogUtil.errorLogInfo("", TAG, re);
  6106. ret = false;
  6107. DBMGR.insertWallPADDB(WallpadStatusData.REMOTE_METERING_ALARM_USE, WallpadStatusData.REMOTE_METERING_ALARM_USE_DEFAULT);
  6108. }
  6109. catch (Exception e)
  6110. {
  6111. LogUtil.errorLogInfo("", TAG, e);
  6112. ret = false;
  6113. DBMGR.insertWallPADDB(WallpadStatusData.REMOTE_METERING_ALARM_USE, WallpadStatusData.REMOTE_METERING_ALARM_USE_DEFAULT);
  6114. }
  6115. DBMGR.closeDB();
  6116. }
  6117. bUseofNot_EnergyAlarm = ret;
  6118. Log.d(TAG, "[bUseofNot_EnergyAlarm] bUseofNot_EnergyAlarm :"+bUseofNot_EnergyAlarm);
  6119. return ret;
  6120. }
  6121. /**
  6122. * @description
  6123. * 에너지 사용량 알림 시간 얻어오기
  6124. * @return int Hour시간 값
  6125. */
  6126. public int GetEnergyAlarmTime()
  6127. {
  6128. int ret = 12;
  6129. WallpadStatusData DBMGR = null;
  6130. DBMGR = new WallpadStatusData(getContext());
  6131. try
  6132. {
  6133. ret = DBMGR.GetRemoteMetering_AlarmTime();
  6134. }
  6135. catch (RuntimeException re) {
  6136. LogUtil.errorLogInfo("", TAG, re);
  6137. }
  6138. catch (Exception e)
  6139. {
  6140. LogUtil.errorLogInfo("", TAG, e);
  6141. }
  6142. DBMGR.closeDB();
  6143. Log.d(TAG, "[GetEnergyAlarmTime] GetEnergyAlarmTime :"+ret);
  6144. return ret;
  6145. }
  6146. public void ClearEnergyUsage()
  6147. {
  6148. ResultGetIntent = false;
  6149. elect_target = "Error";
  6150. elect_used = "Error";
  6151. elect_info = "Error";
  6152. water_target = "Error";
  6153. water_used = "Error";
  6154. water_info = "Error";
  6155. gas_target = "Error";
  6156. gas_used = "Error";
  6157. gas_info = "Error";
  6158. hotwater_target = "Error";
  6159. hotwater_used = "Error";
  6160. hotwater_info = "Error";
  6161. heating_target = "Error";
  6162. heating_used = "Error";
  6163. heating_info = "Error";
  6164. }
  6165. // 신규 통화어플 실행을 위한 코드 (JEFF, 2016.05.23)
  6166. // 통화주체를 다루는 enum
  6167. public enum CALLOWNER {
  6168. NONE,
  6169. WALLPAD,
  6170. MOBILE,
  6171. SUB_WALLPAD,
  6172. KITCHEN_TV,
  6173. BATH_PHONE,
  6174. BATH_TV,
  6175. UNIVERSAL_DEVICE,
  6176. ERROR;
  6177. }
  6178. public enum CALLEVENTTYPE {
  6179. RECEIVE_CALL, // 호출 수신 (호출 수신)
  6180. TRYING_CALL, // 호출 시도중 (호출 발신)
  6181. RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
  6182. RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
  6183. REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
  6184. CONNECT_CALL, // 통화 시작
  6185. TERMINATE_CALL, // 통화 종료
  6186. CANCEL_CALL, // 호출 취소
  6187. CANCEL_CALL_2ND, // 멀티콜 호출 취소
  6188. REJECT_CALL, // 호출수신 거절
  6189. REJECT_BUSY_CALL, // 통화중 호출수신 거절
  6190. FORWARD_CALL, // 착신전환 설정
  6191. CALLERID, // Caller ID_OLD
  6192. TIMEOUT_1STCALL, // 1st Call Timeout
  6193. TIMEOUT_2NDCALL, // 2nd Call Timeout
  6194. TIMEOUT_3RDCALL, // 3rd Call Timeout
  6195. MOIP_VIDEO_SET, // MoIP 영상통화 설정
  6196. DOOR_OPEN, // 문열림 설정
  6197. DETECT_STRANGER, // 거동수상자 발생
  6198. NONE;
  6199. }
  6200. public enum CALLTYPE {
  6201. NONE,
  6202. FRONT,
  6203. RESIDENCE,
  6204. LOBBY,
  6205. GUARD,
  6206. PSTN,
  6207. IHUB,
  6208. HISTORY_CALL,
  6209. HISTORY_VISITORPIC,
  6210. FRONT_RECORD, // 현관_영상녹화
  6211. FRONT_TAKEPIC, // 현관_사진촬영
  6212. ERROR,
  6213. }
  6214. public static class CALLTRIGGER {
  6215. public static String CALLOWNER = "CALLOWNER";
  6216. public static String CALLEVENTTYPE = "CALLEVENTTYPE";
  6217. public static String CALLTYPE = "CALLTYPE";
  6218. public enum SOURCE {
  6219. USER,
  6220. CALL_RECEIVE,
  6221. SUBPHONE
  6222. }
  6223. public enum TYPE {
  6224. MENU,
  6225. FRONT,
  6226. LOBBY,
  6227. GUARD,
  6228. RESIDENCE,
  6229. PSTN
  6230. }
  6231. }
  6232. String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
  6233. public void runWallPadCallAPKByUX(int nScreen) {
  6234. try {
  6235. Log.i(TAG, "[runWallPadCallAPKByUX] nScreen [" + nScreen + "]");
  6236. CALLOWNER eCallOwner = CALLOWNER.NONE;
  6237. CALLEVENTTYPE eEventType = CALLEVENTTYPE.NONE;
  6238. CALLTYPE eCallType = CALLTYPE.GUARD;
  6239. if (nScreen == ID.LINKEDSCREEN.SubCall.Door) {
  6240. if (getIsSubWallpad()) eCallOwner = CALLOWNER.SUB_WALLPAD;
  6241. else eCallOwner = CALLOWNER.WALLPAD;
  6242. eEventType = CALLEVENTTYPE.REQUEST_FRONT_MONITORING;
  6243. eCallType = CALLTYPE.FRONT;
  6244. }
  6245. else if (nScreen == ID.LINKEDSCREEN.SubCall.Door_Record) {
  6246. eCallType = CALLTYPE.FRONT;
  6247. eEventType = CALLEVENTTYPE.DETECT_STRANGER;
  6248. }
  6249. else if (nScreen == ID.LINKEDSCREEN.SubCall.Lobby) eCallType = CALLTYPE.LOBBY;
  6250. else if (nScreen == ID.LINKEDSCREEN.SubCall.Guard) eCallType = CALLTYPE.GUARD;
  6251. else if (nScreen == ID.LINKEDSCREEN.SubCall.Neighboor) eCallType = CALLTYPE.RESIDENCE;
  6252. else if (nScreen == ID.LINKEDSCREEN.SubCall.Pstn) eCallType = CALLTYPE.PSTN;
  6253. else if (nScreen == ID.LINKEDSCREEN.SubCall.CallList) eCallType = CALLTYPE.HISTORY_CALL;
  6254. else if (nScreen == ID.LINKEDSCREEN.SubCall.Visitor) eCallType = CALLTYPE.HISTORY_VISITORPIC;
  6255. else {
  6256. Log.w(TAG, "[runWallPadCallAPKByUX] NOT Supported nScreen!! [" + nScreen + "]");
  6257. }
  6258. Log.i(TAG, "[runWallPadCallAPKByUX] eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6259. if (getIsSubWallpad()) {
  6260. // 서브월패드는 국선 기능을 제공하지 않는다.
  6261. if (eCallType != CALLTYPE.PSTN) runCallMainActivity(eCallOwner, eEventType, eCallType);
  6262. }
  6263. else {
  6264. runCallMainActivity(eCallOwner, eEventType, eCallType);
  6265. }
  6266. } catch (RuntimeException re) {
  6267. LogUtil.errorLogInfo("", TAG, re);
  6268. }
  6269. catch (Exception e) {
  6270. Log.e(TAG, "[Exception] runWallPadCallAPKByUX(int nScreen)");
  6271. LogUtil.errorLogInfo("", TAG, e);
  6272. }
  6273. }
  6274. public void runWallPadCallAPKByUX(int nScreen, int nEmerState) {
  6275. try {
  6276. Log.i(TAG, "[runWallPadCallAPKByUX] nScreen [" + nScreen + "], nEmerState [" + nEmerState + "]");
  6277. CALLOWNER eCallOwner = CALLOWNER.NONE;
  6278. CALLEVENTTYPE eEventType = CALLEVENTTYPE.NONE;
  6279. CALLTYPE eCallType = CALLTYPE.GUARD;
  6280. if (nScreen == ID.LINKEDSCREEN.SubCall.Door) {
  6281. if (getIsSubWallpad()) eCallOwner = CALLOWNER.SUB_WALLPAD;
  6282. else eCallOwner = CALLOWNER.WALLPAD;
  6283. eEventType = CALLEVENTTYPE.REQUEST_FRONT_MONITORING;
  6284. eCallType = CALLTYPE.FRONT;
  6285. }
  6286. else if (nScreen == ID.LINKEDSCREEN.SubCall.Door_Record) {
  6287. eCallType = CALLTYPE.FRONT;
  6288. eEventType = CALLEVENTTYPE.DETECT_STRANGER;
  6289. }
  6290. else if (nScreen == ID.LINKEDSCREEN.SubCall.Lobby) eCallType = CALLTYPE.LOBBY;
  6291. else if (nScreen == ID.LINKEDSCREEN.SubCall.Guard) eCallType = CALLTYPE.GUARD;
  6292. else if (nScreen == ID.LINKEDSCREEN.SubCall.Neighboor) eCallType = CALLTYPE.RESIDENCE;
  6293. else if (nScreen == ID.LINKEDSCREEN.SubCall.Pstn) eCallType = CALLTYPE.PSTN;
  6294. else if (nScreen == ID.LINKEDSCREEN.SubCall.CallList) eCallType = CALLTYPE.HISTORY_CALL;
  6295. else if (nScreen == ID.LINKEDSCREEN.SubCall.Visitor) eCallType = CALLTYPE.HISTORY_VISITORPIC;
  6296. else {
  6297. Log.w(TAG, "[runWallPadCallAPKByUX] NOT Supported nScreen!! [" + nScreen + "]");
  6298. }
  6299. Log.i(TAG, "[runWallPadCallAPKByUX] eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6300. if (getIsSubWallpad()) {
  6301. // 서브월패드는 국선 기능을 제공하지 않는다.
  6302. if (eCallType != CALLTYPE.PSTN) runCallMainActivity(eCallOwner, eEventType, eCallType, nEmerState);
  6303. }
  6304. else {
  6305. runCallMainActivity(eCallOwner, eEventType, eCallType, nEmerState);
  6306. }
  6307. } catch (RuntimeException re) {
  6308. LogUtil.errorLogInfo("", TAG, re);
  6309. }
  6310. catch (Exception e) {
  6311. Log.e(TAG, "[Exception] runWallPadCallAPKByUX(int nScreen, int nEmerState)");
  6312. LogUtil.errorLogInfo("", TAG, e);
  6313. }
  6314. }
  6315. static public Handler CallIntentHandler = new Handler(Looper.getMainLooper()) {
  6316. public void handleMessage(Message msg) {
  6317. if(CallBrList!=null && CallBrList.size() > 0)
  6318. {
  6319. Intent intent = CallBrList.get(0);
  6320. mContext_call.sendBroadcast(intent);
  6321. 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) );
  6322. }
  6323. }
  6324. };
  6325. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
  6326. try {
  6327. Log.i(TAG, "[runCallMainActivity] Common.bWallPadCallLive [" + Common.bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "]");
  6328. if (!Common.bWallPadCallLive) {
  6329. // 통화어플을 실행시킨다.
  6330. sendLCDBacklightStatus(true);
  6331. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  6332. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6333. // mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  6334. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  6335. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  6336. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  6337. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6338. mIntent.setComponent(mComponentName);
  6339. startActivity(mIntent);
  6340. }
  6341. else {
  6342. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  6343. }
  6344. } catch (RuntimeException re) {
  6345. LogUtil.errorLogInfo("", TAG, re);
  6346. }
  6347. catch (Exception e) {
  6348. Log.e(TAG, "[Exception] runCallMainActivity()");
  6349. LogUtil.errorLogInfo("", TAG, e);
  6350. }
  6351. }
  6352. /**
  6353. * Edited by jeff (2020.06.22)
  6354. * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
  6355. * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
  6356. * @param bOn
  6357. */
  6358. private void sendLCDBacklightStatus(boolean bOn) {
  6359. try {
  6360. Log.d(TAG,"[sendLCDBacklightStatus] bOn [" + bOn + "]");
  6361. Intent mIntent = new Intent();
  6362. if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  6363. else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  6364. getApplicationContext().sendBroadcast(mIntent);
  6365. } catch (RuntimeException re) {
  6366. LogUtil.errorLogInfo("", TAG, re);
  6367. }
  6368. catch (Exception e) {
  6369. Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
  6370. LogUtil.errorLogInfo("", TAG, e);
  6371. }
  6372. }
  6373. public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nEmerState) {
  6374. try {
  6375. Log.i(TAG, "[runCallMainActivity] Common.bWallPadCallLive [" + Common.bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "], nEmerState [" + nEmerState + "]");
  6376. if (!Common.bWallPadCallLive) {
  6377. // 통화어플을 실행시킨다.
  6378. sendLCDBacklightStatus(true);
  6379. if (eEventType == CALLEVENTTYPE.DETECT_STRANGER) {
  6380. if (nEmerState >= 0) {
  6381. if (nEmerState != WallpadStatusData.GUARD_OUT)
  6382. Common.SendAppFinishReqBR(getApplicationContext());
  6383. }
  6384. }
  6385. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
  6386. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6387. // mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  6388. mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
  6389. mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
  6390. mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
  6391. mIntent.putExtra("EMERGENCY_STATE", nEmerState);
  6392. if (nEmerState != WallpadStatusData.GUARD_OUT) Common.SendAppFinishReqBR(getApplicationContext());
  6393. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6394. mIntent.setComponent(mComponentName);
  6395. startActivity(mIntent);
  6396. }
  6397. else {
  6398. Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
  6399. }
  6400. } catch (RuntimeException re) {
  6401. LogUtil.errorLogInfo("", TAG, re);
  6402. }
  6403. catch (Exception e) {
  6404. Log.e(TAG, "[Exception] runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nEmerState)");
  6405. LogUtil.errorLogInfo("", TAG, e);
  6406. }
  6407. }
  6408. private String getTopActivity() {
  6409. try {
  6410. ActivityManager mActivityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
  6411. List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
  6412. // LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
  6413. ComponentName mComponentName = mTaskInfo.get(0).topActivity;
  6414. // LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
  6415. return mComponentName.getPackageName();
  6416. } catch (RuntimeException re) {
  6417. LogUtil.errorLogInfo("", TAG, re);
  6418. return null;
  6419. }
  6420. catch (Exception e) {
  6421. Log.e(TAG, "[Exception] getTopActivity()");
  6422. LogUtil.errorLogInfo("", TAG, e);
  6423. return null;
  6424. }
  6425. }
  6426. /**
  6427. * 월패드에 설치된 APP들의 패키지 명 및 버전을 저장하는 클래스
  6428. * **/
  6429. class PackageVersionInfo {
  6430. protected String strPackageName;
  6431. protected String strPackageVersion;
  6432. public PackageVersionInfo(String strName, String strVersion) {
  6433. strPackageName = strName;
  6434. strPackageVersion = strVersion;
  6435. }
  6436. public String getPackageName() {
  6437. return strPackageName;
  6438. }
  6439. public String getPackageVersion() {
  6440. return strPackageVersion;
  6441. }
  6442. }
  6443. /**
  6444. * 통화 타임아웃 DB정보 초기화 (무조건 사용함으로 변경)
  6445. * **/
  6446. public void setCallAppTimeoutAsDefault() {
  6447. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getContext());
  6448. try {
  6449. mWallpadDeviceSet.Set_CallAppCallTimeout(true);
  6450. mWallpadDeviceSet.closeDB();
  6451. } catch (RuntimeException re) {
  6452. LogUtil.errorLogInfo("", TAG, re);
  6453. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6454. }
  6455. catch (Exception e) {
  6456. Log.e(TAG, "[Exception] setCallAppTimeoutAsDefault()");
  6457. LogUtil.errorLogInfo("", TAG, e);
  6458. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6459. }
  6460. }
  6461. /**
  6462. * 동호 설정 화면 나오게 처리
  6463. * **/
  6464. private void startManagerSettingSetAddress() {
  6465. try {
  6466. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6467. MAINStatus = MAIN_WAIT_SETIP;
  6468. mIntent.setComponent(new ComponentName("com.artncore.managersetting", "com.artncore.managersetting.ui.activities.SetAddress"));
  6469. mIntent.putExtra("KIND", "SOLO");
  6470. startActivity(mIntent);
  6471. } catch (RuntimeException re) {
  6472. LogUtil.errorLogInfo("", TAG, re);
  6473. }
  6474. catch (Exception e) {
  6475. Log.e(TAG, "[Exception] startManagerSettingSetAddress()");
  6476. LogUtil.errorLogInfo("", TAG, e);
  6477. }
  6478. }
  6479. private Handler mGetCallHistoryCheckHandler = new Handler() {
  6480. @Override
  6481. public void handleMessage(Message msg) {
  6482. if (msg.what == 0) {
  6483. // CheckCallData_CalledCountAndVisitorCount();
  6484. checkEventNotifications();
  6485. }
  6486. }
  6487. };
  6488. /**
  6489. * 음력 데이터를 raw resource에서 wallpaddata폴더 밑으로 복사한다.
  6490. * **/
  6491. private void copyDataBase(String OutputDBPath) throws IOException {
  6492. // Open your local db as the input stream
  6493. //InputStream myInput = this.getAssets().open("luna_db.db");
  6494. InputStream myInput = getResources().openRawResource(R.raw.luna_db);
  6495. // Path to the just created empty db
  6496. String outFileName = OutputDBPath;
  6497. // Open the empty db as the output stream
  6498. OutputStream myOutput = new FileOutputStream(outFileName);
  6499. try {
  6500. // transfer bytes from the inputfile to the outputfile
  6501. byte[] buffer = new byte[1024];
  6502. int length;
  6503. while ((length = myInput.read(buffer)) > 0)
  6504. {
  6505. myOutput.write(buffer, 0, length);
  6506. }
  6507. // Close the streams
  6508. myOutput.flush();
  6509. }
  6510. catch (RuntimeException re) {
  6511. LogUtil.errorLogInfo("", TAG, re);
  6512. }
  6513. catch (Exception e)
  6514. {
  6515. LogUtil.errorLogInfo("", TAG, e);
  6516. }
  6517. finally {
  6518. if(myOutput!=null)
  6519. myOutput.close();
  6520. myOutput = null;
  6521. if(myInput!=null)
  6522. myInput.close();
  6523. myInput = null;
  6524. }
  6525. }
  6526. @SuppressLint("HandlerLeak")
  6527. protected Handler mLCD_SleepHandler = new Handler()
  6528. {
  6529. @SuppressLint("HandlerLeak")
  6530. @Override
  6531. public void handleMessage(Message msg)
  6532. {
  6533. if (msg.what == 0) {
  6534. try {
  6535. if (m_ModelHouseSleepModeRelease == true) {
  6536. if (Version.getPlatformType() == Version.PLATFORM_TYPE.A40i) {
  6537. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  6538. }
  6539. else {
  6540. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  6541. }
  6542. Log.i(TAG, "[SAMPLE SLEEP MODE] Never Sleep Run ~~~");
  6543. }
  6544. } catch (RuntimeException re) {
  6545. LogUtil.errorLogInfo("", TAG, re);
  6546. }
  6547. catch (Exception e) {
  6548. LogUtil.errorLogInfo("", TAG, e);
  6549. }
  6550. }
  6551. }
  6552. };
  6553. public void runIcon(int nIconID) {
  6554. try {
  6555. Log.d(TAG, "[runIcon] nIconID [" + nIconID + "]");
  6556. if (nIconID == ID.ICONS.MENUS.MAIN_ELEVATOR.getID()) {
  6557. // DB를 체크해서 층표시이면 팝업을 띄우고 아니면 바로 호출하도록 한다
  6558. String strElevShortEnabled = Common.getSubDevListItem(this.getContext() ,Common.SETTING_ITEM_SUB_DEVICE_ELEVATOR);
  6559. if(strElevShortEnabled!=null)
  6560. {
  6561. Log.d(TAG, "[runIcon] strElevShortEnabled [" + strElevShortEnabled + "]");
  6562. if (strElevShortEnabled.contains("사용함") && strElevShortEnabled.contains("기본")) {
  6563. Sound().Play(SND.effect.TOUCH_LATCHED);
  6564. Intent intent = new Intent(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
  6565. intent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN);
  6566. getContext().sendBroadcast(intent);
  6567. }
  6568. else {
  6569. ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.ElevatorPopupScreen);
  6570. }
  6571. }
  6572. }
  6573. else if (nIconID == ID.ICONS.MENUS.MAIN_LIGHTS_OUT.getID()) {
  6574. ((MainActivity)(getContext())).StartPopup(ID.POPUPS.POPUP_COLLECTIVELIGHTCTRL);
  6575. }
  6576. else if (nIconID == ID.ICONS.MENUS.MAIN_CALRENDAR.getID()) {
  6577. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.TimeSetting);
  6578. }
  6579. else if (nIconID == ID.ICONS.MENUS.MAIN_WEATHER.getID()) {
  6580. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Weather);
  6581. }
  6582. else if (nIconID == ID.ICONS.MENUS.TALK_FRONT.getID()) {
  6583. // Common.command_iGW200( this.getContext(), Common.IGW200_DOOR_MONITERING );
  6584. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Door);
  6585. }
  6586. else if (nIconID == ID.ICONS.MENUS.TALK_LOBBY.getID()) {
  6587. // 로비는 수신시에만 출력되는 화면이므로 해당코드 없음
  6588. }
  6589. else if (nIconID == ID.ICONS.MENUS.TALK_NEIGHBOR.getID()) {
  6590. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Neighboor);
  6591. }
  6592. else if (nIconID == ID.ICONS.MENUS.TALK_GUARD.getID()) {
  6593. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Guard);
  6594. }
  6595. else if (nIconID == ID.ICONS.MENUS.TALK_PHONE.getID()) {
  6596. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Pstn);
  6597. }
  6598. else if (nIconID == ID.ICONS.MENUS.TALK_CALLHISTORY.getID()) {
  6599. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.CallList);
  6600. }
  6601. else if (nIconID == ID.ICONS.MENUS.TALK_VISITORPIC.getID()) {
  6602. m_CallSubMenuScreen.callStartCallAPK(ID.LINKEDSCREEN.SubCall.Visitor);
  6603. }
  6604. else if (nIconID == ID.ICONS.MENUS.CTRL_LIGHT.getID()) {
  6605. // 모델별 설정에 따라 구분하여 호출하는 기능 추가해야함
  6606. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  6607. int[] naLightEnable = mWallpadDeviceSet.Get_Light_info(); // 조명설정 확인
  6608. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6609. // for (int i = 0; i < naLightEnable.length; i++) Log.i(TAG, "[runIcon] naLightEnable[" + i + "] = " + naLightEnable[i]);
  6610. if (naLightEnable[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_ADD_BATCHLIGHT_MULTISWITCH) {
  6611. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDCLivingNEach_Lamp);
  6612. }
  6613. else {
  6614. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDC_EachLamp);
  6615. }
  6616. }
  6617. else if (nIconID == ID.ICONS.MENUS.CTRL_HEATING.getID()) {
  6618. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Heating_V1);
  6619. }
  6620. //커튼 추가(전동커튼)
  6621. else if (nIconID == ID.ICONS.MENUS.CTRL_CURTAIN.getID()) {
  6622. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Curtain);
  6623. }
  6624. else if (nIconID == ID.ICONS.MENUS.CTRL_GAS.getID()) {
  6625. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Gas);
  6626. }
  6627. else if (nIconID == ID.ICONS.MENUS.CTRL_DOORLOCK.getID()) {
  6628. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.DoorLockWL);
  6629. }
  6630. else if (nIconID == ID.ICONS.MENUS.CTRL_VENT.getID()) {
  6631. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.ChangAir_Normal);
  6632. }
  6633. else if (nIconID == ID.ICONS.MENUS.CTRL_OUTLET.getID()) {
  6634. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
  6635. int[] naLightEnable = mWallpadDeviceSet.Get_Light_info(); // 조명설정 확인
  6636. if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
  6637. if (naLightEnable[1] == WallpadDeviceSet.LIGHT_TYPE_HDC_INTLIGHT_ADD_BATCHLIGHT_MULTISWITCH) {
  6638. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDCLivingNEach_Concent);
  6639. }
  6640. else {
  6641. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.Concent);
  6642. }
  6643. }
  6644. else if (nIconID == ID.ICONS.MENUS.CTRL_LIVINGLIGHT.getID()) {
  6645. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.HDC_LivingLamp);
  6646. }
  6647. else if (nIconID == ID.ICONS.MENUS.CTRL_AIRQUALTY.getID()) {
  6648. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.AirQualty);
  6649. }
  6650. else if (nIconID == ID.ICONS.MENUS.CTRL_ELECCOOKTOP.getID()) {
  6651. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.ElecCooktop);
  6652. }
  6653. else if (nIconID == ID.ICONS.MENUS.CTRL_COOKTOPOUTLET.getID()) {
  6654. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.CooktopOutlet);
  6655. }
  6656. else if (nIconID == ID.ICONS.MENUS.CTRL_SYSTEMAIRCON.getID()) {
  6657. m_CallSubMenuScreen.callStartHomeCtrlAPK(ID.LINKEDSCREEN.SubMenuCtrl.SystemAircon);
  6658. }
  6659. else if (nIconID == ID.ICONS.MENUS.ADD_NOTICE.getID()) {
  6660. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Notice);
  6661. }
  6662. else if (nIconID == ID.ICONS.MENUS.ADD_WEATHER.getID()) {
  6663. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Weather);
  6664. }
  6665. else if (nIconID == ID.ICONS.MENUS.ADD_MEMO.getID()) {
  6666. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Memo);
  6667. }
  6668. else if (nIconID == ID.ICONS.MENUS.ADD_E_FRAME.getID()) {
  6669. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.AutoPicture);
  6670. }
  6671. else if (nIconID == ID.ICONS.MENUS.ADD_SCHEDULE.getID()) {
  6672. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Schedule);
  6673. }
  6674. else if (nIconID == ID.ICONS.MENUS.ADD_CCTV.getID()) {
  6675. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Cctv);
  6676. }
  6677. else if (nIconID == ID.ICONS.MENUS.ADD_PARKING.getID()) {
  6678. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.Parking);
  6679. }
  6680. else if (nIconID == ID.ICONS.MENUS.ADD_PARKINGLIST.getID()) {
  6681. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.ParkingList);
  6682. }
  6683. else if (nIconID == ID.ICONS.MENUS.ADD_ELECTRICCAR.getID()) {
  6684. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.ElecCar);
  6685. }
  6686. else if (nIconID == ID.ICONS.MENUS.ADD_INTERLAYERNOISE.getID()) {
  6687. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.InterlayerNoiseHistory);
  6688. }
  6689. else if (nIconID == ID.ICONS.MENUS.ADD_VISITEDVEHICLEREGI.getID()) {
  6690. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.VisitedVehicleRegi);
  6691. }
  6692. else if (nIconID == ID.ICONS.MENUS.ADD_BANDLOCATION.getID()) {
  6693. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.BandLocation);
  6694. }
  6695. else if (nIconID == ID.ICONS.MENUS.ADD_GUARDINGSTREETLAMP.getID()) {
  6696. m_CallSubMenuScreen.callStartAddServiceAPK(ID.LINKEDSCREEN.SubMenuAddService.GuardingStreetLamp);
  6697. }
  6698. else if (nIconID == ID.ICONS.MENUS.SECURITY_SETARMED.getID()) {
  6699. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.SecurityMain);
  6700. }
  6701. else if (nIconID == ID.ICONS.MENUS.SECURITY_DEVICELINK.getID()) {
  6702. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.LinkDeviceSet);
  6703. }
  6704. else if (nIconID == ID.ICONS.MENUS.SECURITY_DEVICELINKSLEEP.getID()) {
  6705. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.lnkBedDeviceSet);
  6706. }
  6707. else if (nIconID == ID.ICONS.MENUS.SECURITY_ACCESSHISTORY.getID()) {
  6708. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.AccessHistoryDoor);
  6709. }
  6710. else if (nIconID == ID.ICONS.MENUS.SECURITY_VISITORVIDEO.getID()) {
  6711. runSecurityAPK(ID.LINKEDSCREEN.SubMenuSecurity.VisitorVideo);
  6712. }
  6713. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTPANEL.getID()) {
  6714. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartPanel);
  6715. }
  6716. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTLIGHT.getID()) {
  6717. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartLight);
  6718. }
  6719. else if (nIconID == ID.ICONS.MENUS.ENERGY_SMARTOUTLET.getID()) {
  6720. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.SmartOutlet);
  6721. }
  6722. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYMETER.getID()) {
  6723. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.IEnergy);
  6724. }
  6725. else if (nIconID == ID.ICONS.MENUS.ENERGY_REMOTEMETER.getID()) {
  6726. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.RemoteMeter);
  6727. }
  6728. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYCONSUMPTION.getID()) {
  6729. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.EnergyMgr);
  6730. }
  6731. else if (nIconID == ID.ICONS.MENUS.ENERGY_ENERGYCOSTTABLE.getID()) {
  6732. m_CallSubMenuScreen.callStartEnergyAPK(ID.LINKEDSCREEN.SubMenuEnergy.CostTable);
  6733. }
  6734. else if (nIconID == ID.ICONS.MENUS.SETTING_CONFIG.getID()) {
  6735. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.Configuration);
  6736. }
  6737. else if (nIconID == ID.ICONS.MENUS.SETTING_CLREANSCREEN.getID()) {
  6738. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.CleanLcd);
  6739. }
  6740. else if (nIconID == ID.ICONS.MENUS.SETTING_PWCHANGE.getID()) {
  6741. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.PassWordChange);
  6742. }
  6743. else if (nIconID == ID.ICONS.MENUS.SETTING_MORNINGCALL.getID()) {
  6744. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.MoningCall);
  6745. }
  6746. else if (nIconID == ID.ICONS.MENUS.SETTING_SMARTKEY.getID()) {
  6747. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.SmartKey);
  6748. }
  6749. else if (nIconID == ID.ICONS.MENUS.SETTING_SMARTBAND.getID()) {
  6750. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.SmartBand);
  6751. }
  6752. else if (nIconID == ID.ICONS.MENUS.SETTING_ACCESSCARD.getID()) {
  6753. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.RfCard);
  6754. }
  6755. else if (nIconID == ID.ICONS.MENUS.SETTING_CALENDAR.getID()) {
  6756. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.TimeSetting);
  6757. }
  6758. else if (nIconID == ID.ICONS.MENUS.SETTING_REMOTECALLUSER.getID()) {
  6759. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.RemoteCallUser);
  6760. }
  6761. else if (nIconID == ID.ICONS.MENUS.SETTING_REMOTECTRL.getID()) {
  6762. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.MobileDeviceReg);
  6763. }
  6764. else if (nIconID == ID.ICONS.MENUS.SETTING_OCCUPANCYSENSOR.getID()) {
  6765. m_CallSubMenuScreen.callStartConfigAPK(ID.LINKEDSCREEN.SubMenuConfig.OccupancySensorConfig);
  6766. }
  6767. else {
  6768. Log.w(TAG, "[runShortcut] nIconID is not supported!! [" + nIconID + "]");
  6769. }
  6770. } catch (RuntimeException re) {
  6771. LogUtil.errorLogInfo("", TAG, re);
  6772. }
  6773. catch (Exception e) {
  6774. Log.e(TAG, "[Exception] runShortcut(int nIconID)");
  6775. LogUtil.errorLogInfo("", TAG, e);
  6776. }
  6777. }
  6778. public void runSecurityAPK(int nScreenID) {
  6779. try {
  6780. WallpadStatusData wdb = new WallpadStatusData(this.getContext());
  6781. int nSecurityMode = wdb.GetAlarmStatus();
  6782. wdb.closeDB();
  6783. Log.w(TAG, "[runSecurityAPK] nSecurityMode [" + nSecurityMode + "]");
  6784. if (nSecurityMode == WallpadStatusData.GUARD_IN) {
  6785. // 팝업 띄워서 재택모드 해제 유도
  6786. StartPopup(ID.POPUPS.POPUP_RELEASEINMODE);
  6787. // ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.SecurityReleasePopupScreen);
  6788. }
  6789. else if (nSecurityMode == WallpadStatusData.OUT_MODE) {
  6790. // 팝업 띄워서 외출모드 해제 유도
  6791. StartPopup(ID.POPUPS.POPUP_RELEASEOUTMODE);
  6792. // ((MainActivity)(getContext())).StartPopup(ID_OLD.SCREENS.OutModeReleasePopupScreen);
  6793. }
  6794. else if (nSecurityMode == WallpadStatusData.ALARM_STOP) {
  6795. // 알람 화면을 띄우도록 한다.
  6796. runEmergencyAPK(this, getAlarmType(), 2 , "모름");
  6797. }
  6798. else {
  6799. m_CallSubMenuScreen.callStartSecurityAPK(nScreenID);
  6800. }
  6801. } catch (RuntimeException re) {
  6802. LogUtil.errorLogInfo("", TAG, re);
  6803. }
  6804. catch (Exception e) {
  6805. Log.e(TAG, "[Exception] runSecurityAPK(int nScreenID)");
  6806. LogUtil.errorLogInfo("", TAG, e);
  6807. }
  6808. }
  6809. public void runEmergencyAPK(Context context, int nScreenID, int startOption, String detailInfo) {
  6810. try {
  6811. // DB 체크 해서 띄우 도록 한다.
  6812. int [] m_EmerMenuList = new int[4];
  6813. m_EmerMenuList[0] = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  6814. m_EmerMenuList[1] = ID.LINKEDSCREEN.SubEmergency.FIRE_ALARM;
  6815. m_EmerMenuList[2] = ID.LINKEDSCREEN.SubEmergency.BREAKIN_ALARM;
  6816. m_EmerMenuList[3] = ID.LINKEDSCREEN.SubEmergency.LADDER_ALARM;
  6817. Intent intent = new Intent(Intent.ACTION_MAIN);
  6818. intent.putExtra(Common.MENU_ID_LIST, m_EmerMenuList); // KEY : MENU_ID_LIST
  6819. intent.putExtra(Common.MENU_START_ID, nScreenID); // KEY : MENU_START_ID
  6820. intent.putExtra(Common.MENU_START_OPTION, startOption); // KEY : MENU_START_OPTION
  6821. intent.putExtra(Common.MENU_DETAIL_INFO, detailInfo);
  6822. intent.setComponent(new ComponentName(Common.EMER_ALARM_APK, Common.EMER_ALARM_APK + Common.MAIN_ACTIVITY ));
  6823. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  6824. context.startActivity(intent);
  6825. } catch (RuntimeException re) {
  6826. LogUtil.errorLogInfo("", TAG, re);
  6827. }
  6828. catch (Exception e) {
  6829. Log.e(TAG, "[Exception] runEmergencyAPK(Context context, int nScreenID, int startOption, String detailInfo)");
  6830. LogUtil.errorLogInfo("", TAG, e);
  6831. }
  6832. }
  6833. public int getAlarmType() {
  6834. WallpadStatusData SetData = new WallpadStatusData(this.getContext());
  6835. int alarmtype = SetData.GetAlarmType();
  6836. SetData.closeDB();
  6837. int Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  6838. switch (alarmtype) {
  6839. case WallpadStatusData.ALARM_ALERT:
  6840. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.FIRE_ALARM;
  6841. break;
  6842. case WallpadStatusData.ALARM_EMM:
  6843. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
  6844. break;
  6845. case WallpadStatusData.ALARM_EVAC:
  6846. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.LADDER_ALARM;
  6847. break;
  6848. case WallpadStatusData.ALARM_INVADE:
  6849. Menu_Start_Option = ID.LINKEDSCREEN.SubEmergency.BREAKIN_ALARM;
  6850. break;
  6851. }
  6852. return Menu_Start_Option;
  6853. }
  6854. public void runGoogleLauncher() {
  6855. try {
  6856. ComponentName mComponentName = new ComponentName("com.android.launcher3", "com.android.launcher3.Launcher");
  6857. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  6858. mIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
  6859. mIntent.setComponent(mComponentName);
  6860. startActivity(mIntent);
  6861. } catch (RuntimeException re) {
  6862. LogUtil.errorLogInfo("", TAG, re);
  6863. }
  6864. catch (Exception e) {
  6865. Log.e(TAG, "[Exception] runGoogleLauncher()");
  6866. LogUtil.errorLogInfo("", TAG, e);
  6867. }
  6868. }
  6869. public void setCallAppRunning(boolean bRunning) {
  6870. try {
  6871. Log.i(TAG, "[setCallAppRunning] bRunning [" + bRunning + "]");
  6872. WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
  6873. DBMGR.SetCallAPKStatus(bRunning);
  6874. DBMGR.closeDB();
  6875. } catch (RuntimeException re) {
  6876. LogUtil.errorLogInfo("", TAG, re);
  6877. }
  6878. catch (Exception e) {
  6879. Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
  6880. LogUtil.errorLogInfo("", TAG, e);
  6881. }
  6882. }
  6883. private void registerMainActivityBR() {
  6884. try {
  6885. IntentFilter filter = new IntentFilter();
  6886. filter.addAction(Common.BR_REQUEST_APK_RUN);
  6887. filter.addAction(ACTION_TIME_TICK);
  6888. filter.addAction(Common.BR_PLAY_SOUND);
  6889. filter.addAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
  6890. filter.addAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
  6891. mContext.registerReceiver(MainActivityBroadcastReceiver, filter);
  6892. } catch (RuntimeException re) {
  6893. LogUtil.errorLogInfo("", TAG, re);
  6894. }
  6895. catch (Exception e) {
  6896. Log.e(TAG, "[Exception] registerMainActivityBR()");
  6897. LogUtil.errorLogInfo("", TAG, e);
  6898. }
  6899. }
  6900. String strAPKType = "APKType";
  6901. String strMenuType = "MenuType";
  6902. String strSoundID = "SoundID";
  6903. BroadcastReceiver MainActivityBroadcastReceiver = new BroadcastReceiver() {
  6904. @Override
  6905. public void onReceive(Context context, Intent intent) {
  6906. try {
  6907. if (((MainActivity)(getContext())).getMainSubScreenLoadingComplite() == false)
  6908. return;
  6909. String strActionName = intent.getAction();
  6910. Log.d(TAG,"[MainActivityBroadcastReceiver] strActionName [" + strActionName + "]");
  6911. if (strActionName.equals(Common.BR_REQUEST_APK_RUN)) {
  6912. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) BR_REQUEST_APK_RUN");
  6913. int nAPKType = intent.getIntExtra(strAPKType,0);
  6914. int nMenuType = intent.getIntExtra(strMenuType,0);
  6915. int nCardNum = intent.getIntExtra(Common.BR_MAIN_NOTI.CARD_NUM, 0);
  6916. Log.d(TAG, "[MainActivityBroadcastReceiver] nAPKType [" + nAPKType + "], nMenuType [" + nMenuType + "], nCardNum [" + nCardNum + "]");
  6917. if (nAPKType == ID.LINKEDSCREEN.SubCall.BASE) {
  6918. m_CallSubMenuScreen.callStartCallAPK(nMenuType);
  6919. }
  6920. else if (nAPKType == ID.LINKEDSCREEN.SubMenuAddService.BASE) {
  6921. m_CallSubMenuScreen.callStartAddServiceAPK(nMenuType, nCardNum);
  6922. }
  6923. }
  6924. else if (strActionName.equals(ACTION_TIME_TICK)) {
  6925. // checkTimeTasks();
  6926. if (bLCDKeeperUsage) ctrlLCDKeeper();
  6927. }
  6928. else if (strActionName.equals(Common.BR_PLAY_SOUND)) {
  6929. int nSoundID = intent.getIntExtra(strSoundID,0);
  6930. Sound().Play(nSoundID);
  6931. }
  6932. else if (strActionName.equals(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON)) {
  6933. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) NOTIFY_ACNAME_LCD_BACKLIGHT_ON: bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  6934. if (bLCDKeeperUsage) {
  6935. bLCDBacklightPower = true;
  6936. ctrlLCDKeeper();
  6937. }
  6938. }
  6939. else if (strActionName.equals(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF)) {
  6940. Log.d(TAG, "[MainActivityBroadcastReceiver] (BR.Action) NOTIFY_ACNAME_LCD_BACKLIGHT_OFF: bLCDKeeperUsage [" + bLCDKeeperUsage + "], nLCDKeeperType [" + getLCDKeeperType(nLCDKeeperType) + "]");
  6941. if (bLCDKeeperUsage) {
  6942. bLCDBacklightPower = false;
  6943. ctrlLCDKeeper();
  6944. }
  6945. }
  6946. else {
  6947. Log.w(TAG,"[MainActivityBroadcastReceiver] Not supported strActionName [" + strActionName + "]");
  6948. }
  6949. } catch (RuntimeException re) {
  6950. LogUtil.errorLogInfo("", TAG, re);
  6951. }
  6952. catch (Exception e) {
  6953. Log.e(TAG, "[Exception] MainActivityBroadcastReceiver()");
  6954. LogUtil.errorLogInfo("", TAG, e);
  6955. }
  6956. }
  6957. };
  6958. public Common.GUI_TYPE checkGUIType(Context context) {
  6959. try {
  6960. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(context);
  6961. String strGUIType = mWallpadDeviceSet.GetMainGUISelect();
  6962. mWallpadDeviceSet.closeDB();
  6963. if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_DEFAULT)) return Common.GUI_TYPE.STANDARD;
  6964. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_METRO)) return Common.GUI_TYPE.METRO;
  6965. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_HYOSUNG)) return Common.GUI_TYPE.HYOSUNG;
  6966. else if (strGUIType.equalsIgnoreCase(WallpadDeviceSet.MAIN_GUI_TYPE_HIMCHAN)) return Common.GUI_TYPE.HIMCHAN;
  6967. else return Common.GUI_TYPE.STANDARD;
  6968. } catch (RuntimeException re) {
  6969. LogUtil.errorLogInfo("", TAG, re);
  6970. return Common.GUI_TYPE.STANDARD;
  6971. }
  6972. catch (Exception e) {
  6973. Log.e(TAG, "[Exception] checkGUIType(Context context)");
  6974. LogUtil.errorLogInfo("", TAG, e);
  6975. return Common.GUI_TYPE.STANDARD;
  6976. }
  6977. }
  6978. public void finishActivity() {
  6979. try {
  6980. Log.i(TAG, "[finishActivity]");
  6981. super.finish();
  6982. } catch (RuntimeException re) {
  6983. LogUtil.errorLogInfo("", TAG, re);
  6984. }
  6985. catch (Exception e) {
  6986. Log.e(TAG, "[Exception] finishActivity()");
  6987. LogUtil.errorLogInfo("", TAG, e);
  6988. }
  6989. }
  6990. // MainActivity Handler
  6991. public final class HANDLERMSG {
  6992. public final static int CHECK_FLIPPER_MAINSCREEN_ID = 100;
  6993. public final static int CHECK_WALLPAD_CAMERA_INIT = 200;
  6994. public final static int CHECK_WALLPAD_CAMERA_REMOVE = 300;
  6995. public final static int CHECK_WALLPAD_CAMERA_RESET = 400;
  6996. public final static int CHECK_WALLPAD_CAMERA_CHECK = 500;
  6997. public final static int FINISH_ACTIVITY = 999;
  6998. }
  6999. public Handler MainHandler = new Handler(Looper.getMainLooper()) {
  7000. public void handleMessage(Message msg) {
  7001. Log.d(TAG, "[MainHandler] MainHandler : what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
  7002. switch (msg.what) {
  7003. case HANDLERMSG.CHECK_FLIPPER_MAINSCREEN_ID:
  7004. // checkMainPage();
  7005. break;
  7006. case HANDLERMSG.CHECK_WALLPAD_CAMERA_INIT:
  7007. if (getWallPadCameraUsage()) {
  7008. initMyVideoSurfaceLayout();
  7009. sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_REMOVE, 0, 0, 3000); // 월패드 카메라 영상을 띄우고 5초뒤에 없앤다.
  7010. }
  7011. break;
  7012. case HANDLERMSG.CHECK_WALLPAD_CAMERA_REMOVE:
  7013. if (getWallPadCameraUsage()) removeMyVideoSurfaceLayout();
  7014. break;
  7015. case HANDLERMSG.CHECK_WALLPAD_CAMERA_RESET:
  7016. if (getWallPadCameraUsage()) resetCameraService();
  7017. break;
  7018. case HANDLERMSG.CHECK_WALLPAD_CAMERA_CHECK:
  7019. checkCameraLoading();
  7020. break;
  7021. case HANDLERMSG.FINISH_ACTIVITY:
  7022. finishActivity();
  7023. break;
  7024. default:
  7025. Log.d(TAG, "MainHandler : " + msg.what);
  7026. break;
  7027. }
  7028. }
  7029. };
  7030. public void sendHandlerMsg(int what, int arg1, int arg2) {
  7031. try {
  7032. Log.i(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
  7033. Message HandleMsg = MainHandler.obtainMessage();
  7034. HandleMsg.what = what;
  7035. HandleMsg.arg1 = arg1;
  7036. HandleMsg.arg2 = arg2;
  7037. MainHandler.sendMessage(HandleMsg);
  7038. } catch (RuntimeException re) {
  7039. LogUtil.errorLogInfo("", TAG, re);
  7040. }
  7041. catch (Exception e) {
  7042. Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
  7043. LogUtil.errorLogInfo("", TAG, e);
  7044. }
  7045. }
  7046. public void sendHandlerMsgDelayed(int what, int arg1, int arg2, long delay) {
  7047. try {
  7048. Log.i(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
  7049. Message HandleMsg = MainHandler.obtainMessage();
  7050. HandleMsg.what = what;
  7051. HandleMsg.arg1 = arg1;
  7052. HandleMsg.arg2 = arg2;
  7053. MainHandler.sendMessageDelayed(HandleMsg, delay);
  7054. } catch (RuntimeException re) {
  7055. LogUtil.errorLogInfo("", TAG, re);
  7056. }
  7057. catch (Exception e) {
  7058. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
  7059. LogUtil.errorLogInfo("", TAG, e);
  7060. }
  7061. }
  7062. private boolean savePresetValue(String strPresetValues) {
  7063. try {
  7064. Log.i(TAG, "[savePresetValue] strPresetValues [" + strPresetValues + "]");
  7065. String[] strParse_01 = strPresetValues.split("/");
  7066. int presetid = Integer.parseInt(strParse_01[0]);
  7067. String[] strParse_02 = strParse_01[1].split(":");
  7068. String onoff = strParse_02[0];
  7069. int dim = Integer.parseInt(strParse_02[1]);
  7070. int color = Integer.parseInt(strParse_02[2]);
  7071. WallpadStatusData mWallpadStatusData = new WallpadStatusData(mContext);
  7072. boolean result = mWallpadStatusData.setLivinglightModeCtrlUnitValues(presetid, 0, "on", dim, color);
  7073. mWallpadStatusData.closeDB();
  7074. Log.d(TAG, "[savePresetValue] result [" + result + "], onoff [" + onoff + "], dim [" + dim + "], color [" + color + "]");
  7075. if (result) {
  7076. mLightInfo.mPreset[presetid].mLights[0].ONOFF = onoff;
  7077. mLightInfo.mPreset[presetid].mLights[0].DIM = dim;
  7078. mLightInfo.mPreset[presetid].mLights[0].COLOR = color;
  7079. 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 + "]");
  7080. return true;
  7081. }
  7082. else {
  7083. Log.w(TAG,"[savePresetValue] Fail to save light preset values!!");
  7084. return false;
  7085. }
  7086. } catch (RuntimeException re) {
  7087. LogUtil.errorLogInfo("", TAG, re);
  7088. return false;
  7089. }
  7090. catch (Exception e) {
  7091. Log.e(TAG, "[Exception] savePresetValue(String strPresetValues)");
  7092. LogUtil.errorLogInfo("", TAG, e);
  7093. return false;
  7094. }
  7095. }
  7096. private void initProximitySensor() {
  7097. try {
  7098. WallpadStatusData mWallpadStatusData = new WallpadStatusData(this);
  7099. int nProximitySensorLevel = mWallpadStatusData.GetCloseSensorValue();
  7100. mWallpadStatusData.closeDB();
  7101. Log.i(TAG, "[initProximitySensor] nProximitySensorLevel = " + nProximitySensorLevel);
  7102. if (nProximitySensorLevel < 0 || 5 < nProximitySensorLevel) {
  7103. Log.w(TAG, "[initProximitySensor] nProximitySensorLevel is out of range!!");
  7104. nProximitySensorLevel = 5;
  7105. }
  7106. int nResult = mIOInterface.setProximitySensorLevel(nProximitySensorLevel * 3);
  7107. Log.i(TAG, "[initProximitySensor] nResult = " + nResult);
  7108. } catch (RuntimeException re) {
  7109. LogUtil.errorLogInfo("", TAG, re);
  7110. }
  7111. catch (Exception e) {
  7112. Log.e(TAG, "[Exception] initProximitySensor()");
  7113. LogUtil.errorLogInfo("", TAG, e);
  7114. }
  7115. }
  7116. private boolean checkInterFloorNoiseError() {
  7117. try {
  7118. WallpadStatusData wsd = new WallpadStatusData(getContext());
  7119. String stSensorStatus = wsd.Get_InterlayerSensor_Status();
  7120. wsd.closeDB();
  7121. // 센서 정상 : false, 센서 이상 : true
  7122. Log.i(TAG, "[checkInterFloorNoiseError] stSensorStatus : " + stSensorStatus);
  7123. if (stSensorStatus.equalsIgnoreCase(define.INTERLAYER_NOISE_STATUS_NORMAL)) return false;
  7124. else return true;
  7125. } catch (RuntimeException re) {
  7126. LogUtil.errorLogInfo("", TAG, re);
  7127. return false;
  7128. }
  7129. catch (Exception e) {
  7130. Log.e(TAG, "[Exception] checkInterFloorNoiseError()");
  7131. LogUtil.errorLogInfo("", TAG, e);
  7132. return false;
  7133. }
  7134. }
  7135. private boolean checkInterFloorNoiseFuncUsage() {
  7136. try {
  7137. WallpadStatusData wsd = new WallpadStatusData(getContext());
  7138. boolean bUsage = wsd.GetNoisePopupUse();
  7139. wsd.closeDB();
  7140. return bUsage;
  7141. } catch (RuntimeException re) {
  7142. LogUtil.errorLogInfo("", TAG, re);
  7143. return false;
  7144. }
  7145. catch (Exception e) {
  7146. Log.e(TAG, "[Exception] checkInterFloorNoiseFuncUsage()");
  7147. LogUtil.errorLogInfo("", TAG, e);
  7148. return false;
  7149. }
  7150. }
  7151. /**
  7152. * 현관호출 or 전화호출시 사용되는 keycode - Broadcast 을 송신한다.
  7153. *
  7154. * @param nKeyCode - (int) 송신할 keycode
  7155. * @return (int) - >=0 : 성공, <0 : 실패
  7156. */
  7157. private int sendKeyEventBR(int nKeyCode) {
  7158. try {
  7159. Log.i(TAG, "[sendKeyEventBR] nKeyCode [" + nKeyCode +"] -> EVENT_DEVICE_CONTROL");
  7160. KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
  7161. Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
  7162. intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
  7163. intent.putExtra("keycode",nKeyCode);
  7164. sendBroadcast(intent);
  7165. } catch (RuntimeException re) {
  7166. LogUtil.errorLogInfo("", TAG, re);
  7167. return -100;
  7168. }
  7169. catch (Exception e) {
  7170. Log.e(TAG, "[Exception] sendKeyEventBR(int nKeyCode) [" + nKeyCode + "]");
  7171. LogUtil.errorLogInfo("", TAG, e);
  7172. return -100;
  7173. }
  7174. return 0;
  7175. }
  7176. // 카카오 연동 관련
  7177. public static boolean bKakaoiEnable = false;
  7178. /**
  7179. * 이진규
  7180. * kakaohome 서비스 사용 유무 판단
  7181. */
  7182. protected boolean bKakaoHomeEnable = false;
  7183. // run Kakao i floating button 실행
  7184. private void startKakaoiFloatingBTN() {
  7185. try {
  7186. Log.i(TAG, "[startKakaoiFloatingBTN] ========== Run Kakao i floating button ==========");
  7187. ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadglobalbutton", "kr.co.icontrols.wallpadglobalbutton.MainActivity");
  7188. Intent mIntent = new Intent(Intent.ACTION_MAIN);
  7189. mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  7190. mIntent.setComponent(mComponentName);
  7191. startActivity(mIntent);
  7192. } catch (RuntimeException re) {
  7193. LogUtil.errorLogInfo("", TAG, re);
  7194. }
  7195. catch (Exception e) {
  7196. Log.e(TAG, "[Exception] startKakaoiFloatingBTN()");
  7197. LogUtil.errorLogInfo("", TAG, e);
  7198. }
  7199. }
  7200. public void Send_NotiSmartSwitch(int nNoticeCnt, int nParcelCnt, int nVisitorPicCnt)
  7201. {
  7202. try
  7203. {
  7204. Intent intentBR = new Intent();
  7205. intentBR.setAction(define.DRIVER_ISD_NOTIINFO);
  7206. //if( m_NoticeCNT > 0 || m_ParcelCNT > 0 || m_InCallCNT > 0 || m_VisitorCNT > 0 )
  7207. {
  7208. // 아이콘 활성화
  7209. if( nNoticeCnt > 0 )
  7210. {
  7211. Log.d(TAG, "LOG : NOTICE CNT INCREASED ++");
  7212. intentBR.putExtra(define.NOTIBR_ISD_NOTICECNT, nNoticeCnt);
  7213. Log.d(TAG, "NoticeCNT BroadCast Added");
  7214. }
  7215. else
  7216. {
  7217. intentBR.putExtra(define.NOTIBR_ISD_NOTICECNT, 0);
  7218. Log.d(TAG, "NoticeCNT ZERO Added");
  7219. }
  7220. if( nParcelCnt > 0 )
  7221. {
  7222. Log.d(TAG, "LOG : Parcel CNT INCREASED ++");
  7223. intentBR.putExtra(define.NOTIBR_ISD_PARCELCNT, nParcelCnt);
  7224. Log.d(TAG, "ParcelCNT BroadCast Added");
  7225. }
  7226. else
  7227. {
  7228. intentBR.putExtra(define.NOTIBR_ISD_PARCELCNT, 0);
  7229. Log.d(TAG, "ParcelCNT ZERO Added");
  7230. }
  7231. if( nVisitorPicCnt > 0 )
  7232. {
  7233. Log.d(TAG, "LOG : VISITOR CNT INCREASED ++");
  7234. intentBR.putExtra(define.NOTIBR_ISD_VISITORCNT, nVisitorPicCnt);
  7235. Log.d(TAG, "VisitorCNT BroadCast Added");
  7236. }
  7237. else
  7238. {
  7239. intentBR.putExtra(define.NOTIBR_ISD_VISITORCNT, nVisitorPicCnt);
  7240. Log.d(TAG, "VisitorCNT ZERO Added");
  7241. }
  7242. // 알림정보 intent BroadCast
  7243. getContext().sendBroadcast(intentBR);
  7244. }
  7245. }
  7246. catch (RuntimeException re) {
  7247. LogUtil.errorLogInfo("", TAG, re);
  7248. }
  7249. catch (Exception e)
  7250. {
  7251. Log.e(TAG, e.toString());
  7252. LogUtil.errorLogInfo("", TAG, e);
  7253. }
  7254. }
  7255. // private void startKakaoiVoiceAgent() {
  7256. // try {
  7257. // Log.i(TAG, "[startKakaoiVoiceAgent] ========== Start Kakao i Voice Agent ==========");
  7258. // Intent mIntent = new Intent("com.kakao.i.agent.START_SERVICE").setPackage("com.kakao.i.test.sandbox");
  7259. // ContextCompat.startForegroundService(this, mIntent);
  7260. // } catch (RuntimeException re) {
  7261. // LogUtil.errorLogInfo("", TAG, re);
  7262. // }
  7263. // catch (Exception e) {
  7264. // Log.e(TAG, "[Exception] startKakaoiVoiceAgent()");
  7265. // e.printStackTrace();
  7266. // }
  7267. // }
  7268. //
  7269. // private void enableKakaoiVoiceAgent() {
  7270. // try {
  7271. // Log.i(TAG, "[enableKakaoiVoiceAgent] ========== Enable Kakao i Voice Agent ==========");
  7272. // Intent mIntent = new Intent("com.kakao.i.agent.ENABLE_KAKAO_I").setPackage("com.kakao.i.test.sandbox");
  7273. // ContextCompat.startForegroundService(this, mIntent);
  7274. // } catch (RuntimeException re) {
  7275. // LogUtil.errorLogInfo("", TAG, re);
  7276. // }
  7277. // catch (Exception e) {
  7278. // Log.e(TAG, "[Exception] enableKakaoiVoiceAgent()");
  7279. // e.printStackTrace();
  7280. // }
  7281. // }
  7282. //
  7283. // private void diableKakaoiVoiceAgent() {
  7284. // try {
  7285. // Log.i(TAG, "[diableKakaoiVoiceAgent] ========== Disable Kakao i Voice Agent ==========");
  7286. // Intent mIntent = new Intent("com.kakao.i.agent.DISABLE_KAKAO_I").setPackage("com.kakao.i.test.sandbox");
  7287. // ContextCompat.startForegroundService(this, mIntent);
  7288. // } catch (RuntimeException re) {
  7289. // LogUtil.errorLogInfo("", TAG, re);
  7290. // }
  7291. // catch (Exception e) {
  7292. // Log.e(TAG, "[Exception] diableKakaoiVoiceAgent()");
  7293. // e.printStackTrace();
  7294. // }
  7295. // }
  7296. /**
  7297. * JEFF, 2019.08.06
  7298. * 동탄현장 월패드 죽는 이슈 원인 분석을 위한 월패드 App 삭제 코드
  7299. * 메인App만 남기고 모두 삭제
  7300. */
  7301. UninstallAPKs mUninstallAPKs = new UninstallAPKs();
  7302. class UninstallAPKs extends Thread {
  7303. @Override
  7304. public void run() {
  7305. super.run();
  7306. try {
  7307. Log.d(TAG, "[UninstallAPKs.run()] Started getting installed package infomation");
  7308. ArrayList<PackageVersionInfo> PackageVersionInfos = new ArrayList<PackageVersionInfo>();
  7309. List<PackageInfo> PackageInfoList = getPackageManager().getInstalledPackages(PackageManager.PERMISSION_GRANTED);
  7310. while (true) {
  7311. Log.d(TAG, "[UninstallAPKs.run()] Get installed packages start!!");
  7312. try {
  7313. for (PackageInfo pack : PackageInfoList) {
  7314. // Log.d(TAG, "[UninstallAPKs.run()] Package Name [" + pack.packageName + "]");
  7315. // Log.d(TAG, "[UninstallAPKs.run()] Version Name [" + pack.versionName + "]");
  7316. if ((pack.packageName.contains("icontrols")) || (pack.packageName.contains("artncore"))) {
  7317. PackageVersionInfos.add(new PackageVersionInfo(pack.packageName, pack.versionName));
  7318. }
  7319. }
  7320. } catch (RuntimeException re) {
  7321. LogUtil.errorLogInfo("", TAG, re);
  7322. break;
  7323. } catch (Exception e) {
  7324. LogUtil.errorLogInfo("", TAG, e);
  7325. break;
  7326. }
  7327. Log.d(TAG, "[getInstalledPackageInfo.run()] Get installed packages end!!");
  7328. break;
  7329. }
  7330. for (int i = 0; i < PackageVersionInfos.size(); i++) {
  7331. Log.d(TAG, "[UninstallAPKs.run()] Package Name [" + PackageVersionInfos.get(i).getPackageName() + "]");
  7332. Log.d(TAG, "[UninstallAPKs.run()] Version Name [" + PackageVersionInfos.get(i).strPackageVersion + "]");
  7333. uninstallWallPadApp(PackageVersionInfos.get(i).getPackageName());
  7334. try {
  7335. Thread.sleep(5000);
  7336. } catch (RuntimeException re) {
  7337. LogUtil.errorLogInfo("", TAG, re);
  7338. } catch (Exception e) {
  7339. LogUtil.errorLogInfo("", TAG, e);
  7340. }
  7341. }
  7342. } catch (RuntimeException re) {
  7343. LogUtil.errorLogInfo("", TAG, re);
  7344. } catch (Exception e) {
  7345. Log.e(TAG, "[Exception] UninstallAPKs.run()");
  7346. LogUtil.errorLogInfo("", TAG, e);
  7347. }
  7348. // try {Thread.sleep(5000);}catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
  7349. }
  7350. }
  7351. private void uninstallWallPadApp(String strAPK) {
  7352. try {
  7353. Log.w(TAG, "[uninstallWallPadApp] strAPK [" + strAPK + "]");
  7354. if (checkAppInstalled(strAPK)) {
  7355. // Intent mIntent = new Intent(Intent.ACTION_DELETE);
  7356. Intent mIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
  7357. mIntent.setData(Uri.parse("package:" + strAPK));
  7358. mIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
  7359. startActivityForResult(mIntent, UNINSTALL_REQUEST_CODE);
  7360. }
  7361. else {
  7362. Log.w(TAG, "[uninstallWallPadApp] Not installed [" + strAPK + "]");
  7363. }
  7364. } catch (RuntimeException re) {
  7365. LogUtil.errorLogInfo("", TAG, re);
  7366. }
  7367. catch (Exception e) {;
  7368. Log.e(TAG, "[Exception] uninstallWallPadApp()");
  7369. LogUtil.errorLogInfo("", TAG, e);
  7370. }
  7371. }
  7372. iMAPRemotemeter miMAPRemotemeter;
  7373. boolean mEMS_Enable;
  7374. int nEnergyTypeCnt;
  7375. private boolean mCostInfo_Enable = false;
  7376. private Calendar nowCal, HourCal, DateCal, MonthCal, YearCal, EnergyDataGetCal;
  7377. int CalendarYear;
  7378. int CalendarMonth;
  7379. int CalendarDate;
  7380. int ShowNowEnergyIndex = 0;
  7381. String[] ShowListEnergyType_String = {
  7382. "전기",
  7383. "수도",
  7384. "가스",
  7385. "온수",
  7386. "난방",
  7387. "탄소"
  7388. };
  7389. // 원격검침 월사용량 데이터 클래스
  7390. MonthTableClass monthTableClass[] = new MonthTableClass[6];
  7391. class MonthTableClass {
  7392. private String Use;
  7393. private String SamePyungUse;
  7394. private String Rank;
  7395. private String Goal;
  7396. private String Price;
  7397. public MonthTableClass (String Use, String SamePyungUse, String Rank, String Goal) {
  7398. this.Use = Use;
  7399. this.SamePyungUse = SamePyungUse;
  7400. this.Rank = Rank;
  7401. this.Goal = Goal;
  7402. }
  7403. public String getUse(){return Use;}
  7404. public String getSamePyungUse(){return SamePyungUse;}
  7405. public String getRank(){return Rank;}
  7406. public String getGoal(){return Goal;}
  7407. public String getPrice(){return Price;}
  7408. }
  7409. public void GetMeteringCount()
  7410. {
  7411. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  7412. String[] MetringDB = devSet.GetSettingData("원격검침");
  7413. devSet.closeDB();
  7414. if (MetringDB != null)
  7415. {
  7416. try
  7417. {
  7418. String devInfo = MetringDB[1];
  7419. devInfo = devInfo.replace('(', '_');
  7420. devInfo = devInfo.replace(':', '_');
  7421. devInfo = devInfo.replace(')', '_');
  7422. String[] MetringInfo = devInfo.split("_");
  7423. // MetringInfo[1] -> 회로수
  7424. // MetringInfo[5] -> EMS 사용여부 사용함 or 사용안함
  7425. if ((Integer.parseInt(MetringInfo[1]) == 2) || (Integer.parseInt(MetringInfo[1]) == 3) || (Integer.parseInt(MetringInfo[1]) == 5) || (Integer.parseInt(MetringInfo[1]) == 6))
  7426. {
  7427. nEnergyTypeCnt = Integer.parseInt(MetringInfo[1]);
  7428. }
  7429. else
  7430. {
  7431. nEnergyTypeCnt = 5;
  7432. }
  7433. if (MetringInfo[5].equals("사용함"))
  7434. {
  7435. mEMS_Enable = true;
  7436. }
  7437. else
  7438. {
  7439. mEMS_Enable = false;
  7440. }
  7441. if(MetringInfo[7].equals("사용함"))
  7442. {
  7443. mCostInfo_Enable = true;
  7444. }
  7445. else
  7446. {
  7447. mCostInfo_Enable = false;
  7448. }
  7449. }
  7450. catch (RuntimeException re) {
  7451. LogUtil.errorLogInfo("", TAG, re);
  7452. nEnergyTypeCnt = 5;
  7453. mEMS_Enable = true;
  7454. }
  7455. catch (Exception e)
  7456. {
  7457. LogUtil.errorLogInfo("", TAG, e);
  7458. nEnergyTypeCnt = 5;
  7459. mEMS_Enable = true;
  7460. }
  7461. }
  7462. else
  7463. {
  7464. nEnergyTypeCnt = 5;
  7465. mEMS_Enable = true;
  7466. }
  7467. }
  7468. /**
  7469. * @description
  7470. * 서버로 부터 데이터를 받아와 분석하고 표현하는 함수<br>
  7471. * @param
  7472. * InputType 0 당월, 1 일별<br>
  7473. * @param
  7474. * //year - 연도<br>
  7475. * @param
  7476. * //month - 월<br>
  7477. * @param
  7478. * //energy - 0 전기, 1 수도, 2 가스, 3 온수, 4 열량, 5 탄소<br>
  7479. */
  7480. private void LoadRemotemeterDataFromServer(int InputType, int Year, int Month, int Energy, final boolean bSendToMobile) {
  7481. final int inputType = InputType;
  7482. final int year = Year;
  7483. final int month = (Month+1);
  7484. try {
  7485. Log.i(TAG, "[LoadRemotemeterDataFromServer] InputType [" + InputType + "], Year [" + Year + "], Month [" + Month + "], Energy [" + Energy + "], bSendToMobile [" + bSendToMobile + "]");
  7486. Log.i(TAG, "[LoadRemotemeterDataFromServer] inputType [" + inputType + "], year [" + year + "], month [" + month + "]");
  7487. miMAPRemotemeter = new iMAPRemotemeter(getApplicationContext());
  7488. switch(inputType) {
  7489. case 0: //당월
  7490. miMAPRemotemeter.DoWork(true, true, true, true, true, true, true, mEMS_Enable, year, month);
  7491. break;
  7492. case 1: //일별
  7493. miMAPRemotemeter.DoWork(false, true, true, true, true, true, false, false, year, month);
  7494. break;
  7495. default:
  7496. break;
  7497. }
  7498. boolean isUseEMS = true;
  7499. WallpadDeviceSet wds = new WallpadDeviceSet(getContext());
  7500. isUseEMS = wds.GetEMSProtocolUse();
  7501. wds.closeDB();
  7502. if(isUseEMS)
  7503. {
  7504. miMAPRemotemeter.SetRetCtr(new RetProci() {
  7505. @Override
  7506. public void ProcSuccess() {
  7507. String TempString = null;
  7508. // DB
  7509. WallpadStatusData StatusDBMGR = null;
  7510. try {
  7511. StatusDBMGR = new WallpadStatusData(getApplicationContext());
  7512. Log.i(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] inputType [" + inputType + "]");
  7513. boolean result = false;
  7514. switch (inputType) {
  7515. case 0: // 당월
  7516. EnergyDataGetCal = Calendar.getInstance();
  7517. int NumberOfValuelist = miMAPRemotemeter.SetItem("valuelist");
  7518. if (NumberOfValuelist != 0) {
  7519. for (int i = 0; i < NumberOfValuelist; i++) {
  7520. //DebugLogOutput("NumberOfValuelist " + Integer.toString(NumberOfValuelist));
  7521. //DebugLogOutput("GetAttributeVal(i, month) " + imapRemotemeter.GetAttributeVal(i, "month"));
  7522. //DebugLogOutput("CalendarMonth " + (CalendarMonth + 1));
  7523. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == (CalendarMonth + 1)) && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == (CalendarYear))) {
  7524. result = true;
  7525. int Temp_mNumberOfEnergy = nEnergyTypeCnt;
  7526. if (Temp_mNumberOfEnergy == 2) {
  7527. Temp_mNumberOfEnergy = 3;
  7528. }
  7529. for (int j = 0; j < Temp_mNumberOfEnergy; j++) {
  7530. switch (j) {
  7531. case 0:
  7532. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7533. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  7534. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000") == true) {
  7535. monthTableClass[j].Use = "0";
  7536. }
  7537. else {
  7538. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  7539. }
  7540. }
  7541. if (miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize") != null) {
  7542. if (miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize").equals("null") == true) {
  7543. monthTableClass[j].SamePyungUse = "0";
  7544. }
  7545. else {
  7546. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "elect_average_used_samesize");
  7547. }
  7548. }
  7549. if ((miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7550. if (miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize").equals("null") == true) {
  7551. TempString = "- / ";
  7552. }
  7553. else {
  7554. TempString = miMAPRemotemeter.GetAttributeVal(i, "elect_ranking_samesize") + " / ";
  7555. }
  7556. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7557. TempString = TempString + "-";
  7558. }
  7559. else {
  7560. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7561. }
  7562. monthTableClass[j].Rank = TempString;
  7563. }
  7564. //가격정보
  7565. if (mCostInfo_Enable == true) {
  7566. if (miMAPRemotemeter.GetAttributeVal(i, "elect_price") != null) {
  7567. if (miMAPRemotemeter.GetAttributeVal(i, "elect_price").equals("null") == true) {
  7568. monthTableClass[j].Price = "";
  7569. }
  7570. else {
  7571. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "elect_price");
  7572. }
  7573. }
  7574. }
  7575. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7576. //DebugLogOutput("전기");
  7577. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7578. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7579. break;
  7580. case 1:
  7581. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7582. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  7583. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  7584. monthTableClass[j].Use = "0";
  7585. }
  7586. else {
  7587. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  7588. }
  7589. }
  7590. if (miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize") != null) {
  7591. if (miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize").equals("null") == true) {
  7592. monthTableClass[j].SamePyungUse = "0";
  7593. }
  7594. else {
  7595. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "water_average_used_samesize");
  7596. }
  7597. }
  7598. if ((miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7599. if (miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize").equals("null") == true) {
  7600. TempString = "- / ";
  7601. }
  7602. else {
  7603. TempString = miMAPRemotemeter.GetAttributeVal(i, "water_ranking_samesize") + " / ";
  7604. }
  7605. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7606. TempString = TempString + "-";
  7607. }
  7608. else {
  7609. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7610. }
  7611. monthTableClass[j].Rank = TempString;
  7612. }
  7613. //가격정보
  7614. if (mCostInfo_Enable == true) {
  7615. if (miMAPRemotemeter.GetAttributeVal(i, "water_price") != null) {
  7616. if (miMAPRemotemeter.GetAttributeVal(i, "water_price").equals("null") == true) {
  7617. monthTableClass[j].Price = "";
  7618. }
  7619. else {
  7620. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "water_price");
  7621. }
  7622. }
  7623. }
  7624. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7625. //DebugLogOutput("수도");
  7626. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7627. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7628. break;
  7629. case 2:
  7630. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7631. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  7632. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  7633. monthTableClass[j].Use = "0";
  7634. }
  7635. else {
  7636. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  7637. }
  7638. }
  7639. if (miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize") != null) {
  7640. if (miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize").equals("null") == true) {
  7641. monthTableClass[j].SamePyungUse = "0";
  7642. }
  7643. else {
  7644. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "gas_average_used_samesize");
  7645. }
  7646. }
  7647. if ((miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7648. if (miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize").equals("null") == true) {
  7649. TempString = "- / ";
  7650. }
  7651. else {
  7652. TempString = miMAPRemotemeter.GetAttributeVal(i, "gas_ranking_samesize") + " / ";
  7653. }
  7654. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7655. TempString = TempString + "-";
  7656. }
  7657. else {
  7658. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7659. }
  7660. monthTableClass[j].Rank = TempString;
  7661. }
  7662. //가격정보
  7663. if (mCostInfo_Enable == true) {
  7664. if (miMAPRemotemeter.GetAttributeVal(i, "gas_price") != null) {
  7665. if (miMAPRemotemeter.GetAttributeVal(i, "gas_price").equals("null") == true) {
  7666. monthTableClass[j].Price = "";
  7667. }
  7668. else {
  7669. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "gas_price");
  7670. }
  7671. }
  7672. }
  7673. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7674. //DebugLogOutput("가스");
  7675. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7676. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7677. break;
  7678. case 3:
  7679. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7680. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  7681. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  7682. monthTableClass[j].Use = "0";
  7683. }
  7684. else {
  7685. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  7686. }
  7687. }
  7688. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize") != null) {
  7689. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize").equals("null") == true) {
  7690. monthTableClass[j].SamePyungUse = "0";
  7691. }
  7692. else {
  7693. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "hotwater_average_used_samesize");
  7694. }
  7695. }
  7696. if ((miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7697. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize").equals("null") == true) {
  7698. TempString = "- / ";
  7699. }
  7700. else {
  7701. TempString = miMAPRemotemeter.GetAttributeVal(i, "hotwater_ranking_samesize") + " / ";
  7702. }
  7703. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7704. TempString = TempString + "-";
  7705. }
  7706. else {
  7707. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7708. }
  7709. monthTableClass[j].Rank = TempString;
  7710. }
  7711. //가격정보
  7712. if (mCostInfo_Enable == true) {
  7713. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_price") != null) {
  7714. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_price").equals("null") == true) {
  7715. monthTableClass[j].Price = "";
  7716. }
  7717. else {
  7718. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "hotwater_price");
  7719. }
  7720. }
  7721. }
  7722. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7723. //DebugLogOutput("온수");
  7724. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7725. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7726. break;
  7727. case 4:
  7728. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7729. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  7730. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  7731. monthTableClass[j].Use = "0";
  7732. }
  7733. else {
  7734. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  7735. }
  7736. }
  7737. if (miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize") != null) {
  7738. if (miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize").equals("null") == true) {
  7739. monthTableClass[j].SamePyungUse = "0";
  7740. }
  7741. else {
  7742. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "energy_average_used_samesize");
  7743. }
  7744. }
  7745. if ((miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7746. if (miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize").equals("null") == true) {
  7747. TempString = "- / ";
  7748. }
  7749. else {
  7750. TempString = miMAPRemotemeter.GetAttributeVal(i, "energy_ranking_samesize") + " / ";
  7751. }
  7752. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7753. TempString = TempString + "-";
  7754. }
  7755. else {
  7756. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7757. }
  7758. monthTableClass[j].Rank = TempString;
  7759. }
  7760. //가격정보
  7761. if (mCostInfo_Enable == true) {
  7762. if (miMAPRemotemeter.GetAttributeVal(i, "energy_price") != null) {
  7763. if (miMAPRemotemeter.GetAttributeVal(i, "energy_price").equals("null") == true) {
  7764. monthTableClass[j].Price = "";
  7765. }
  7766. else {
  7767. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "energy_price");
  7768. }
  7769. }
  7770. }
  7771. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7772. //DebugLogOutput("열량");
  7773. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7774. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7775. break;
  7776. case 5:
  7777. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7778. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_used") != null) {
  7779. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_used").equals("1000000") == true) {
  7780. monthTableClass[j].Use = "0";
  7781. }
  7782. else {
  7783. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "carbon_used");
  7784. }
  7785. }
  7786. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize") != null) {
  7787. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize").equals("null") == true) {
  7788. monthTableClass[j].SamePyungUse = "0";
  7789. }
  7790. else {
  7791. monthTableClass[j].SamePyungUse = miMAPRemotemeter.GetAttributeVal(i, "carbon_average_used_samesize");
  7792. }
  7793. }
  7794. if ((miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize") != null) && (miMAPRemotemeter.GetAttributeVal(i, "count_samesize") != null)) {
  7795. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize").equals("null") == true) {
  7796. TempString = "- / ";
  7797. }
  7798. else {
  7799. TempString = miMAPRemotemeter.GetAttributeVal(i, "carbon_ranking_samesize") + " / ";
  7800. }
  7801. if (miMAPRemotemeter.GetAttributeVal(i, "count_samesize").equals("null") == true) {
  7802. TempString = TempString + "-";
  7803. }
  7804. else {
  7805. TempString = TempString + miMAPRemotemeter.GetAttributeVal(i, "count_samesize");
  7806. }
  7807. monthTableClass[j].Rank = TempString;
  7808. }
  7809. //가격정보
  7810. if (mCostInfo_Enable == true) {
  7811. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_price") != null) {
  7812. if (miMAPRemotemeter.GetAttributeVal(i, "carbon_price").equals("null") == true) {
  7813. monthTableClass[j].Price = "";
  7814. }
  7815. else {
  7816. monthTableClass[j].Price = miMAPRemotemeter.GetAttributeVal(i, "carbon_price");
  7817. }
  7818. }
  7819. }
  7820. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7821. //DebugLogOutput("탄소");
  7822. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7823. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7824. break;
  7825. default:
  7826. break;
  7827. }
  7828. }
  7829. }
  7830. }
  7831. if (result) {
  7832. if (1 < nEnergyTypeCnt && nEnergyTypeCnt < 6) {
  7833. Intent intent = new Intent();
  7834. intent.setAction(define.NOTIFY_ACNAME);
  7835. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  7836. intent.putExtra("FromWhere", "IcEnergyMgrScreen");
  7837. if (nEnergyTypeCnt == 2) {
  7838. elect_target = monthTableClass[0].Goal;
  7839. elect_used = monthTableClass[0].Use;
  7840. water_target = monthTableClass[1].Goal;
  7841. water_used = monthTableClass[1].Use;
  7842. }
  7843. else if (nEnergyTypeCnt == 3) {
  7844. elect_target = monthTableClass[0].Goal;
  7845. elect_used = monthTableClass[0].Use;
  7846. water_target = monthTableClass[1].Goal;
  7847. water_used = monthTableClass[1].Use;
  7848. gas_target = monthTableClass[2].Goal;
  7849. gas_used = monthTableClass[2].Use;
  7850. }
  7851. else if (nEnergyTypeCnt == 4) {
  7852. elect_target = monthTableClass[0].Goal;
  7853. elect_used = monthTableClass[0].Use;
  7854. water_target = monthTableClass[1].Goal;
  7855. water_used = monthTableClass[1].Use;
  7856. hotwater_target = monthTableClass[2].Goal;
  7857. hotwater_used = monthTableClass[2].Use;
  7858. heating_target = monthTableClass[3].Goal;
  7859. heating_used = monthTableClass[3].Use;
  7860. }
  7861. else if (nEnergyTypeCnt == 5) {
  7862. elect_target = monthTableClass[0].Goal;
  7863. elect_used = monthTableClass[0].Use;
  7864. water_target = monthTableClass[1].Goal;
  7865. water_used = monthTableClass[1].Use;
  7866. gas_target = monthTableClass[2].Goal;
  7867. gas_used = monthTableClass[2].Use;
  7868. hotwater_target = monthTableClass[3].Goal;
  7869. hotwater_used = monthTableClass[3].Use;
  7870. heating_target = monthTableClass[4].Goal;
  7871. heating_used = monthTableClass[4].Use;
  7872. }
  7873. else {
  7874. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =1 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  7875. return;
  7876. }
  7877. getApplicationContext().sendBroadcast(intent);
  7878. if (bSendToMobile) sendRemotemeterDataToMobile();
  7879. }
  7880. else {
  7881. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =2 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  7882. }
  7883. return;
  7884. }
  7885. else {
  7886. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] result [" + result + "]");
  7887. }
  7888. }
  7889. break;
  7890. default:
  7891. break;
  7892. }
  7893. StatusDBMGR.closeDB();
  7894. } catch (RuntimeException re) {
  7895. if (StatusDBMGR != null) {
  7896. StatusDBMGR.closeDB();
  7897. }
  7898. LogUtil.errorLogInfo("", TAG, re);
  7899. }
  7900. catch (Exception e) {
  7901. if (StatusDBMGR != null) {
  7902. StatusDBMGR.closeDB();
  7903. }
  7904. LogUtil.errorLogInfo("", TAG, e);
  7905. }
  7906. }
  7907. @Override
  7908. public void ProcError() {
  7909. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcError] Error!!!");
  7910. }
  7911. @Override
  7912. public void ProcDoing() {
  7913. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcDoing] Processing!!!");
  7914. }
  7915. });
  7916. }
  7917. else {
  7918. miMAPRemotemeter.SetRetCtr(new RetProci() {
  7919. @Override
  7920. public void ProcSuccess() {
  7921. String TempString = null;
  7922. // DB
  7923. WallpadStatusData StatusDBMGR = null;
  7924. try {
  7925. StatusDBMGR = new WallpadStatusData(getApplicationContext());
  7926. Log.i(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] inputType [" + inputType + "]");
  7927. boolean result = false;
  7928. switch (inputType) {
  7929. case 0: // 당월
  7930. EnergyDataGetCal = Calendar.getInstance();
  7931. int NumberOfValuelist = miMAPRemotemeter.SetItem("valuelist");
  7932. if (NumberOfValuelist != 0) {
  7933. for (int i = 0; i < NumberOfValuelist; i++) {
  7934. //DebugLogOutput("NumberOfValuelist " + Integer.toString(NumberOfValuelist));
  7935. //DebugLogOutput("GetAttributeVal(i, month) " + imapRemotemeter.GetAttributeVal(i, "month"));
  7936. //DebugLogOutput("CalendarMonth " + (CalendarMonth + 1));
  7937. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == (CalendarMonth + 1)) && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == (CalendarYear))) {
  7938. result = true;
  7939. int Temp_mNumberOfEnergy = nEnergyTypeCnt;
  7940. if (Temp_mNumberOfEnergy == 2) {
  7941. Temp_mNumberOfEnergy = 3;
  7942. }
  7943. for (int j = 0; j < Temp_mNumberOfEnergy; j++) {
  7944. switch (j) {
  7945. case 0:
  7946. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7947. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  7948. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000") == true) {
  7949. monthTableClass[j].Use = "0";
  7950. }
  7951. else {
  7952. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  7953. }
  7954. }
  7955. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7956. //DebugLogOutput("전기");
  7957. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7958. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7959. break;
  7960. case 1:
  7961. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7962. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  7963. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  7964. monthTableClass[j].Use = "0";
  7965. }
  7966. else {
  7967. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  7968. }
  7969. }
  7970. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7971. //DebugLogOutput("수도");
  7972. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7973. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7974. break;
  7975. case 2:
  7976. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7977. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  7978. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  7979. monthTableClass[j].Use = "0";
  7980. }
  7981. else {
  7982. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  7983. }
  7984. }
  7985. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  7986. //DebugLogOutput("가스");
  7987. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  7988. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  7989. break;
  7990. case 3:
  7991. monthTableClass[j] = new MonthTableClass("", "", "", "");
  7992. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  7993. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  7994. monthTableClass[j].Use = "0";
  7995. }
  7996. else {
  7997. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  7998. }
  7999. }
  8000. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  8001. //DebugLogOutput("온수");
  8002. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  8003. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  8004. break;
  8005. case 4:
  8006. monthTableClass[j] = new MonthTableClass("", "", "", "");
  8007. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  8008. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  8009. monthTableClass[j].Use = "0";
  8010. }
  8011. else {
  8012. monthTableClass[j].Use = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  8013. }
  8014. }
  8015. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  8016. //DebugLogOutput("열량");
  8017. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  8018. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  8019. break;
  8020. case 5:
  8021. monthTableClass[j] = new MonthTableClass("", "", "", "");
  8022. monthTableClass[j].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(j);
  8023. //DebugLogOutput("탄소");
  8024. //DebugLogOutput("Homeuse: " + monthTableClass[j].Use);
  8025. //DebugLogOutput("SamePyungUse: " + monthTableClass[j].SamePyungUse);
  8026. break;
  8027. default:
  8028. break;
  8029. }
  8030. }
  8031. }
  8032. }
  8033. if (result) {
  8034. if (1 < nEnergyTypeCnt && nEnergyTypeCnt < 6) {
  8035. Intent intent = new Intent();
  8036. intent.setAction(define.NOTIFY_ACNAME);
  8037. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  8038. intent.putExtra("FromWhere", "IcEnergyMgrScreen");
  8039. if (nEnergyTypeCnt == 2) {
  8040. elect_target = monthTableClass[0].Goal;
  8041. elect_used = monthTableClass[0].Use;
  8042. water_target = monthTableClass[1].Goal;
  8043. water_used = monthTableClass[1].Use;
  8044. }
  8045. else if (nEnergyTypeCnt == 3) {
  8046. elect_target = monthTableClass[0].Goal;
  8047. elect_used = monthTableClass[0].Use;
  8048. water_target = monthTableClass[1].Goal;
  8049. water_used = monthTableClass[1].Use;
  8050. gas_target = monthTableClass[2].Goal;
  8051. gas_used = monthTableClass[2].Use;
  8052. }
  8053. else if (nEnergyTypeCnt == 4) {
  8054. elect_target = monthTableClass[0].Goal;
  8055. elect_used = monthTableClass[0].Use;
  8056. water_target = monthTableClass[1].Goal;
  8057. water_used = monthTableClass[1].Use;
  8058. hotwater_target = monthTableClass[2].Goal;
  8059. hotwater_used = monthTableClass[2].Use;
  8060. heating_target = monthTableClass[3].Goal;
  8061. heating_used = monthTableClass[3].Use;
  8062. }
  8063. else if (nEnergyTypeCnt == 5) {
  8064. elect_target = monthTableClass[0].Goal;
  8065. elect_used = monthTableClass[0].Use;
  8066. water_target = monthTableClass[1].Goal;
  8067. water_used = monthTableClass[1].Use;
  8068. gas_target = monthTableClass[2].Goal;
  8069. gas_used = monthTableClass[2].Use;
  8070. hotwater_target = monthTableClass[3].Goal;
  8071. hotwater_used = monthTableClass[3].Use;
  8072. heating_target = monthTableClass[4].Goal;
  8073. heating_used = monthTableClass[4].Use;
  8074. }
  8075. else {
  8076. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =1 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  8077. return;
  8078. }
  8079. getApplicationContext().sendBroadcast(intent);
  8080. if (bSendToMobile) sendRemotemeterDataToMobile();
  8081. }
  8082. else {
  8083. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] Out of range!! =2 = mNumberOfEnergy -> " + nEnergyTypeCnt);
  8084. }
  8085. return;
  8086. }
  8087. else {
  8088. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcSuccess] result [" + result + "]");
  8089. }
  8090. }
  8091. break;
  8092. default:
  8093. break;
  8094. }
  8095. StatusDBMGR.closeDB();
  8096. } catch (RuntimeException re) {
  8097. if (StatusDBMGR != null) {
  8098. StatusDBMGR.closeDB();
  8099. }
  8100. LogUtil.errorLogInfo("", TAG, re);
  8101. }
  8102. catch (Exception e) {
  8103. if (StatusDBMGR != null) {
  8104. StatusDBMGR.closeDB();
  8105. }
  8106. LogUtil.errorLogInfo("", TAG, e);
  8107. }
  8108. }
  8109. @Override
  8110. public void ProcError() {
  8111. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcError] Error!!!");
  8112. }
  8113. @Override
  8114. public void ProcDoing() {
  8115. Log.w(TAG, "[LoadRemotemeterDataFromServer.ProcDoing] Processing!!!");
  8116. }
  8117. });
  8118. }
  8119. } catch (RuntimeException re) {
  8120. LogUtil.errorLogInfo("", TAG, re);
  8121. }
  8122. catch (Exception e) {
  8123. Log.e(TAG, "[Exception] LoadRemotemeterDataFromServer(int InputType, int Year, int Month, int Energy)");
  8124. LogUtil.errorLogInfo("", TAG, e);
  8125. }
  8126. }
  8127. /**
  8128. * @description
  8129. * 서버로 부터 데이터를 받아와 분석하고 표현하는 함수<br>
  8130. * @param
  8131. * //year - 연도<br>
  8132. * @param
  8133. * //month - 월<br>
  8134. * @param
  8135. * //energy - 0 전기, 1 수도, 2 가스, 3 온수, 4 열량, 5 탄소<br>
  8136. */
  8137. private void getTelemeringDailyUsageData(final int nYear, final int nMonth, final int nDate) {
  8138. try {
  8139. Log.i(TAG, "[getTelemeringDailyUsageData] nYear [" + nYear + "], nMonth [" + nMonth + "], nDate [" + nDate + "]");
  8140. miMAPRemotemeter = new iMAPRemotemeter(getApplicationContext());
  8141. miMAPRemotemeter.DoWork(false, true, true, true, true, true, false, false, nYear, nMonth);
  8142. boolean isUseEMS = true;
  8143. WallpadDeviceSet wds = new WallpadDeviceSet(getContext());
  8144. isUseEMS = wds.GetEMSProtocolUse();
  8145. wds.closeDB();
  8146. if(isUseEMS)
  8147. {
  8148. miMAPRemotemeter.SetRetCtr(new RetProci() {
  8149. @Override
  8150. public void ProcSuccess() {
  8151. String strTempValue = null;
  8152. int nEnergyTypeCnt = 5;
  8153. try {
  8154. boolean bResult = false;
  8155. String strElecUsage = "", strGasUsage = "", strWaterUsage = "", strHotwaterUsage = "", strHeatingUsage = "";
  8156. int nDataCnt = miMAPRemotemeter.SetItem("valuelist");
  8157. if (nDataCnt != 0) {
  8158. Log.i(TAG, "[getTelemeringDailyData] nDataCnt [" + nDataCnt + "]");
  8159. for (int i = 0; i < nDataCnt; i++) {
  8160. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == nYear)
  8161. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == nMonth)
  8162. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "day")) == nDate)) {
  8163. bResult = true;
  8164. Log.i(TAG, "[getTelemeringDailyUsageData] Find!!! nYear [" + nYear + "], nMonth [" + nMonth + "], nDate [" + nDate + "]");
  8165. for (int j = 0; j < nEnergyTypeCnt; j++) {
  8166. if (j == 0) {
  8167. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  8168. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000")) {
  8169. strElecUsage = "0";
  8170. }
  8171. else {
  8172. strElecUsage = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  8173. }
  8174. }
  8175. }
  8176. else if (j == 1) {
  8177. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  8178. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  8179. strWaterUsage = "0";
  8180. }
  8181. else {
  8182. strWaterUsage = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  8183. }
  8184. }
  8185. }
  8186. else if (j == 2) {
  8187. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  8188. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  8189. strGasUsage = "0";
  8190. }
  8191. else {
  8192. strGasUsage = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  8193. }
  8194. }
  8195. }
  8196. else if (j == 3) {
  8197. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  8198. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  8199. strHotwaterUsage = "0";
  8200. }
  8201. else {
  8202. strHotwaterUsage = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  8203. }
  8204. }
  8205. }
  8206. else if (j == 4) {
  8207. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  8208. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  8209. strHeatingUsage = "0";
  8210. }
  8211. else {
  8212. strHeatingUsage = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  8213. }
  8214. }
  8215. }
  8216. }
  8217. }
  8218. }
  8219. if (bResult) {
  8220. Intent mIntent = new Intent();
  8221. mIntent.setAction(define.NOTIFY_ACNAME);
  8222. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_TELEMETERING_DAILY_USAGE);
  8223. mIntent.putExtra("elect_used", strElecUsage);
  8224. mIntent.putExtra("water_used", strWaterUsage);
  8225. mIntent.putExtra("gas_used", strGasUsage);
  8226. mIntent.putExtra("hotwater_used", strHotwaterUsage);
  8227. mIntent.putExtra("heating_used", strHeatingUsage);
  8228. getApplicationContext().sendBroadcast(mIntent);
  8229. }
  8230. else {
  8231. Log.w(TAG, "[getTelemeringDailyUsageData.ProcSuccess] bResult [" + bResult + "]");
  8232. }
  8233. }
  8234. } catch (RuntimeException re) {
  8235. LogUtil.errorLogInfo("", TAG, re);
  8236. }
  8237. catch (Exception e) {
  8238. Log.e(TAG, "[Exception] getTelemeringDailyData.ProcSuccess");
  8239. LogUtil.errorLogInfo("", TAG, e);
  8240. }
  8241. }
  8242. @Override
  8243. public void ProcError() {
  8244. Log.w(TAG, "[getTelemeringDailyData.ProcError] Error!!!");
  8245. }
  8246. @Override
  8247. public void ProcDoing() {
  8248. Log.w(TAG, "[getTelemeringDailyData.ProcDoing] Processing!!!");
  8249. }
  8250. });
  8251. }
  8252. else
  8253. {
  8254. miMAPRemotemeter.SetRetCtr(new RetProci() {
  8255. @Override
  8256. public void ProcSuccess() {
  8257. String strTempValue = null;
  8258. int nEnergyTypeCnt = 5;
  8259. try {
  8260. boolean bResult = false;
  8261. String strElecUsage = "", strGasUsage = "", strWaterUsage = "", strHotwaterUsage = "", strHeatingUsage = "";
  8262. int nDataCnt = miMAPRemotemeter.SetItem("valuelist");
  8263. if (nDataCnt != 0) {
  8264. Log.i(TAG, "[getTelemeringDailyData] nDataCnt [" + nDataCnt + "]");
  8265. for (int i = 0; i < nDataCnt; i++) {
  8266. if ((Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "year")) == nYear)
  8267. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "month")) == nMonth)
  8268. && (Integer.parseInt(miMAPRemotemeter.GetAttributeVal(i, "day")) == nDate)) {
  8269. bResult = true;
  8270. Log.i(TAG, "[getTelemeringDailyUsageData] Find!!! nYear [" + nYear + "], nMonth [" + nMonth + "], nDate [" + nDate + "]");
  8271. for (int j = 0; j < nEnergyTypeCnt; j++) {
  8272. if (j == 0) {
  8273. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used") != null) {
  8274. if (miMAPRemotemeter.GetAttributeVal(i, "elect_used").equals("1000000")) {
  8275. strElecUsage = "0";
  8276. }
  8277. else {
  8278. strElecUsage = miMAPRemotemeter.GetAttributeVal(i, "elect_used");
  8279. }
  8280. }
  8281. }
  8282. else if (j == 1) {
  8283. if (miMAPRemotemeter.GetAttributeVal(i, "water_used") != null) {
  8284. if (miMAPRemotemeter.GetAttributeVal(i, "water_used").equals("1000000") == true) {
  8285. strWaterUsage = "0";
  8286. }
  8287. else {
  8288. strWaterUsage = miMAPRemotemeter.GetAttributeVal(i, "water_used");
  8289. }
  8290. }
  8291. }
  8292. else if (j == 2) {
  8293. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used") != null) {
  8294. if (miMAPRemotemeter.GetAttributeVal(i, "gas_used").equals("1000000") == true) {
  8295. strGasUsage = "0";
  8296. }
  8297. else {
  8298. strGasUsage = miMAPRemotemeter.GetAttributeVal(i, "gas_used");
  8299. }
  8300. }
  8301. }
  8302. else if (j == 3) {
  8303. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used") != null) {
  8304. if (miMAPRemotemeter.GetAttributeVal(i, "hotwater_used").equals("1000000") == true) {
  8305. strHotwaterUsage = "0";
  8306. }
  8307. else {
  8308. strHotwaterUsage = miMAPRemotemeter.GetAttributeVal(i, "hotwater_used");
  8309. }
  8310. }
  8311. }
  8312. else if (j == 4) {
  8313. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used") != null) {
  8314. if (miMAPRemotemeter.GetAttributeVal(i, "energy_used").equals("1000000") == true) {
  8315. strHeatingUsage = "0";
  8316. }
  8317. else {
  8318. strHeatingUsage = miMAPRemotemeter.GetAttributeVal(i, "energy_used");
  8319. }
  8320. }
  8321. }
  8322. }
  8323. }
  8324. }
  8325. if (bResult) {
  8326. Intent mIntent = new Intent();
  8327. mIntent.setAction(define.NOTIFY_ACNAME);
  8328. mIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_TELEMETERING_DAILY_USAGE);
  8329. mIntent.putExtra("elect_used", strElecUsage);
  8330. mIntent.putExtra("water_used", strWaterUsage);
  8331. mIntent.putExtra("gas_used", strGasUsage);
  8332. mIntent.putExtra("hotwater_used", strHotwaterUsage);
  8333. mIntent.putExtra("heating_used", strHeatingUsage);
  8334. getApplicationContext().sendBroadcast(mIntent);
  8335. }
  8336. else {
  8337. Log.w(TAG, "[getTelemeringDailyUsageData.ProcSuccess] bResult [" + bResult + "]");
  8338. }
  8339. }
  8340. } catch (RuntimeException re) {
  8341. LogUtil.errorLogInfo("", TAG, re);
  8342. }
  8343. catch (Exception e) {
  8344. Log.e(TAG, "[Exception] getTelemeringDailyData.ProcSuccess");
  8345. LogUtil.errorLogInfo("", TAG, e);
  8346. }
  8347. }
  8348. @Override
  8349. public void ProcError() {
  8350. Log.w(TAG, "[getTelemeringDailyData.ProcError] Error!!!");
  8351. }
  8352. @Override
  8353. public void ProcDoing() {
  8354. Log.w(TAG, "[getTelemeringDailyData.ProcDoing] Processing!!!");
  8355. }
  8356. });
  8357. }
  8358. } catch (RuntimeException re) {
  8359. LogUtil.errorLogInfo("", TAG, re);
  8360. }
  8361. catch (Exception e) {
  8362. Log.e(TAG, "[Exception] getTelemeringDailyData(int nYear, int nMonth)");
  8363. LogUtil.errorLogInfo("", TAG, e);
  8364. }
  8365. }
  8366. public void sendRemotemeterDataToMobile() {
  8367. try {
  8368. Log.i(TAG, "[sendRemotemeterDataToMobile] ========== START ==========");
  8369. Intent intent = new Intent();
  8370. intent.setAction(define.NOTIFY_ACNAME);
  8371. intent.putExtra("KIND", define.NOTIFY_ENERGY_DATA);
  8372. intent.putExtra(Common.ENERGY_INTENT_ENERGY_COUNT, nEnergyTypeCnt);
  8373. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_YEAR, EnergyDataGetCal.get(Calendar.YEAR));
  8374. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MONTH, (EnergyDataGetCal.get(Calendar.MONTH)+1));
  8375. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_DAY, EnergyDataGetCal.get(Calendar.DATE));
  8376. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_HOUR, EnergyDataGetCal.get(Calendar.HOUR_OF_DAY));
  8377. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MINUTE, EnergyDataGetCal.get(Calendar.MINUTE));
  8378. if (nEnergyTypeCnt == 2) {
  8379. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8380. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8381. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8382. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8383. }
  8384. else if (nEnergyTypeCnt == 3) {
  8385. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8386. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8387. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8388. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8389. intent.putExtra(Common.ENERGY_INTENT_USE_GAS, gas_used); //가스
  8390. intent.putExtra(Common.ENERGY_INTENT_GOAL_GAS, gas_target);
  8391. }
  8392. else if (nEnergyTypeCnt == 4) {
  8393. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8394. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8395. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8396. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8397. intent.putExtra(Common.ENERGY_INTENT_USE_HOTWATER, hotwater_used); //온수
  8398. intent.putExtra(Common.ENERGY_INTENT_GOAL_HOTWATER, hotwater_target);
  8399. intent.putExtra(Common.ENERGY_INTENT_USE_HEATING, heating_used); //열량
  8400. intent.putExtra(Common.ENERGY_INTENT_GOAL_HEATING, heating_target);
  8401. }
  8402. else if (nEnergyTypeCnt == 5) {
  8403. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, elect_used); //전기
  8404. intent.putExtra(Common.ENERGY_INTENT_GOAL_ELECTRIC, elect_target);
  8405. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, water_used); //수도
  8406. intent.putExtra(Common.ENERGY_INTENT_GOAL_WATER, water_target);
  8407. intent.putExtra(Common.ENERGY_INTENT_USE_GAS, gas_used); //가스
  8408. intent.putExtra(Common.ENERGY_INTENT_GOAL_GAS, gas_target);
  8409. intent.putExtra(Common.ENERGY_INTENT_USE_HOTWATER, hotwater_used); //온수
  8410. intent.putExtra(Common.ENERGY_INTENT_GOAL_HOTWATER, hotwater_target);
  8411. intent.putExtra(Common.ENERGY_INTENT_USE_HEATING, heating_used); //열량
  8412. intent.putExtra(Common.ENERGY_INTENT_GOAL_HEATING, heating_target);
  8413. }
  8414. getContext().sendBroadcast(intent);
  8415. Log.i(TAG, "[sendRemotemeterDataToMobile] Sent ENERGY_INTENT_ BR "+define.NOTIFY_ENERGY_DATA);
  8416. } catch (RuntimeException re) {
  8417. LogUtil.errorLogInfo("", TAG, re);
  8418. }
  8419. catch (Exception e) {
  8420. Log.e(TAG, "[Exception] sendRemotemeterDataToMobile()");
  8421. LogUtil.errorLogInfo("", TAG, e);
  8422. }
  8423. }
  8424. private void getTelemeteringDataOnRandomTime() {
  8425. try {
  8426. int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  8427. if (DelayTime < 1) {
  8428. return;
  8429. }
  8430. Log.i(TAG, "[getTelemeteringDataOnRandomTime] DelayTime : "+ DelayTime);
  8431. getTelemeteringDataHandler.sendEmptyMessageDelayed(0, 1000 * DelayTime);
  8432. } catch (RuntimeException re) {
  8433. LogUtil.errorLogInfo("", TAG, re);
  8434. return;
  8435. }
  8436. catch (Exception e) {
  8437. Log.e(TAG, "[Exception] getTelemeteringDataOnRandomTime()");
  8438. LogUtil.errorLogInfo("", TAG, e);
  8439. return;
  8440. }
  8441. }
  8442. @SuppressLint("HandlerLeak")
  8443. private Handler getTelemeteringDataHandler = new Handler() {
  8444. @SuppressLint("HandlerLeak")
  8445. @Override
  8446. public void handleMessage(Message msg) {
  8447. if (msg.what == 0) {
  8448. getRemoteMeterDataFromServer(true);
  8449. }
  8450. }
  8451. };
  8452. boolean bTelemeteringToISS = false;
  8453. private void checkISSEnergyType() {
  8454. try {
  8455. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplication());
  8456. int nEnergyKind = mWallpadDeviceSet.Get_SmartSwitchEnergy_Kind();
  8457. mWallpadDeviceSet.closeDB();
  8458. if (nEnergyKind == WallpadDeviceSet.SMARTSWITCH_ENERGY_REMOTE) bTelemeteringToISS = true;
  8459. else bTelemeteringToISS = false;
  8460. } catch (RuntimeException re) {
  8461. LogUtil.errorLogInfo("", TAG, re);
  8462. }
  8463. catch (Exception e) {
  8464. Log.e(TAG, "[Exception] checkISSEnergyType()");
  8465. LogUtil.errorLogInfo("", TAG, e);
  8466. }
  8467. }
  8468. public void getRemoteMeterDataFromServer(boolean bSendToMobile) {
  8469. try {
  8470. nowCal = Calendar.getInstance();
  8471. CalendarYear = nowCal.get(Calendar.YEAR);
  8472. CalendarMonth = nowCal.get(Calendar.MONTH);
  8473. CalendarDate = nowCal.get(Calendar.DATE);
  8474. GetMeteringCount();
  8475. LoadRemotemeterDataFromServer(0, CalendarYear, CalendarMonth, ShowNowEnergyIndex, bSendToMobile);
  8476. if (bTelemeteringToISS) getTelemeringDailyUsageData(CalendarYear, CalendarMonth + 1, CalendarDate);
  8477. } catch (RuntimeException re) {
  8478. LogUtil.errorLogInfo("", TAG, re);
  8479. }
  8480. catch (Exception e) {
  8481. Log.e(TAG, "[Exception] getRemoteMeterDataFromServer()");
  8482. LogUtil.errorLogInfo("", TAG, e);
  8483. }
  8484. }
  8485. private boolean getBlackoutStatus() {
  8486. try {
  8487. SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
  8488. return mSharedPreferences.getBoolean("status", false);
  8489. } catch (RuntimeException re) {
  8490. LogUtil.errorLogInfo("", TAG, re);
  8491. return false;
  8492. }
  8493. catch (Exception e) {
  8494. Log.e(TAG, "[Exception] getBlackoutStatus()");
  8495. LogUtil.errorLogInfo("", TAG, e);
  8496. return false;
  8497. }
  8498. }
  8499. private void sendBlackoutScreenRunBR() {
  8500. try {
  8501. Log.i(TAG, "[sendBlackoutScreenRunBR] ========== START ==========");
  8502. Intent mIntent = new Intent(Common.BR_BLACKOUT_SCREEN_RUN, null);
  8503. mContext.sendBroadcast(mIntent);
  8504. } catch (RuntimeException re) {
  8505. LogUtil.errorLogInfo("", TAG, re);
  8506. }
  8507. catch (Exception e) {
  8508. Log.e(TAG, "[Exception] sendBlackoutScreenRunBR()");
  8509. LogUtil.errorLogInfo("", TAG, e);
  8510. }
  8511. }
  8512. /**
  8513. * 월패드 타입 판별
  8514. * @return bResult
  8515. * false: 메인월패드
  8516. * true: 서브월패드
  8517. */
  8518. public boolean getIsSubWallpad() {
  8519. boolean bResult = false;
  8520. try {
  8521. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
  8522. String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
  8523. mWallpadDeviceSet.closeDB();
  8524. if (DBinfo == null) bResult = false;
  8525. else {
  8526. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  8527. else bResult = false;
  8528. }
  8529. Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
  8530. return bResult;
  8531. } catch (RuntimeException re) {
  8532. LogUtil.errorLogInfo("", TAG, re);
  8533. return false;
  8534. }
  8535. catch (Exception e) {
  8536. Log.e(TAG, "[Exception] getIsSubWallpad()");
  8537. LogUtil.errorLogInfo("", TAG, e);
  8538. return false;
  8539. }
  8540. }
  8541. /**
  8542. * JEFF, 2020.01.14
  8543. * 월패드 카메라의 초기화를 위한 코드 삽입
  8544. * 월패드 카메라 preview 실행시, 최초 1회에 한하여 카메라 화면에 녹색이 보이는 증상을 해결하기 위함
  8545. */
  8546. /* ================================================================================================
  8547. * 내 영상
  8548. ================================================================================================ */
  8549. // SurfaceLayout 구성
  8550. RelativeLayout MyVideoLayout; // MoIP 카메라 영상
  8551. SurfaceHolder MyVideoHolder;
  8552. SurfaceView MyVideoSurface;
  8553. RelativeLayout SurfaceLayout; // 영상표시 화면
  8554. public Camera mMyCamera;
  8555. public void toggleMyVideo() {
  8556. try {
  8557. if (MyVideoLayout == null) {
  8558. Log.e(TAG, "[toggleMyVideo] Show My Video!!!");
  8559. initMyVideoSurfaceLayout();
  8560. }
  8561. else {
  8562. Log.e(TAG, "[toggleMyVideo] Remove My Video!!!");
  8563. removeMyVideoSurfaceLayout();
  8564. }
  8565. } catch (RuntimeException re) {
  8566. LogUtil.errorLogInfo("", TAG, re);
  8567. }
  8568. catch (Exception e) {
  8569. Log.e(TAG, "[Exception] toggleMyVideo()");
  8570. LogUtil.errorLogInfo("", TAG, e);
  8571. }
  8572. }
  8573. public void initMyVideoSurfaceLayout() {
  8574. try {
  8575. // LOG_INFO("[initMyVideoSurfaceLayout] MyVideoLayout = " + MyVideoLayout);
  8576. if (MyVideoLayout != null) {
  8577. MyVideoSurface.getHolder().removeCallback(MyVideoCallback);
  8578. MyVideoLayout.removeAllViews();
  8579. MyVideoLayout = null;
  8580. }
  8581. MyVideoLayout = new RelativeLayout(mContext);
  8582. WpadUtil.LayoutRegistration(SurfaceLayout, MyVideoLayout, 1024, 600, 0, 0, ID.MAINACTIVITY.LAYOUT.MYVIDEO);
  8583. MyVideoSurface = new SurfaceView(mContext);
  8584. MyVideoHolder = MyVideoSurface.getHolder();
  8585. WpadRelativeLayoutParams MyVideoParams = new WpadRelativeLayoutParams(320, 240);
  8586. // MyVideoParams.setMargins(10, 10, 0, 0); // 보이게
  8587. MyVideoParams.setMargins(1300, 112, 0, 0); // 안보이게
  8588. MyVideoLayout.addView(MyVideoSurface, MyVideoParams);
  8589. MyVideoSurface.getHolder().addCallback(MyVideoCallback);
  8590. MyVideoSurface.setZOrderOnTop(true);
  8591. } catch (RuntimeException re) {
  8592. LogUtil.errorLogInfo("", TAG, re);
  8593. }
  8594. catch (Exception e) {
  8595. Log.e(TAG, "[Exception] initMyVideoSurfaceLayout()");
  8596. LogUtil.errorLogInfo("", TAG, e);
  8597. }
  8598. }
  8599. public void removeMyVideoSurfaceLayout() {
  8600. try {
  8601. Log.i(TAG, "[removeMyVideoSurfaceLayout] MyVideoLayout = " + MyVideoLayout);
  8602. if (MyVideoLayout != null) {
  8603. MyVideoLayout.removeAllViews();
  8604. MyVideoLayout = null;
  8605. }
  8606. } catch (RuntimeException re) {
  8607. LogUtil.errorLogInfo("", TAG, re);
  8608. }
  8609. catch (Exception e) {
  8610. Log.e(TAG, "[Exception] removeRemoteVideoSurfaceLayout()");
  8611. LogUtil.errorLogInfo("", TAG, e);
  8612. }
  8613. }
  8614. private SurfaceHolder.Callback MyVideoCallback = new SurfaceHolder.Callback() {
  8615. @Override
  8616. public void surfaceCreated(SurfaceHolder holder) {
  8617. try {
  8618. Log.i(TAG, "[MyVideoCallback] surfaceCreated!!");
  8619. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8620. mIOInterface.ctrlWallPadCamPower(true);
  8621. mMyCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  8622. Camera.Parameters params = mMyCamera.getParameters();
  8623. params.setPictureSize(320, 240);
  8624. mMyCamera.setParameters(params);
  8625. mMyCamera.setPreviewDisplay(holder);
  8626. } else {
  8627. Log.w(TAG, "[MyVideoCallback] surfaceCreated!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8628. }
  8629. } catch (RuntimeException re) {
  8630. LogUtil.errorLogInfo("", TAG, re);
  8631. }
  8632. catch (Exception e) {
  8633. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceCreated(SurfaceHolder holder)");
  8634. LogUtil.errorLogInfo("", TAG, e);
  8635. }
  8636. }
  8637. @Override
  8638. public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
  8639. try {
  8640. Log.i(TAG, "[MyVideoCallback] surfaceChanged!!");
  8641. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8642. mMyCamera.startPreview();
  8643. } else {
  8644. Log.w(TAG, "[MyVideoCallback] surfaceChanged!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8645. }
  8646. } catch (RuntimeException re) {
  8647. LogUtil.errorLogInfo("", TAG, re);
  8648. }
  8649. catch (Exception e) {
  8650. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceChanged(SurfaceHolder holder, int format, int width, int height)");
  8651. LogUtil.errorLogInfo("", TAG, e);
  8652. // if (getWallPadCameraUsage()) sendHandlerMsgDelayed(HANDLERMSG.CHECK_WALLPAD_CAMERA_RESET, 0, 0, 3000); // 3초후 카메라 서비스를 재실행한다.
  8653. }
  8654. }
  8655. @Override
  8656. public void surfaceDestroyed(SurfaceHolder holder) {
  8657. try {
  8658. Log.i(TAG, "[MyVideoCallback] surfaceDestroyed!!");
  8659. if (Common.CurrentBoardType == Common.BOARD_TYPE.V40 || Common.CurrentBoardType == Common.BOARD_TYPE.V40_NOUGAT) {
  8660. mIOInterface.ctrlWallPadCamPower(false);
  8661. if (mMyCamera != null) {
  8662. mMyCamera.stopPreview();
  8663. mMyCamera.release();
  8664. mMyCamera = null;
  8665. }
  8666. } else {
  8667. Log.w(TAG, "[MyVideoCallback] surfaceDestroyed!! -> NOT Supported Common.CurrentBoardType [" + Common.CurrentBoardType + "]");
  8668. }
  8669. } catch (RuntimeException re) {
  8670. LogUtil.errorLogInfo("", TAG, re);
  8671. }
  8672. catch (Exception e) {
  8673. Log.e(TAG, "[Exception] MyVideoCallback -> surfaceDestroyed(SurfaceHolder holder)");
  8674. LogUtil.errorLogInfo("", TAG, e);
  8675. }
  8676. }
  8677. };
  8678. private boolean getWallPadCameraUsage() {
  8679. boolean bResult = false;
  8680. try {
  8681. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this.getContext());
  8682. int nResult = mWallpadDeviceSet.GetDeviceSetted("월패드카메라");
  8683. mWallpadDeviceSet.closeDB();
  8684. if (nResult == WallpadDeviceSet.DEV_DATA_ENABLE) bResult = true;
  8685. else bResult = false;
  8686. } catch (RuntimeException re) {
  8687. LogUtil.errorLogInfo("", TAG, re);
  8688. }
  8689. catch (Exception e) {
  8690. Log.e(TAG, "[Exception] getWallPadCameraUsage()");
  8691. LogUtil.errorLogInfo("", TAG, e);
  8692. }
  8693. Log.i(TAG, "[getWallPadCameraUsage] bResult [" + bResult + "]");
  8694. return bResult;
  8695. }
  8696. private void forceCtrlStrangerRecordingUserSettingDisable(boolean bEnable) {
  8697. try {
  8698. WallpadStatusData DBMGR = new WallpadStatusData(getContext());
  8699. DBMGR.SetStrangerRecordingOnOff(bEnable);
  8700. DBMGR.closeDB();
  8701. } catch (RuntimeException re) {
  8702. LogUtil.errorLogInfo("", TAG, re);
  8703. }
  8704. catch (Exception e) {
  8705. Log.e(TAG, "[Exception] forceCtrlStrangerRecordingUserSettingDisable(boolean bEnable)");
  8706. LogUtil.errorLogInfo("", TAG, e);
  8707. }
  8708. }
  8709. private void registerLCDKeeper() {
  8710. try {
  8711. Log.i(TAG, "[registerLCDKeeper] ===== START =====");
  8712. if (!bLCDKeeperUsage) {
  8713. Log.w(TAG, "[registerLCDKeeper] bLCDKeeperUsage is false!!!");
  8714. return;
  8715. }
  8716. if (Build.VERSION.SDK_INT < 24) {
  8717. Log.w(TAG, "[registerLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8718. return;
  8719. }
  8720. IMG_LCD_KEEPER = (ImageView) findViewById(R.id.view_lcdkeeper);
  8721. IMG_LCD_KEEPER.bringToFront();
  8722. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8723. Log.i(TAG, "[registerLCDKeeper] ===== END =====");
  8724. } catch (RuntimeException re) {
  8725. LogUtil.errorLogInfo("", TAG, re);
  8726. }
  8727. catch (Exception e) {
  8728. Log.e(TAG, "[Exception] registerLCDKeeper()");
  8729. LogUtil.errorLogInfo("", TAG, e);
  8730. }
  8731. }
  8732. int LCDKEEPER_MODE_NONE = 0; // 동작중 아님
  8733. int LCDKEEPER_MODE_RESTROE = 1; // 복구모드
  8734. int LCDKEEPER_MODE_PROTECT = 2; // 보호모드
  8735. boolean bLCDBacklightPower = true; // LCD backlight on/off 여부 (true: on, false: off)
  8736. int nLCDKeeperRunMode = LCDKEEPER_MODE_NONE; // LCD Keeper 동작 모드 (0: 동작중 아님, 1: 복구모드, 2: 예방모드)
  8737. private void runLCDKeeper(int nKeeperMode) {
  8738. try {
  8739. if (!bLCDKeeperUsage) {
  8740. Log.w(TAG, "[runLCDKeeper] bLCDKeeperUsage is false!!!");
  8741. return;
  8742. }
  8743. Log.i(TAG, "[runLCDKeeper] nKeeperMode [" + nKeeperMode +"], bLCDBacklightPower [" + bLCDBacklightPower +"]");
  8744. if (Build.VERSION.SDK_INT < 24) {
  8745. Log.w(TAG, "[runLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8746. return;
  8747. }
  8748. if (IMG_LCD_KEEPER == null) {
  8749. Log.w(TAG, "[runLCDKeeper] IMG_LCD_KEEPER is null!!");
  8750. return;
  8751. }
  8752. // check run mode
  8753. if (nLCDKeeperRunMode == nKeeperMode) {
  8754. // already run LCDKeeper!!
  8755. Log.w(TAG, "[runLCDKeeper] LCD Keeper mode is same -> Asis [" + nLCDKeeperRunMode + "], Tobe [" + nKeeperMode + "]");
  8756. return;
  8757. }
  8758. nLCDKeeperRunMode = nKeeperMode;
  8759. if (nKeeperMode == LCDKEEPER_MODE_NONE) {
  8760. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8761. }
  8762. else if (nKeeperMode == LCDKEEPER_MODE_RESTROE) {
  8763. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) {
  8764. Glide.with(this).asGif().load(R.drawable.lcd_restore_1280).diskCacheStrategy(DiskCacheStrategy.RESOURCE).into(IMG_LCD_KEEPER);
  8765. }
  8766. else {
  8767. Glide.with(this).asGif().load(R.drawable.lcd_restore_1024).diskCacheStrategy(DiskCacheStrategy.RESOURCE).into(IMG_LCD_KEEPER);
  8768. }
  8769. IMG_LCD_KEEPER.setVisibility(View.VISIBLE);
  8770. }
  8771. else if (nKeeperMode == LCDKEEPER_MODE_PROTECT) {
  8772. IMG_LCD_KEEPER.setImageBitmap(null);
  8773. IMG_LCD_KEEPER.setBackgroundColor(Color.BLACK);
  8774. IMG_LCD_KEEPER.setVisibility(View.VISIBLE);
  8775. }
  8776. else {
  8777. Log.w(TAG, "[runLCDKeeper] Not supported mode!! -> " + nKeeperMode);
  8778. IMG_LCD_KEEPER.setVisibility(View.INVISIBLE);
  8779. }
  8780. } catch (RuntimeException re) {
  8781. LogUtil.errorLogInfo("", TAG, re);
  8782. }
  8783. catch (Exception e) {
  8784. Log.e(TAG, "[Exception] runLCDKeeper(int nKeeperMode)");
  8785. LogUtil.errorLogInfo("", TAG, e);
  8786. }
  8787. }
  8788. private void ctrlLCDKeeper() {
  8789. try {
  8790. if (!bLCDKeeperUsage) {
  8791. Log.w(TAG, "[ctrlLCDKeeper] bLCDKeeperUsage is false!!");
  8792. return;
  8793. }
  8794. if (Build.VERSION.SDK_INT < 24) {
  8795. Log.w(TAG, "[ctrlLCDKeeper] not support LCDKeeper!! Build.VERSION.SDK_INT -> " + Build.VERSION.SDK_INT);
  8796. return;
  8797. }
  8798. if (IMG_LCD_KEEPER == null) {
  8799. Log.w(TAG, "[ctrlLCDKeeper] IMG_LCD_KEEPER is null!!");
  8800. return;
  8801. }
  8802. Log.i(TAG, "[ctrlLCDKeeper] bLCDBacklightPower [" + bLCDBacklightPower +"]");
  8803. if (bLCDBacklightPower) {
  8804. // backlight on시 lcd keeper를 비활성화 한다.
  8805. runLCDKeeper(LCDKEEPER_MODE_NONE);
  8806. }
  8807. else {
  8808. if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT) {
  8809. // LCD backlight off시, LCD protect 화면을 구동한다.
  8810. runLCDKeeper(LCDKEEPER_MODE_PROTECT);
  8811. }
  8812. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_RECOVER) {
  8813. // LCD backlight off시, LCD restore 화면을 구동한다.
  8814. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8815. }
  8816. else if (nLCDKeeperType == WallpadDeviceSet.LCDKEEPER_PROTECT_RECOVER) {
  8817. // 새벽 2:00 ~ 3:59까지 LCD restore 화면을 구동하고, 나머지 시간에는 LCD protect 화면을 구동한다.
  8818. // 화면에 스모그 또는 미러 글라스 적용이 아닌 경우에는 LCD 보호모드(블랙)만 사용을 권장한다. (LCD RGBW rolling시 컬러가 화면에 비침)
  8819. Calendar LCDCal = Calendar.getInstance();
  8820. int nYear = LCDCal.get(Calendar.YEAR);
  8821. int nMonth = LCDCal.get(Calendar.MONTH) + 1;
  8822. int nDay = LCDCal.get(Calendar.DAY_OF_MONTH);
  8823. int nHour = LCDCal.get(Calendar.HOUR_OF_DAY);
  8824. Log.i(TAG, "[ctrlLCDKeeper] nYear [" + nYear +"], nMonth [" + nMonth +"], nDay [" + nDay +"], nHour [" + nHour +"]");
  8825. if (3 >= nHour && nHour >= 2) {
  8826. // 새벽 2:00 ~ 3:59까지 LCD restore 화면을 구동한다.
  8827. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8828. }
  8829. else {
  8830. // 새벽 2:00 ~ 3:59 이외의 시간에는 LCD protect 화면을 구동한다.
  8831. if (nYear == 2020 && ((nMonth < 8 && nDay < 20) || (nMonth < 7))) {
  8832. // 단, 이미 증상이 발생한 현장의 LCD 복구를 위해 2020년 7월 19일까지는 protection 화면 대신 restore 화면을 구동한다.
  8833. runLCDKeeper(LCDKEEPER_MODE_RESTROE);
  8834. }
  8835. else {
  8836. runLCDKeeper(LCDKEEPER_MODE_PROTECT);
  8837. }
  8838. }
  8839. }
  8840. }
  8841. } catch (RuntimeException re) {
  8842. LogUtil.errorLogInfo("", TAG, re);
  8843. }
  8844. catch (Exception e) {
  8845. Log.e(TAG, "[Exception] ctrlLCDKeeper()");
  8846. LogUtil.errorLogInfo("", TAG, e);
  8847. }
  8848. }
  8849. private boolean checkTranslucentGlassUsage() {
  8850. try {
  8851. if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I
  8852. || Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
  8853. || Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I
  8854. || Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
  8855. || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I_6410
  8856. || Version.getModelType() == MODEL_TYPE.IHN_T1010 || Version.getModelType() == MODEL_TYPE.IHN_T1010_I
  8857. || Version.getModelType() == MODEL_TYPE.IHN_1303_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
  8858. return true;
  8859. }
  8860. else return false;
  8861. } catch (RuntimeException re) {
  8862. LogUtil.errorLogInfo("", TAG, re);
  8863. return false;
  8864. }
  8865. catch (Exception e) {
  8866. Log.e(TAG, "[Exception] checkTranslucentGlassUsage()");
  8867. LogUtil.errorLogInfo("", TAG, e);
  8868. return false;
  8869. }
  8870. }
  8871. /**
  8872. * LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
  8873. * 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
  8874. * Jeff, 2020.09.07
  8875. * @return true: LCD backlight On, false: LCD backlight Off
  8876. */
  8877. public boolean checkLCDOnByCMD() {
  8878. try {
  8879. Runtime mRuntime = Runtime.getRuntime();
  8880. Process mProcess;
  8881. String cmd = "getprop persist.sys.lcdcon";
  8882. mProcess = mRuntime.exec(cmd);
  8883. BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
  8884. String line;
  8885. String strResult = null;
  8886. while ((line = br.readLine()) != null) {
  8887. strResult = line;
  8888. }
  8889. if(strResult!=null)
  8890. {
  8891. if (strResult.equals("0")) {
  8892. Log.e(TAG, "[checkLCDOnByCMD] LCD On");
  8893. return true;
  8894. }
  8895. else if (strResult.equals("1")) {
  8896. Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
  8897. return false;
  8898. }
  8899. else {
  8900. Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
  8901. return false;
  8902. }
  8903. }
  8904. else return false;
  8905. } catch (RuntimeException re) {
  8906. LogUtil.errorLogInfo("", TAG, re);
  8907. return false;
  8908. }
  8909. catch (Exception e) {
  8910. Log.e(TAG, "[Exception] checkLCDOnByCMD()");
  8911. LogUtil.errorLogInfo("", TAG, e);
  8912. return false;
  8913. }
  8914. }
  8915. /**
  8916. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  8917. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  8918. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  8919. */
  8920. public boolean getCompareBSPVersion() {
  8921. try {
  8922. StringBuilder strBSPVersion = new StringBuilder();
  8923. StringBuffer sysInfoBuffer = new StringBuffer();
  8924. sysInfoBuffer.append(Build.DISPLAY);
  8925. strBSPVersion.append(sysInfoBuffer.toString());
  8926. String result = strBSPVersion.toString();
  8927. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  8928. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  8929. Date date = simpleDateFormat.parse(result);
  8930. Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
  8931. if (date.compareTo(standardDate) >= 0) {
  8932. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  8933. return true;
  8934. }
  8935. } catch (RuntimeException re) {
  8936. LogUtil.errorLogInfo("", TAG, re);
  8937. }
  8938. catch (Exception e) {
  8939. Log.e(TAG, "[Exception] getCompareBSPVersion()");
  8940. LogUtil.errorLogInfo("", TAG, e);
  8941. }
  8942. return false;
  8943. }
  8944. /**
  8945. * 월패드 부팅시 카메라서비스 로딩이 실패하는 경우가 생겨 카메라 화면이 안나오는 경우 발생
  8946. * WallPadMain에서 부팅시 카메라를 확인하여 Exception이 발생하는 경우
  8947. * 카메라 서비스를 재실행한다.
  8948. * (Edited by jeff, 2020.09.08)
  8949. */
  8950. public void resetCameraService() {
  8951. try {
  8952. Log.e(TAG, "[resetCameraService] start!!");
  8953. Runtime mRuntime = Runtime.getRuntime();
  8954. String cmd = "setprop persist.sys.fakeactivitydel 1";
  8955. mRuntime.exec(cmd);
  8956. } catch (RuntimeException re) {
  8957. LogUtil.errorLogInfo("", TAG, re);
  8958. }
  8959. catch (Exception e) {
  8960. Log.e(TAG, "[Exception] resetCameraService()");
  8961. LogUtil.errorLogInfo("", TAG, e);
  8962. }
  8963. }
  8964. /**
  8965. * 월패드 부팅시 카메라서비스 로딩이 실패하는 경우가 발생하여
  8966. * 카메라서비스 정상동작 여부를 확인하기위한 함수를 정의한다.
  8967. * 카메라서비스 정상: 정상적으로 카메라가 open되며, camera object가 null이 아니면 카메라를 release한다.
  8968. * 카메라 서비스 비정상: 카메라 open시 Exception이 발생하며 resetCameraService() 함수를 실행하여 카메라서비스를 재실행한다.
  8969. * (Edited by jeff, 2020.09.08)
  8970. */
  8971. public void checkCameraLoading() {
  8972. try {
  8973. Camera checkCamera = Camera.open();
  8974. if (checkCamera != null) {
  8975. Log.e(TAG, "[checkCameraLoading] checkCamera is not null!!");
  8976. checkCamera.release();
  8977. }
  8978. else {
  8979. Log.e(TAG, "[checkCameraLoading] checkCamera is null!!");
  8980. resetCameraService();
  8981. }
  8982. } catch (RuntimeException re) {
  8983. LogUtil.errorLogInfo("", TAG, re);
  8984. resetCameraService();
  8985. }
  8986. catch (Exception e) {
  8987. Log.e(TAG, "[Exception] checkCameraLoading()");
  8988. LogUtil.errorLogInfo("", TAG, e);
  8989. resetCameraService();
  8990. }
  8991. }
  8992. private synchronized void FileDelete(File file)
  8993. {
  8994. if(file!=null && file.exists())
  8995. {
  8996. file.delete();
  8997. }
  8998. }
  8999. public static void ReDirectCall(String ip)
  9000. {
  9001. Intent Intent = new Intent();
  9002. Intent.setAction("CERES_CALL");
  9003. Intent.putExtra("REMOTEINFO", ip);
  9004. mContext_call.sendBroadcast(Intent);
  9005. }
  9006. /**
  9007. * 거동 수상자 녹화 중지(MainActivity -> WallPadCall)
  9008. */
  9009. private void stopStrangerRecord() {
  9010. try {
  9011. Log.d(TAG, "[stopStrangerRecord] bRecordStatus [" + Common.bRecordStatus + "]");
  9012. if (Common.bRecordStatus) {
  9013. Common.bRecordStatus = false;
  9014. // yjyoon. 녹화 중지 브로드캐스트
  9015. Intent iIntent = new Intent();
  9016. iIntent.setAction(Common.BR_REQUEST_RECORD_STOP);
  9017. iIntent.putExtra(define.NOTIBR_KIND, 1);
  9018. getApplicationContext().sendBroadcast(iIntent);
  9019. mediaStopRecord();
  9020. }
  9021. } catch (RuntimeException re) {
  9022. LogUtil.errorLogInfo("", TAG, re);
  9023. } catch (Exception e) {
  9024. Log.e(TAG, "[Exception] stopStrangerRecord(boolean bSave)");
  9025. //e.printStackTrace();
  9026. LogUtil.errorLogInfo("", TAG, e);
  9027. }
  9028. }
  9029. Handler StrangeDelayHandler = null;
  9030. Runnable strangedelay_runnable = new Runnable() {
  9031. @Override
  9032. public void run() {
  9033. if (cv_bStrangerVideoRecordUsage) {
  9034. if (cv_bStrangerUserVideoRecordUsage) {
  9035. Log.d(TAG, "[RecordDelay]");
  9036. Common.bRecordDelay = true;
  9037. if(mSmartKeyRfDoorAPI == null && mWallPadAPI!=null ) mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  9038. //jglee - 2022.07.27 시나리오 변경에 따른 추가 설정
  9039. //딜레이 기간동안 LED 자동 OFF 실행
  9040. if (mSmartKeyRfDoorAPI != null) mSmartKeyRfDoorAPI.SetLEDmode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  9041. if (mSmartKeyRfDoorAPI != null) mSmartKeyRfDoorAPI.SetCAMERAmode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  9042. //여기서 감지시간을 강제로 늘림
  9043. if(mSmartKeyRfDoorAPI!=null)
  9044. {
  9045. String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, (byte)0x240);
  9046. }
  9047. }
  9048. }
  9049. }
  9050. };
  9051. /**
  9052. * 거동 수상자 연속 녹화 방지(10초간 막음)
  9053. */
  9054. private void RecordDelayOn()
  9055. {
  9056. try {
  9057. Log.d(TAG, "[RecordDelayOn] Delay Start bRecordDelay : " + Common.bRecordDelay);
  9058. boolean isStrangeUse = false;
  9059. recordDelayHandler.removeMessages(0);
  9060. if(StrangeDelayHandler == null)
  9061. StrangeDelayHandler = new Handler();
  9062. if(cv_bStrangerUserVideoRecordUsage && cv_bStrangerUserVideoRecordUsage)
  9063. {
  9064. if(!Common.bRecordDelay) {
  9065. StrangeDelayHandler.removeCallbacksAndMessages(null);
  9066. StrangeDelayHandler.post(strangedelay_runnable);
  9067. }
  9068. //기존 핸들러 삭제 해야 함
  9069. Message msg = recordDelayHandler.obtainMessage();
  9070. msg.what = 0;
  9071. recordDelayHandler.sendMessageDelayed(msg, 90 * 1000); // 녹화 종료 후 90초 동안 녹화를 막는다.
  9072. }
  9073. else
  9074. {
  9075. Common.bRecordDelay = false;
  9076. Log.i(TAG, "[RecordDelayOn] - Not Use Strange()");
  9077. }
  9078. }
  9079. catch (Exception e)
  9080. {
  9081. }
  9082. }
  9083. /**
  9084. * 거동 수상자 사용설정
  9085. */
  9086. private void RecordNotUse(boolean isUse)
  9087. {
  9088. try {
  9089. if (cv_bStrangerVideoRecordUsage) {
  9090. if (cv_bStrangerUserVideoRecordUsage) {
  9091. if(mSmartKeyRfDoorAPI == null && mWallPadAPI!=null ) mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
  9092. //jglee - 2022.07.27 시나리오 변경에 따른 추가 설정
  9093. //딜레이 기간동안 LED 자동 OFF 실행
  9094. if(isUse)
  9095. {
  9096. if (mSmartKeyRfDoorAPI != null) mSmartKeyRfDoorAPI.SetLEDmode(Common.SmartRFCamLEDMode.LED_AUTO_ON);
  9097. if (mSmartKeyRfDoorAPI != null) mSmartKeyRfDoorAPI.SetCAMERAmode(Common.SmartRFCamStatusMode.STATUS_AUTO_ON);
  9098. //여기서 감지시간을 강제로 늘림
  9099. if(mSmartKeyRfDoorAPI!=null)
  9100. {
  9101. String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, (byte)0x01);
  9102. }
  9103. }
  9104. else
  9105. {
  9106. if (mSmartKeyRfDoorAPI != null) mSmartKeyRfDoorAPI.SetLEDmode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
  9107. if (mSmartKeyRfDoorAPI != null) mSmartKeyRfDoorAPI.SetCAMERAmode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
  9108. //여기서 감지시간을 강제로 늘림
  9109. if(mSmartKeyRfDoorAPI!=null)
  9110. {
  9111. String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, (byte)0x240);
  9112. }
  9113. }
  9114. }
  9115. }
  9116. }
  9117. catch (Exception e)
  9118. {
  9119. }
  9120. }
  9121. /**
  9122. * 거동 수상자 녹화 중지 관련 내부 변수 처리
  9123. */
  9124. private void mediaStopRecord() {
  9125. try {
  9126. Log.d(TAG, "[mediaStopRecord]");
  9127. Log.d(TAG, "[mediaStopRecord] - RecordDelayOn()");
  9128. RecordDelayOn();
  9129. Common.bRecordStatus = false; // 녹화 종료
  9130. } catch (RuntimeException re) {
  9131. LogUtil.errorLogInfo("", TAG, re);
  9132. } catch (Exception e) {
  9133. Log.e(TAG, "[Exception] mediaStopRecord()");
  9134. //e.printStackTrace();
  9135. LogUtil.errorLogInfo("", TAG, e);
  9136. }
  9137. }
  9138. /**
  9139. * 거동 수상자 역속 녹화를 막기 위한 Handler
  9140. */
  9141. Handler recordDelayHandler = new Handler() {
  9142. @Override
  9143. public void handleMessage(Message msg) {
  9144. Common.bRecordDelay = false;
  9145. Log.d(TAG, "[recordDelayHandler] RecordDelay Init + CallingStatus : " +Common.bWallPadCallingLive);
  9146. if (cv_bStrangerVideoRecordUsage) {
  9147. if (cv_bStrangerUserVideoRecordUsage) {
  9148. if(!Common.bWallPadCallingLive)
  9149. {
  9150. if (mSmartKeyRfDoorAPI != null) mSmartKeyRfDoorAPI.SetLEDmode(Common.SmartRFCamLEDMode.LED_AUTO_ON);
  9151. else Log.w(TAG, "[recordDelayHandler] Status LED ON smartKeyRfDoorAPI is null!!");
  9152. if (mSmartKeyRfDoorAPI != null) mSmartKeyRfDoorAPI.SetCAMERAmode(Common.SmartRFCamStatusMode.STATUS_AUTO_ON);
  9153. else Log.w(TAG, "[recordDelayHandler] Status Auto ON smartKeyRfDoorAPI is null!!");
  9154. //여기서 감지시간을 원래대로 복구
  9155. if(mSmartKeyRfDoorAPI!=null)
  9156. {
  9157. String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, (byte)0x01);
  9158. Log.i(TAG, "[recordDelayHandler SenSorConfig] - Test Setting result = " + ret);
  9159. }
  9160. }
  9161. }
  9162. }
  9163. }
  9164. };
  9165. /**
  9166. * 거동 수상자 관련 BR 등록
  9167. */
  9168. private void registerStrangeRecordBR() {
  9169. try {
  9170. IntentFilter filter = new IntentFilter();
  9171. filter.addAction(Common.BR_RECORD_EXCEPTION);
  9172. filter.addAction(Common.BR_RECORD_STOP);
  9173. filter.addAction(Common.BR_RECORD_DELAY);
  9174. filter.addAction(Common.BR_RECORD_NOT_USE);
  9175. filter.addAction(Common.BR_RECORD_DELAY_INIT);
  9176. mContext.registerReceiver(StrangeRecordBroadcastReceiver, filter);
  9177. } catch (RuntimeException re) {
  9178. LogUtil.errorLogInfo("", TAG, re);
  9179. }
  9180. catch (Exception e) {
  9181. Log.e(TAG, "[Exception] registerMainActivityBR()");
  9182. LogUtil.errorLogInfo("", TAG, e);
  9183. }
  9184. }
  9185. /**
  9186. * 거동 수상자 관련 BR
  9187. */
  9188. BroadcastReceiver StrangeRecordBroadcastReceiver = new BroadcastReceiver() {
  9189. @Override
  9190. public void onReceive(Context context, Intent intent) {
  9191. if(intent.getAction().equals(Common.BR_RECORD_EXCEPTION))
  9192. {
  9193. mediaStopRecord();
  9194. }
  9195. else if(intent.getAction().equals(Common.BR_RECORD_STOP))
  9196. {
  9197. stopStrangerRecord();
  9198. }
  9199. else if(intent.getAction().equals(Common.BR_RECORD_DELAY))
  9200. {
  9201. Log.d(TAG, "BR - RecordDelayOn()");
  9202. RecordDelayOn();
  9203. }
  9204. else if(intent.getAction().equals(Common.BR_RECORD_NOT_USE))
  9205. {
  9206. RecordNotUse(false);
  9207. }
  9208. else if(intent.getAction().equals(Common.BR_RECORD_DELAY_INIT))
  9209. {
  9210. //jglee - 거동수상자 초기화
  9211. //시나리오에 따라 딜레이가 있는 경우, 딜레이가 완료 되고 해당 초기화 진행
  9212. //거동 수상자 설정(사용함)일 경우, 해당 BR 받음
  9213. Log.d(TAG, "Recrod Delay Init Config, RecordDelay Status :" + Common.bRecordDelay);
  9214. if(!Common.bRecordDelay)
  9215. RecordNotUse(true);
  9216. }
  9217. }
  9218. };
  9219. }