FirmwareManager.java 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  1. package epson.maintain;
  2. import android.content.Context;
  3. import android.os.AsyncTask;
  4. import android.util.Log;
  5. import com.epson.iprint.prtlogger.Analytics;
  6. import com.epson.mobilephone.common.escpr.EscprLib;
  7. import com.epson.mobilephone.common.maintain2.BatteryInfoEx;
  8. import com.epson.mobilephone.common.maintain2.MaintainPrinter2;
  9. import java.io.File;
  10. import java.io.FilterOutputStream;
  11. import java.io.IOException;
  12. import java.io.OutputStream;
  13. import java.util.EnumMap;
  14. import java.util.Locale;
  15. import java.util.UUID;
  16. import epson.common.ExternalFileUtils;
  17. import epson.common.IPAddressUtils;
  18. import epson.print.CommonDefine;
  19. import epson.print.MyPrinter;
  20. import epson.print.Util.EPLog;
  21. public class FirmwareManager {
  22. static final int BUFFER_SIZE = 4096;
  23. static final boolean DEV_FWUPDATE = false;
  24. static final String EVAL_UPDATEINF_URL_PREFIX = "https://epsonpfu-stg.ebz.epson.net";
  25. static String FW_POST_FILE_NAME = "/FWUPDATE_POST_DATA.dat";
  26. private static String FW_POST_FILE_PATH = null;
  27. private static final String TAG = "FirmwareManager";
  28. static final String UPDATEINF_URL_PREFIX = "https://epsonpfu.ebz.epson.net";
  29. private final String boundary;
  30. private final String lineEnd;
  31. int mCurRomNum;
  32. String mCurVer;
  33. byte[] mDlData;
  34. AsyncTask<FWUpdateStep, Integer, FWUpdateProcResult> mFWUpdateTask;
  35. private FirmInfFile mFirmInfFile;
  36. String mMarketID;
  37. String mNewVer;
  38. private final MyPrinter mPrinter;
  39. private String mPrinterMainVersion;
  40. FWUpdateProcResult mProcResult;
  41. FWUpdateStep mProcStep;
  42. String mSendProtocol;
  43. long mTotalSize;
  44. private volatile String mUpdateInfUrl;
  45. private volatile FWUpdateListener mUpdateListener;
  46. private final MaintainPrinterWrapper maintainPrinter;
  47. private final String twoHyphens;
  48. public interface FWUpdateListener {
  49. void fwManagerDidEndProc(FWUpdateProcResult fWUpdateProcResult, FWUpdateStep fWUpdateStep);
  50. void fwManagerProcDoing(int i);
  51. }
  52. public enum FWUpdateProcResult {
  53. None,
  54. Success,
  55. Cancel,
  56. Fail,
  57. NotVerUp,
  58. NotSupport,
  59. Interrupted,
  60. DiskFull,
  61. NotAC,
  62. PrinterBadStatus
  63. }
  64. public enum FWUpdateStep {
  65. Init,
  66. GetPrinterFWVersion,
  67. GetUpdateInf,
  68. Download,
  69. ReadyUpdate,
  70. Send
  71. }
  72. public interface ProgressListener {
  73. void transferred(long j);
  74. }
  75. public FirmwareManager(Context context, MyPrinter myPrinter) {
  76. this(myPrinter, new File(ExternalFileUtils.getInstance(context).getDownloadDir(), FW_POST_FILE_NAME).getPath(), new MaintainPrinterWrapper());
  77. }
  78. @VisibleForTesting
  79. FirmwareManager(MyPrinter myPrinter, @NonNull String str, @Nullable MaintainPrinterWrapper maintainPrinterWrapper) {
  80. twoHyphens = "--";
  81. boundary = "*****" + UUID.randomUUID().toString() + "*****";
  82. lineEnd = "\r\n";
  83. mFirmInfFile = new FirmInfFile();
  84. mProcResult = FWUpdateProcResult.None;
  85. mProcStep = FWUpdateStep.Init;
  86. mFWUpdateTask = buildFWUpdateTask();
  87. mPrinter = myPrinter;
  88. FW_POST_FILE_PATH = str;
  89. maintainPrinter = maintainPrinterWrapper;
  90. }
  91. private void endConnect() {
  92. mFWUpdateTask.cancel(true);
  93. }
  94. private void startProc(FWUpdateStep fWUpdateStep) {
  95. mProcStep = fWUpdateStep;
  96. mProcResult = FWUpdateProcResult.None;
  97. mFWUpdateTask = buildFWUpdateTask();
  98. mFWUpdateTask.execute(new FWUpdateStep[]{fWUpdateStep});
  99. }
  100. private void endWithProcResult(FWUpdateProcResult fWUpdateProcResult) {
  101. endConnect();
  102. if (fWUpdateProcResult != FWUpdateProcResult.Success) {
  103. removeSavedFile();
  104. }
  105. mProcResult = fWUpdateProcResult;
  106. if (mUpdateListener != null) {
  107. mUpdateListener.fwManagerDidEndProc(mProcResult, mProcStep);
  108. }
  109. }
  110. public void cancelProc() {
  111. endWithProcResult(FWUpdateProcResult.Cancel);
  112. }
  113. public void interruptProc() {
  114. endWithProcResult(FWUpdateProcResult.Interrupted);
  115. }
  116. private String getUpdateInfURL() {
  117. return String.format("%s/%s_model_%s/UPDATE.INF", new Object[]{getUpdateInfSchemeAndHost(), mPrinter.getName().replaceAll(" ", CommonDefine.UNDER_BAR), mMarketID});
  118. }
  119. private static String getUpdateInfSchemeAndHost() {
  120. return DEV_FWUPDATE ? EVAL_UPDATEINF_URL_PREFIX : UPDATEINF_URL_PREFIX;
  121. }
  122. private String getStartUpdateURL() {
  123. return IPAddressUtils.buildURL(mSendProtocol, mPrinter.getIp(), "/FIRMWAREUPDATE");
  124. }
  125. private String getSendFWURL() {
  126. return IPAddressUtils.buildURL(mSendProtocol, mPrinter.getIp(), "/DOWN/FIRMWAREUPDATE/ROM1");
  127. }
  128. private String getNextRomURL() {
  129. mCurRomNum++;
  130. return mFirmInfFile.getRomUrl(mCurRomNum);
  131. }
  132. public void startVersionCheck(FWUpdateListener fWUpdateListener) {
  133. mUpdateListener = fWUpdateListener;
  134. startProc(FWUpdateStep.GetPrinterFWVersion);
  135. }
  136. private FWUpdateProcResult getPrinterFWVer() {
  137. int firmwareInfo;
  138. String str;
  139. EnumMap enumMap = new EnumMap(EscprLib.PrinterFirmInfo.class);
  140. int i = 0;
  141. while (true) {
  142. firmwareInfo = maintainPrinter.getFirmwareInfo(enumMap);
  143. EPLog.d(TAG, "getFirmwareInfo = " + firmwareInfo);
  144. if (firmwareInfo != -1100) {
  145. break;
  146. }
  147. int i2 = i + 1;
  148. if (i >= 5) {
  149. break;
  150. }
  151. i = i2;
  152. }
  153. FWUpdateProcResult fWUpdateProcResult = FWUpdateProcResult.Fail;
  154. if (firmwareInfo == -1016) {
  155. return FWUpdateProcResult.NotSupport;
  156. }
  157. if (firmwareInfo != 0 || enumMap.isEmpty()) {
  158. return fWUpdateProcResult;
  159. }
  160. boolean equals = ((String) enumMap.get(EscprLib.PrinterFirmInfo.NicFlg)).equals("1");
  161. mMarketID = (String) enumMap.get(EscprLib.PrinterFirmInfo.MarketID);
  162. mPrinterMainVersion = (String) enumMap.get(EscprLib.PrinterFirmInfo.MainVer);
  163. String str2 = mPrinterMainVersion;
  164. if (str2 == null) {
  165. return FWUpdateProcResult.NotSupport;
  166. }
  167. mCurVer = String.format("%s.%s", new Object[]{str2, enumMap.get(EscprLib.PrinterFirmInfo.NetVer)});
  168. if (mCurVer == null || (str = mMarketID) == null || "NA".equals(str) || equals) {
  169. return FWUpdateProcResult.NotSupport;
  170. }
  171. mUpdateInfUrl = getUpdateInfUrlForAllUrlVer(enumMap);
  172. if (mUpdateInfUrl == null) {
  173. return FWUpdateProcResult.NotSupport;
  174. }
  175. FWUpdateProcResult checkNotBatteryPowered = checkNotBatteryPowered();
  176. return checkNotBatteryPowered != FWUpdateProcResult.Success ? checkNotBatteryPowered : checkNotBatteryPowered;
  177. }
  178. private FWUpdateProcResult checkNotBatteryPowered() {
  179. int batteryInfoEx;
  180. FWUpdateProcResult fWUpdateProcResult = FWUpdateProcResult.Success;
  181. BatteryInfoEx batteryInfoEx2 = new BatteryInfoEx();
  182. int i = 0;
  183. while (true) {
  184. batteryInfoEx = maintainPrinter.getBatteryInfoEx(batteryInfoEx2);
  185. EPLog.d(TAG, "getBatteryInfoEx = " + batteryInfoEx);
  186. if (batteryInfoEx != -1100) {
  187. break;
  188. }
  189. int i2 = i + 1;
  190. if (i >= 5) {
  191. break;
  192. }
  193. i = i2;
  194. }
  195. return (batteryInfoEx != 0 || batteryInfoEx2.powerSourceType == -1 || batteryInfoEx2.powerSourceType == 1) ? fWUpdateProcResult : FWUpdateProcResult.NotAC;
  196. }
  197. /* access modifiers changed from: package-private */
  198. @Nullable
  199. public String getUpdateInfUrlForAllUrlVer(@NonNull EnumMap<EscprLib.PrinterFirmInfo, String> enumMap) {
  200. String str = enumMap.get(EscprLib.PrinterFirmInfo.UrlVer);
  201. if (str == null) {
  202. return null;
  203. }
  204. char c = 65535;
  205. switch (str.hashCode()) {
  206. case 1536:
  207. if (str.equals("00")) {
  208. c = 0;
  209. break;
  210. }
  211. break;
  212. case 1537:
  213. if (str.equals("01")) {
  214. c = 1;
  215. break;
  216. }
  217. break;
  218. }
  219. switch (c) {
  220. case 0:
  221. return getUpdateInfURL();
  222. case 1:
  223. return getUpdateInfUrlV01(enumMap);
  224. default:
  225. return null;
  226. }
  227. }
  228. @Nullable
  229. @VisibleForTesting
  230. static String getUpdateInfUrlV01(@NonNull EnumMap<EscprLib.PrinterFirmInfo, String> enumMap) {
  231. String str;
  232. String str2 = enumMap.get(EscprLib.PrinterFirmInfo.FY);
  233. if (str2 == null || (str = enumMap.get(EscprLib.PrinterFirmInfo.MainVer)) == null || str.length() < 2) {
  234. return null;
  235. }
  236. return String.format(Locale.US, "%s/%s_%s_00/UPDATE.INF", new Object[]{getUpdateInfSchemeAndHost(), str2, str.substring(0, 2)});
  237. }
  238. public void startGetUpdateInf(FWUpdateListener fWUpdateListener) {
  239. mUpdateListener = fWUpdateListener;
  240. startProc(FWUpdateStep.GetUpdateInf);
  241. }
  242. /* access modifiers changed from: private */
  243. /* JADX WARNING: Can't wrap try/catch for region: R(2:10|11) */
  244. /* JADX WARNING: Code restructure failed: missing block: B:11:?, code lost:
  245. endWithProcResult(epson.maintain.FirmwareManager.FWUpdateProcResult.Fail);
  246. */
  247. /* JADX WARNING: Missing exception handler attribute for start block: B:10:0x001a */
  248. /* Code decompiled incorrectly, please refer to instructions dump. */
  249. public synchronized void localCheckInfFileVersion(byte[] r3) {
  250. /*
  251. r2 = this;
  252. monitor-enter(r2)
  253. epson.maintain.FirmInfFile r0 = r2.mFirmInfFile // Catch:{ all -> 0x002b }
  254. boolean r3 = r0.checkInfFileVersion(r3) // Catch:{ all -> 0x002b }
  255. if (r3 != 0) goto L_0x0010
  256. epson.maintain.FirmwareManager$FWUpdateProcResult r3 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail // Catch:{ all -> 0x002b }
  257. r2.endWithProcResult(r3) // Catch:{ all -> 0x002b }
  258. monitor-exit(r2)
  259. return
  260. L_0x0010:
  261. r3 = 0
  262. epson.maintain.FirmInfFile r0 = r2.mFirmInfFile // Catch:{ IllegalArgumentException -> 0x001a }
  263. java.lang.String r1 = r2.mPrinterMainVersion // Catch:{ IllegalArgumentException -> 0x001a }
  264. int r3 = r0.compareVersion(r1) // Catch:{ IllegalArgumentException -> 0x001a }
  265. goto L_0x001f
  266. L_0x001a:
  267. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail // Catch:{ all -> 0x002b }
  268. r2.endWithProcResult(r0) // Catch:{ all -> 0x002b }
  269. L_0x001f:
  270. if (r3 < 0) goto L_0x0024
  271. epson.maintain.FirmwareManager$FWUpdateProcResult r3 = epson.maintain.FirmwareManager.FWUpdateProcResult.NotVerUp // Catch:{ all -> 0x002b }
  272. goto L_0x0026
  273. L_0x0024:
  274. epson.maintain.FirmwareManager$FWUpdateProcResult r3 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success // Catch:{ all -> 0x002b }
  275. L_0x0026:
  276. r2.endWithProcResult(r3) // Catch:{ all -> 0x002b }
  277. monitor-exit(r2)
  278. return
  279. L_0x002b:
  280. r3 = move-exception
  281. monitor-exit(r2)
  282. throw r3
  283. */
  284. throw new UnsupportedOperationException("Method not decompiled: epson.maintain.FirmwareManager.localCheckInfFileVersion(byte[]):void");
  285. }
  286. public void startFWDownload(FWUpdateListener fWUpdateListener) {
  287. mUpdateListener = fWUpdateListener;
  288. startProc(FWUpdateStep.Download);
  289. }
  290. public static void removeSavedFile() {
  291. try {
  292. File file = new File(FW_POST_FILE_PATH);
  293. if (file.exists()) {
  294. file.delete();
  295. }
  296. } catch (Exception e) {
  297. e.printStackTrace();
  298. }
  299. }
  300. static File createNewSaveFile() throws IOException, SecurityException {
  301. File file = new File(FW_POST_FILE_PATH);
  302. file.getParentFile().mkdirs();
  303. file.createNewFile();
  304. return file;
  305. }
  306. public static boolean isExistSaveFile() {
  307. try {
  308. return new File(FW_POST_FILE_PATH).exists();
  309. } catch (Exception unused) {
  310. return false;
  311. }
  312. }
  313. public void startFWUpdate(FWUpdateListener fWUpdateListener) {
  314. mUpdateListener = fWUpdateListener;
  315. startProc(FWUpdateStep.ReadyUpdate);
  316. }
  317. public static class CountingOutputStream extends FilterOutputStream {
  318. private final ProgressListener listener;
  319. private long transferred = 0;
  320. public CountingOutputStream(OutputStream outputStream, ProgressListener progressListener) {
  321. super(outputStream);
  322. listener = progressListener;
  323. }
  324. public void write(byte[] bArr, int i, int i2) throws IOException {
  325. out.write(bArr, i, i2);
  326. transferred += (long) i2;
  327. listener.transferred(transferred);
  328. }
  329. public void write(int i) throws IOException {
  330. out.write(i);
  331. transferred++;
  332. listener.transferred(transferred);
  333. }
  334. }
  335. private AsyncTask<FWUpdateStep, Integer, FWUpdateProcResult> buildFWUpdateTask() {
  336. return new LocalAsyncTask();
  337. }
  338. class LocalAsyncTask extends AsyncTask<FWUpdateStep, Integer, FWUpdateProcResult> {
  339. LocalAsyncTask() {
  340. }
  341. protected void onPreExecute() {
  342. FirmwareManager.mDlData = null;
  343. publishProgress(new Integer[0]);
  344. }
  345. protected FWUpdateProcResult doInBackground(FWUpdateStep... fWUpdateStepArr) {
  346. FirmwareManager.mProcResult = FWUpdateProcResult.None;
  347. int[] iArr = C20021.$SwitchMap$epson$maintain$FirmwareManager$FWUpdateStep;
  348. FirmwareManager firmwareManager = FirmwareManager.this;
  349. FWUpdateStep fWUpdateStep = fWUpdateStepArr[0];
  350. firmwareManager.mProcStep = fWUpdateStep;
  351. switch (iArr[fWUpdateStep.ordinal()]) {
  352. case 1:
  353. return getPrinterFWVer();
  354. case 2:
  355. if (FirmwareManager.mUpdateInfUrl == null) {
  356. return FWUpdateProcResult.NotSupport;
  357. }
  358. return download(FirmwareManager.mUpdateInfUrl, (File) null, false);
  359. case 3:
  360. switch (FirmwareManager.mFirmInfFile.getInfFileVersion()) {
  361. case 1:
  362. return downloadNewFW();
  363. case 2:
  364. return extractFirmDataFromRcx();
  365. default:
  366. return FWUpdateProcResult.Fail;
  367. }
  368. case 4:
  369. if (FirmwareManager.mPrinter.getIp() != null && FirmwareManager.isExistSaveFile()) {
  370. FirmwareManager firmwareManager2 = FirmwareManager.this;
  371. firmwareManager2.mSendProtocol = "https";
  372. FWUpdateProcResult download = download(firmwareManager2.getStartUpdateURL(), (File) null, false);
  373. if (download == FWUpdateProcResult.Success) {
  374. return download;
  375. }
  376. FirmwareManager firmwareManager3 = FirmwareManager.this;
  377. firmwareManager3.mSendProtocol = Analytics.EXTENSION_STRING_WEB;
  378. return download(firmwareManager3.getStartUpdateURL(), (File) null, false);
  379. }
  380. case 5:
  381. return sendFW();
  382. }
  383. return FWUpdateProcResult.Fail;
  384. }
  385. protected void onPostExecute(FWUpdateProcResult fWUpdateProcResult) {
  386. if (fWUpdateProcResult == FWUpdateProcResult.Success) {
  387. switch (FirmwareManager.mProcStep) {
  388. case GetPrinterFWVersion:
  389. endWithProcResult(fWUpdateProcResult);
  390. return;
  391. case GetUpdateInf:
  392. FirmwareManager firmwareManager = FirmwareManager.this;
  393. firmwareManager.localCheckInfFileVersion(firmwareManager.mDlData);
  394. return;
  395. case Download:
  396. endWithProcResult(fWUpdateProcResult);
  397. return;
  398. case ReadyUpdate:
  399. startProc(FWUpdateStep.Send);
  400. return;
  401. case Send:
  402. endWithProcResult(fWUpdateProcResult);
  403. return;
  404. default:
  405. endWithProcResult(FWUpdateProcResult.Fail);
  406. return;
  407. }
  408. } else {
  409. endWithProcResult(fWUpdateProcResult);
  410. }
  411. }
  412. protected void onProgressUpdate(Integer... numArr) {
  413. int i = 0;
  414. if (numArr.length == 1 && C20021.$SwitchMap$epson$maintain$FirmwareManager$FWUpdateStep[FirmwareManager.mProcStep.ordinal()] != 4) {
  415. i = numArr[0].intValue();
  416. }
  417. FirmwareManager.mUpdateListener.fwManagerProcDoing(i);
  418. }
  419. protected void onCancelled() {
  420. Log.d(toString(), "onCancelled");
  421. }
  422. private FWUpdateProcResult downloadEfuFile(File file) {
  423. String str = FirmwareManager.mFirmInfFile.getfuUrl();
  424. if (str == null) {
  425. return FWUpdateProcResult.NotSupport;
  426. }
  427. return download(str, file, false);
  428. }
  429. /* JADX WARNING: Code restructure failed: missing block: B:19:0x0059, code lost:
  430. if (r2.exists() != false) goto L_0x005b;
  431. */
  432. /* JADX WARNING: Code restructure failed: missing block: B:20:0x005b, code lost:
  433. r2.delete();
  434. */
  435. /* JADX WARNING: Code restructure failed: missing block: B:21:0x005f, code lost:
  436. r0 = move-exception;
  437. */
  438. /* JADX WARNING: Code restructure failed: missing block: B:23:?, code lost:
  439. r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail;
  440. */
  441. /* JADX WARNING: Code restructure failed: missing block: B:25:0x0067, code lost:
  442. if (r1.exists() != false) goto L_0x0069;
  443. */
  444. /* JADX WARNING: Code restructure failed: missing block: B:26:0x0069, code lost:
  445. r1.delete();
  446. */
  447. /* JADX WARNING: Code restructure failed: missing block: B:28:0x0070, code lost:
  448. if (r2.exists() == false) goto L_0x0085;
  449. */
  450. /* JADX WARNING: Code restructure failed: missing block: B:30:?, code lost:
  451. r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.DiskFull;
  452. */
  453. /* JADX WARNING: Code restructure failed: missing block: B:32:0x0079, code lost:
  454. if (r1.exists() != false) goto L_0x007b;
  455. */
  456. /* JADX WARNING: Code restructure failed: missing block: B:33:0x007b, code lost:
  457. r1.delete();
  458. */
  459. /* JADX WARNING: Code restructure failed: missing block: B:35:0x0082, code lost:
  460. if (r2.exists() == false) goto L_0x0085;
  461. */
  462. /* JADX WARNING: Code restructure failed: missing block: B:36:0x0085, code lost:
  463. return r0;
  464. */
  465. /* JADX WARNING: Code restructure failed: missing block: B:38:0x008a, code lost:
  466. if (r1.exists() != false) goto L_0x008c;
  467. */
  468. /* JADX WARNING: Code restructure failed: missing block: B:39:0x008c, code lost:
  469. r1.delete();
  470. */
  471. /* JADX WARNING: Code restructure failed: missing block: B:41:0x0093, code lost:
  472. if (r2.exists() != false) goto L_0x0095;
  473. */
  474. /* JADX WARNING: Code restructure failed: missing block: B:42:0x0095, code lost:
  475. r2.delete();
  476. */
  477. /* JADX WARNING: Code restructure failed: missing block: B:43:0x0098, code lost:
  478. throw r0;
  479. */
  480. /* JADX WARNING: Exception block dominator not found, dom blocks: [B:22:0x0061, B:29:0x0073] */
  481. /* JADX WARNING: Missing exception handler attribute for start block: B:22:0x0061 */
  482. /* JADX WARNING: Missing exception handler attribute for start block: B:29:0x0073 */
  483. /* JADX WARNING: Unknown top exception splitter block from list: {B:22:0x0061=Splitter:B:22:0x0061, B:29:0x0073=Splitter:B:29:0x0073} */
  484. /* Code decompiled incorrectly, please refer to instructions dump. */
  485. private epson.maintain.FirmwareManager.FWUpdateProcResult extractFirmDataFromRcx() {
  486. /*
  487. r5 = this;
  488. java.io.File r0 = epson.maintain.FirmwareManager.createNewSaveFile() // Catch:{ IOException -> 0x0099 }
  489. java.io.File r1 = new java.io.File
  490. java.io.File r2 = r0.getParentFile()
  491. java.lang.String r3 = "zip.efu"
  492. r1.<init>(r2, r3)
  493. java.io.File r2 = new java.io.File
  494. java.io.File r3 = r0.getParentFile()
  495. java.lang.String r4 = "unzip.efu"
  496. r2.<init>(r3, r4)
  497. epson.maintain.FirmwareManager$FWUpdateProcResult r3 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail
  498. epson.maintain.FirmwareManager$FWUpdateProcResult r3 = r5.downloadEfuFile(r1) // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
  499. epson.maintain.FirmwareManager$FWUpdateProcResult r4 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
  500. if (r3 == r4) goto L_0x0037
  501. boolean r0 = r1.exists()
  502. if (r0 == 0) goto L_0x002d
  503. r1.delete()
  504. L_0x002d:
  505. boolean r0 = r2.exists()
  506. if (r0 == 0) goto L_0x0036
  507. r2.delete()
  508. L_0x0036:
  509. return r3
  510. L_0x0037:
  511. java.lang.String r3 = r1.getPath() // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
  512. java.lang.String r4 = r2.getPath() // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
  513. epson.maintain.EfuReader.unzipOnlyOneEntry(r3, r4) // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
  514. epson.maintain.EfuReader r3 = new epson.maintain.EfuReader // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
  515. r3.<init>() // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
  516. r3.writeOnlyOneFirmwareData(r2, r0) // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
  517. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success // Catch:{ WriteException -> 0x0073, IOException -> 0x0061 }
  518. boolean r3 = r1.exists()
  519. if (r3 == 0) goto L_0x0055
  520. r1.delete()
  521. L_0x0055:
  522. boolean r1 = r2.exists()
  523. if (r1 == 0) goto L_0x0085
  524. L_0x005b:
  525. r2.delete()
  526. goto L_0x0085
  527. L_0x005f:
  528. r0 = move-exception
  529. goto L_0x0086
  530. L_0x0061:
  531. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail // Catch:{ all -> 0x005f }
  532. boolean r3 = r1.exists()
  533. if (r3 == 0) goto L_0x006c
  534. r1.delete()
  535. L_0x006c:
  536. boolean r1 = r2.exists()
  537. if (r1 == 0) goto L_0x0085
  538. goto L_0x005b
  539. L_0x0073:
  540. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.DiskFull // Catch:{ all -> 0x005f }
  541. boolean r3 = r1.exists()
  542. if (r3 == 0) goto L_0x007e
  543. r1.delete()
  544. L_0x007e:
  545. boolean r1 = r2.exists()
  546. if (r1 == 0) goto L_0x0085
  547. goto L_0x005b
  548. L_0x0085:
  549. return r0
  550. L_0x0086:
  551. boolean r3 = r1.exists()
  552. if (r3 == 0) goto L_0x008f
  553. r1.delete()
  554. L_0x008f:
  555. boolean r1 = r2.exists()
  556. if (r1 == 0) goto L_0x0098
  557. r2.delete()
  558. L_0x0098:
  559. throw r0
  560. L_0x0099:
  561. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.DiskFull
  562. return r0
  563. */
  564. throw new UnsupportedOperationException("Method not decompiled: epson.maintain.FirmwareManager.LocalAsyncTask.extractFirmDataFromRcx():epson.maintain.FirmwareManager$FWUpdateProcResult");
  565. }
  566. private FWUpdateProcResult download(String str, File file, boolean z) {
  567. return download(str, file, z, 1, 1);
  568. }
  569. /* JADX WARNING: type inference failed for: r0v7, types: [java.net.URLConnection] */
  570. /* access modifiers changed from: package-private */
  571. /* JADX WARNING: Code restructure failed: missing block: B:105:0x0139, code lost:
  572. if (r13 != null) goto L_0x0105;
  573. */
  574. /* JADX WARNING: Code restructure failed: missing block: B:75:0x0103, code lost:
  575. if (r13 != null) goto L_0x0105;
  576. */
  577. /* JADX WARNING: Code restructure failed: missing block: B:78:?, code lost:
  578. r13.disconnect();
  579. */
  580. /* JADX WARNING: Failed to process nested try/catch */
  581. /* JADX WARNING: Missing exception handler attribute for start block: B:73:0x0100 */
  582. /* JADX WARNING: Multi-variable type inference failed */
  583. /* JADX WARNING: Removed duplicated region for block: B:102:0x0134 A[SYNTHETIC, Splitter:B:102:0x0134] */
  584. /* JADX WARNING: Removed duplicated region for block: B:111:0x0142 A[SYNTHETIC, Splitter:B:111:0x0142] */
  585. /* JADX WARNING: Removed duplicated region for block: B:115:0x0149 A[SYNTHETIC, Splitter:B:115:0x0149] */
  586. /* JADX WARNING: Removed duplicated region for block: B:119:0x0150 A[SYNTHETIC, Splitter:B:119:0x0150] */
  587. /* JADX WARNING: Removed duplicated region for block: B:98:0x012d A[SYNTHETIC, Splitter:B:98:0x012d] */
  588. /* JADX WARNING: Unknown top exception splitter block from list: {B:39:0x0076=Splitter:B:39:0x0076, B:32:0x006e=Splitter:B:32:0x006e} */
  589. /* Code decompiled incorrectly, please refer to instructions dump. */
  590. public epson.maintain.FirmwareManager.FWUpdateProcResult download(java.lang.String r20, java.io.File r21, boolean r22, int r23, int r24) {
  591. /*
  592. r19 = this;
  593. r1 = r19
  594. r0 = r20
  595. r2 = r21
  596. if (r0 != 0) goto L_0x000b
  597. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail
  598. return r0
  599. L_0x000b:
  600. r3 = 1
  601. java.lang.Integer[] r4 = new java.lang.Integer[r3]
  602. int r5 = r23 + -1
  603. double r5 = r5
  604. r7 = 4636737291354636288(0x4059000000000000, double:100.0)
  605. double r9 = r5 * r7
  606. r11 = r24
  607. double r11 = r11
  608. double r9 = r9 / r11
  609. int r9 = r9
  610. java.lang.Integer r9 = java.lang.Integer.valueOf(r9)
  611. r10 = 0
  612. r4[r10] = r9
  613. r1.publishProgress(r4)
  614. epson.maintain.FirmwareManager$FWUpdateProcResult r4 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success
  615. java.net.URL r13 = new java.net.URL // Catch:{ Exception -> 0x0122, all -> 0x011d }
  616. r13.<init>(r0) // Catch:{ Exception -> 0x0122, all -> 0x011d }
  617. java.net.URLConnection r0 = r13.openConnection() // Catch:{ Exception -> 0x0122, all -> 0x011d }
  618. r13 = r0
  619. java.net.HttpURLConnection r13 = (java.net.HttpURLConnection) r13 // Catch:{ Exception -> 0x0122, all -> 0x011d }
  620. java.lang.String r0 = "GET"
  621. r13.setRequestMethod(r0) // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  622. r13.connect() // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  623. int r0 = r13.getResponseCode() // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  624. r14 = 400(0x190, float:5.6E-43)
  625. r15 = 500(0x1f4, float:7.0E-43)
  626. if (r14 > r0) goto L_0x004e
  627. if (r0 >= r15) goto L_0x004e
  628. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.NotSupport // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  629. if (r13 == 0) goto L_0x004d
  630. r13.disconnect() // Catch:{ Exception -> 0x004d }
  631. L_0x004d:
  632. return r0
  633. L_0x004e:
  634. if (r15 > r0) goto L_0x0076
  635. r14 = 600(0x258, float:8.41E-43)
  636. if (r0 >= r14) goto L_0x0076
  637. if (r15 != r0) goto L_0x006e
  638. int[] r0 = epson.maintain.FirmwareManager.C20021.$SwitchMap$epson$maintain$FirmwareManager$FWUpdateStep // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  639. epson.maintain.FirmwareManager r2 = epson.maintain.FirmwareManager.this // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  640. epson.maintain.FirmwareManager$FWUpdateStep r2 = r2.mProcStep // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  641. int r2 = r2.ordinal() // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  642. r0 = r0[r2] // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  643. switch(r0) {
  644. case 4: goto L_0x0066;
  645. case 5: goto L_0x0066;
  646. default: goto L_0x0065;
  647. } // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  648. L_0x0065:
  649. goto L_0x006e
  650. L_0x0066:
  651. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.PrinterBadStatus // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  652. if (r13 == 0) goto L_0x006d
  653. r13.disconnect() // Catch:{ Exception -> 0x006d }
  654. L_0x006d:
  655. return r0
  656. L_0x006e:
  657. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  658. if (r13 == 0) goto L_0x0075
  659. r13.disconnect() // Catch:{ Exception -> 0x0075 }
  660. L_0x0075:
  661. return r0
  662. L_0x0076:
  663. java.io.BufferedInputStream r14 = new java.io.BufferedInputStream // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  664. java.io.InputStream r0 = r13.getInputStream() // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  665. r15 = 4096(0x1000, float:5.74E-42)
  666. r14.<init>(r0, r15) // Catch:{ Exception -> 0x0119, all -> 0x0116 }
  667. if (r2 == 0) goto L_0x008b
  668. java.io.FileOutputStream r0 = new java.io.FileOutputStream // Catch:{ Exception -> 0x0112, all -> 0x010f }
  669. r9 = r22
  670. r0.<init>(r2, r9) // Catch:{ Exception -> 0x0112, all -> 0x010f }
  671. goto L_0x0090
  672. L_0x008b:
  673. java.io.ByteArrayOutputStream r0 = new java.io.ByteArrayOutputStream // Catch:{ Exception -> 0x0112, all -> 0x010f }
  674. r0.<init>() // Catch:{ Exception -> 0x0112, all -> 0x010f }
  675. L_0x0090:
  676. r9 = r0
  677. byte[] r0 = new byte[r15] // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  678. int r2 = r13.getContentLength() // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  679. long r7 = (long) r2 // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  680. r17 = 0
  681. L_0x009a:
  682. int r2 = r14.read(r0) // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  683. r15 = -1
  684. if (r2 == r15) goto L_0x00e5
  685. boolean r15 = r19.isCancelled() // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  686. if (r15 == 0) goto L_0x00ad
  687. r13.disconnect() // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  688. epson.maintain.FirmwareManager$FWUpdateProcResult r4 = epson.maintain.FirmwareManager.FWUpdateProcResult.Cancel // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  689. goto L_0x00e7
  690. L_0x00ad:
  691. r24 = r4
  692. long r3 = (long) r2
  693. long r3 = r17 + r3
  694. r9.write(r0, r10, r2) // Catch:{ IOException -> 0x00da }
  695. r2 = 1
  696. java.lang.Integer[] r15 = new java.lang.Integer[r2] // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  697. r16 = r11
  698. double r10 = r3 // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  699. r22 = r3
  700. double r2 = r7 // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  701. double r10 = r10 / r2
  702. double r10 = r10 + r5
  703. r2 = 4636737291354636288(0x4059000000000000, double:100.0)
  704. double r10 = r10 * r2
  705. double r10 = r10 / r16
  706. int r10 = r10 // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  707. java.lang.Integer r10 = java.lang.Integer.valueOf(r10) // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  708. r11 = 0
  709. r15[r11] = r10 // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  710. r1.publishProgress(r15) // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  711. r4 = r24
  712. r11 = r16
  713. r3 = 1
  714. r10 = 0
  715. r17 = r22
  716. goto L_0x009a
  717. L_0x00da:
  718. boolean r0 = r9 instanceof java.io.ByteArrayOutputStream // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  719. if (r0 == 0) goto L_0x00e1
  720. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  721. goto L_0x00e3
  722. L_0x00e1:
  723. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.DiskFull // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  724. L_0x00e3:
  725. r4 = r0
  726. goto L_0x00e7
  727. L_0x00e5:
  728. r24 = r4
  729. L_0x00e7:
  730. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  731. if (r4 != r0) goto L_0x00fd
  732. r9.flush() // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  733. boolean r0 = r9 instanceof java.io.ByteArrayOutputStream // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  734. if (r0 == 0) goto L_0x00fd
  735. epson.maintain.FirmwareManager r0 = epson.maintain.FirmwareManager.this // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  736. r2 = r9
  737. java.io.ByteArrayOutputStream r2 = (java.io.ByteArrayOutputStream) r2 // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  738. byte[] r2 = r2.toByteArray() // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  739. r0.mDlData = r2 // Catch:{ Exception -> 0x010b, all -> 0x0109 }
  740. L_0x00fd:
  741. r14.close() // Catch:{ Exception -> 0x0100 }
  742. L_0x0100:
  743. r9.close() // Catch:{ Exception -> 0x0103 }
  744. L_0x0103:
  745. if (r13 == 0) goto L_0x013c
  746. L_0x0105:
  747. r13.disconnect() // Catch:{ Exception -> 0x013c }
  748. goto L_0x013c
  749. L_0x0109:
  750. r0 = move-exception
  751. goto L_0x0140
  752. L_0x010b:
  753. r0 = move-exception
  754. r2 = r9
  755. r9 = r14
  756. goto L_0x0126
  757. L_0x010f:
  758. r0 = move-exception
  759. r9 = 0
  760. goto L_0x0140
  761. L_0x0112:
  762. r0 = move-exception
  763. r9 = r14
  764. r2 = 0
  765. goto L_0x0126
  766. L_0x0116:
  767. r0 = move-exception
  768. r9 = 0
  769. goto L_0x0120
  770. L_0x0119:
  771. r0 = move-exception
  772. r2 = 0
  773. r9 = 0
  774. goto L_0x0126
  775. L_0x011d:
  776. r0 = move-exception
  777. r9 = 0
  778. r13 = 0
  779. L_0x0120:
  780. r14 = 0
  781. goto L_0x0140
  782. L_0x0122:
  783. r0 = move-exception
  784. r2 = 0
  785. r9 = 0
  786. r13 = 0
  787. L_0x0126:
  788. r0.printStackTrace() // Catch:{ all -> 0x013d }
  789. epson.maintain.FirmwareManager$FWUpdateProcResult r4 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail // Catch:{ all -> 0x013d }
  790. if (r9 == 0) goto L_0x0132
  791. r9.close() // Catch:{ Exception -> 0x0131 }
  792. goto L_0x0132
  793. L_0x0131:
  794. L_0x0132:
  795. if (r2 == 0) goto L_0x0139
  796. r2.close() // Catch:{ Exception -> 0x0138 }
  797. goto L_0x0139
  798. L_0x0138:
  799. L_0x0139:
  800. if (r13 == 0) goto L_0x013c
  801. goto L_0x0105
  802. L_0x013c:
  803. return r4
  804. L_0x013d:
  805. r0 = move-exception
  806. r14 = r9
  807. r9 = r2
  808. L_0x0140:
  809. if (r14 == 0) goto L_0x0147
  810. r14.close() // Catch:{ Exception -> 0x0146 }
  811. goto L_0x0147
  812. L_0x0146:
  813. L_0x0147:
  814. if (r9 == 0) goto L_0x014e
  815. r9.close() // Catch:{ Exception -> 0x014d }
  816. goto L_0x014e
  817. L_0x014d:
  818. L_0x014e:
  819. if (r13 == 0) goto L_0x0153
  820. r13.disconnect() // Catch:{ Exception -> 0x0153 }
  821. L_0x0153:
  822. throw r0
  823. */
  824. throw new UnsupportedOperationException("Method not decompiled: epson.maintain.FirmwareManager.LocalAsyncTask.download(java.lang.String, java.io.File, boolean, int, int):epson.maintain.FirmwareManager$FWUpdateProcResult");
  825. }
  826. private FWUpdateProcResult downloadNewFW() {
  827. String access$500;
  828. FWUpdateProcResult fWUpdateProcResult = FWUpdateProcResult.Success;
  829. try {
  830. File createNewSaveFile = FirmwareManager.createNewSaveFile();
  831. String access$5002 = getNextRomURL();
  832. if (access$5002 == null || FirmwareManager.mCurVer == null || FirmwareManager.mFirmInfFile.getMainVersion() == null) {
  833. return FWUpdateProcResult.Fail;
  834. }
  835. int romNum = FirmwareManager.mFirmInfFile.getRomNum();
  836. FWUpdateProcResult download = download(access$5002, createNewSaveFile, false, FirmwareManager.mCurRomNum, romNum);
  837. while (download == FWUpdateProcResult.Success && (access$500 = getNextRomURL()) != null) {
  838. if (isCancelled()) {
  839. return FWUpdateProcResult.Cancel;
  840. }
  841. download = download(access$500, createNewSaveFile, true, FirmwareManager.mCurRomNum, romNum);
  842. }
  843. return download;
  844. } catch (IOException e) {
  845. e.printStackTrace();
  846. return FWUpdateProcResult.DiskFull;
  847. } catch (Exception e2) {
  848. e2.printStackTrace();
  849. return FWUpdateProcResult.Fail;
  850. }
  851. }
  852. /* access modifiers changed from: package-private */
  853. /* JADX WARNING: Can't wrap try/catch for region: R(19:0|1|2|3|4|5|6|(3:7|8|(3:10|11|12)(1:65))|18|19|20|21|22|23|24|(1:(1:31))(1:27)|(2:33|34)|56|(2:59|66)(1:67)) */
  854. /* JADX WARNING: Can't wrap try/catch for region: R(7:35|39|40|41|42|43|44) */
  855. /* JADX WARNING: Missing exception handler attribute for start block: B:21:0x0160 */
  856. /* JADX WARNING: Missing exception handler attribute for start block: B:23:0x0163 */
  857. /* JADX WARNING: Missing exception handler attribute for start block: B:41:0x0187 */
  858. /* JADX WARNING: Missing exception handler attribute for start block: B:43:0x018a */
  859. /* JADX WARNING: Removed duplicated region for block: B:26:0x016d A[ADDED_TO_REGION, Catch:{ all -> 0x0180, Exception -> 0x018d, all -> 0x018b }] */
  860. /* JADX WARNING: Removed duplicated region for block: B:33:0x017c A[SYNTHETIC, Splitter:B:33:0x017c] */
  861. /* JADX WARNING: Removed duplicated region for block: B:59:0x01a4 */
  862. /* JADX WARNING: Removed duplicated region for block: B:61:0x01a9 A[SYNTHETIC, Splitter:B:61:0x01a9] */
  863. /* JADX WARNING: Removed duplicated region for block: B:67:? A[RETURN, SYNTHETIC] */
  864. /* JADX WARNING: Unknown top exception splitter block from list: {B:23:0x0163=Splitter:B:23:0x0163, B:43:0x018a=Splitter:B:43:0x018a} */
  865. /* Code decompiled incorrectly, please refer to instructions dump. */
  866. public epson.maintain.FirmwareManager.FWUpdateProcResult sendFW() {
  867. /*
  868. r10 = this;
  869. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Success
  870. r1 = 0
  871. java.net.URL r2 = new java.net.URL // Catch:{ Exception -> 0x0193 }
  872. epson.maintain.FirmwareManager r3 = epson.maintain.FirmwareManager.this // Catch:{ Exception -> 0x0193 }
  873. java.lang.String r3 = r3.getSendFWURL() // Catch:{ Exception -> 0x0193 }
  874. r2.<init>(r3) // Catch:{ Exception -> 0x0193 }
  875. java.net.URLConnection r2 = r2.openConnection() // Catch:{ Exception -> 0x0193 }
  876. java.net.HttpURLConnection r2 = (java.net.HttpURLConnection) r2 // Catch:{ Exception -> 0x0193 }
  877. java.io.ByteArrayOutputStream r1 = new java.io.ByteArrayOutputStream // Catch:{ Exception -> 0x018d, all -> 0x018b }
  878. r1.<init>() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  879. java.lang.StringBuilder r3 = new java.lang.StringBuilder // Catch:{ Exception -> 0x018d, all -> 0x018b }
  880. r3.<init>() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  881. java.lang.String r4 = "--"
  882. r3.append(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  883. epson.maintain.FirmwareManager r4 = epson.maintain.FirmwareManager.this // Catch:{ Exception -> 0x018d, all -> 0x018b }
  884. java.lang.String r4 = r4.boundary // Catch:{ Exception -> 0x018d, all -> 0x018b }
  885. r3.append(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  886. java.lang.String r4 = "\r\n"
  887. r3.append(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  888. java.lang.String r3 = r3.toString() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  889. java.lang.String r4 = "UTF-8"
  890. byte[] r3 = r3.getBytes(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  891. r1.write(r3) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  892. java.lang.StringBuilder r3 = new java.lang.StringBuilder // Catch:{ Exception -> 0x018d, all -> 0x018b }
  893. r3.<init>() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  894. java.lang.String r4 = "Content-Disposition: form-data; name=\"\"fname\"\"; filename=\""
  895. r3.append(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  896. java.io.File r4 = new java.io.File // Catch:{ Exception -> 0x018d, all -> 0x018b }
  897. java.lang.String r5 = epson.maintain.FirmwareManager.FW_POST_FILE_PATH // Catch:{ Exception -> 0x018d, all -> 0x018b }
  898. r4.<init>(r5) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  899. java.lang.String r4 = r4.getName() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  900. r3.append(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  901. java.lang.String r4 = "\""
  902. r3.append(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  903. java.lang.String r4 = "\r\n"
  904. r3.append(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  905. java.lang.String r3 = r3.toString() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  906. java.lang.String r4 = "UTF-8"
  907. byte[] r3 = r3.getBytes(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  908. r1.write(r3) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  909. java.lang.String r3 = "Content-Type: application/octet-stream\r\n"
  910. java.lang.String r4 = "UTF-8"
  911. byte[] r3 = r3.getBytes(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  912. r1.write(r3) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  913. java.lang.String r3 = "Content-Transfer-Encoding: binary\r\n"
  914. java.lang.String r4 = "UTF-8"
  915. byte[] r3 = r3.getBytes(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  916. r1.write(r3) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  917. java.lang.String r3 = "\r\n"
  918. java.lang.String r4 = "UTF-8"
  919. byte[] r3 = r3.getBytes(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  920. r1.write(r3) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  921. java.io.File r3 = new java.io.File // Catch:{ Exception -> 0x018d, all -> 0x018b }
  922. java.lang.String r4 = epson.maintain.FirmwareManager.FW_POST_FILE_PATH // Catch:{ Exception -> 0x018d, all -> 0x018b }
  923. r3.<init>(r4) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  924. java.io.ByteArrayOutputStream r4 = new java.io.ByteArrayOutputStream // Catch:{ Exception -> 0x018d, all -> 0x018b }
  925. r4.<init>() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  926. java.lang.StringBuilder r5 = new java.lang.StringBuilder // Catch:{ Exception -> 0x018d, all -> 0x018b }
  927. r5.<init>() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  928. java.lang.String r6 = "--"
  929. r5.append(r6) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  930. epson.maintain.FirmwareManager r6 = epson.maintain.FirmwareManager.this // Catch:{ Exception -> 0x018d, all -> 0x018b }
  931. java.lang.String r6 = r6.boundary // Catch:{ Exception -> 0x018d, all -> 0x018b }
  932. r5.append(r6) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  933. java.lang.String r6 = "--"
  934. r5.append(r6) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  935. java.lang.String r6 = "\r\n"
  936. r5.append(r6) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  937. java.lang.String r5 = r5.toString() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  938. java.lang.String r6 = "UTF-8"
  939. byte[] r5 = r5.getBytes(r6) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  940. r4.write(r5) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  941. epson.maintain.FirmwareManager r5 = epson.maintain.FirmwareManager.this // Catch:{ Exception -> 0x018d, all -> 0x018b }
  942. int r6 = r1.size() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  943. long r6 = (long) r6 // Catch:{ Exception -> 0x018d, all -> 0x018b }
  944. long r8 = r3.length() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  945. long r6 = r6 + r8
  946. int r8 = r4.size() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  947. long r8 = (long) r8 // Catch:{ Exception -> 0x018d, all -> 0x018b }
  948. long r6 = r6 + r8
  949. r5.mTotalSize = r6 // Catch:{ Exception -> 0x018d, all -> 0x018b }
  950. java.lang.String r5 = "POST"
  951. r2.setRequestMethod(r5) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  952. r5 = 1
  953. r2.setDoOutput(r5) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  954. java.lang.String r5 = "Content-Type"
  955. java.lang.StringBuilder r6 = new java.lang.StringBuilder // Catch:{ Exception -> 0x018d, all -> 0x018b }
  956. r6.<init>() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  957. java.lang.String r7 = "multipart/form-data; boundary="
  958. r6.append(r7) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  959. epson.maintain.FirmwareManager r7 = epson.maintain.FirmwareManager.this // Catch:{ Exception -> 0x018d, all -> 0x018b }
  960. java.lang.String r7 = r7.boundary // Catch:{ Exception -> 0x018d, all -> 0x018b }
  961. r6.append(r7) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  962. java.lang.String r6 = r6.toString() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  963. r2.setRequestProperty(r5, r6) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  964. epson.maintain.FirmwareManager r5 = epson.maintain.FirmwareManager.this // Catch:{ Exception -> 0x018d, all -> 0x018b }
  965. long r5 = r5.mTotalSize // Catch:{ Exception -> 0x018d, all -> 0x018b }
  966. int r6 = r5 // Catch:{ Exception -> 0x018d, all -> 0x018b }
  967. r2.setFixedLengthStreamingMode(r6) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  968. r2.connect() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  969. java.io.BufferedInputStream r5 = new java.io.BufferedInputStream // Catch:{ Exception -> 0x018d, all -> 0x018b }
  970. java.io.FileInputStream r6 = new java.io.FileInputStream // Catch:{ Exception -> 0x018d, all -> 0x018b }
  971. java.lang.String r3 = r3.getPath() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  972. r6.<init>(r3) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  973. r3 = 4096(0x1000, float:5.74E-42)
  974. r5.<init>(r6, r3) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  975. epson.maintain.FirmwareManager$CountingOutputStream r6 = new epson.maintain.FirmwareManager$CountingOutputStream // Catch:{ Exception -> 0x018d, all -> 0x018b }
  976. java.io.OutputStream r7 = r2.getOutputStream() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  977. epson.maintain.FirmwareManager$LocalAsyncTask$1 r8 = new epson.maintain.FirmwareManager$LocalAsyncTask$1 // Catch:{ Exception -> 0x018d, all -> 0x018b }
  978. r8.<init>(r2) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  979. r6.<init>(r7, r8) // Catch:{ Exception -> 0x018d, all -> 0x018b }
  980. r1.writeTo(r6) // Catch:{ IOException -> 0x0182 }
  981. byte[] r1 = new byte[r3] // Catch:{ IOException -> 0x0182 }
  982. L_0x012f:
  983. int r3 = r5.read(r1) // Catch:{ IOException -> 0x0182 }
  984. r7 = -1
  985. if (r3 == r7) goto L_0x0157
  986. r7 = 0
  987. r6.write(r1, r7, r3) // Catch:{ IOException -> 0x013b }
  988. goto L_0x012f
  989. L_0x013b:
  990. r0 = move-exception
  991. java.lang.String r1 = "FirmwareManager"
  992. java.lang.StringBuilder r3 = new java.lang.StringBuilder // Catch:{ IOException -> 0x0182 }
  993. r3.<init>() // Catch:{ IOException -> 0x0182 }
  994. java.lang.String r4 = "error: in executeFile() : "
  995. r3.append(r4) // Catch:{ IOException -> 0x0182 }
  996. java.lang.String r4 = r0.toString() // Catch:{ IOException -> 0x0182 }
  997. r3.append(r4) // Catch:{ IOException -> 0x0182 }
  998. java.lang.String r3 = r3.toString() // Catch:{ IOException -> 0x0182 }
  999. epson.print.Util.EPLog.w((java.lang.String) r1, (java.lang.String) r3) // Catch:{ IOException -> 0x0182 }
  1000. throw r0 // Catch:{ IOException -> 0x0182 }
  1001. L_0x0157:
  1002. r4.writeTo(r6) // Catch:{ IOException -> 0x0182 }
  1003. r6.flush() // Catch:{ IOException -> 0x0182 }
  1004. r5.close() // Catch:{ IOException -> 0x0160 }
  1005. L_0x0160:
  1006. r6.close() // Catch:{ IOException -> 0x0163 }
  1007. L_0x0163:
  1008. int r1 = r2.getResponseCode() // Catch:{ Exception -> 0x018d, all -> 0x018b }
  1009. r3 = 400(0x190, float:5.6E-43)
  1010. r4 = 500(0x1f4, float:7.0E-43)
  1011. if (r3 > r1) goto L_0x0172
  1012. if (r1 >= r4) goto L_0x0172
  1013. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.NotSupport // Catch:{ Exception -> 0x018d, all -> 0x018b }
  1014. goto L_0x017a
  1015. L_0x0172:
  1016. if (r4 > r1) goto L_0x017a
  1017. r3 = 600(0x258, float:8.41E-43)
  1018. if (r1 >= r3) goto L_0x017a
  1019. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail // Catch:{ Exception -> 0x018d, all -> 0x018b }
  1020. L_0x017a:
  1021. if (r2 == 0) goto L_0x019e
  1022. r2.disconnect() // Catch:{ Exception -> 0x019e }
  1023. goto L_0x019e
  1024. L_0x0180:
  1025. r0 = move-exception
  1026. goto L_0x0184
  1027. L_0x0182:
  1028. r0 = move-exception
  1029. throw r0 // Catch:{ all -> 0x0180 }
  1030. L_0x0184:
  1031. r5.close() // Catch:{ IOException -> 0x0187 }
  1032. L_0x0187:
  1033. r6.close() // Catch:{ IOException -> 0x018a }
  1034. L_0x018a:
  1035. throw r0 // Catch:{ Exception -> 0x018d, all -> 0x018b }
  1036. L_0x018b:
  1037. r0 = move-exception
  1038. goto L_0x01a7
  1039. L_0x018d:
  1040. r0 = move-exception
  1041. r1 = r2
  1042. goto L_0x0194
  1043. L_0x0190:
  1044. r0 = move-exception
  1045. r2 = r1
  1046. goto L_0x01a7
  1047. L_0x0193:
  1048. r0 = move-exception
  1049. L_0x0194:
  1050. r0.printStackTrace() // Catch:{ all -> 0x0190 }
  1051. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Fail // Catch:{ all -> 0x0190 }
  1052. if (r1 == 0) goto L_0x019e
  1053. r1.disconnect() // Catch:{ Exception -> 0x019e }
  1054. L_0x019e:
  1055. boolean r1 = r10.isCancelled()
  1056. if (r1 == 0) goto L_0x01a6
  1057. epson.maintain.FirmwareManager$FWUpdateProcResult r0 = epson.maintain.FirmwareManager.FWUpdateProcResult.Cancel
  1058. L_0x01a6:
  1059. return r0
  1060. L_0x01a7:
  1061. if (r2 == 0) goto L_0x01ac
  1062. r2.disconnect() // Catch:{ Exception -> 0x01ac }
  1063. L_0x01ac:
  1064. throw r0
  1065. */
  1066. throw new UnsupportedOperationException("Method not decompiled: epson.maintain.FirmwareManager.LocalAsyncTask.sendFW():epson.maintain.FirmwareManager$FWUpdateProcResult");
  1067. }
  1068. }
  1069. @VisibleForTesting
  1070. static class MaintainPrinterWrapper {
  1071. private final MaintainPrinter2 mMaintainPrinter2 = MaintainPrinter2.getInstance();
  1072. MaintainPrinterWrapper() {
  1073. }
  1074. public int getFirmwareInfo(EnumMap<EscprLib.PrinterFirmInfo, String> enumMap) {
  1075. return mMaintainPrinter2.getFirmwareInfo(enumMap);
  1076. }
  1077. public int getBatteryInfoEx(BatteryInfoEx batteryInfoEx) {
  1078. return mMaintainPrinter2.getBatteryInfo(batteryInfoEx);
  1079. }
  1080. }
  1081. }