WallPadiMAPUpgrade.java 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439
  1. package kr.co.icontrols.wallpadmain.util;
  2. import java.io.BufferedOutputStream;
  3. import java.io.DataOutputStream;
  4. import java.io.File;
  5. import java.io.FileOutputStream;
  6. import java.io.FilenameFilter;
  7. import java.io.IOException;
  8. import java.net.Socket;
  9. import java.net.SocketException;
  10. import java.util.ArrayList;
  11. import java.util.List;
  12. import kr.co.icontrols.v40ioctl.V40IOInterface;
  13. import kr.co.icontrols.wallpadsupport.Version;
  14. import org.apache.commons.net.ftp.FTP;
  15. import org.apache.commons.net.ftp.FTPClient;
  16. import org.w3c.dom.Document;
  17. import org.w3c.dom.NamedNodeMap;
  18. import org.w3c.dom.Node;
  19. import org.w3c.dom.NodeList;
  20. import android.content.Context;
  21. import android.content.pm.PackageInfo;
  22. import android.os.Build;
  23. import android.os.Environment;
  24. import android.os.Handler;
  25. import android.os.Looper;
  26. import android.os.Message;
  27. import android.os.StatFs;
  28. import android.util.Log;
  29. import com.artncore.WallPadDataMgr.WallpadStatusData;
  30. import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
  31. import com.artncore.commons.APIErrorCode;
  32. import com.artncore.commons.define;
  33. import com.util.LogUtil;
  34. import com.artncore.wallpadimap.WallPadiMAPClient;
  35. public class WallPadiMAPUpgrade {
  36. String TAG = "WallPadiMAPUpgrade";
  37. public static final int STATE_REPLY = 1;
  38. public static final int STATE_REQUEST = 2;
  39. public static final int STATE_DOWNLOADREPLY = 3;
  40. public static final int STATE_UPGRADE = 4;
  41. public static final int DOWNLOAD_SUCCESS_MSG = 100;
  42. public static final int DOWNLOAD_FAIL_MSG = 200;
  43. public static String DownloadLocation = "sdcard";
  44. public static final String APPDownloadLocation = "sdcard";
  45. public static final String EPICDownloadLocation = define.ALBUM_PICTURE_LOCATION;
  46. public static final String SVRDownloadLocation = "/storage/sdcard0/Bestin/DownloadAddservice";
  47. public class DownloadFileInfo {
  48. static final int TYPE_BSP = 1; //BSP
  49. static final int TYPE_APP = 2; //APP
  50. static final int TYPE_IMG = 3; //EPIC - 전자액자 사진
  51. static final int TYPE_SVR = 4; //부가서비스 - CCTV, 주차정보
  52. static final int TYPE_BSP_FAIL = 101;
  53. static final int TYPE_APP_FAIL = 102;
  54. static final int TYPE_IMG_FAIL = 103;
  55. static final int TYPE_SVR_FAIL = 104;
  56. public String filename;
  57. public int filesize;
  58. public int state = 0;
  59. public int type = 0;
  60. public long checkedtime = 0;
  61. public DownloadFileInfo(String fname, int size, int type) {
  62. filename = fname;
  63. filesize = size;
  64. this.type = type;
  65. checkedtime = 0;
  66. }
  67. }
  68. List<DownloadFileInfo> downloadfilelist = new ArrayList<DownloadFileInfo>();
  69. ftp_FileDownload filedownloader;
  70. public static boolean active = false;
  71. String FTPServer;
  72. APIErrorCode ErrorCode;
  73. String myDong;
  74. String myIP;
  75. String myHo;
  76. Socket receiveSocket;
  77. int currentState = 0;
  78. Document Docm;
  79. String upgradetype;
  80. String id;
  81. String passwd;
  82. String[] imglist;
  83. String[] imgpath;
  84. String Count;
  85. static int retrycnt = 0;
  86. SendiMAPreq SocClient;
  87. Context ThisCtx;
  88. String ProposeUpgrade;
  89. int retryDelay = 180000;
  90. public WallPadiMAPUpgrade(Context ctx, Document Docm, Socket soc) {
  91. ThisCtx = ctx;
  92. WallpadStatusData DBMGR;
  93. DBMGR = new WallpadStatusData(ctx);
  94. AddressSet addc = DBMGR.getAddressMGR();
  95. DBMGR.closeDB();
  96. myDong = addc.Dong;
  97. myIP = addc.IPAddress;
  98. myHo = addc.Ho;
  99. retrycnt = 0;
  100. this.Docm = Docm;
  101. String result_Str = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"+
  102. "<imap ver = \"1.0\" address = \""+myIP+"\" sender = \""+myDong+"동 "+myHo+"호\">\r\n"+
  103. "<service type = \"reply\" name= \"upgrade\" result = \"ok\"/>\r\n</imap>\r\n";
  104. downloadfilelist.clear();
  105. DataOutputStream outstream;
  106. try {
  107. outstream = new DataOutputStream(soc.getOutputStream());
  108. byte[] outBF = result_Str.getBytes("euc-kr");
  109. outstream.write(outBF);
  110. outstream.flush();
  111. Thread.sleep(300);
  112. soc.close();
  113. WallPadiMAPUpgrade.active = true;
  114. } catch (RuntimeException re) {
  115. LogUtil.errorLogInfo("", TAG, re);
  116. WallPadiMAPUpgrade.active = false;
  117. return;
  118. }
  119. catch (Exception e) {
  120. Log.e(TAG, "[Exception] WallPadiMAPUpgrade(Context ctx, Document Docm, Socket soc)");
  121. //e.printStackTrace();
  122. LogUtil.errorLogInfo("", TAG, e);
  123. Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
  124. WallPadiMAPUpgrade.active = false;
  125. return;
  126. }
  127. }
  128. public void StartUpgrade() {
  129. int waittime = 200;
  130. NodeList itemsguide = Docm.getElementsByTagName("guidemap");
  131. Node item = itemsguide.item(0);
  132. active = true;
  133. if (item != null) {
  134. NamedNodeMap attrs = item.getAttributes();
  135. for (int j = 0; j < attrs.getLength(); j++) {
  136. Node attr = attrs.item(j);
  137. if (attr.getNodeName().equalsIgnoreCase("type")) upgradetype = attr.getNodeValue();
  138. else if (attr.getNodeName().equalsIgnoreCase("count")) {
  139. Count = attr.getNodeValue();
  140. int cnt = Integer.parseInt(Count);
  141. imglist = new String[cnt];
  142. imgpath = new String[cnt];
  143. }
  144. else if (attr.getNodeName().equalsIgnoreCase("user")) id = attr.getNodeValue();
  145. else if (attr.getNodeName().equalsIgnoreCase("passwd")) passwd = attr.getNodeValue();
  146. }
  147. }
  148. NodeList itemsImg = Docm.getElementsByTagName("img");
  149. for (int i = 0; i < itemsImg.getLength(); i++) {
  150. Node Img = itemsImg.item(i);
  151. NamedNodeMap attrs = Img.getAttributes();
  152. for (int j = 0; j < attrs.getLength(); j++) {
  153. Node attr = attrs.item(j);
  154. if (attr.getNodeName().equalsIgnoreCase("module")) {
  155. imglist[i] = attr.getNodeValue();
  156. }
  157. else if (attr.getNodeName().equalsIgnoreCase("path")) {
  158. imgpath[i] = attr.getNodeValue();
  159. }
  160. }
  161. }
  162. try { Thread.sleep(waittime);} catch (RuntimeException re) {
  163. LogUtil.errorLogInfo("", TAG, re);
  164. }
  165. catch (Exception e) {
  166. LogUtil.errorLogInfo("", TAG, e);
  167. }
  168. try {
  169. ProposeUpgrade = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"+
  170. "<imap ver = \"1.0\" address = \""+myIP+"\" sender = \""+myDong+"동 "+myHo+"호\">\r\n"+
  171. "<service type = \"request\" name= \"propose_upgrade\" >\r\n"+
  172. "<guidemap type = \"upgrade\" count = \""+imglist.length+"\" value = \"list\">\r\n";
  173. for (int i = 0; i < imglist.length; i++) {
  174. ProposeUpgrade += "<img module = \""+imglist[i]+"\" /> \r\n";
  175. }
  176. ProposeUpgrade += " </guidemap>\r\n</service>\r\n</imap>\r\n";
  177. SocClient = new SendiMAPreq();
  178. SocClient.setContext(ThisCtx);
  179. /*
  180. WallpadStatusData Wsdata = new WallpadStatusData(ThisCtx);
  181. SocClient.SendXMLDoc(Wsdata.GetServerIP(), Wsdata.GetServerPort(), ProposeUpgrade, true);
  182. Wsdata.closeDB();
  183. */
  184. SocClient.SendXMLDoc(ProposeUpgrade, true);
  185. } catch (RuntimeException re) {
  186. LogUtil.errorLogInfo("", TAG, re);
  187. active = false;
  188. return;
  189. }
  190. catch (Exception e) {
  191. Log.e(TAG, "[Exception] StartUpgrade()");
  192. //e.printStackTrace();
  193. LogUtil.errorLogInfo("", TAG, e);
  194. active = false;
  195. return;
  196. }
  197. }
  198. public static final int MAX_UPGRADE_DOWNLOAD_RETRY = -3;
  199. public class SendiMAPreq extends WallPadiMAPClient {
  200. Handler resultProc = new Handler(Looper.getMainLooper()) {
  201. public void handleMessage(Message msg) {
  202. if (msg.what == DOWNLOAD_SUCCESS_MSG) {
  203. DownloadFileInfo finfo = downloadfilelist.get(msg.arg2);
  204. finfo.state = 1;
  205. downloadfilelist.set(msg.arg2, finfo);
  206. }
  207. else if (msg.what == DOWNLOAD_FAIL_MSG) {
  208. if (msg.arg2>=downloadfilelist.size() || downloadfilelist.size()==0) {
  209. active = false;
  210. return;
  211. }
  212. DownloadFileInfo finfo = downloadfilelist.get(msg.arg2);
  213. finfo.state = finfo.state - 1;
  214. downloadfilelist.set(msg.arg2, finfo);
  215. }
  216. else return;
  217. for (int i = 0; i < downloadfilelist.size(); i++) {
  218. Log.w(TAG, "[SendiMAPreq] downloadfilelist.get(" + i + ").filename = " + downloadfilelist.get(i).filename);
  219. }
  220. for (int i = 0; i < downloadfilelist.size(); i++) {
  221. DownloadFileInfo finfo = downloadfilelist.get(i);
  222. if (finfo.state > 0) continue;
  223. else {
  224. if (finfo.state < MAX_UPGRADE_DOWNLOAD_RETRY) {
  225. downloadfilelist.remove(i);
  226. i = 0;
  227. if (downloadfilelist.size() == 0) {
  228. Log.e(TAG,APIErrorCode.GetLogPrefix() + " Return setActive False");
  229. active = false;
  230. return;
  231. }
  232. continue;
  233. }
  234. Log.e(TAG, "[JEFFREY] ========== 1 ==========");
  235. checkMemorySize();
  236. if (startDownloadUpgradeTargetFile(i)) return;
  237. else {
  238. downloadfilelist.remove(i);
  239. i=0;
  240. }
  241. }
  242. }
  243. if (downloadfilelist.size() > 0) {
  244. DownloadFileInfo finfo;
  245. String Updatefilename=null;
  246. String UpdateAppfilename=null;
  247. String UpdateServicefileName = null;
  248. for (int i=0;i<downloadfilelist.size();i++) {
  249. finfo = downloadfilelist.get(i);
  250. if (finfo.type == DownloadFileInfo.TYPE_BSP) {
  251. String[] namelist = finfo.filename.split("/");
  252. Updatefilename = namelist[namelist.length - 1];
  253. String filepath = DownloadLocation + "/" + Updatefilename;
  254. Log.i(TAG, "[SendiMAPreq] filepath [" + filepath + "]");
  255. File check_file = new File(filepath);
  256. Log.i(TAG, "[SendiMAPreq] (TYPE_BSP) check update file size : downloaded file [" + check_file.length() + "], server file [" + finfo.filesize + "]");
  257. if (!check_file.exists() || check_file.length() != finfo.filesize) {
  258. if (check_file.exists()) Log.e(TAG, "UPDATE Check File size : " + check_file.length() + " (" + finfo.filesize + ")");
  259. else Log.e(TAG, "UPDATE Check File FileNotExist : " + filepath);
  260. Updatefilename = null;
  261. }
  262. } else if (finfo.type == DownloadFileInfo.TYPE_APP) {
  263. String[] namelist = finfo.filename.split("/");
  264. UpdateAppfilename = namelist[namelist.length - 1];
  265. String filepath = DownloadLocation + "/" + UpdateAppfilename;
  266. Log.i(TAG, "[SendiMAPreq] filepath [" + filepath + "]");
  267. File check_file = new File(filepath);
  268. Log.i(TAG, "[SendiMAPreq] (TYPE_APP) check update file size : downloaded file [" + check_file.length() + "], server file [" + finfo.filesize + "]");
  269. if (!check_file.exists() || check_file.length() != finfo.filesize) {
  270. if (check_file.exists()) Log.e(TAG, "UPDATE Check File size : " + check_file.length() + " (" + finfo.filesize + ")");
  271. else Log.e(TAG, "UPDATE Check File FileNotExist : " + filepath);
  272. UpdateAppfilename = null;
  273. }
  274. } else if (finfo.type == DownloadFileInfo.TYPE_IMG) {
  275. active = false;
  276. ProposeUpgrade = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
  277. "<imap ver = \"1.0\" address = \"" + myIP + "\" sender = \"" + myDong + "동 " + myHo + "호\">\r\n" +
  278. "<service type = \"request\" name= \"event_notify\">\r\n" +
  279. " <event> \"epic_completed\" </event>\r\n" +
  280. "</service>\r\n</imap>\r\n";
  281. WallPadiMAPClient notis = new WallPadiMAPClient();
  282. notis.setContext(ThisCtx);
  283. WallpadStatusData Wsdata = new WallpadStatusData(ThisCtx);
  284. notis.SendXMLDoc(Wsdata.GetServerIP(), Wsdata.GetServerPort(), ProposeUpgrade, true);
  285. Wsdata.closeDB();
  286. } else if (finfo.type == DownloadFileInfo.TYPE_SVR) {
  287. Log.i(TAG, "Service upgrade file download =============> %%");
  288. // String[] namelist = finfo.filename.split("/");
  289. // UpdateServicefileName = namelist[namelist.length-1];
  290. // String filepath = SVRDownloadLocation+"/"+UpdateServicefileName;
  291. // File check_file = new File(filepath);
  292. // if (!check_file.exists() || check_file.length() != finfo.filesize)
  293. // {
  294. // if (check_file.exists()) Log.e("HIGH", "UPDATE Check File size : "+check_file.length()+" ("+finfo.filesize+")");
  295. // else Log.e("HIGH", "UPDATE Check File FileNotExist : "+filepath);
  296. // UpdateServicefileName = null;
  297. // }
  298. // else
  299. // {
  300. // // 서비스 파일이 다운로드가 완료되면 압축을 해제 하도록 한다.
  301. // }
  302. }
  303. }
  304. if (Updatefilename != null || UpdateAppfilename != null ) {
  305. if (Updatefilename == null) Updatefilename = "no";
  306. if (UpdateAppfilename == null) UpdateAppfilename = "no";
  307. //String SetPP = System.setProperty("persist.sys.update.ready", "1");
  308. // Log.e(TAG,APIErrorCode.GetLogPrefix()+" Before Call PowerManager ");
  309. // PowerManager pm = (PowerManager) ThisCtx.getSystemService(Context.POWER_SERVICE);
  310. // Log.d(TAG,APIErrorCode.GetLogPrefix()+" Create PowerManager "+pm.toString());
  311. // pm.userActivity(0, true);
  312. // Log.i(TAG,APIErrorCode.GetLogPrefix()+" after Call pm.userActivity ");
  313. //WallPadUpgradeLog("Set property ret "+SetPP);
  314. Log.w(TAG, "[SendiMAPreq] Updatefilename [" + Updatefilename+ "], UpdateAppfilename [" + UpdateAppfilename + "]");
  315. WallpadStatusData Wsdata = new WallpadStatusData(ThisCtx);
  316. Wsdata.SetSystemUpdate(Updatefilename, UpdateAppfilename);
  317. Wsdata.closeDB();
  318. V40IOInterface mV40IOInterface = new V40IOInterface();
  319. mV40IOInterface.WpdInterfaceOpen();
  320. mV40IOInterface.LiveUpdate();
  321. mV40IOInterface.WpdInterfaceClose();
  322. active = true;
  323. }
  324. else {
  325. active = false;
  326. }
  327. return;
  328. }
  329. else {
  330. Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
  331. active = false;
  332. return;
  333. }
  334. }
  335. };
  336. protected void ProcComplite() {
  337. int item_cnt = SocClient.SetItem("service");
  338. String type;
  339. String fname;
  340. int fsize;
  341. DownloadFileInfo finfo;
  342. active = true;
  343. if (item_cnt > 0) {
  344. if (SocClient.GetAttributeVal(0, "result").equals("ok")) {
  345. item_cnt = SocClient.SetItem("guidemap");
  346. if (item_cnt > 0) {
  347. for (int i = 0; i < item_cnt; i++) {
  348. type = SocClient.GetAttributeVal(i, "type");
  349. fname = SocClient.GetAttributeVal(i, "fname");
  350. for (int j = 0; j < imgpath.length; j++) {
  351. String[] namelist = imgpath[j].split("/");
  352. if (fname.equals(namelist[namelist.length-1])) {
  353. fsize = Integer.parseInt(SocClient.GetAttributeVal(i, "fsize"));
  354. //int typeID = (type.equalsIgnoreCase("bsp")?DownloadFileInfo.TYPE_BSP:type.equalsIgnoreCase("app")?DownloadFileInfo.TYPE_APP:type.equalsIgnoreCase("epic")?DownloadFileInfo.TYPE_IMG:0);
  355. int typeID;
  356. if (type.equalsIgnoreCase("bsp") == true) {
  357. typeID = DownloadFileInfo.TYPE_BSP;
  358. }
  359. else if(type.equalsIgnoreCase("app") == true) {
  360. typeID = DownloadFileInfo.TYPE_APP;
  361. }
  362. else if(type.equalsIgnoreCase("additional") == true) {
  363. typeID = DownloadFileInfo.TYPE_SVR;
  364. }
  365. else if(type.equalsIgnoreCase("epic") == true) {
  366. typeID = DownloadFileInfo.TYPE_IMG;
  367. }
  368. else {
  369. typeID = 0;
  370. }
  371. finfo = new DownloadFileInfo(imgpath[j], fsize, typeID);
  372. downloadfilelist.add(finfo);
  373. break;
  374. }
  375. }
  376. }
  377. }
  378. if (downloadfilelist.size() > 0) {
  379. Log.e(TAG, "[JEFFREY] ========== 2 ==========");
  380. checkMemorySize();
  381. cleanSDRoot();
  382. checkMemorySize();
  383. for (int i = 0; i < downloadfilelist.size(); i++) {
  384. if (startDownloadUpgradeTargetFile(i)) return;
  385. else {
  386. downloadfilelist.remove(i);
  387. i=0;
  388. }
  389. }
  390. Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
  391. active = false;
  392. return;
  393. }
  394. else {
  395. Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
  396. active = false;
  397. return;
  398. }
  399. }
  400. else {
  401. Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
  402. active = false;
  403. return;
  404. }
  405. }
  406. else {
  407. Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
  408. active = false;
  409. }
  410. }
  411. protected boolean startDownloadUpgradeTargetFile(int seqnum) {
  412. if (seqnum >= downloadfilelist.size()) return false;
  413. DownloadFileInfo finfo = downloadfilelist.get(seqnum);
  414. String[] namelist = finfo.filename.split("/");
  415. if (checkDownloadFilename(namelist[namelist.length-1], finfo.type ) == false) {
  416. Log.e(TAG,APIErrorCode.GetLogPrefix()+"Start Download Check FileName is false return false");
  417. return false;
  418. }
  419. String strTargetFile = null;
  420. if (finfo.type == DownloadFileInfo.TYPE_BSP) strTargetFile = DownloadLocation + "/" + namelist[namelist.length-1];
  421. else if (finfo.type == DownloadFileInfo.TYPE_APP) strTargetFile = APPDownloadLocation + "/" + namelist[namelist.length-1];
  422. else if (finfo.type == DownloadFileInfo.TYPE_IMG) strTargetFile = EPICDownloadLocation + "/" + namelist[namelist.length-1];
  423. else if (finfo.type == DownloadFileInfo.TYPE_SVR) strTargetFile = SVRDownloadLocation + "/" + namelist[namelist.length-1];
  424. else return false;
  425. //Log.e(TAG, "startDownloadUpgradeTargetFile 1");
  426. File TargetFile = new File(strTargetFile);
  427. Log.i(TAG, "[startDownloadUpgradeTargetFile] strTargetFile [" + strTargetFile + "], TargetFile.length() [" + TargetFile.length() +"], finfo.filesize [" + finfo.filesize +"]");
  428. if (TargetFile.exists() && TargetFile.length() == finfo.filesize) {
  429. Message msg = resultProc.obtainMessage();
  430. msg.what = DOWNLOAD_SUCCESS_MSG;
  431. msg.arg1 = 1;
  432. msg.arg2 = seqnum;
  433. msg.obj = strTargetFile;
  434. resultProc.sendMessage(msg);
  435. return true;
  436. }
  437. Log.i(TAG, "[startDownloadUpgradeTargetFile] ftp_FileDownload will be started finfo.filename [" + finfo.filename + "]");
  438. filedownloader = new ftp_FileDownload(resultProc, finfo.filename, seqnum, strTargetFile);
  439. filedownloader.start();
  440. return true;
  441. }
  442. protected void ProcError() {
  443. Log.e(TAG,APIErrorCode.GetLogPrefix()+" Return setActive False");
  444. WallPadiMAPUpgrade.active = false;
  445. return;
  446. }
  447. }
  448. public static final String BSP_FILE_ID = "BSP";
  449. public static final String APP_FILE_ID = "APP";
  450. public static final String DEV_TCC8935_ARCH_ID = "8935";
  451. public static final String DEV_A20_ARCH_ID = "A20";
  452. public static final String DEV_V40_ARCH_ID = "V40"; // V40 플랫폼
  453. public static final String DEV_A40i_ARCH_ID = "A40i"; // A40i 플랫폼
  454. public static final String SA_DEV_ID = "IHN1020B-A"; // 일반 대외향
  455. public static final String SA_A20_DEV_ID = "IHN1030-D"; // 다담 일반 대외향
  456. public static final String SA_A20_DEV_ID_NEW = "IHN1030-A2"; // 다담 일반 대외향 - 신규 모델명
  457. public static final String SA_A20_C_DEV_ID = "IHN1020B-C"; // 다담 일반 대외향
  458. public static final String SA_A20_C_DEV_ID_NEW = "IHN1020B-A2"; // 다담 일반 대외향 - 신규 모델명
  459. public static final String LH_DEV_ID = "IHN1020SA-A"; // LH 향
  460. public static final String GLE_DEV_ID = "IHN1020GL"; // 현산향
  461. public static final String IHN_750_ID = "IHN750";
  462. public static final String IHN_750S_ID = "IHN750S";
  463. public static final String IHN_D101_ID = "IHND101"; // 조그월패드
  464. public static final String IHN_D101K_ID = "IHND101K"; // 카카오 조그월패드
  465. public static final String IHN_1010_ID = "IHN1010"; // 대외향 월패드
  466. public static final String IHN_1010GL_ID = "IHN1010GL"; // 연합사업지용 월패드
  467. public static final String IHN_T1010_ID = "IHNT1010"; // 힘찬건설향 월패드
  468. public static final String IHN_HS101_ID = "IHNHS101"; // 효성건설향 월패드
  469. public static final String IHN_1040_ID = "IHN1040"; // 보급형(엔트리급) 월패드
  470. public static final String IHN_1050_ID = "IHN1050"; // 대우건설향 월패드
  471. public static final String IHN_D101_I_ID = "IHND101-I"; // 조그월패드 (중국생산)
  472. public static final String IHN_D101_I_LX2_ID = "IHND101-I-LX2"; // 조그월패드 (중국생산)
  473. public static final String IHN_D101K_I_ID = "IHND101K-I"; // 카카오 조그월패드 (중국생산)
  474. public static final String IHN_D101_I_OCF_ID = "IHND101-I-OCF"; // 조그월패드 (OCF 월패드, 중국생산)
  475. public static final String IHN_1010_I_ID = "IHN1010-I"; // 대외향 월패드 (중국생산)
  476. public static final String IHN_1010_I_LX2_ID = "IHN1010-I-LX2"; // 대외향 월패드 고급주택(중국생산)
  477. public static final String IHN_1010GL_I_ID = "IHN1010GL-I"; // 연합사업지용 월패드 (중국생산)
  478. public static final String IHN_1010GL_I_2443_ID = "IHN1010GL-I-2443"; // 현산향 2443 대체품 월패드 (중국생산)
  479. public static final String IHN_1010GL_I_6410_ID = "IHN1010GL-I-6410"; // 현산향 6410 대체품 월패드 (중국생산)
  480. public static final String IHN_T1010_I_ID = "IHNT1010-I"; // 힘찬건설향 월패드 (중국생산)
  481. public static final String IHN_HS101_I_ID = "IHNHS101-I"; // 효성건설향 월패드 (중국생산)
  482. public static final String IHN_1030_I_ID = "IHN1030-I"; // 보급형(엔트리급) 월패드 (중국생산)
  483. public static final String IHN_1040_I_ID = "IHN1040-I"; // 보급형(엔트리급) 월패드 (중국생산)
  484. public static final String IHN_1050_I_ID = "IHN1050-I"; // 대우건설향 월패드 (중국생산)
  485. public static final String IHN_DW101_I_ID = "IHNDW101-I"; // 신형 대우건설향 월패드 (중국생산)
  486. public static final String IHN_1020B_I_ID = "IHN1020B-I"; // IHN-1020B-A2 대체용 월패드 (중국생산)
  487. public static final String IHN_1303_I_ID = "IHN1303-I"; // 13.3인치 월패드 (중국생산)
  488. private boolean checkDownloadFilename(String filename, int type) {
  489. try {
  490. String[] astrFileName = filename.split("_");
  491. if (astrFileName != null) {
  492. for (int i = 0; i < astrFileName.length; i++) {
  493. Log.d( TAG , "[checkDownloadFilename] astrFileName[" + i + "] = " + astrFileName[i] );
  494. }
  495. }
  496. if (filename != null) Log.d( TAG , "[checkDownloadFilename] filename [" + filename + "], type [" + type + "]");
  497. else Log.d( TAG , "[checkDownloadFilename] filename [null] , type [" + type + "]");
  498. if (type == DownloadFileInfo.TYPE_BSP || type == DownloadFileInfo.TYPE_APP) {
  499. // check update option
  500. if (!checkUpdateOption(astrFileName[2])) {
  501. Log.w( TAG , "[checkDownloadFilename] Update option is not correct!!! astrFileName[2] : [" + astrFileName[2] + "]");
  502. return false;
  503. }
  504. // check & change update module name, if the module name contains "#". ("#" means it has update option)
  505. astrFileName[2] = changeUpdateModuleName(astrFileName[2]);
  506. if (type == DownloadFileInfo.TYPE_BSP && !astrFileName[0].equals(BSP_FILE_ID)) {
  507. Log.w( TAG , "[checkDownloadFilename] Filetype is not correct!! astrFileName[0] : [" + astrFileName[0] + "], type + [" + type + "]");
  508. return false;
  509. }
  510. if (type == DownloadFileInfo.TYPE_APP && !astrFileName[0].equals(APP_FILE_ID)) {
  511. Log.w( TAG , "[checkDownloadFilename] Filetype is not correct!! astrFileName[0] : [" + astrFileName[0] + "], type + [" + type + "]");
  512. return false;
  513. }
  514. if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101) {
  515. // V40 플랫폼 업그레이드
  516. 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)) {
  517. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  518. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  519. return false;
  520. }
  521. }
  522. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I) {
  523. // V40 플랫폼 업그레이드
  524. 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)) {
  525. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  526. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  527. return false;
  528. }
  529. }
  530. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2) {
  531. // V40 플랫폼 업그레이드
  532. if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_D101_I_LX2_ID) || (astrFileName[3].length() != 14)) {
  533. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  534. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  535. return false;
  536. }
  537. }
  538. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101K) {
  539. // V40 플랫폼 업그레이드
  540. 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)) {
  541. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  542. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  543. return false;
  544. }
  545. }
  546. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I) {
  547. // V40 플랫폼 업그레이드
  548. 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)) {
  549. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  550. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  551. return false;
  552. }
  553. }
  554. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF) {
  555. // V40 플랫폼 업그레이드
  556. 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)) {
  557. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  558. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  559. return false;
  560. }
  561. }
  562. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010) {
  563. // V40 플랫폼 업그레이드
  564. 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)) {
  565. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  566. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  567. return false;
  568. }
  569. }
  570. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010_I) {
  571. // V40 플랫폼 업그레이드
  572. 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)) {
  573. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  574. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  575. return false;
  576. }
  577. }
  578. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010_I_LX2) {
  579. // V40 플랫폼 업그레이드
  580. if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_1010_I_LX2_ID) || (astrFileName[3].length() != 14)) {
  581. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  582. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  583. return false;
  584. }
  585. }
  586. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL) {
  587. // V40 플랫폼 업그레이드
  588. 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)) {
  589. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  590. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  591. return false;
  592. }
  593. }
  594. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I) {
  595. // V40 플랫폼 업그레이드
  596. 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)) {
  597. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  598. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  599. return false;
  600. }
  601. }
  602. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443) {
  603. // V40 플랫폼 업그레이드
  604. 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)) {
  605. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  606. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  607. return false;
  608. }
  609. }
  610. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
  611. // V40 플랫폼 업그레이드
  612. 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)) {
  613. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  614. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  615. return false;
  616. }
  617. }
  618. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1030_I) {
  619. // V40 플랫폼 업그레이드
  620. 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)) {
  621. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  622. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  623. return false;
  624. }
  625. }
  626. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1040) {
  627. // V40 플랫폼 업그레이드
  628. 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)) {
  629. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  630. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  631. return false;
  632. }
  633. }
  634. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1040_I) {
  635. // V40 플랫폼 업그레이드
  636. 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)) {
  637. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  638. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  639. return false;
  640. }
  641. }
  642. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1050) {
  643. // V40 플랫폼 업그레이드
  644. 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)) {
  645. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  646. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  647. return false;
  648. }
  649. }
  650. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1050_I) {
  651. // V40 플랫폼 업그레이드
  652. 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)) {
  653. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  654. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  655. return false;
  656. }
  657. }
  658. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_T1010) {
  659. // V40 플랫폼 업그레이드
  660. 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)) {
  661. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  662. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  663. return false;
  664. }
  665. }
  666. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_T1010_I) {
  667. // V40 플랫폼 업그레이드
  668. 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)) {
  669. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  670. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  671. return false;
  672. }
  673. }
  674. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_HS101) {
  675. // V40 플랫폼 업그레이드
  676. 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)) {
  677. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  678. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  679. return false;
  680. }
  681. }
  682. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_HS101_I) {
  683. // V40 플랫폼 업그레이드
  684. 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)) {
  685. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  686. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  687. return false;
  688. }
  689. }
  690. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_DW101_I) {
  691. // V40 플랫폼 업그레이드
  692. if (!(astrFileName[1].equals(DEV_V40_ARCH_ID) || astrFileName[1].equals(DEV_A40i_ARCH_ID)) || !astrFileName[2].equals(IHN_DW101_I_ID) || (astrFileName[3].length() != 14)) {
  693. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  694. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  695. return false;
  696. }
  697. }
  698. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_I) {
  699. // V40 플랫폼 업그레이드
  700. 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)) {
  701. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  702. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  703. return false;
  704. }
  705. }
  706. else if(Version.getModelType() == Version.MODEL_TYPE.IHN_1303_I) {
  707. // V40 플랫폼 업그레이드
  708. 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)) {
  709. Log.d( TAG , "[checkDownloadFilename] astrFileName[1] : + " + astrFileName[1] + ", DEV_V40_ARCH_ID :" + DEV_V40_ARCH_ID);
  710. Log.d( TAG , "[checkDownloadFilename] astrFileName[3].length() : + " + astrFileName[3].length());
  711. return false;
  712. }
  713. }
  714. else {
  715. Log.d(TAG, "[checkDownloadFilename] model : " + Version.getModelType() + " , Build.MODEL :" + Build.MODEL );
  716. return false;
  717. }
  718. }
  719. else if (type == DownloadFileInfo.TYPE_IMG) return true;
  720. return true;
  721. } catch (RuntimeException re) {
  722. LogUtil.errorLogInfo("", TAG, re);
  723. return false;
  724. }
  725. catch (Exception e) {
  726. Log.e(TAG, "[Exception] checkDownloadFilename(String filename, int type)");
  727. //e.printStackTrace();
  728. LogUtil.errorLogInfo("", TAG, e);
  729. return false;
  730. }
  731. }
  732. /**
  733. * 플랫폼 ID에 업데이트 가능한 App 버전 존재 유무 확인
  734. * @param strValue - 다운로드할 파일의 모델명 (예. IHND101-I#APP#2020101501)
  735. * @return true: 업데이트 가능, false: 업데이트 불가
  736. */
  737. private boolean checkUpdateOption(String strValue) {
  738. if(strValue!=null)
  739. {
  740. try {
  741. Log.i(TAG, "[checkUpdateOption] strValue [" + strValue + "]");
  742. if (strValue.contains("#")) {
  743. String[] strParsed = strValue.split("#");
  744. String strModuleType = strParsed[1];
  745. String strVer = strParsed[2];
  746. // Log.i(TAG, "[checkUpdateOption] strModuleType [" + strModuleType + "], strVer [" + strVer + "]");
  747. return checkUpdatableModuleVer(strModuleType, strVer);
  748. }
  749. else return true;
  750. } catch (RuntimeException re) {
  751. LogUtil.errorLogInfo("", TAG, re);
  752. return false;
  753. }
  754. catch (Exception e) {
  755. Log.e(TAG, "[Exception] checkUpdateOption(String strValue)");
  756. //e.printStackTrace();
  757. LogUtil.errorLogInfo("", TAG, e);
  758. return false;
  759. }
  760. }
  761. else return false;
  762. }
  763. private boolean checkUpdatableModuleVer(String strModule, String strVer) {
  764. try {
  765. Log.i(TAG, "[checkUpdatableModuleVer] strModuleType [" + strModule + "], strVer [" + strVer + "]");
  766. if (strModule.equalsIgnoreCase(BSP_FILE_ID)) {
  767. int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
  768. int nMinVer = Integer.parseInt(strVer);
  769. Log.i(TAG, "[checkUpdatableModuleVer] BSP Ver. check -> nCurrentVer [" + nCurrentVer + "], nMinVer [" + nMinVer + "]");
  770. if (nCurrentVer >= nMinVer) {
  771. Log.w(TAG, "[checkUpdatableModuleVer] BSP update OK!! Current Ver. is bigger than minimum Ver!!");
  772. return true;
  773. }
  774. else {
  775. Log.w(TAG, "[checkUpdatableModuleVer] BSP update FAIL!! Current Ver. is smaller than minimum Ver!!");
  776. return false;
  777. }
  778. }
  779. else if (strModule.equalsIgnoreCase(APP_FILE_ID)) {
  780. int nCurrentVer = Integer.parseInt(getAppVersion().replace(".", ""));
  781. int nMinVer = Integer.parseInt(strVer);
  782. Log.i(TAG, "[checkUpdatableModuleVer] APP Ver. check -> nCurrentVer [" + nCurrentVer + "], nMinVer [" + nMinVer + "]");
  783. if (nCurrentVer >= nMinVer) {
  784. Log.w(TAG, "[checkUpdatableModuleVer] APP update OK!! Current Ver. is bigger than minimum Ver!!");
  785. return true;
  786. }
  787. else {
  788. Log.w(TAG, "[checkUpdatableModuleVer] APP update FAIL!! Current Ver. is smaller than minimum Ver!!");
  789. return false;
  790. }
  791. }
  792. else return false;
  793. } catch (RuntimeException re) {
  794. LogUtil.errorLogInfo("", TAG, re);
  795. return false;
  796. }
  797. catch (Exception e) {
  798. Log.e(TAG, "[Exception] checkUpdatableModuleVer(String strModule, String strVer)");
  799. //e.printStackTrace();
  800. LogUtil.errorLogInfo("", TAG, e);
  801. return false;
  802. }
  803. }
  804. private String changeUpdateModuleName(String strValue) {
  805. String strResult = "";
  806. if(strValue!=null)
  807. {
  808. try {
  809. Log.i(TAG, "[changeUpdateModuleName] strValue [" + strValue + "]");
  810. if (strValue.contains("#")) {
  811. String[] strParsed = strValue.split("#");
  812. strResult = strParsed[0];
  813. }
  814. else strResult = strValue;
  815. } catch (RuntimeException re) {
  816. LogUtil.errorLogInfo("", TAG, re);
  817. strResult = "Exception";
  818. }
  819. catch (Exception e) {
  820. Log.e(TAG, "[Exception] changeUpdateModuleName(String strValue)");
  821. //e.printStackTrace();
  822. LogUtil.errorLogInfo("", TAG, e);
  823. strResult = "Exception";
  824. }
  825. Log.i(TAG, "[changeUpdateModuleName] strResult [" + strResult + "]");
  826. }
  827. return strResult;
  828. }
  829. public String getAppVersion() {
  830. PackageInfo mPackageInfo = null;
  831. try {
  832. mPackageInfo = ThisCtx.getPackageManager().getPackageInfo(ThisCtx.getPackageName(), 0);
  833. }
  834. catch (RuntimeException re) {
  835. LogUtil.errorLogInfo("", TAG, re);
  836. }
  837. catch (Exception e) {
  838. Log.e(TAG, "[Exception] getAppVersion()");
  839. //e.printStackTrace();
  840. LogUtil.errorLogInfo("", TAG, e);
  841. }
  842. return mPackageInfo.versionName;
  843. }
  844. class ftp_FileDownloadWatcher extends Thread {
  845. String DownloadFile;
  846. long oldsize = 0;
  847. long size;
  848. Handler ExitHandle;
  849. File ProcF;
  850. int seqnum;
  851. public boolean onoff = false;
  852. public ftp_FileDownloadWatcher(String DownLoadFile, long size, Handler handle, int snum) {
  853. this.size = size;
  854. ExitHandle = handle;
  855. DownloadFile = DownLoadFile;
  856. seqnum = snum;
  857. }
  858. public void run() {
  859. long cursize;
  860. onoff = true;
  861. while (onoff) {
  862. try{Thread.sleep(1000);}
  863. catch (RuntimeException re) {
  864. LogUtil.errorLogInfo("", TAG, re);
  865. }
  866. catch (Exception e) {
  867. LogUtil.errorLogInfo("", TAG, e);
  868. }
  869. Log.e(TAG, "ftp_FileDownloadWatcher start!");
  870. if (ProcF == null) ProcF = new File(DownloadFile);
  871. if (!ProcF.exists()) return;
  872. cursize = ProcF.length();
  873. if (oldsize != cursize) oldsize = cursize;
  874. else {
  875. if (cursize >= size) return;
  876. if (filedownloader.isAlive()) filedownloader.interrupt();
  877. if (onoff != true) return;
  878. Message msg = ExitHandle.obtainMessage();
  879. msg.what = DOWNLOAD_FAIL_MSG;
  880. msg.arg1 = 0;
  881. msg.arg2 = seqnum;
  882. ExitHandle.sendMessage(msg);
  883. return;
  884. }
  885. }
  886. }
  887. }
  888. class ftp_FileDownload extends Thread {
  889. String ftpPATH;
  890. Handler handle;
  891. int Index;
  892. FTPClient f;
  893. //ftp_FileDownloadWatcher WatchThread;
  894. String localFile;
  895. boolean CompleteFlag = true; //event_notify 계속보내는 버그로 인하여 추가함
  896. public ftp_FileDownload(Handler handle, String path, int idx, String LocalFileName) {
  897. ftpPATH = path;
  898. Index = idx;
  899. this.handle = handle;
  900. //WatchThread = wat;
  901. localFile = LocalFileName;
  902. }
  903. public void run() {
  904. Log.e(TAG, "[ftp_FileDownload.run()] ftp_FileDownload start! " + ftpPATH + "]");
  905. f = new FTPClient();
  906. f.setControlEncoding("euc-kr"); //한글이름의 파일은 FTP 다운로드가 안되기 때문에 인코딩 추가로 넣어줌
  907. f.setReceieveDataSocketBufferSize(1024*512);
  908. try {
  909. f.setReceiveBufferSize(1024*512);
  910. } catch (SocketException e1) {
  911. //e1.printStackTrace();
  912. LogUtil.errorLogInfo("", TAG, e1);
  913. //RetryHandler.sendEmptyMessageDelayed(0, retryDelay);
  914. ProcDownFail();
  915. return;
  916. }
  917. int recebf = f.getReceiveDataSocketBufferSize();
  918. FileOutputStream fos = null;
  919. BufferedOutputStream ffos = null;
  920. try {
  921. WallpadStatusData Wsdata = new WallpadStatusData(ThisCtx);
  922. FTPServer = Wsdata.GetFTPIP();
  923. Wsdata.closeDB();
  924. f.connect(FTPServer);
  925. boolean ret = false;
  926. for(int i =0; i< 1; i++)
  927. ret = f.login(id, passwd);
  928. if (ret == false) {
  929. ProcDownFail();
  930. }
  931. String[] namelist = ftpPATH.split("/");
  932. String path = "";
  933. if (namelist.length > 2) {
  934. for (int i = 1; i < namelist.length - 1; i++) {
  935. path += "/"+namelist[i];
  936. }
  937. }
  938. Log.i(TAG, "[ftp_FileDownload] path [" + path+ "], localFile [" + localFile+ "]");
  939. ret = f.changeWorkingDirectory(path);
  940. if (ret == false) {
  941. ProcDownFail();
  942. }
  943. ret = f.setFileType(FTP.BINARY_FILE_TYPE);
  944. if (ret == false) {
  945. ProcDownFail();
  946. }
  947. File downloadfile = new File(localFile);
  948. if (downloadfile.exists()) FileDelete(downloadfile);//.delete();
  949. fos = new FileOutputStream(downloadfile);
  950. ffos = new BufferedOutputStream(fos);
  951. path = ftpPATH;
  952. boolean result;
  953. result = f.retrieveFile(path, ffos);
  954. ffos.flush();
  955. if (result == false) {
  956. ProcDownFail();
  957. }
  958. if (handle == null) Log.i(TAG, "[ftp_FileDownload.run()] handle is null!!");
  959. else Log.i(TAG, "[ftp_FileDownload.run()] handle is not null!!");
  960. Log.i(TAG, "[ftp_FileDownload.run()] CompleteFlag [" + CompleteFlag+ "]");
  961. if ((handle != null) && (CompleteFlag == true)) {
  962. // event_notify 계속보내는 버그로 인하여 추가함
  963. Message msg = handle.obtainMessage();
  964. msg.what = DOWNLOAD_SUCCESS_MSG;
  965. msg.arg1 = (result) ? 1 : 0;
  966. msg.arg2 = Index;
  967. msg.obj = localFile;
  968. handle.sendMessage(msg);
  969. }
  970. //WatchThread.onoff = false;
  971. } catch (RuntimeException re) {
  972. LogUtil.errorLogInfo("", TAG, re);
  973. ProcDownFail();
  974. }
  975. catch (Exception e) {
  976. Log.e(TAG, "[Exception] ftp_FileDownload.run() 1");
  977. //e.printStackTrace();
  978. LogUtil.errorLogInfo("", TAG, e);
  979. ProcDownFail();
  980. }
  981. finally {
  982. if(fos!=null) {
  983. try {
  984. fos.close();
  985. } catch (IOException e) {
  986. LogUtil.errorLogInfo("", TAG, e);
  987. }
  988. }
  989. fos = null;
  990. if(ffos!=null) {
  991. try {
  992. ffos.close();
  993. } catch (IOException e) {
  994. LogUtil.errorLogInfo("", TAG, e);
  995. }
  996. ffos = null;
  997. }
  998. }
  999. try{
  1000. f.quit();
  1001. } catch (RuntimeException re) {
  1002. LogUtil.errorLogInfo("", TAG, re);
  1003. }
  1004. catch (Exception e) {
  1005. Log.e(TAG, "[Exception] ftp_FileDownload.run() 2");
  1006. //e.printStackTrace();
  1007. LogUtil.errorLogInfo("", TAG, e);
  1008. }
  1009. }
  1010. private void ProcDownFail() {
  1011. try {
  1012. Log.w(TAG, "[ProcDownFail] ========== Download failed ==========");
  1013. CompleteFlag = false; //event_notify 계속보내는 버그로 인하여 추가함
  1014. f.logout();
  1015. f.quit();
  1016. } catch (RuntimeException re) {
  1017. LogUtil.errorLogInfo("", TAG, re);
  1018. }
  1019. catch (Exception e) {
  1020. //e.printStackTrace();
  1021. LogUtil.errorLogInfo("", TAG, e);
  1022. }
  1023. //WatchThread.onoff = false;
  1024. Message msg = handle.obtainMessage();
  1025. msg.what = DOWNLOAD_FAIL_MSG;
  1026. msg.arg1 = 0;
  1027. msg.arg2 = Index;
  1028. msg.obj = ftpPATH;
  1029. handle.sendMessage(msg);
  1030. }
  1031. }
  1032. public boolean parseXML(String XMLDOC) {
  1033. return true;
  1034. }
  1035. static String PATH_LOCAL_ROOT = "/sdcard/";
  1036. public static String[] strUpgradeFileKeyword_ALL = { "_V40_", "_A40i_" };
  1037. public static String strUpgradeFileExtention = "zip";
  1038. public boolean cleanSDRoot() {
  1039. try {
  1040. Log.i(TAG, "[cleanSDRoot] =====START =====");
  1041. for (int i = 0; i < strUpgradeFileKeyword_ALL.length; i++) {
  1042. String[] DeleteFile = findDirectoryFiles(PATH_LOCAL_ROOT, strUpgradeFileKeyword_ALL[i], strUpgradeFileExtention);
  1043. if(DeleteFile!=null)
  1044. {
  1045. Log.i(TAG, "[cleanSDRoot] DeleteFile.length = " + DeleteFile.length);
  1046. File TargetFile;
  1047. for (int j = 0; j < DeleteFile.length; j++) {
  1048. TargetFile = new File(PATH_LOCAL_ROOT + DeleteFile[j]);
  1049. if (TargetFile.delete()) {
  1050. Log.i(TAG, "[cleanSDRoot] Success to delete!! TargetFile = " + TargetFile.getName());
  1051. }
  1052. else {
  1053. Log.i(TAG, "[cleanSDRoot] Fail to delete!! TargetFile = " + TargetFile.getName());
  1054. }
  1055. }
  1056. }
  1057. }
  1058. return true;
  1059. } catch (RuntimeException re) {
  1060. LogUtil.errorLogInfo("", TAG, re);
  1061. return false;
  1062. }
  1063. catch (Exception e) {
  1064. Log.e(TAG, "[Exception] cleanSDRoot()");
  1065. //e.printStackTrace();
  1066. LogUtil.errorLogInfo("", TAG, e);
  1067. return false;
  1068. }
  1069. }
  1070. public String[] findDirectoryFiles(String strDstDir, final String strKeyword, final String strExtention) {
  1071. try {
  1072. Log.i(TAG, "[findDirectoryFiles] strDstDir [" + strDstDir + "], strKeyword [" + strKeyword + "], strExtention [" + strExtention + "]");
  1073. String[] strResult = null;
  1074. if (strDstDir == null) return null;
  1075. File Directory = new File(strDstDir);
  1076. if (Directory.exists()) {
  1077. FilenameFilter mFilenameFilter = new FilenameFilter() {
  1078. @Override
  1079. public boolean accept(File dir, String filename) {
  1080. if (strKeyword != null && strExtention != null) {
  1081. return (filename.endsWith(strExtention) && filename.matches(".*" + strKeyword + ".*"));
  1082. }
  1083. else if (strKeyword != null && strExtention == null) {
  1084. return filename.matches(".*" + strKeyword + ".*");
  1085. }
  1086. else if (strKeyword == null && strExtention != null) {
  1087. return filename.endsWith(strExtention);
  1088. }
  1089. else if (strKeyword == null && strExtention == null) {
  1090. return true;
  1091. }
  1092. return false;
  1093. }
  1094. };
  1095. String[] mFiles = Directory.list(mFilenameFilter);
  1096. if(mFiles!=null)
  1097. {
  1098. Log.i(TAG, "[findDirectoryFiles] mFiles.length = " + mFiles.length);
  1099. strResult = new String[mFiles.length];
  1100. for (int i = 0; i < strResult.length; i++) {
  1101. strResult[i] = mFiles[i];
  1102. Log.i(TAG, "[findDirectoryFiles] strResult[" + i + "] = " + strResult[i]);
  1103. }
  1104. }
  1105. return strResult;
  1106. }
  1107. else {
  1108. Log.i(TAG, "[findDirectoryFiles] Directory is not exist!! [" + strDstDir + "]");
  1109. return null;
  1110. }
  1111. } catch (RuntimeException re) {
  1112. LogUtil.errorLogInfo("", TAG, re);
  1113. return null;
  1114. }
  1115. catch (Exception e) {
  1116. Log.e(TAG, "[Exception] findDirectoryFiles()");
  1117. //e.printStackTrace();
  1118. LogUtil.errorLogInfo("", TAG, e);
  1119. return null;
  1120. }
  1121. }
  1122. public void checkMemorySize() {
  1123. try {
  1124. String strInternalTotalMemorySize = formatSize(getTotalInternalMemorySize());
  1125. String strAvailableInternalMemorySize = formatSize(getAvailableInternalMemorySize());
  1126. String strExternalTotalMemorySize = formatSize(getTotalExternalMemorySize());
  1127. String strAvailableExternalMemorySize = formatSize(getAvailableExternalMemorySize());
  1128. Log.i(TAG, "[checkMemorySize] strInternalTotalMemorySize [" + strInternalTotalMemorySize + "], strAvailableInternalMemorySize [" + strAvailableInternalMemorySize + "]");
  1129. Log.i(TAG, "[checkMemorySize] strExternalTotalMemorySize [" + strExternalTotalMemorySize + "], strAvailableExternalMemorySize [" + strAvailableExternalMemorySize + "]");
  1130. } catch (RuntimeException re) {
  1131. LogUtil.errorLogInfo("", TAG, re);
  1132. }
  1133. catch (Exception e) {
  1134. Log.e(TAG, "[Exception] checkMemorySize()");
  1135. //e.printStackTrace();
  1136. LogUtil.errorLogInfo("", TAG, e);
  1137. }
  1138. }
  1139. /** 전체 내장 메모리 크기를 가져온다 */
  1140. private long getTotalInternalMemorySize() {
  1141. try {
  1142. File path = Environment.getDataDirectory();
  1143. StatFs stat = new StatFs(path.getPath());
  1144. long blockSize = stat.getBlockSize();
  1145. long totalBlocks = stat.getBlockCount();
  1146. return totalBlocks * blockSize;
  1147. } catch (RuntimeException re) {
  1148. LogUtil.errorLogInfo("", TAG, re);
  1149. return -99;
  1150. }
  1151. catch (Exception e) {
  1152. Log.e(TAG, "[Exception] getTotalInternalMemorySize()");
  1153. //e.printStackTrace();
  1154. LogUtil.errorLogInfo("", TAG, e);
  1155. return -99;
  1156. }
  1157. }
  1158. /** 사용가능한 내장 메모리 크기를 가져온다 */
  1159. private long getAvailableInternalMemorySize() {
  1160. try {
  1161. File path = Environment.getDataDirectory();
  1162. StatFs stat = new StatFs(path.getPath());
  1163. long blockSize = stat.getBlockSize();
  1164. long availableBlocks = stat.getAvailableBlocks();
  1165. return availableBlocks * blockSize;
  1166. } catch (RuntimeException re) {
  1167. LogUtil.errorLogInfo("", TAG, re);
  1168. return -99;
  1169. }
  1170. catch (Exception e) {
  1171. Log.e(TAG, "[Exception] getAvailableInternalMemorySize()");
  1172. //e.printStackTrace();
  1173. LogUtil.errorLogInfo("", TAG, e);
  1174. return -99;
  1175. }
  1176. }
  1177. /** 전체 외장 메모리 크기를 가져온다 */
  1178. private long getTotalExternalMemorySize() {
  1179. try {
  1180. if (isStorage(true) == true) {
  1181. File path = Environment.getExternalStorageDirectory();
  1182. StatFs stat = new StatFs(path.getPath());
  1183. long blockSize = stat.getBlockSize();
  1184. long totalBlocks = stat.getBlockCount();
  1185. return totalBlocks * blockSize;
  1186. } else {
  1187. return -1;
  1188. }
  1189. } catch (RuntimeException re) {
  1190. LogUtil.errorLogInfo("", TAG, re);
  1191. return -99;
  1192. }
  1193. catch (Exception e) {
  1194. Log.e(TAG, "[Exception] getTotalExternalMemorySize()");
  1195. //e.printStackTrace();
  1196. LogUtil.errorLogInfo("", TAG, e);
  1197. return -99;
  1198. }
  1199. }
  1200. /** 사용가능한 외장 메모리 크기를 가져온다 */
  1201. private long getAvailableExternalMemorySize() {
  1202. try {
  1203. if (isStorage(true) == true) {
  1204. File path = Environment.getExternalStorageDirectory();
  1205. StatFs stat = new StatFs(path.getPath());
  1206. long blockSize = stat.getBlockSize();
  1207. long availableBlocks = stat.getAvailableBlocks();
  1208. return availableBlocks * blockSize;
  1209. } else {
  1210. return -1;
  1211. }
  1212. } catch (RuntimeException re) {
  1213. LogUtil.errorLogInfo("", TAG, re);
  1214. return -99;
  1215. }
  1216. catch (Exception e) {
  1217. Log.e(TAG, "[Exception] getAvailableExternalMemorySize()");
  1218. //e.printStackTrace();
  1219. LogUtil.errorLogInfo("", TAG, e);
  1220. return -99;
  1221. }
  1222. }
  1223. /** 보기 좋게 MB,KB 단위로 축소시킨다 */
  1224. private String formatSize(long size) {
  1225. try {
  1226. String suffix = null;
  1227. if (size >= 1024) {
  1228. suffix = "KB";
  1229. size /= 1024;
  1230. if (size >= 1024) {
  1231. suffix = "MB";
  1232. size /= 1024;
  1233. }
  1234. }
  1235. StringBuilder resultBuffer = new StringBuilder(Long.toString(size));
  1236. int commaOffset = resultBuffer.length() - 3;
  1237. while (commaOffset > 0) {
  1238. resultBuffer.insert(commaOffset, ',');
  1239. commaOffset -= 3;
  1240. }
  1241. if (suffix != null) {
  1242. resultBuffer.append(suffix);
  1243. }
  1244. return resultBuffer.toString();
  1245. } catch (RuntimeException re) {
  1246. LogUtil.errorLogInfo("", TAG, re);
  1247. return null;
  1248. }
  1249. catch (Exception e) {
  1250. Log.e(TAG, "[Exception] formatSize(long size)");
  1251. //e.printStackTrace();
  1252. LogUtil.errorLogInfo("", TAG, e);
  1253. return null;
  1254. }
  1255. }
  1256. /** 외장메모리 sdcard 사용가능한지에 대한 여부 판단 */
  1257. private boolean isStorage(boolean requireWriteAccess) {
  1258. try {
  1259. String state = Environment.getExternalStorageState();
  1260. if (Environment.MEDIA_MOUNTED.equals(state)) {
  1261. return true;
  1262. } else if (!requireWriteAccess &&
  1263. Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
  1264. return true;
  1265. }
  1266. return false;
  1267. } catch (RuntimeException re) {
  1268. LogUtil.errorLogInfo("", TAG, re);
  1269. return false;
  1270. }
  1271. catch (Exception e) {
  1272. Log.e(TAG, "[Exception] isStorage(boolean requireWriteAccess)");
  1273. //e.printStackTrace();
  1274. LogUtil.errorLogInfo("", TAG, e);
  1275. return false;
  1276. }
  1277. }
  1278. private synchronized void FileDelete(File file)
  1279. {
  1280. if(file!=null && file.exists())
  1281. {
  1282. file.delete();
  1283. }
  1284. }
  1285. }