FirmwareManager.java 58 KB

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