12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472 |
- package kr.co.icontrols.wallpadmain.util;
- import java.io.BufferedOutputStream;
- import java.io.DataOutputStream;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.FilenameFilter;
- import java.io.IOException;
- import java.net.Socket;
- import java.net.SocketException;
- import java.util.ArrayList;
- import java.util.List;
- import kr.co.icontrols.v40ioctl.V40IOInterface;
- import kr.co.icontrols.wallpadmain.declare.Common;
- import kr.co.icontrols.wallpadsupport.Version;
- import org.apache.commons.net.ftp.FTP;
- import org.apache.commons.net.ftp.FTPClient;
- import org.w3c.dom.Document;
- import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
- import android.content.Context;
- import android.content.Intent;
- import android.content.pm.PackageInfo;
- import android.os.Build;
- import android.os.Environment;
- import android.os.Handler;
- import android.os.Looper;
- import android.os.Message;
- import android.os.StatFs;
- import android.util.Log;
- import com.artncore.WallPadDataMgr.WallpadDeviceSet;
- import com.artncore.WallPadDataMgr.WallpadStatusData;
- import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
- import com.artncore.commons.APIErrorCode;
- import com.artncore.commons.define;
- import com.util.LogUtil;
- import com.artncore.wallpadimap.WallPadiMAPClient;
- public class WallPadiMAPUpgrade {
- String TAG = "WallPadiMAPUpgrade";
- public static final int STATE_REPLY = 1;
- public static final int STATE_REQUEST = 2;
- public static final int STATE_DOWNLOADREPLY = 3;
- public static final int STATE_UPGRADE = 4;
-
- public static final int DOWNLOAD_SUCCESS_MSG = 100;
- public static final int DOWNLOAD_FAIL_MSG = 200;
-
- public static String DownloadLocation = "sdcard";
- public static final String APPDownloadLocation = "sdcard";
- public static final String EPICDownloadLocation = define.ALBUM_PICTURE_LOCATION;
- public static final String SVRDownloadLocation = "/storage/sdcard0/Bestin/DownloadAddservice";
-
- public class DownloadFileInfo {
- static final int TYPE_BSP = 1; //BSP
- static final int TYPE_APP = 2; //APP
- static final int TYPE_IMG = 3; //EPIC - 전자액자 사진
- static final int TYPE_SVR = 4; //부가서비스 - CCTV, 주차정보
-
- static final int TYPE_BSP_FAIL = 101;
- static final int TYPE_APP_FAIL = 102;
- static final int TYPE_IMG_FAIL = 103;
- static final int TYPE_SVR_FAIL = 104;
-
- public String filename;
- public int filesize;
- public int state = 0;
- public int type = 0;
-
- public long checkedtime = 0;
-
- public DownloadFileInfo(String fname, int size, int type) {
- filename = fname;
- filesize = size;
- this.type = type;
- checkedtime = 0;
- }
- }
-
- List<DownloadFileInfo> downloadfilelist = new ArrayList<DownloadFileInfo>();
-
- ftp_FileDownload filedownloader;
- public static boolean active = false;
- String FTPServer;
- APIErrorCode ErrorCode;
- String myDong;
- String myIP;
- String myHo;
- Socket receiveSocket;
- int currentState = 0;
- Document Docm;
-
- String upgradetype;
- String id;
- String passwd;
-
- String[] imglist;
- String[] imgpath;
- String Count;
-
- static int retrycnt = 0;
- SendiMAPreq SocClient;
- Context ThisCtx;
- String ProposeUpgrade;
- int retryDelay = 180000;
-
-
- public WallPadiMAPUpgrade(Context ctx, Document Docm, Socket soc) {
- ThisCtx = ctx;
-
- WallpadStatusData DBMGR;
- DBMGR = new WallpadStatusData(ctx);
- AddressSet addc = DBMGR.getAddressMGR();
- DBMGR.closeDB();
- myDong = addc.Dong;
- myIP = addc.IPAddress;
- myHo = addc.Ho;
- retrycnt = 0;
- this.Docm = Docm;
- String result_Str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"+
- "<imap ver = \"1.0\" address = \""+myIP+"\" sender = \""+myDong+"동 "+myHo+"호\">\r\n"+
- "<service type = \"reply\" name= \"upgrade\" result = \"ok\"/>\r\n</imap>\r\n";
- downloadfilelist.clear();
- DataOutputStream outstream;
- try {
- outstream = new DataOutputStream(soc.getOutputStream());
- byte[] outBF = result_Str.getBytes("euc-kr");
- outstream.write(outBF);
- outstream.flush();
- Thread.sleep(300);
- soc.close();
- WallPadiMAPUpgrade.active = true;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- WallPadiMAPUpgrade.active = false;
- return;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] WallPadiMAPUpgrade(Context ctx, Document Docm, Socket soc)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
- WallPadiMAPUpgrade.active = false;
- return;
- }
- }
-
- public void StartUpgrade() {
- int waittime = 200;
- NodeList itemsguide = Docm.getElementsByTagName("guidemap");
-
- Node item = itemsguide.item(0);
- active = true;
- if (item != null) {
- NamedNodeMap attrs = item.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("type")) upgradetype = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("count")) {
- Count = attr.getNodeValue();
- int cnt = Integer.parseInt(Count);
- imglist = new String[cnt];
- imgpath = new String[cnt];
- }
- else if (attr.getNodeName().equalsIgnoreCase("user")) id = attr.getNodeValue();
- else if (attr.getNodeName().equalsIgnoreCase("passwd")) passwd = attr.getNodeValue();
- }
- }
-
- NodeList itemsImg = Docm.getElementsByTagName("img");
-
- for (int i = 0; i < itemsImg.getLength(); i++) {
- Node Img = itemsImg.item(i);
- NamedNodeMap attrs = Img.getAttributes();
- for (int j = 0; j < attrs.getLength(); j++) {
- Node attr = attrs.item(j);
- if (attr.getNodeName().equalsIgnoreCase("module")) {
- imglist[i] = attr.getNodeValue();
- }
- else if (attr.getNodeName().equalsIgnoreCase("path")) {
- imgpath[i] = attr.getNodeValue();
- }
- }
- }
-
- try { Thread.sleep(waittime);} catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
-
- try {
- ProposeUpgrade = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"+
- "<imap ver = \"1.0\" address = \""+myIP+"\" sender = \""+myDong+"동 "+myHo+"호\">\r\n"+
- "<service type = \"request\" name= \"propose_upgrade\" >\r\n"+
- "<guidemap type = \"upgrade\" count = \""+imglist.length+"\" value = \"list\">\r\n";
- for (int i = 0; i < imglist.length; i++) {
- ProposeUpgrade += "<img module = \""+imglist[i]+"\" /> \r\n";
- }
- ProposeUpgrade += " </guidemap>\r\n</service>\r\n</imap>\r\n";
-
- SocClient = new SendiMAPreq();
- SocClient.setContext(ThisCtx);
- /*
- WallpadStatusData Wsdata = new WallpadStatusData(ThisCtx);
- SocClient.SendXMLDoc(Wsdata.GetServerIP(), Wsdata.GetServerPort(), ProposeUpgrade, true);
- Wsdata.closeDB();
- */
- SocClient.SendXMLDoc(ProposeUpgrade, true);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- active = false;
- return;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] StartUpgrade()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- active = false;
- return;
- }
- }
- public static final int MAX_UPGRADE_DOWNLOAD_RETRY = -3;
- public class SendiMAPreq extends WallPadiMAPClient {
- Handler resultProc = new Handler(Looper.getMainLooper()) {
- public void handleMessage(Message msg) {
- if (msg.what == DOWNLOAD_SUCCESS_MSG) {
- DownloadFileInfo finfo = downloadfilelist.get(msg.arg2);
- finfo.state = 1;
- downloadfilelist.set(msg.arg2, finfo);
- }
- else if (msg.what == DOWNLOAD_FAIL_MSG) {
- if (msg.arg2>=downloadfilelist.size() || downloadfilelist.size()==0) {
- active = false;
- return;
- }
- DownloadFileInfo finfo = downloadfilelist.get(msg.arg2);
-
- finfo.state = finfo.state - 1;
- downloadfilelist.set(msg.arg2, finfo);
- }
- else return;
- for (int i = 0; i < downloadfilelist.size(); i++) {
- Log.w(TAG, "[SendiMAPreq] downloadfilelist.get(" + i + ").filename = " + downloadfilelist.get(i).filename);
- }
- for (int i = 0; i < downloadfilelist.size(); i++) {
- DownloadFileInfo finfo = downloadfilelist.get(i);
- if (finfo.state > 0) continue;
- else {
- if (finfo.state < MAX_UPGRADE_DOWNLOAD_RETRY) {
- downloadfilelist.remove(i);
- i = 0;
- if (downloadfilelist.size() == 0) {
- Log.e(TAG,APIErrorCode.GetLogPrefix() + " Return setActive False");
- active = false;
- return;
- }
- continue;
- }
- Log.e(TAG, "[JEFFREY] ========== 1 ==========");
- checkMemorySize();
- if (startDownloadUpgradeTargetFile(i)) return;
- else {
- downloadfilelist.remove(i);
- i=0;
- }
- }
- }
- if (downloadfilelist.size() > 0) {
- DownloadFileInfo finfo;
- String Updatefilename=null;
- String UpdateAppfilename=null;
- String UpdateServicefileName = null;
- for (int i=0;i<downloadfilelist.size();i++) {
- finfo = downloadfilelist.get(i);
- if (finfo.type == DownloadFileInfo.TYPE_BSP) {
- String[] namelist = finfo.filename.split("/");
- Updatefilename = namelist[namelist.length - 1];
- String filepath = DownloadLocation + "/" + Updatefilename;
- Log.i(TAG, "[SendiMAPreq] filepath [" + filepath + "]");
- File check_file = new File(filepath);
- Log.i(TAG, "[SendiMAPreq] (TYPE_BSP) check update file size : downloaded file [" + check_file.length() + "], server file [" + finfo.filesize + "]");
- if (!check_file.exists() || check_file.length() != finfo.filesize) {
- if (check_file.exists()) Log.e(TAG, "UPDATE Check File size : " + check_file.length() + " (" + finfo.filesize + ")");
- else Log.e(TAG, "UPDATE Check File FileNotExist : " + filepath);
- Updatefilename = null;
- }
- } else if (finfo.type == DownloadFileInfo.TYPE_APP) {
- String[] namelist = finfo.filename.split("/");
- UpdateAppfilename = namelist[namelist.length - 1];
- String filepath = DownloadLocation + "/" + UpdateAppfilename;
- Log.i(TAG, "[SendiMAPreq] filepath [" + filepath + "]");
- File check_file = new File(filepath);
- Log.i(TAG, "[SendiMAPreq] (TYPE_APP) check update file size : downloaded file [" + check_file.length() + "], server file [" + finfo.filesize + "]");
- if (!check_file.exists() || check_file.length() != finfo.filesize) {
- if (check_file.exists()) Log.e(TAG, "UPDATE Check File size : " + check_file.length() + " (" + finfo.filesize + ")");
- else Log.e(TAG, "UPDATE Check File FileNotExist : " + filepath);
- UpdateAppfilename = null;
- }
- } else if (finfo.type == DownloadFileInfo.TYPE_IMG) {
- active = false;
- ProposeUpgrade = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
- "<imap ver = \"1.0\" address = \"" + myIP + "\" sender = \"" + myDong + "동 " + myHo + "호\">\r\n" +
- "<service type = \"request\" name= \"event_notify\">\r\n" +
- " <event> \"epic_completed\" </event>\r\n" +
- "</service>\r\n</imap>\r\n";
- WallPadiMAPClient notis = new WallPadiMAPClient();
- notis.setContext(ThisCtx);
- WallpadStatusData Wsdata = new WallpadStatusData(ThisCtx);
- notis.SendXMLDoc(Wsdata.GetServerIP(), Wsdata.GetServerPort(), ProposeUpgrade, true);
- Wsdata.closeDB();
- } else if (finfo.type == DownloadFileInfo.TYPE_SVR) {
- Log.i(TAG, "Service upgrade file download =============> %%");
- // String[] namelist = finfo.filename.split("/");
- // UpdateServicefileName = namelist[namelist.length-1];
- // String filepath = SVRDownloadLocation+"/"+UpdateServicefileName;
- // File check_file = new File(filepath);
- // if (!check_file.exists() || check_file.length() != finfo.filesize)
- // {
- // if (check_file.exists()) Log.e("HIGH", "UPDATE Check File size : "+check_file.length()+" ("+finfo.filesize+")");
- // else Log.e("HIGH", "UPDATE Check File FileNotExist : "+filepath);
- // UpdateServicefileName = null;
- // }
- // else
- // {
- // // 서비스 파일이 다운로드가 완료되면 압축을 해제 하도록 한다.
- // }
- }
- }
- if (Updatefilename != null || UpdateAppfilename != null ) {
- if (Updatefilename == null) Updatefilename = "no";
- if (UpdateAppfilename == null) UpdateAppfilename = "no";
-
- //jglee - 여기서 거동 수상자 녹화가 진행되면 안되기 때문에 거동수상자 사용않람을 실행 해야 함
- //거동수상자 사용안함 설정
- Intent Newintent = new Intent();
- Newintent.setAction(Common.BR_RECORD_NOT_USE);
- ThisCtx.sendBroadcast(Newintent);
-
- //String SetPP = System.setProperty("persist.sys.update.ready", "1");
- // Log.e(TAG,APIErrorCode.GetLogPrefix()+" Before Call PowerManager ");
- // PowerManager pm = (PowerManager) ThisCtx.getSystemService(Context.POWER_SERVICE);
- // Log.d(TAG,APIErrorCode.GetLogPrefix()+" Create PowerManager "+pm.toString());
- // pm.userActivity(0, true);
- // Log.i(TAG,APIErrorCode.GetLogPrefix()+" after Call pm.userActivity ");
- //WallPadUpgradeLog("Set property ret "+SetPP);
- Log.w(TAG, "[SendiMAPreq] Updatefilename [" + Updatefilename+ "], UpdateAppfilename [" + UpdateAppfilename + "]");
- WallpadStatusData Wsdata = new WallpadStatusData(ThisCtx);
- Wsdata.SetSystemUpdate(Updatefilename, UpdateAppfilename);
- Wsdata.closeDB();
- V40IOInterface mV40IOInterface = new V40IOInterface();
- mV40IOInterface.WpdInterfaceOpen();
- mV40IOInterface.LiveUpdate();
- mV40IOInterface.WpdInterfaceClose();
-
- active = true;
- }
- else {
- active = false;
- }
- return;
- }
- else {
- Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
- active = false;
- return;
- }
- }
- };
-
- protected void ProcComplite() {
- int item_cnt = SocClient.SetItem("service");
- String type;
- String fname;
- int fsize;
- DownloadFileInfo finfo;
-
- active = true;
- if (item_cnt > 0) {
- if (SocClient.GetAttributeVal(0, "result").equals("ok")) {
- item_cnt = SocClient.SetItem("guidemap");
- if (item_cnt > 0) {
- for (int i = 0; i < item_cnt; i++) {
- type = SocClient.GetAttributeVal(i, "type");
- fname = SocClient.GetAttributeVal(i, "fname");
- for (int j = 0; j < imgpath.length; j++) {
- String[] namelist = imgpath[j].split("/");
-
- if (fname.equals(namelist[namelist.length-1])) {
- fsize = Integer.parseInt(SocClient.GetAttributeVal(i, "fsize"));
- //int typeID = (type.equalsIgnoreCase("bsp")?DownloadFileInfo.TYPE_BSP:type.equalsIgnoreCase("app")?DownloadFileInfo.TYPE_APP:type.equalsIgnoreCase("epic")?DownloadFileInfo.TYPE_IMG:0);
- int typeID;
-
- if (type.equalsIgnoreCase("bsp") == true) {
- typeID = DownloadFileInfo.TYPE_BSP;
- }
- else if(type.equalsIgnoreCase("app") == true) {
- typeID = DownloadFileInfo.TYPE_APP;
- }
- else if(type.equalsIgnoreCase("additional") == true) {
- typeID = DownloadFileInfo.TYPE_SVR;
- }
- else if(type.equalsIgnoreCase("epic") == true) {
- typeID = DownloadFileInfo.TYPE_IMG;
- }
- else {
- typeID = 0;
- }
-
- finfo = new DownloadFileInfo(imgpath[j], fsize, typeID);
- downloadfilelist.add(finfo);
- break;
- }
- }
- }
- }
- if (downloadfilelist.size() > 0) {
- Log.e(TAG, "[JEFFREY] ========== 2 ==========");
- checkMemorySize();
- cleanSDRoot();
- checkMemorySize();
- for (int i = 0; i < downloadfilelist.size(); i++) {
- if (startDownloadUpgradeTargetFile(i)) return;
- else {
- downloadfilelist.remove(i);
- i=0;
- }
- }
- Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
- active = false;
- return;
- }
- else {
- Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
- active = false;
- return;
- }
- }
- else {
- Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
- active = false;
- return;
- }
- }
- else {
- Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
- active = false;
- }
- }
-
- protected boolean startDownloadUpgradeTargetFile(int seqnum) {
- if (seqnum >= downloadfilelist.size()) return false;
- DownloadFileInfo finfo = downloadfilelist.get(seqnum);
- String[] namelist = finfo.filename.split("/");
- if (checkDownloadFilename(namelist[namelist.length-1], finfo.type ) == false) {
- Log.e(TAG,APIErrorCode.GetLogPrefix()+"Start Download Check FileName is false return false");
- return false;
- }
- String strTargetFile = null;
- if (finfo.type == DownloadFileInfo.TYPE_BSP) strTargetFile = DownloadLocation + "/" + namelist[namelist.length-1];
- else if (finfo.type == DownloadFileInfo.TYPE_APP) strTargetFile = APPDownloadLocation + "/" + namelist[namelist.length-1];
- else if (finfo.type == DownloadFileInfo.TYPE_IMG) strTargetFile = EPICDownloadLocation + "/" + namelist[namelist.length-1];
- else if (finfo.type == DownloadFileInfo.TYPE_SVR) strTargetFile = SVRDownloadLocation + "/" + namelist[namelist.length-1];
- else return false;
-
- //Log.e(TAG, "startDownloadUpgradeTargetFile 1");
- File TargetFile = new File(strTargetFile);
-
- Log.i(TAG, "[startDownloadUpgradeTargetFile] strTargetFile [" + strTargetFile + "], TargetFile.length() [" + TargetFile.length() +"], finfo.filesize [" + finfo.filesize +"]");
-
- if (TargetFile.exists() && TargetFile.length() == finfo.filesize) {
- Message msg = resultProc.obtainMessage();
- msg.what = DOWNLOAD_SUCCESS_MSG;
- msg.arg1 = 1;
- msg.arg2 = seqnum;
- msg.obj = strTargetFile;
- resultProc.sendMessage(msg);
-
- return true;
- }
- Log.i(TAG, "[startDownloadUpgradeTargetFile] ftp_FileDownload will be started finfo.filename [" + finfo.filename + "]");
-
- filedownloader = new ftp_FileDownload(resultProc, finfo.filename, seqnum, strTargetFile);
- filedownloader.start();
- return true;
- }
-
- protected void ProcError() {
- Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
- WallPadiMAPUpgrade.active = false;
- return;
- }
- }
- public static final String BSP_FILE_ID = "BSP";
- public static final String APP_FILE_ID = "APP";
- public static final String DEV_TCC8935_ARCH_ID = "8935";
- public static final String DEV_A20_ARCH_ID = "A20";
- public static final String DEV_V40_ARCH_ID = "V40"; // V40 플랫폼
- public static final String DEV_A40i_ARCH_ID = "A40i"; // A40i 플랫폼
- public static final String SA_DEV_ID = "IHN1020B-A"; // 일반 대외향
- public static final String SA_A20_DEV_ID = "IHN1030-D"; // 다담 일반 대외향
- public static final String SA_A20_DEV_ID_NEW = "IHN1030-A2"; // 다담 일반 대외향 - 신규 모델명
- public static final String SA_A20_C_DEV_ID = "IHN1020B-C"; // 다담 일반 대외향
- public static final String SA_A20_C_DEV_ID_NEW = "IHN1020B-A2"; // 다담 일반 대외향 - 신규 모델명
- public static final String LH_DEV_ID = "IHN1020SA-A"; // LH 향
- public static final String GLE_DEV_ID = "IHN1020GL"; // 현산향
- public static final String IHN_750_ID = "IHN750";
- public static final String IHN_750S_ID = "IHN750S";
- public static final String IHN_D101_ID = "IHND101"; // 조그월패드
- public static final String IHN_D101K_ID = "IHND101K"; // 카카오 조그월패드
- public static final String IHN_1010_ID = "IHN1010"; // 대외향 월패드
- public static final String IHN_1010GL_ID = "IHN1010GL"; // 연합사업지용 월패드
- public static final String IHN_T1010_ID = "IHNT1010"; // 힘찬건설향 월패드
- public static final String IHN_HS101_ID = "IHNHS101"; // 효성건설향 월패드
- public static final String IHN_1040_ID = "IHN1040"; // 보급형(엔트리급) 월패드
- public static final String IHN_1050_ID = "IHN1050"; // 대우건설향 월패드
- public static final String IHN_D101_I_ID = "IHND101-I"; // 조그월패드 (중국생산)
- public static final String IHN_D101K_I_ID = "IHND101K-I"; // 카카오 조그월패드 (중국생산)
- public static final String IHN_D101_I_OCF_ID = "IHND101-I-OCF"; // 조그월패드 (OCF 월패드, 중국생산)
- public static final String IHN_1010_I_ID = "IHN1010-I"; // 대외향 월패드 (중국생산)
- public static final String IHN_1010GL_I_ID = "IHN1010GL-I"; // 연합사업지용 월패드 (중국생산)
- public static final String IHN_1010GL_I_2443_ID = "IHN1010GL-I-2443"; // 현산향 2443 대체품 월패드 (중국생산)
- public static final String IHN_1010GL_I_6410_ID = "IHN1010GL-I-6410"; // 현산향 6410 대체품 월패드 (중국생산)
- public static final String IHN_1010_I_2443_ID = "IHN1010-I-2443"; // 대외향 2443 대체품 월패드 (중국생산)
- public static final String IHN_T1010_I_ID = "IHNT1010-I"; // 힘찬건설향 월패드 (중국생산)
- public static final String IHN_HS101_I_ID = "IHNHS101-I"; // 효성건설향 월패드 (중국생산)
- public static final String IHN_1030_I_ID = "IHN1030-I"; // 보급형(엔트리급) 월패드 (중국생산)
- public static final String IHN_1040_I_ID = "IHN1040-I"; // 보급형(엔트리급) 월패드 (중국생산)
- public static final String IHN_1050_I_ID = "IHN1050-I"; // 대우건설향 월패드 (중국생산)
- public static final String IHN_1050DW_I_ID = "IHN1050DW-I"; // 대우건설향 월패드 (중국생산)
- public static final String IHN_1020B_I_ID = "IHN1020B-I"; // IHN-1020B-A2 대체용 월패드 (중국생산)
- public static final String IHN_1303_I_ID = "IHN1303-I"; // 13.3인치 월패드 (중국생산)
-
- private boolean checkDownloadFilename(String filename, int type) {
- try {
- String[] astrFileName = filename.split("_");
- if (astrFileName != null) {
- for (int i = 0; i < astrFileName.length; i++) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[" + i + "] = " + astrFileName[i] );
- }
- }
- if (filename != null) Log.d( TAG , "[checkDownloadFilename] filename [" + filename + "], type [" + type + "]");
- else Log.d( TAG , "[checkDownloadFilename] filename [null] , type [" + type + "]");
- if (type == DownloadFileInfo.TYPE_BSP || type == DownloadFileInfo.TYPE_APP) {
- // check update option
- if (!checkUpdateOption(astrFileName[2])) {
- Log.w( TAG , "[checkDownloadFilename] Update option is not correct!!! astrFileName[2] : [" + astrFileName[2] + "]");
- return false;
- }
- // check & change update module name, if the module name contains "#". ("#" means it has update option)
- astrFileName[2] = changeUpdateModuleName(astrFileName[2]);
- if (type == DownloadFileInfo.TYPE_BSP && !astrFileName[0].equals(BSP_FILE_ID)) {
- Log.w( TAG , "[checkDownloadFilename] Filetype is not correct!! astrFileName[0] : [" + astrFileName[0] + "], type + [" + type + "]");
- return false;
- }
- if (type == DownloadFileInfo.TYPE_APP && !astrFileName[0].equals(APP_FILE_ID)) {
- Log.w( TAG , "[checkDownloadFilename] Filetype is not correct!! astrFileName[0] : [" + astrFileName[0] + "], type + [" + type + "]");
- return false;
- }
- if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_D101_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_D101_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101K) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_D101K_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_D101K_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_D101_I_OCF_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1010_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1010_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010_I_2443) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1010_I_2443_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1010GL_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1010GL_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1010GL_I_2443_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1010GL_I_6410_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1030_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1030_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1040) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1040_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1040_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1040_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1050) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1050_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1050_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1050_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_T1010) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_T1010_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_T1010_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_T1010_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_HS101) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_HS101_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_HS101_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_HS101_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1050DW_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1050DW_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1020B_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1303_I) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1303_I_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1010GL_I_2443_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
- // V40 플랫폼 업그레이드
- if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1010GL_I_6410_ID) || (astrFileName[3].length() != 14)) {
- Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
- Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
- return false;
- }
- }
- else {
- Log.d(TAG, "[checkDownloadFilename] model : " + Version.getModelType() + " , Build.MODEL :" + Build.MODEL );
- return false;
- }
- }
- else if (type == DownloadFileInfo.TYPE_IMG) return true;
- return true;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] checkDownloadFilename(String filename, int type)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- /**
- * 플랫폼 ID에 업데이트 가능한 App 버전 존재 유무 확인
- * @param strValue - 다운로드할 파일의 모델명 (예. IHND101-I#APP#2020101501)
- * @return true: 업데이트 가능, false: 업데이트 불가
- */
- private boolean checkUpdateOption(String strValue) {
- if(strValue!=null)
- {
- try {
- Log.i(TAG, "[checkUpdateOption] strValue [" + strValue + "]");
- if (strValue.contains("#")) {
- String[] strParsed = strValue.split("#");
- String strModuleType = strParsed[1];
- String strVer = strParsed[2];
- // Log.i(TAG, "[checkUpdateOption] strModuleType [" + strModuleType + "], strVer [" + strVer + "]");
- return checkUpdatableModuleVer(strModuleType, strVer);
- }
- else return true;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] checkUpdateOption(String strValue)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- else return false;
- }
- private boolean checkUpdatableModuleVer(String strModule, String strVer) {
- try {
- Log.i(TAG, "[checkUpdatableModuleVer] strModuleType [" + strModule + "], strVer [" + strVer + "]");
- if (strModule.equalsIgnoreCase(BSP_FILE_ID)) {
- int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
- int nMinVer = Integer.parseInt(strVer);
- Log.i(TAG, "[checkUpdatableModuleVer] BSP Ver. check -> nCurrentVer [" + nCurrentVer + "], nMinVer [" + nMinVer + "]");
- if (nCurrentVer >= nMinVer) {
- Log.w(TAG, "[checkUpdatableModuleVer] BSP update OK!! Current Ver. is bigger than minimum Ver!!");
- return true;
- }
- else {
- Log.w(TAG, "[checkUpdatableModuleVer] BSP update FAIL!! Current Ver. is smaller than minimum Ver!!");
- return false;
- }
- }
- else if (strModule.equalsIgnoreCase(APP_FILE_ID)) {
- int nCurrentVer = Integer.parseInt(getAppVersion().replace(".", ""));
- int nMinVer = Integer.parseInt(strVer);
- Log.i(TAG, "[checkUpdatableModuleVer] APP Ver. check -> nCurrentVer [" + nCurrentVer + "], nMinVer [" + nMinVer + "]");
- if (nCurrentVer >= nMinVer) {
- Log.w(TAG, "[checkUpdatableModuleVer] APP update OK!! Current Ver. is bigger than minimum Ver!!");
- return true;
- }
- else {
- Log.w(TAG, "[checkUpdatableModuleVer] APP update FAIL!! Current Ver. is smaller than minimum Ver!!");
- return false;
- }
- }
- else return false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] checkUpdatableModuleVer(String strModule, String strVer)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- private String changeUpdateModuleName(String strValue) {
- String strResult = "";
- if(strValue!=null)
- {
- try {
- Log.i(TAG, "[changeUpdateModuleName] strValue [" + strValue + "]");
- if (strValue.contains("#")) {
- String[] strParsed = strValue.split("#");
- strResult = strParsed[0];
- }
- else strResult = strValue;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- strResult = "Exception";
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] changeUpdateModuleName(String strValue)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- strResult = "Exception";
- }
- Log.i(TAG, "[changeUpdateModuleName] strResult [" + strResult + "]");
- }
- return strResult;
- }
- public String getAppVersion() {
- PackageInfo mPackageInfo = null;
- try {
- mPackageInfo = ThisCtx.getPackageManager().getPackageInfo(ThisCtx.getPackageName(), 0);
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] getAppVersion()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return mPackageInfo.versionName;
- }
- class ftp_FileDownloadWatcher extends Thread {
- String DownloadFile;
- long oldsize = 0;
- long size;
- Handler ExitHandle;
- File ProcF;
- int seqnum;
- public boolean onoff = false;
-
- public ftp_FileDownloadWatcher(String DownLoadFile, long size, Handler handle, int snum) {
- this.size = size;
- ExitHandle = handle;
- DownloadFile = DownLoadFile;
- seqnum = snum;
- }
-
- public void run() {
- long cursize;
-
- onoff = true;
- while (onoff) {
- try{Thread.sleep(1000);}
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- Log.e(TAG, "ftp_FileDownloadWatcher start!");
- if (ProcF == null) ProcF = new File(DownloadFile);
- if (!ProcF.exists()) return;
- cursize = ProcF.length();
- if (oldsize != cursize) oldsize = cursize;
- else {
- if (cursize >= size) return;
- if (filedownloader.isAlive()) filedownloader.interrupt();
- if (onoff != true) return;
-
- Message msg = ExitHandle.obtainMessage();
- msg.what = DOWNLOAD_FAIL_MSG;
- msg.arg1 = 0;
- msg.arg2 = seqnum;
- ExitHandle.sendMessage(msg);
- return;
- }
- }
- }
- }
- class ftp_FileDownload extends Thread {
- String ftpPATH;
- Handler handle;
- int Index;
- FTPClient f;
- //ftp_FileDownloadWatcher WatchThread;
- String localFile;
- int danjiserverType;
- boolean CompleteFlag = true; //event_notify 계속보내는 버그로 인하여 추가함
-
- public ftp_FileDownload(Handler handle, String path, int idx, String LocalFileName) {
- ftpPATH = path;
- Index = idx;
- this.handle = handle;
- //WatchThread = wat;
- localFile = LocalFileName;
- WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(ThisCtx);
- danjiserverType = wallpadDeviceSet.GetNewDanjiServer();
- wallpadDeviceSet.closeDB();
- }
-
- public void run() {
- Log.e(TAG, "[ftp_FileDownload.run()] ftp_FileDownload start! " + ftpPATH + "]");
- f = new FTPClient();
- f.setControlEncoding("euc-kr"); //한글이름의 파일은 FTP 다운로드가 안되기 때문에 인코딩 추가로 넣어줌
-
- f.setReceieveDataSocketBufferSize(1024*512);
- try {
- f.setReceiveBufferSize(1024*512);
- } catch (SocketException e1) {
- //e1.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e1);
- //RetryHandler.sendEmptyMessageDelayed(0, retryDelay);
- ProcDownFail();
- return;
- }
- int recebf = f.getReceiveDataSocketBufferSize();
- FileOutputStream fos = null;
- BufferedOutputStream ffos = null;
- try {
- WallpadStatusData Wsdata = new WallpadStatusData(ThisCtx);
- FTPServer = Wsdata.GetFTPIP();
- Wsdata.closeDB();
- //여기서 ip정보를 변경해야 함
- if(danjiserverType == define.DanjiServer1 || danjiserverType == define.DanjiServer2)
- {
- f.connect(FTPServer);
- }
- else
- {
- f.connect(define.NewDanjiServerIP);
- }
- boolean ret = false;
- for(int i =0; i< 1; i++)
- ret = f.login(id, passwd);
- if (ret == false) {
- ProcDownFail();
- }
- String[] namelist = ftpPATH.split("/");
- String path = "";
- if (namelist.length > 2) {
- for (int i = 1; i < namelist.length - 1; i++) {
- path += "/"+namelist[i];
- }
- }
- Log.i(TAG, "[ftp_FileDownload] path [" + path+ "], localFile [" + localFile+ "]");
- ret = f.changeWorkingDirectory(path);
- if (ret == false) {
- ProcDownFail();
- }
- ret = f.setFileType(FTP.BINARY_FILE_TYPE);
- if (ret == false) {
- ProcDownFail();
- }
-
- File downloadfile = new File(localFile);
- if (downloadfile.exists()) FileDelete(downloadfile);//.delete();
- fos = new FileOutputStream(downloadfile);
- ffos = new BufferedOutputStream(fos);
- path = ftpPATH;
- boolean result;
-
- result = f.retrieveFile(path, ffos);
- ffos.flush();
-
-
- if (result == false) {
- ProcDownFail();
- }
- if (handle == null) Log.i(TAG, "[ftp_FileDownload.run()] handle is null!!");
- else Log.i(TAG, "[ftp_FileDownload.run()] handle is not null!!");
- Log.i(TAG, "[ftp_FileDownload.run()] CompleteFlag [" + CompleteFlag+ "]");
- if ((handle != null) && (CompleteFlag == true)) {
- // event_notify 계속보내는 버그로 인하여 추가함
- Message msg = handle.obtainMessage();
- msg.what = DOWNLOAD_SUCCESS_MSG;
- msg.arg1 = (result) ? 1 : 0;
- msg.arg2 = Index;
- msg.obj = localFile;
- handle.sendMessage(msg);
- }
- //WatchThread.onoff = false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- ProcDownFail();
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] ftp_FileDownload.run() 1");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- ProcDownFail();
- }
- finally {
- if(fos!=null) {
- try {
- fos.close();
- } catch (IOException e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- fos = null;
- if(ffos!=null) {
- try {
- ffos.close();
- } catch (IOException e) {
- LogUtil.errorLogInfo("", TAG, e);
- }
- ffos = null;
- }
- }
- try{
- f.quit();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] ftp_FileDownload.run() 2");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void ProcDownFail() {
- try {
- Log.w(TAG, "[ProcDownFail] ========== Download failed ==========");
- CompleteFlag = false; //event_notify 계속보내는 버그로 인하여 추가함
- f.logout();
- f.quit();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- //WatchThread.onoff = false;
-
- Message msg = handle.obtainMessage();
- msg.what = DOWNLOAD_FAIL_MSG;
- msg.arg1 = 0;
- msg.arg2 = Index;
- msg.obj = ftpPATH;
- handle.sendMessage(msg);
- }
- }
-
- public boolean parseXML(String XMLDOC) {
- return true;
- }
- static String PATH_LOCAL_ROOT = "/sdcard/";
- public static String[] strUpgradeFileKeyword_ALL = { "_V40_", "_A40i_" };
- public static String strUpgradeFileExtention = "zip";
- public boolean cleanSDRoot() {
- try {
- Log.i(TAG, "[cleanSDRoot] =====START =====");
- for (int i = 0; i < strUpgradeFileKeyword_ALL.length; i++) {
- String[] DeleteFile = findDirectoryFiles(PATH_LOCAL_ROOT, strUpgradeFileKeyword_ALL[i], strUpgradeFileExtention);
- if(DeleteFile!=null)
- {
- Log.i(TAG, "[cleanSDRoot] DeleteFile.length = " + DeleteFile.length);
- File TargetFile;
- for (int j = 0; j < DeleteFile.length; j++) {
- TargetFile = new File(PATH_LOCAL_ROOT + DeleteFile[j]);
- if (TargetFile.delete()) {
- Log.i(TAG, "[cleanSDRoot] Success to delete!! TargetFile = " + TargetFile.getName());
- }
- else {
- Log.i(TAG, "[cleanSDRoot] Fail to delete!! TargetFile = " + TargetFile.getName());
- }
- }
- }
- }
- return true;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] cleanSDRoot()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- public String[] findDirectoryFiles(String strDstDir, final String strKeyword, final String strExtention) {
- try {
- Log.i(TAG, "[findDirectoryFiles] strDstDir [" + strDstDir + "], strKeyword [" + strKeyword + "], strExtention [" + strExtention + "]");
- String[] strResult = null;
- if (strDstDir == null) return null;
- File Directory = new File(strDstDir);
- if (Directory.exists()) {
- FilenameFilter mFilenameFilter = new FilenameFilter() {
- @Override
- public boolean accept(File dir, String filename) {
- if (strKeyword != null && strExtention != null) {
- return (filename.endsWith(strExtention) && filename.matches(".*" + strKeyword + ".*"));
- }
- else if (strKeyword != null && strExtention == null) {
- return filename.matches(".*" + strKeyword + ".*");
- }
- else if (strKeyword == null && strExtention != null) {
- return filename.endsWith(strExtention);
- }
- else if (strKeyword == null && strExtention == null) {
- return true;
- }
- return false;
- }
- };
- String[] mFiles = Directory.list(mFilenameFilter);
- if(mFiles!=null)
- {
- Log.i(TAG, "[findDirectoryFiles] mFiles.length = " + mFiles.length);
- strResult = new String[mFiles.length];
- for (int i = 0; i < strResult.length; i++) {
- strResult[i] = mFiles[i];
- Log.i(TAG, "[findDirectoryFiles] strResult[" + i + "] = " + strResult[i]);
- }
- }
- return strResult;
- }
- else {
- Log.i(TAG, "[findDirectoryFiles] Directory is not exist!! [" + strDstDir + "]");
- return null;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] findDirectoryFiles()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public void checkMemorySize() {
- try {
- String strInternalTotalMemorySize = formatSize(getTotalInternalMemorySize());
- String strAvailableInternalMemorySize = formatSize(getAvailableInternalMemorySize());
- String strExternalTotalMemorySize = formatSize(getTotalExternalMemorySize());
- String strAvailableExternalMemorySize = formatSize(getAvailableExternalMemorySize());
- Log.i(TAG, "[checkMemorySize] strInternalTotalMemorySize [" + strInternalTotalMemorySize + "], strAvailableInternalMemorySize [" + strAvailableInternalMemorySize + "]");
- Log.i(TAG, "[checkMemorySize] strExternalTotalMemorySize [" + strExternalTotalMemorySize + "], strAvailableExternalMemorySize [" + strAvailableExternalMemorySize + "]");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] checkMemorySize()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /** 전체 내장 메모리 크기를 가져온다 */
- private long getTotalInternalMemorySize() {
- try {
- File path = Environment.getDataDirectory();
- StatFs stat = new StatFs(path.getPath());
- long blockSize = stat.getBlockSize();
- long totalBlocks = stat.getBlockCount();
- return totalBlocks * blockSize;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -99;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] getTotalInternalMemorySize()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -99;
- }
- }
- /** 사용가능한 내장 메모리 크기를 가져온다 */
- private long getAvailableInternalMemorySize() {
- try {
- File path = Environment.getDataDirectory();
- StatFs stat = new StatFs(path.getPath());
- long blockSize = stat.getBlockSize();
- long availableBlocks = stat.getAvailableBlocks();
- return availableBlocks * blockSize;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -99;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] getAvailableInternalMemorySize()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -99;
- }
- }
- /** 전체 외장 메모리 크기를 가져온다 */
- private long getTotalExternalMemorySize() {
- try {
- if (isStorage(true) == true) {
- File path = Environment.getExternalStorageDirectory();
- StatFs stat = new StatFs(path.getPath());
- long blockSize = stat.getBlockSize();
- long totalBlocks = stat.getBlockCount();
- return totalBlocks * blockSize;
- } else {
- return -1;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -99;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] getTotalExternalMemorySize()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -99;
- }
- }
- /** 사용가능한 외장 메모리 크기를 가져온다 */
- private long getAvailableExternalMemorySize() {
- try {
- if (isStorage(true) == true) {
- File path = Environment.getExternalStorageDirectory();
- StatFs stat = new StatFs(path.getPath());
- long blockSize = stat.getBlockSize();
- long availableBlocks = stat.getAvailableBlocks();
- return availableBlocks * blockSize;
- } else {
- return -1;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -99;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] getAvailableExternalMemorySize()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -99;
- }
- }
- /** 보기 좋게 MB,KB 단위로 축소시킨다 */
- private String formatSize(long size) {
- try {
- String suffix = null;
- if (size >= 1024) {
- suffix = "KB";
- size /= 1024;
- if (size >= 1024) {
- suffix = "MB";
- size /= 1024;
- }
- }
- StringBuilder resultBuffer = new StringBuilder(Long.toString(size));
- int commaOffset = resultBuffer.length() - 3;
- while (commaOffset > 0) {
- resultBuffer.insert(commaOffset, ',');
- commaOffset -= 3;
- }
- if (suffix != null) {
- resultBuffer.append(suffix);
- }
- return resultBuffer.toString();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] formatSize(long size)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- /** 외장메모리 sdcard 사용가능한지에 대한 여부 판단 */
- private boolean isStorage(boolean requireWriteAccess) {
- try {
- String state = Environment.getExternalStorageState();
- if (Environment.MEDIA_MOUNTED.equals(state)) {
- return true;
- } else if (!requireWriteAccess &&
- Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
- return true;
- }
- return false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] isStorage(boolean requireWriteAccess)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- private synchronized void FileDelete(File file)
- {
- if(file!=null && file.exists())
- {
- file.delete();
- }
- }
- }
|