CopyTask.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. package com.epson.memcardacc;
  2. import android.content.Context;
  3. import android.support.annotation.NonNull;
  4. import android.support.annotation.Nullable;
  5. import com.epson.iprint.prtlogger.CommonLog;
  6. import epson.print.Util.AsyncTaskExecutor;
  7. import epson.print.Util.EPLog;
  8. import java.util.ArrayList;
  9. /* compiled from: MemcardWriteProgress */
  10. class CopyTask extends AsyncTaskExecutor<Void, Integer, Integer> {
  11. private static final String LOG_TAG = "CopyTask";
  12. MemcardWriteProgress mCallback;
  13. private boolean mCanceling;
  14. CifsAccess mCifsAccess = CifsAccess.getInstance();
  15. private int mCifsAccessStorageType;
  16. private int mErrorCode = 0;
  17. private boolean mEscprCheck = false;
  18. private ArrayList<String> mImageList;
  19. private CommonLog mLogData;
  20. private int mMemcardStorageType;
  21. private String mTargetFolderName;
  22. private ArrayList<String> mWriteFileList;
  23. public CopyTask(@NonNull MemcardWriteProgress memcardWriteProgress, int i, int i2, @NonNull ArrayList<String> arrayList, @NonNull ArrayList<String> arrayList2, @NonNull String str, @Nullable CommonLog commonLog) {
  24. this.mCallback = memcardWriteProgress;
  25. this.mCifsAccessStorageType = i;
  26. this.mMemcardStorageType = i2;
  27. this.mImageList = arrayList;
  28. this.mWriteFileList = arrayList2;
  29. this.mTargetFolderName = str;
  30. this.mLogData = commonLog;
  31. }
  32. public void setCheck(boolean z, boolean z2) {
  33. this.mEscprCheck = z;
  34. }
  35. /* access modifiers changed from: protected */
  36. public void onCancelled() {
  37. EPLog.m313i(LOG_TAG, "canceled in AsyncTask");
  38. this.mCallback.finishWithState(0, 0, this.mLogData);
  39. }
  40. /* access modifiers changed from: protected */
  41. public void onPostExecute(Integer num) {
  42. EPLog.m313i(LOG_TAG, "onPostExecute in AsyncTask");
  43. this.mCallback.finishWithState(num.intValue(), this.mErrorCode, this.mLogData);
  44. }
  45. /* access modifiers changed from: protected */
  46. public void onPreExecute() {
  47. this.mCanceling = false;
  48. this.mCallback.setProgress(0, this.mImageList.size());
  49. }
  50. /* access modifiers changed from: protected */
  51. public void onProgressUpdate(Integer... numArr) {
  52. this.mCallback.setProgress(numArr[0].intValue(), this.mImageList.size());
  53. }
  54. /* access modifiers changed from: protected */
  55. public EscprLibPrinter getEscprLibPrinter() {
  56. return new EscprLibPrinter();
  57. }
  58. private int checkPrinterByEscprLib(Context context) {
  59. EscprLibPrinter escprLibPrinter = getEscprLibPrinter();
  60. if (escprLibPrinter.init(context, 60, true) != 0) {
  61. return 1;
  62. }
  63. int status = escprLibPrinter.getStatus();
  64. escprLibPrinter.release();
  65. return (status == 0 || status == 4) ? 0 : 2;
  66. }
  67. /* access modifiers changed from: protected */
  68. /* JADX WARNING: Code restructure failed: missing block: B:68:0x00e5, code lost:
  69. r8 = move-exception;
  70. */
  71. /* JADX WARNING: Code restructure failed: missing block: B:69:0x00e6, code lost:
  72. r7.mCifsAccess.free();
  73. */
  74. /* JADX WARNING: Code restructure failed: missing block: B:70:0x00eb, code lost:
  75. throw r8;
  76. */
  77. /* JADX WARNING: Removed duplicated region for block: B:68:0x00e5 A[ExcHandler: all (r8v5 'th' java.lang.Throwable A[CUSTOM_DECLARE]), Splitter:B:21:0x003e] */
  78. /* Code decompiled incorrectly, please refer to instructions dump. */
  79. public java.lang.Integer doInBackground(java.lang.Void... r8) {
  80. /*
  81. r7 = this;
  82. r8 = 3
  83. com.epson.memcardacc.MemcardWriteProgress r0 = r7.mCallback // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  84. boolean r0 = r0.waitWifiConnect() // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  85. if (r0 != 0) goto L_0x0013
  86. java.lang.Integer r8 = java.lang.Integer.valueOf(r8) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  87. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess
  88. r0.free()
  89. return r8
  90. L_0x0013:
  91. boolean r0 = r7.isCancelled() // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  92. r1 = 0
  93. if (r0 == 0) goto L_0x0024
  94. java.lang.Integer r8 = java.lang.Integer.valueOf(r1) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  95. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess
  96. r0.free()
  97. return r8
  98. L_0x0024:
  99. boolean r0 = r7.mEscprCheck // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  100. if (r0 == 0) goto L_0x003e
  101. com.epson.memcardacc.MemcardWriteProgress r0 = r7.mCallback // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  102. int r0 = r7.checkPrinterByEscprLib(r0) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  103. r7.mErrorCode = r0 // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  104. int r0 = r7.mErrorCode // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  105. if (r0 == 0) goto L_0x003e
  106. java.lang.Integer r8 = java.lang.Integer.valueOf(r8) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  107. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess
  108. r0.free()
  109. return r8
  110. L_0x003e:
  111. boolean r0 = r7.isCancelled() // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  112. if (r0 == 0) goto L_0x004e
  113. java.lang.Integer r8 = java.lang.Integer.valueOf(r1) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  114. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess
  115. r0.free()
  116. return r8
  117. L_0x004e:
  118. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  119. com.epson.memcardacc.MemcardWriteProgress r1 = r7.mCallback // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  120. int r2 = r7.mCifsAccessStorageType // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  121. int r0 = r0.initDefault(r1, r2) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  122. if (r0 != 0) goto L_0x0064
  123. java.lang.Integer r8 = java.lang.Integer.valueOf(r8) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  124. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess
  125. r0.free()
  126. return r8
  127. L_0x0064:
  128. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  129. int r1 = r7.mMemcardStorageType // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  130. int r0 = r0.connectDefaultStorageWidthDefaultAthInfo(r1) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  131. r1 = 1
  132. r2 = -1100(0xfffffffffffffbb4, float:NaN)
  133. if (r0 != 0) goto L_0x0088
  134. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  135. int r0 = r0.getErrorCode() // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  136. if (r0 != r2) goto L_0x007c
  137. r7.mErrorCode = r1 // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  138. goto L_0x007e
  139. L_0x007c:
  140. r7.mErrorCode = r8 // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  141. L_0x007e:
  142. java.lang.Integer r8 = java.lang.Integer.valueOf(r8) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  143. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess
  144. r0.free()
  145. return r8
  146. L_0x0088:
  147. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  148. long r3 = r0.getFreeUnit() // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  149. r5 = 0
  150. int r0 = (r3 > r5 ? 1 : (r3 == r5 ? 0 : -1))
  151. if (r0 >= 0) goto L_0x00a0
  152. r7.mErrorCode = r8 // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  153. java.lang.Integer r8 = java.lang.Integer.valueOf(r8) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  154. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess
  155. r0.free()
  156. return r8
  157. L_0x00a0:
  158. java.lang.String r0 = r7.mTargetFolderName // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  159. int r0 = r0.length() // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  160. if (r0 <= 0) goto L_0x00d0
  161. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  162. java.lang.String r3 = r7.mTargetFolderName // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  163. int r0 = r0.createDirectory(r3) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  164. if (r0 == 0) goto L_0x00cf
  165. r3 = -1203(0xfffffffffffffb4d, float:NaN)
  166. if (r0 == r3) goto L_0x00cf
  167. if (r0 != r2) goto L_0x00bb
  168. r7.mErrorCode = r1 // Catch:{ Exception -> 0x00cd, all -> 0x00e5 }
  169. goto L_0x00be
  170. L_0x00bb:
  171. r1 = 4
  172. r7.mErrorCode = r1 // Catch:{ Exception -> 0x00cd, all -> 0x00e5 }
  173. L_0x00be:
  174. com.epson.memcardacc.CifsAccess r1 = r7.mCifsAccess // Catch:{ Exception -> 0x00cd, all -> 0x00e5 }
  175. r1.disconnectStorage() // Catch:{ Exception -> 0x00cd, all -> 0x00e5 }
  176. java.lang.Integer r8 = java.lang.Integer.valueOf(r8) // Catch:{ Exception -> 0x00cd, all -> 0x00e5 }
  177. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess
  178. r0.free()
  179. return r8
  180. L_0x00cd:
  181. r8 = r0
  182. goto L_0x00ec
  183. L_0x00cf:
  184. r8 = r0
  185. L_0x00d0:
  186. int r8 = r7.copyFile() // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  187. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  188. r0.disconnectStorage() // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  189. com.epson.iprint.prtlogger.CommonLog r0 = r7.mLogData // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  190. com.epson.memcardacc.MemcardWriteProgress r1 = r7.mCallback // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  191. android.content.Context r1 = r1.getApplicationContext() // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  192. r0.setConnectionType(r1) // Catch:{ Exception -> 0x00ec, all -> 0x00e5 }
  193. goto L_0x00ec
  194. L_0x00e5:
  195. r8 = move-exception
  196. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess
  197. r0.free()
  198. throw r8
  199. L_0x00ec:
  200. com.epson.memcardacc.CifsAccess r0 = r7.mCifsAccess
  201. r0.free()
  202. java.lang.Integer r8 = java.lang.Integer.valueOf(r8)
  203. return r8
  204. */
  205. throw new UnsupportedOperationException("Method not decompiled: com.epson.memcardacc.CopyTask.doInBackground(java.lang.Void[]):java.lang.Integer");
  206. }
  207. /* access modifiers changed from: protected */
  208. /* JADX WARNING: Removed duplicated region for block: B:30:0x00ae */
  209. /* JADX WARNING: Removed duplicated region for block: B:47:0x00f8 */
  210. /* Code decompiled incorrectly, please refer to instructions dump. */
  211. public int copyFile() {
  212. /*
  213. r13 = this;
  214. java.util.ArrayList<java.lang.String> r0 = r13.mImageList
  215. java.util.Iterator r0 = r0.iterator()
  216. r1 = 0
  217. r2 = 0
  218. L_0x0008:
  219. boolean r3 = r0.hasNext()
  220. r4 = -2
  221. if (r3 == 0) goto L_0x00fe
  222. boolean r3 = r13.isCancelled()
  223. if (r3 == 0) goto L_0x0016
  224. return r1
  225. L_0x0016:
  226. r13.localPublishProgress(r2)
  227. java.lang.Object r3 = r0.next()
  228. java.lang.String r3 = (java.lang.String) r3
  229. java.util.ArrayList<java.lang.String> r5 = r13.mWriteFileList
  230. r6 = 2
  231. r7 = 1
  232. if (r5 == 0) goto L_0x003c
  233. java.lang.Object r5 = r5.get(r2)
  234. java.lang.String r5 = (java.lang.String) r5
  235. java.util.Locale r8 = java.util.Locale.US
  236. java.lang.String r9 = "%s\\%s"
  237. java.lang.Object[] r6 = new java.lang.Object[r6]
  238. java.lang.String r10 = r13.mTargetFolderName
  239. r6[r1] = r10
  240. r6[r7] = r5
  241. java.lang.String r5 = java.lang.String.format(r8, r9, r6)
  242. goto L_0x0050
  243. L_0x003c:
  244. java.util.Locale r5 = java.util.Locale.US
  245. java.lang.String r8 = "%s\\IMG_%04d.JPG"
  246. java.lang.Object[] r6 = new java.lang.Object[r6]
  247. java.lang.String r9 = r13.mTargetFolderName
  248. r6[r1] = r9
  249. java.lang.Integer r9 = java.lang.Integer.valueOf(r2)
  250. r6[r7] = r9
  251. java.lang.String r5 = java.lang.String.format(r5, r8, r6)
  252. L_0x0050:
  253. int r2 = r2 + 1
  254. java.lang.String r6 = "MemcardWriteProgress"
  255. java.lang.StringBuilder r8 = new java.lang.StringBuilder
  256. r8.<init>()
  257. java.lang.String r9 = "copy "
  258. r8.append(r9)
  259. r8.append(r3)
  260. java.lang.String r9 = " => "
  261. r8.append(r9)
  262. r8.append(r5)
  263. java.lang.String r8 = r8.toString()
  264. epson.print.Util.EPLog.m313i(r6, r8)
  265. long r8 = com.epson.memcardacc.MemcardUtil.getFileLength(r3)
  266. r10 = 2147483647(0x7fffffff, double:1.060997895E-314)
  267. r6 = 3
  268. int r12 = (r8 > r10 ? 1 : (r8 == r10 ? 0 : -1))
  269. if (r12 <= 0) goto L_0x0080
  270. r0 = 5
  271. r13.mErrorCode = r0
  272. return r6
  273. L_0x0080:
  274. r10 = -1203(0xfffffffffffffb4d, float:NaN)
  275. com.epson.memcardacc.CifsAccess r11 = r13.mCifsAccess // Catch:{ UnsupportedEncodingException -> 0x00a7 }
  276. int r9 = (int) r8 // Catch:{ UnsupportedEncodingException -> 0x00a7 }
  277. int r8 = r11.writeToPrinterMemcard(r3, r5, r9) // Catch:{ UnsupportedEncodingException -> 0x00a7 }
  278. java.util.ArrayList<java.lang.String> r11 = r13.mWriteFileList // Catch:{ UnsupportedEncodingException -> 0x00a5 }
  279. if (r11 == 0) goto L_0x00ac
  280. if (r8 == 0) goto L_0x00ac
  281. if (r8 == r4) goto L_0x00ac
  282. com.epson.memcardacc.CifsAccess r11 = r13.mCifsAccess // Catch:{ UnsupportedEncodingException -> 0x00a5 }
  283. int r11 = r11.getErrorCode() // Catch:{ UnsupportedEncodingException -> 0x00a5 }
  284. if (r11 != r10) goto L_0x00ac
  285. com.epson.memcardacc.CifsAccess r11 = r13.mCifsAccess // Catch:{ UnsupportedEncodingException -> 0x00a5 }
  286. r11.deleteFile(r5) // Catch:{ UnsupportedEncodingException -> 0x00a5 }
  287. com.epson.memcardacc.CifsAccess r11 = r13.mCifsAccess // Catch:{ UnsupportedEncodingException -> 0x00a5 }
  288. int r8 = r11.writeToPrinterMemcard(r3, r5, r9) // Catch:{ UnsupportedEncodingException -> 0x00a5 }
  289. goto L_0x00ac
  290. L_0x00a5:
  291. r9 = move-exception
  292. goto L_0x00a9
  293. L_0x00a7:
  294. r9 = move-exception
  295. r8 = 0
  296. L_0x00a9:
  297. r9.printStackTrace()
  298. L_0x00ac:
  299. if (r8 == 0) goto L_0x00f8
  300. java.lang.String r9 = "MemcardWriteProgress"
  301. java.lang.StringBuilder r11 = new java.lang.StringBuilder
  302. r11.<init>()
  303. java.lang.String r12 = "writeFromPrinterMemcard() returns <"
  304. r11.append(r12)
  305. r11.append(r8)
  306. java.lang.String r12 = ">"
  307. r11.append(r12)
  308. java.lang.String r11 = r11.toString()
  309. epson.print.Util.EPLog.m318w((java.lang.String) r9, (java.lang.String) r11)
  310. if (r8 != r4) goto L_0x00d1
  311. com.epson.memcardacc.CifsAccess r0 = r13.mCifsAccess
  312. r0.deleteFile(r5)
  313. return r1
  314. L_0x00d1:
  315. com.epson.memcardacc.CifsAccess r4 = r13.mCifsAccess
  316. int r4 = r4.getErrorCode()
  317. r8 = 4
  318. if (r4 != r10) goto L_0x00e9
  319. java.util.ArrayList<java.lang.String> r4 = r13.mWriteFileList
  320. if (r4 != 0) goto L_0x00e6
  321. boolean r3 = r13.checkFileSize(r3, r5)
  322. if (r3 == 0) goto L_0x00e6
  323. goto L_0x0008
  324. L_0x00e6:
  325. r13.mErrorCode = r8
  326. return r6
  327. L_0x00e9:
  328. com.epson.memcardacc.CifsAccess r0 = r13.mCifsAccess
  329. r0.deleteFile(r5)
  330. r0 = -1100(0xfffffffffffffbb4, float:NaN)
  331. if (r4 != r0) goto L_0x00f5
  332. r13.mErrorCode = r7
  333. goto L_0x00f7
  334. L_0x00f5:
  335. r13.mErrorCode = r8
  336. L_0x00f7:
  337. return r6
  338. L_0x00f8:
  339. com.epson.iprint.prtlogger.CommonLog r3 = r13.mLogData
  340. r3.numberOfSheet = r2
  341. goto L_0x0008
  342. L_0x00fe:
  343. return r4
  344. */
  345. throw new UnsupportedOperationException("Method not decompiled: com.epson.memcardacc.CopyTask.copyFile():int");
  346. }
  347. /* access modifiers changed from: protected */
  348. public void localPublishProgress(int i) {
  349. publishProgress(new Integer[]{Integer.valueOf(i)});
  350. }
  351. /* access modifiers changed from: protected */
  352. public boolean checkFileSize(String str, String str2) {
  353. long fileLength = MemcardUtil.getFileLength(str);
  354. long fileSize = this.mCifsAccess.getFileSize(str2);
  355. return fileSize > 0 && fileLength == fileSize;
  356. }
  357. public void taskCancel() {
  358. if (!this.mCanceling) {
  359. this.mCanceling = true;
  360. EPLog.m313i(LOG_TAG, "taskCancel()");
  361. this.mCifsAccess.cancel();
  362. cancel(false);
  363. }
  364. }
  365. public void taskCancelByFileSizeZero() {
  366. if (!this.mCanceling) {
  367. this.mCanceling = true;
  368. EPLog.m313i(LOG_TAG, "taskCancel()");
  369. this.mCifsAccess.cancelByFileSizeZero();
  370. cancel(false);
  371. }
  372. }
  373. }