PaperSourceInfo.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. package epson.print.screen;
  2. import android.content.Context;
  3. import android.os.AsyncTask;
  4. import android.os.Handler;
  5. import com.epson.mobilephone.common.EPLog;
  6. import com.epson.mobilephone.common.maintain2.MaintainPrinter2;
  7. import epson.print.Util.EPLog;
  8. import java.util.ArrayList;
  9. public class PaperSourceInfo {
  10. private static final long CHECK_INTEVAL = 4000;
  11. private static final int EPS_COMM_BID = 2;
  12. public static final String KEY_PAPERSOURCEINFO = "PAPERSOURCEINFO";
  13. public static final int NOTIFY_PAPERSOURCEINFO = 100;
  14. private static final String TAG = "PaperSourceInfo";
  15. public static PaperSourceInfo instance;
  16. private MaintainPrinter2 mPrinter = MaintainPrinter2.getInstance();
  17. private PaparInfoTask paparInfoTask = null;
  18. private PaperSourceInfo(Context context) {
  19. EPLog.i();
  20. this.mPrinter.doInitDriver(context, 2);
  21. }
  22. public static PaperSourceInfo getInstance(Context context) {
  23. if (instance == null) {
  24. instance = new PaperSourceInfo(context);
  25. }
  26. return instance;
  27. }
  28. public void start(Context context, Handler handler) {
  29. EPLog.i(TAG, "call start()");
  30. if (this.paparInfoTask == null) {
  31. this.paparInfoTask = new PaparInfoTask();
  32. this.paparInfoTask.execute(new Object[]{context, handler});
  33. }
  34. }
  35. public void stop() {
  36. EPLog.i(TAG, "call stop()");
  37. if (this.paparInfoTask != null) {
  38. this.mPrinter.doCancelFindPrinter();
  39. this.paparInfoTask.cancel(true);
  40. this.paparInfoTask = null;
  41. }
  42. }
  43. public class PaparInfoTask extends AsyncTask<Object, Void, Void> {
  44. public PaparInfoTask() {
  45. }
  46. /* access modifiers changed from: protected */
  47. /* JADX WARNING: Removed duplicated region for block: B:41:0x0149 */
  48. /* Code decompiled incorrectly, please refer to instructions dump. */
  49. public java.lang.Void doInBackground(java.lang.Object... r13) {
  50. /*
  51. r12 = this;
  52. r0 = 0
  53. r1 = r13[r0]
  54. android.content.Context r1 = (android.content.Context) r1
  55. r2 = 1
  56. r13 = r13[r2]
  57. android.os.Handler r13 = (android.os.Handler) r13
  58. r3 = 100
  59. epson.print.MyPrinter r4 = epson.print.MyPrinter.getCurPrinter(r1) // Catch:{ InterruptedException -> 0x0141 }
  60. int r5 = r4.getLocation() // Catch:{ InterruptedException -> 0x0141 }
  61. if (r5 == r2) goto L_0x001b
  62. r1 = 3
  63. if (r5 == r1) goto L_0x0025
  64. goto L_0x0142
  65. L_0x001b:
  66. java.lang.String r5 = "printer"
  67. java.lang.String r1 = com.epson.mobilephone.common.wifidirect.WiFiDirectManager.getConnectInfo(r1, r5) // Catch:{ InterruptedException -> 0x0141 }
  68. if (r1 == 0) goto L_0x0025
  69. goto L_0x0142
  70. L_0x0025:
  71. boolean r1 = r12.isCancelled() // Catch:{ InterruptedException -> 0x0141 }
  72. r5 = 4000(0xfa0, double:1.9763E-320)
  73. if (r1 != 0) goto L_0x008b
  74. epson.print.screen.PaperSourceInfo r1 = epson.print.screen.PaperSourceInfo.this // Catch:{ InterruptedException -> 0x0141 }
  75. com.epson.mobilephone.common.maintain2.MaintainPrinter2 r1 = r1.mPrinter // Catch:{ InterruptedException -> 0x0141 }
  76. r7 = 60
  77. java.lang.String r8 = r4.getPrinterId() // Catch:{ InterruptedException -> 0x0141 }
  78. java.lang.String r9 = r4.getIp() // Catch:{ InterruptedException -> 0x0141 }
  79. int r10 = r4.getLocation() // Catch:{ InterruptedException -> 0x0141 }
  80. int r1 = r1.doProbePrinter(r7, r8, r9, r10) // Catch:{ InterruptedException -> 0x0141 }
  81. r7 = -1300(0xfffffffffffffaec, float:NaN)
  82. if (r1 == r7) goto L_0x0071
  83. if (r1 == 0) goto L_0x0063
  84. java.lang.String r0 = "PaperSourceInfo"
  85. java.lang.StringBuilder r2 = new java.lang.StringBuilder // Catch:{ InterruptedException -> 0x0141 }
  86. r2.<init>() // Catch:{ InterruptedException -> 0x0141 }
  87. java.lang.String r4 = "doProbePrinter() return "
  88. r2.append(r4) // Catch:{ InterruptedException -> 0x0141 }
  89. r2.append(r1) // Catch:{ InterruptedException -> 0x0141 }
  90. java.lang.String r1 = r2.toString() // Catch:{ InterruptedException -> 0x0141 }
  91. epson.print.Util.EPLog.e((java.lang.String) r0, (java.lang.String) r1) // Catch:{ InterruptedException -> 0x0141 }
  92. goto L_0x0142
  93. L_0x0063:
  94. epson.print.screen.PaperSourceInfo r1 = epson.print.screen.PaperSourceInfo.this // Catch:{ InterruptedException -> 0x0141 }
  95. com.epson.mobilephone.common.maintain2.MaintainPrinter2 r1 = r1.mPrinter // Catch:{ InterruptedException -> 0x0141 }
  96. int r1 = r1.doSetPrinter() // Catch:{ InterruptedException -> 0x0141 }
  97. if (r1 == 0) goto L_0x008b
  98. goto L_0x0142
  99. L_0x0071:
  100. java.lang.String r7 = "PaperSourceInfo"
  101. java.lang.StringBuilder r8 = new java.lang.StringBuilder // Catch:{ InterruptedException -> 0x0141 }
  102. r8.<init>() // Catch:{ InterruptedException -> 0x0141 }
  103. java.lang.String r9 = "doProbePrinter() return "
  104. r8.append(r9) // Catch:{ InterruptedException -> 0x0141 }
  105. r8.append(r1) // Catch:{ InterruptedException -> 0x0141 }
  106. java.lang.String r1 = r8.toString() // Catch:{ InterruptedException -> 0x0141 }
  107. epson.print.Util.EPLog.i(r7, r1) // Catch:{ InterruptedException -> 0x0141 }
  108. java.lang.Thread.sleep(r5) // Catch:{ InterruptedException -> 0x0141 }
  109. goto L_0x0025
  110. L_0x008b:
  111. boolean r1 = r12.isCancelled() // Catch:{ InterruptedException -> 0x0141 }
  112. if (r1 != 0) goto L_0x0142
  113. epson.print.screen.PaperSourceInfo r1 = epson.print.screen.PaperSourceInfo.this // Catch:{ InterruptedException -> 0x0141 }
  114. com.epson.mobilephone.common.maintain2.MaintainPrinter2 r1 = r1.mPrinter // Catch:{ InterruptedException -> 0x0141 }
  115. int[] r1 = r1.getPaperInfo() // Catch:{ InterruptedException -> 0x0141 }
  116. if (r1 != 0) goto L_0x00a6
  117. java.lang.String r0 = "PaperSourceInfo"
  118. java.lang.String r1 = "getPaperInfo() return null"
  119. epson.print.Util.EPLog.e((java.lang.String) r0, (java.lang.String) r1) // Catch:{ InterruptedException -> 0x0141 }
  120. goto L_0x0142
  121. L_0x00a6:
  122. r4 = r1[r0] // Catch:{ InterruptedException -> 0x0141 }
  123. r7 = -1100(0xfffffffffffffbb4, float:NaN)
  124. if (r4 == r7) goto L_0x0124
  125. if (r4 == 0) goto L_0x00c8
  126. java.lang.String r2 = "PaperSourceInfo"
  127. java.lang.StringBuilder r4 = new java.lang.StringBuilder // Catch:{ InterruptedException -> 0x0141 }
  128. r4.<init>() // Catch:{ InterruptedException -> 0x0141 }
  129. java.lang.String r5 = "getPaperInfo() return "
  130. r4.append(r5) // Catch:{ InterruptedException -> 0x0141 }
  131. r0 = r1[r0] // Catch:{ InterruptedException -> 0x0141 }
  132. r4.append(r0) // Catch:{ InterruptedException -> 0x0141 }
  133. java.lang.String r0 = r4.toString() // Catch:{ InterruptedException -> 0x0141 }
  134. epson.print.Util.EPLog.e((java.lang.String) r2, (java.lang.String) r0) // Catch:{ InterruptedException -> 0x0141 }
  135. goto L_0x0142
  136. L_0x00c8:
  137. r4 = r1[r2] // Catch:{ InterruptedException -> 0x0141 }
  138. java.lang.String r7 = "PaperSourceInfo"
  139. java.lang.StringBuilder r8 = new java.lang.StringBuilder // Catch:{ InterruptedException -> 0x0141 }
  140. r8.<init>() // Catch:{ InterruptedException -> 0x0141 }
  141. java.lang.String r9 = "getPaperInfo() number = "
  142. r8.append(r9) // Catch:{ InterruptedException -> 0x0141 }
  143. r9 = r1[r2] // Catch:{ InterruptedException -> 0x0141 }
  144. r8.append(r9) // Catch:{ InterruptedException -> 0x0141 }
  145. java.lang.String r8 = r8.toString() // Catch:{ InterruptedException -> 0x0141 }
  146. epson.print.Util.EPLog.i(r7, r8) // Catch:{ InterruptedException -> 0x0141 }
  147. if (r4 >= r2) goto L_0x00e5
  148. goto L_0x0142
  149. L_0x00e5:
  150. java.util.ArrayList r7 = new java.util.ArrayList // Catch:{ InterruptedException -> 0x0141 }
  151. r7.<init>() // Catch:{ InterruptedException -> 0x0141 }
  152. r8 = 0
  153. L_0x00eb:
  154. if (r8 >= r4) goto L_0x010c
  155. epson.print.screen.PaperSourceSetting r9 = new epson.print.screen.PaperSourceSetting // Catch:{ InterruptedException -> 0x0141 }
  156. r9.<init>() // Catch:{ InterruptedException -> 0x0141 }
  157. int r10 = r8 * 3
  158. int r11 = r10 + 2
  159. r11 = r1[r11] // Catch:{ InterruptedException -> 0x0141 }
  160. r9.paperSource = r11 // Catch:{ InterruptedException -> 0x0141 }
  161. int r11 = r10 + 3
  162. r11 = r1[r11] // Catch:{ InterruptedException -> 0x0141 }
  163. r9.paperSizeId = r11 // Catch:{ InterruptedException -> 0x0141 }
  164. int r10 = r10 + 4
  165. r10 = r1[r10] // Catch:{ InterruptedException -> 0x0141 }
  166. r9.paperTypeId = r10 // Catch:{ InterruptedException -> 0x0141 }
  167. r7.add(r9) // Catch:{ InterruptedException -> 0x0141 }
  168. int r8 = r8 + 1
  169. goto L_0x00eb
  170. L_0x010c:
  171. android.os.Bundle r1 = new android.os.Bundle // Catch:{ InterruptedException -> 0x0141 }
  172. r1.<init>() // Catch:{ InterruptedException -> 0x0141 }
  173. java.lang.String r4 = "PAPERSOURCEINFO"
  174. r1.putParcelableArrayList(r4, r7) // Catch:{ InterruptedException -> 0x0141 }
  175. android.os.Message r4 = new android.os.Message // Catch:{ InterruptedException -> 0x0141 }
  176. r4.<init>() // Catch:{ InterruptedException -> 0x0141 }
  177. r4.what = r3 // Catch:{ InterruptedException -> 0x0141 }
  178. r4.setData(r1) // Catch:{ InterruptedException -> 0x0141 }
  179. r13.sendMessage(r4) // Catch:{ InterruptedException -> 0x0141 }
  180. goto L_0x013c
  181. L_0x0124:
  182. java.lang.String r4 = "PaperSourceInfo"
  183. java.lang.StringBuilder r7 = new java.lang.StringBuilder // Catch:{ InterruptedException -> 0x0141 }
  184. r7.<init>() // Catch:{ InterruptedException -> 0x0141 }
  185. java.lang.String r8 = "getPaperInfo() return "
  186. r7.append(r8) // Catch:{ InterruptedException -> 0x0141 }
  187. r1 = r1[r0] // Catch:{ InterruptedException -> 0x0141 }
  188. r7.append(r1) // Catch:{ InterruptedException -> 0x0141 }
  189. java.lang.String r1 = r7.toString() // Catch:{ InterruptedException -> 0x0141 }
  190. epson.print.Util.EPLog.i(r4, r1) // Catch:{ InterruptedException -> 0x0141 }
  191. L_0x013c:
  192. java.lang.Thread.sleep(r5) // Catch:{ InterruptedException -> 0x0141 }
  193. goto L_0x008b
  194. L_0x0141:
  195. L_0x0142:
  196. boolean r0 = r12.isCancelled()
  197. r1 = 0
  198. if (r0 != 0) goto L_0x0160
  199. android.os.Bundle r0 = new android.os.Bundle
  200. r0.<init>()
  201. java.lang.String r2 = "PAPERSOURCEINFO"
  202. r0.putParcelableArrayList(r2, r1)
  203. android.os.Message r2 = new android.os.Message
  204. r2.<init>()
  205. r2.what = r3
  206. r2.setData(r0)
  207. r13.sendMessage(r2)
  208. L_0x0160:
  209. return r1
  210. */
  211. throw new UnsupportedOperationException("Method not decompiled: epson.print.screen.PaperSourceInfo.PaparInfoTask.doInBackground(java.lang.Object[]):java.lang.Void");
  212. }
  213. }
  214. public boolean checkPaperMissmatch(PrintSetting printSetting, ArrayList<PaperSourceSetting> arrayList) {
  215. for (int i = 0; i < arrayList.size(); i++) {
  216. if (printSetting.paperSourceValue == arrayList.get(i).paperSource && (printSetting.paperSizeValue != arrayList.get(i).paperSizeId || printSetting.paperTypeValue != arrayList.get(i).paperTypeId)) {
  217. return true;
  218. }
  219. }
  220. return false;
  221. }
  222. }