MainActivity.java 437 KB

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