FirmwareManager.java 57 KB

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