CopyTask.java 17 KB

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