MemcardCheckTask.java 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. package com.epson.memcardacc;
  2. import android.content.Context;
  3. import android.os.AsyncTask;
  4. import java.util.concurrent.SynchronousQueue;
  5. public class MemcardCheckTask extends AsyncTask<Void, Void, Integer> {
  6. public static final int ERROR_CODE_ACTIVITY_ON_PAUSE_CANCEL = 6;
  7. public static final int ERROR_CODE_CANCEL = 5;
  8. public static final int ERROR_MEM_CARD_NOT_FOUND = 1;
  9. public static final int ERROR_PRINTER_BUSY = 3;
  10. public static final int ERROR_PRINTER_CONNECTION = 2;
  11. public static final int ERROR_PRINTER_ERROR = 4;
  12. public static final int NO_ERROR = 0;
  13. protected boolean mActivityOnPauseCancel;
  14. MemcardCheckCallback mCallback;
  15. int mCifsStorageSetType;
  16. Context mContext;
  17. int mErrorCode;
  18. private SynchronousQueue<MyQueueData> mQueue;
  19. public interface MemcardCheckCallback {
  20. void onAuthInfoRequired(MemcardCheckTask memcardCheckTask, boolean z);
  21. void onMemcardCheckEnd(Integer num, int i);
  22. void onPreExecute();
  23. }
  24. public MemcardCheckTask(Context context, MemcardCheckCallback memcardCheckCallback, int i) {
  25. this.mActivityOnPauseCancel = false;
  26. this.mQueue = new SynchronousQueue<>();
  27. this.mContext = context.getApplicationContext();
  28. this.mCallback = memcardCheckCallback;
  29. this.mCifsStorageSetType = i;
  30. }
  31. protected MemcardCheckTask() {
  32. this.mActivityOnPauseCancel = false;
  33. }
  34. /* access modifiers changed from: protected */
  35. /* JADX WARNING: Can't wrap try/catch for region: R(4:50|51|52|53) */
  36. /* JADX WARNING: Code restructure failed: missing block: B:51:?, code lost:
  37. r7.mErrorCode = 5;
  38. */
  39. /* JADX WARNING: Code restructure failed: missing block: B:52:0x00a7, code lost:
  40. r8.free();
  41. */
  42. /* JADX WARNING: Code restructure failed: missing block: B:53:0x00aa, code lost:
  43. return 0;
  44. */
  45. /* JADX WARNING: Missing exception handler attribute for start block: B:50:0x00a1 */
  46. /* Code decompiled incorrectly, please refer to instructions dump. */
  47. public java.lang.Integer doInBackground(java.lang.Void... r8) {
  48. /*
  49. r7 = this;
  50. boolean r8 = r7.isCancelled()
  51. r0 = 5
  52. r1 = 0
  53. if (r8 == 0) goto L_0x000f
  54. r7.mErrorCode = r0
  55. java.lang.Integer r8 = java.lang.Integer.valueOf(r1)
  56. return r8
  57. L_0x000f:
  58. android.content.Context r8 = r7.mContext
  59. r2 = 60
  60. int r8 = r7.checkEscprLib(r8, r2)
  61. r7.mErrorCode = r8
  62. int r8 = r7.mErrorCode
  63. if (r8 == 0) goto L_0x0022
  64. java.lang.Integer r8 = java.lang.Integer.valueOf(r1)
  65. return r8
  66. L_0x0022:
  67. com.epson.memcardacc.CifsAccess r8 = r7.getCifsAccessInstance()
  68. boolean r2 = r7.isCancelled() // Catch:{ all -> 0x00b3 }
  69. if (r2 == 0) goto L_0x0036
  70. r7.mErrorCode = r0 // Catch:{ all -> 0x00b3 }
  71. java.lang.Integer r0 = java.lang.Integer.valueOf(r1) // Catch:{ all -> 0x00b3 }
  72. r8.free()
  73. return r0
  74. L_0x0036:
  75. android.content.Context r2 = r7.mContext // Catch:{ all -> 0x00b3 }
  76. int r3 = r7.mCifsStorageSetType // Catch:{ all -> 0x00b3 }
  77. int r2 = r8.initDefault(r2, r3) // Catch:{ all -> 0x00b3 }
  78. if (r2 != 0) goto L_0x0055
  79. r8.free() // Catch:{ all -> 0x00b3 }
  80. android.content.Context r2 = r7.mContext // Catch:{ all -> 0x00b3 }
  81. int r3 = r7.mCifsStorageSetType // Catch:{ all -> 0x00b3 }
  82. int r2 = r8.initDefault(r2, r3) // Catch:{ all -> 0x00b3 }
  83. if (r2 != 0) goto L_0x0055
  84. java.lang.Integer r0 = java.lang.Integer.valueOf(r1) // Catch:{ all -> 0x00b3 }
  85. r8.free()
  86. return r0
  87. L_0x0055:
  88. r2 = 1
  89. r3 = 0
  90. r4 = 1
  91. L_0x0058:
  92. if (r3 != 0) goto L_0x00ab
  93. boolean r3 = r7.isCancelled() // Catch:{ all -> 0x00b3 }
  94. if (r3 == 0) goto L_0x006a
  95. r7.mErrorCode = r0 // Catch:{ all -> 0x00b3 }
  96. java.lang.Integer r0 = java.lang.Integer.valueOf(r1) // Catch:{ all -> 0x00b3 }
  97. r8.free()
  98. return r0
  99. L_0x006a:
  100. int r3 = r8.checkStorage() // Catch:{ all -> 0x00b3 }
  101. if (r3 != 0) goto L_0x0058
  102. int r5 = r8.getErrorCode() // Catch:{ all -> 0x00b3 }
  103. r6 = -1205(0xfffffffffffffb4b, float:NaN)
  104. if (r5 == r6) goto L_0x0082
  105. r7.mErrorCode = r2 // Catch:{ all -> 0x00b3 }
  106. java.lang.Integer r0 = java.lang.Integer.valueOf(r1) // Catch:{ all -> 0x00b3 }
  107. r8.free()
  108. return r0
  109. L_0x0082:
  110. boolean r5 = r7.isCancelled() // Catch:{ all -> 0x00b3 }
  111. if (r5 == 0) goto L_0x0092
  112. r7.mErrorCode = r0 // Catch:{ all -> 0x00b3 }
  113. java.lang.Integer r0 = java.lang.Integer.valueOf(r1) // Catch:{ all -> 0x00b3 }
  114. r8.free()
  115. return r0
  116. L_0x0092:
  117. com.epson.memcardacc.MemcardCheckTask$MemcardCheckCallback r5 = r7.mCallback // Catch:{ all -> 0x00b3 }
  118. r5.onAuthInfoRequired(r7, r4) // Catch:{ all -> 0x00b3 }
  119. java.util.concurrent.SynchronousQueue<com.epson.memcardacc.MemcardCheckTask$MyQueueData> r4 = r7.mQueue // Catch:{ InterruptedException -> 0x00a1 }
  120. java.lang.Object r4 = r4.take() // Catch:{ InterruptedException -> 0x00a1 }
  121. com.epson.memcardacc.MemcardCheckTask$MyQueueData r4 = (com.epson.memcardacc.MemcardCheckTask.MyQueueData) r4 // Catch:{ InterruptedException -> 0x00a1 }
  122. r4 = 0
  123. goto L_0x0058
  124. L_0x00a1:
  125. r7.mErrorCode = r0 // Catch:{ all -> 0x00b3 }
  126. java.lang.Integer r0 = java.lang.Integer.valueOf(r1) // Catch:{ all -> 0x00b3 }
  127. r8.free()
  128. return r0
  129. L_0x00ab:
  130. r8.free()
  131. java.lang.Integer r8 = java.lang.Integer.valueOf(r3)
  132. return r8
  133. L_0x00b3:
  134. r0 = move-exception
  135. r8.free()
  136. throw r0
  137. */
  138. throw new UnsupportedOperationException("Method not decompiled: com.epson.memcardacc.MemcardCheckTask.doInBackground(java.lang.Void[]):java.lang.Integer");
  139. }
  140. protected CifsAccess getCifsAccessInstance() {
  141. return CifsAccess.getInstance();
  142. }
  143. protected void onPreExecute() {
  144. this.mCallback.onPreExecute();
  145. }
  146. protected void onPostExecute(Integer num) {
  147. this.mCallback.onMemcardCheckEnd(num, this.mErrorCode);
  148. }
  149. protected void onCancelled() {
  150. this.mCallback.onMemcardCheckEnd((Integer) null, this.mActivityOnPauseCancel ? 6 : 5);
  151. }
  152. public void activityOnPauseCancel() {
  153. this.mActivityOnPauseCancel = true;
  154. cancel(true);
  155. }
  156. public void setAuthData(String str, String str2) {
  157. int i = 0;
  158. while (!this.mQueue.offer(new MyQueueData(2)) && i < 4) {
  159. try {
  160. Thread.sleep(300);
  161. i++;
  162. } catch (Exception unused) {
  163. return;
  164. }
  165. }
  166. }
  167. protected int checkEscprLib(Context context, int i) {
  168. EscprLibPrinter newEscprLibPrinter = newEscprLibPrinter();
  169. if (newEscprLibPrinter.init(context, i, true) != 0) {
  170. return 2;
  171. }
  172. int status = newEscprLibPrinter.getStatus();
  173. newEscprLibPrinter.release();
  174. return (status == 0 || status == 4) ? 0 : 3;
  175. }
  176. protected EscprLibPrinter newEscprLibPrinter() {
  177. return new EscprLibPrinter();
  178. }
  179. static class MyQueueData {
  180. public static final int TYPE_AUTH_DATA = 2;
  181. public static final int TYPE_CANCEL = 1;
  182. public int mDataType;
  183. public SmbAuthInfo mSmbAuthInfo;
  184. public static MyQueueData getCancelData() {
  185. return new MyQueueData(1);
  186. }
  187. public MyQueueData(int i) {
  188. this.mDataType = i;
  189. }
  190. public boolean isCancel() {
  191. return this.mDataType == 1;
  192. }
  193. }
  194. }