I2ScanParamManager.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. package epson.scan.i2lib;
  2. import android.content.Context;
  3. import android.support.annotation.NonNull;
  4. import android.support.annotation.Nullable;
  5. import android.support.annotation.VisibleForTesting;
  6. import com.epson.lib.escani2.EscanI2Lib;
  7. import com.epson.lib.escani2.I2LibScannerInfoAndCapability;
  8. import com.epson.lib.escani2.ScanI2Params;
  9. import com.epson.lib.escani2.ScanSize;
  10. import java.io.File;
  11. import java.io.IOException;
  12. public class I2ScanParamManager {
  13. static final int DEFAULT_RESOLUTION = 150;
  14. private static final String I2SCAN_ALL_INFO_FILE_NAME = "i2_all_info";
  15. private static final String I2SCAN_PARAM_FILE_NAME = "i2_scan_params.bin";
  16. private static final String TAG = "I2ScanParamManager";
  17. private static I2ScanParamManager sI2ScanParamManager;
  18. public static synchronized I2ScanParamManager getInstance() {
  19. I2ScanParamManager i2ScanParamManager;
  20. synchronized (I2ScanParamManager.class) {
  21. if (sI2ScanParamManager == null) {
  22. sI2ScanParamManager = new I2ScanParamManager();
  23. }
  24. i2ScanParamManager = sI2ScanParamManager;
  25. }
  26. return i2ScanParamManager;
  27. }
  28. @VisibleForTesting
  29. protected static void replaceInstance(@Nullable I2ScanParamManager i2ScanParamManager) {
  30. sI2ScanParamManager = i2ScanParamManager;
  31. }
  32. @VisibleForTesting
  33. protected I2ScanParamManager() {
  34. }
  35. public static void saveParams(@NonNull Context context, @NonNull ScanI2Params scanI2Params) throws IOException {
  36. getInstance().saveParamsNonStatic(context, scanI2Params);
  37. }
  38. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v1, resolved type: java.io.ObjectOutputStream} */
  39. /* JADX WARNING: type inference failed for: r0v0 */
  40. /* JADX WARNING: type inference failed for: r0v2 */
  41. /* JADX WARNING: type inference failed for: r0v3, types: [java.lang.Throwable] */
  42. /* JADX WARNING: type inference failed for: r0v5 */
  43. /* access modifiers changed from: protected */
  44. /* JADX WARNING: Multi-variable type inference failed */
  45. /* JADX WARNING: Removed duplicated region for block: B:15:0x001f A[SYNTHETIC, Splitter:B:15:0x001f] */
  46. @android.support.annotation.VisibleForTesting
  47. /* Code decompiled incorrectly, please refer to instructions dump. */
  48. public void saveParamsNonStatic(@android.support.annotation.NonNull android.content.Context r5, @android.support.annotation.NonNull com.epson.lib.escani2.ScanI2Params r6) throws java.io.IOException {
  49. /*
  50. r4 = this;
  51. r0 = 0
  52. java.io.ObjectOutputStream r1 = new java.io.ObjectOutputStream // Catch:{ all -> 0x001c }
  53. java.lang.String r2 = "i2_scan_params.bin"
  54. r3 = 0
  55. java.io.FileOutputStream r5 = r5.openFileOutput(r2, r3) // Catch:{ all -> 0x001c }
  56. r1.<init>(r5) // Catch:{ all -> 0x001c }
  57. r1.writeObject(r6) // Catch:{ all -> 0x0019 }
  58. r1.close() // Catch:{ IOException -> 0x0014 }
  59. goto L_0x0015
  60. L_0x0014:
  61. r0 = move-exception
  62. L_0x0015:
  63. if (r0 != 0) goto L_0x0018
  64. return
  65. L_0x0018:
  66. throw r0
  67. L_0x0019:
  68. r5 = move-exception
  69. r0 = r1
  70. goto L_0x001d
  71. L_0x001c:
  72. r5 = move-exception
  73. L_0x001d:
  74. if (r0 == 0) goto L_0x0022
  75. r0.close() // Catch:{ IOException -> 0x0022 }
  76. L_0x0022:
  77. throw r5
  78. */
  79. throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.saveParamsNonStatic(android.content.Context, com.epson.lib.escani2.ScanI2Params):void");
  80. }
  81. @NonNull
  82. public static ScanI2Params loadScanI2Params(@NonNull Context context) {
  83. return getInstance().loadScanI2ParamsNonStatic(context);
  84. }
  85. /* access modifiers changed from: protected */
  86. /* JADX WARNING: Exception block dominator not found, dom blocks: [B:16:0x001f, B:23:0x0029] */
  87. /* JADX WARNING: Missing exception handler attribute for start block: B:16:0x001f */
  88. /* JADX WARNING: Missing exception handler attribute for start block: B:23:0x0029 */
  89. /* JADX WARNING: Removed duplicated region for block: B:19:0x0025 A[SYNTHETIC, Splitter:B:19:0x0025] */
  90. /* JADX WARNING: Removed duplicated region for block: B:26:0x002f A[SYNTHETIC, Splitter:B:26:0x002f] */
  91. /* JADX WARNING: Removed duplicated region for block: B:31:0x0035 A[SYNTHETIC, Splitter:B:31:0x0035] */
  92. /* JADX WARNING: Unknown top exception splitter block from list: {B:23:0x0029=Splitter:B:23:0x0029, B:16:0x001f=Splitter:B:16:0x001f} */
  93. @android.support.annotation.VisibleForTesting
  94. @android.support.annotation.NonNull
  95. /* Code decompiled incorrectly, please refer to instructions dump. */
  96. public com.epson.lib.escani2.ScanI2Params loadScanI2ParamsNonStatic(@android.support.annotation.NonNull android.content.Context r4) {
  97. /*
  98. r3 = this;
  99. r0 = 0
  100. java.io.ObjectInputStream r1 = new java.io.ObjectInputStream // Catch:{ FileNotFoundException -> 0x0029, IOException | ClassNotFoundException -> 0x001f }
  101. java.lang.String r2 = "i2_scan_params.bin"
  102. java.io.FileInputStream r4 = r4.openFileInput(r2) // Catch:{ FileNotFoundException -> 0x0029, IOException | ClassNotFoundException -> 0x001f }
  103. r1.<init>(r4) // Catch:{ FileNotFoundException -> 0x0029, IOException | ClassNotFoundException -> 0x001f }
  104. java.lang.Object r4 = r1.readObject() // Catch:{ FileNotFoundException -> 0x001b, IOException | ClassNotFoundException -> 0x0019, all -> 0x0016 }
  105. com.epson.lib.escani2.ScanI2Params r4 = (com.epson.lib.escani2.ScanI2Params) r4 // Catch:{ FileNotFoundException -> 0x001b, IOException | ClassNotFoundException -> 0x0019, all -> 0x0016 }
  106. r1.close() // Catch:{ IOException -> 0x0015 }
  107. L_0x0015:
  108. return r4
  109. L_0x0016:
  110. r4 = move-exception
  111. r0 = r1
  112. goto L_0x0033
  113. L_0x0019:
  114. r0 = r1
  115. goto L_0x001f
  116. L_0x001b:
  117. r0 = r1
  118. goto L_0x0029
  119. L_0x001d:
  120. r4 = move-exception
  121. goto L_0x0033
  122. L_0x001f:
  123. com.epson.lib.escani2.ScanI2Params r4 = getDefaultScanI2Params() // Catch:{ all -> 0x001d }
  124. if (r0 == 0) goto L_0x0028
  125. r0.close() // Catch:{ IOException -> 0x0028 }
  126. L_0x0028:
  127. return r4
  128. L_0x0029:
  129. com.epson.lib.escani2.ScanI2Params r4 = getDefaultScanI2Params() // Catch:{ all -> 0x001d }
  130. if (r0 == 0) goto L_0x0032
  131. r0.close() // Catch:{ IOException -> 0x0032 }
  132. L_0x0032:
  133. return r4
  134. L_0x0033:
  135. if (r0 == 0) goto L_0x0038
  136. r0.close() // Catch:{ IOException -> 0x0038 }
  137. L_0x0038:
  138. throw r4
  139. */
  140. throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.loadScanI2ParamsNonStatic(android.content.Context):com.epson.lib.escani2.ScanI2Params");
  141. }
  142. public static void deleteScanI2Params(@NonNull Context context) {
  143. getInstance().deleteAllInfoFileNonStatic(context);
  144. }
  145. /* access modifiers changed from: protected */
  146. @VisibleForTesting
  147. public void deleteScanI2ParamsNonStatic(@NonNull Context context) {
  148. File fileStreamPath = context.getFileStreamPath(I2SCAN_PARAM_FILE_NAME);
  149. if (fileStreamPath.exists()) {
  150. fileStreamPath.delete();
  151. }
  152. }
  153. public static ScanI2Params getDefaultScanI2Params() {
  154. ScanI2Params scanI2Params = new ScanI2Params();
  155. scanI2Params.resolutionMain = 150;
  156. scanI2Params.resolutionSub = 150;
  157. scanI2Params.inputUnit = EscanI2Lib.InputUnit.ADF;
  158. scanI2Params.scanSize = ScanSize.getLocaleDefaultSize();
  159. scanI2Params.colorMode = EscanI2Lib.ColorMode.COLOR_24BIT;
  160. scanI2Params.userGamma = EscanI2Lib.Gamma.GAMMA_180;
  161. scanI2Params.autoCrop = EscanI2Lib.AutoCrop.FALSE;
  162. scanI2Params.autoSkew = EscanI2Lib.AutoSkew.FALSE;
  163. scanI2Params.lookupTableNo = 0;
  164. scanI2Params.duplex = false;
  165. scanI2Params.overScan = false;
  166. scanI2Params.density = 128;
  167. scanI2Params.densityChangeable = false;
  168. scanI2Params.doubleFeedLevel = EscanI2Lib.DoubleFeedLevel.LEVEL_NONE;
  169. scanI2Params.maxScanSheets = 30;
  170. scanI2Params.maxWriteSheets = 30;
  171. scanI2Params.qualityHW = 90;
  172. scanI2Params.qualitySW = 90;
  173. return scanI2Params;
  174. }
  175. public static void updateScanSize(Context context, ScanSize scanSize) throws IOException {
  176. getInstance().updateScanSizeNonStatic(context, scanSize);
  177. }
  178. /* access modifiers changed from: protected */
  179. @VisibleForTesting
  180. public void updateScanSizeNonStatic(Context context, ScanSize scanSize) throws IOException {
  181. ScanI2Params loadScanI2Params = loadScanI2Params(context);
  182. loadScanI2Params.scanSize = scanSize;
  183. saveParams(context, loadScanI2Params);
  184. }
  185. public static void saveI2AllInfo(@NonNull Context context, I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability) throws IOException {
  186. getInstance().saveI2AllInfoNonStatic(context, i2LibScannerInfoAndCapability);
  187. }
  188. /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r0v1, resolved type: java.io.ObjectOutputStream} */
  189. /* JADX WARNING: type inference failed for: r0v0 */
  190. /* JADX WARNING: type inference failed for: r0v2 */
  191. /* JADX WARNING: type inference failed for: r0v3, types: [java.lang.Throwable] */
  192. /* JADX WARNING: type inference failed for: r0v5 */
  193. /* access modifiers changed from: protected */
  194. /* JADX WARNING: Multi-variable type inference failed */
  195. /* JADX WARNING: Removed duplicated region for block: B:15:0x001f A[SYNTHETIC, Splitter:B:15:0x001f] */
  196. @android.support.annotation.VisibleForTesting
  197. /* Code decompiled incorrectly, please refer to instructions dump. */
  198. public void saveI2AllInfoNonStatic(@android.support.annotation.NonNull android.content.Context r5, com.epson.lib.escani2.I2LibScannerInfoAndCapability r6) throws java.io.IOException {
  199. /*
  200. r4 = this;
  201. r0 = 0
  202. java.io.ObjectOutputStream r1 = new java.io.ObjectOutputStream // Catch:{ all -> 0x001c }
  203. java.lang.String r2 = "i2_all_info"
  204. r3 = 0
  205. java.io.FileOutputStream r5 = r5.openFileOutput(r2, r3) // Catch:{ all -> 0x001c }
  206. r1.<init>(r5) // Catch:{ all -> 0x001c }
  207. r1.writeObject(r6) // Catch:{ all -> 0x0019 }
  208. r1.close() // Catch:{ IOException -> 0x0014 }
  209. goto L_0x0015
  210. L_0x0014:
  211. r0 = move-exception
  212. L_0x0015:
  213. if (r0 != 0) goto L_0x0018
  214. return
  215. L_0x0018:
  216. throw r0
  217. L_0x0019:
  218. r5 = move-exception
  219. r0 = r1
  220. goto L_0x001d
  221. L_0x001c:
  222. r5 = move-exception
  223. L_0x001d:
  224. if (r0 == 0) goto L_0x0022
  225. r0.close() // Catch:{ IOException -> 0x0022 }
  226. L_0x0022:
  227. throw r5
  228. */
  229. throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.saveI2AllInfoNonStatic(android.content.Context, com.epson.lib.escani2.I2LibScannerInfoAndCapability):void");
  230. }
  231. @Nullable
  232. public static I2LibScannerInfoAndCapability loadI2AllInfo(@NonNull Context context) {
  233. return getInstance().loadI2AllInfoNonStatic(context);
  234. }
  235. /* access modifiers changed from: protected */
  236. /* JADX WARNING: Removed duplicated region for block: B:15:0x0021 A[SYNTHETIC, Splitter:B:15:0x0021] */
  237. /* JADX WARNING: Removed duplicated region for block: B:30:? A[RETURN, SYNTHETIC] */
  238. /* JADX WARNING: Removed duplicated region for block: B:31:? A[RETURN, SYNTHETIC] */
  239. @android.support.annotation.Nullable
  240. @android.support.annotation.VisibleForTesting
  241. /* Code decompiled incorrectly, please refer to instructions dump. */
  242. public com.epson.lib.escani2.I2LibScannerInfoAndCapability loadI2AllInfoNonStatic(@android.support.annotation.NonNull android.content.Context r4) {
  243. /*
  244. r3 = this;
  245. r0 = 0
  246. java.io.ObjectInputStream r1 = new java.io.ObjectInputStream // Catch:{ FileNotFoundException -> 0x002c, IOException | ClassNotFoundException -> 0x0025, all -> 0x001e }
  247. java.lang.String r2 = "i2_all_info"
  248. java.io.FileInputStream r4 = r4.openFileInput(r2) // Catch:{ FileNotFoundException -> 0x002c, IOException | ClassNotFoundException -> 0x0025, all -> 0x001e }
  249. r1.<init>(r4) // Catch:{ FileNotFoundException -> 0x002c, IOException | ClassNotFoundException -> 0x0025, all -> 0x001e }
  250. java.lang.Object r4 = r1.readObject() // Catch:{ FileNotFoundException -> 0x001c, IOException | ClassNotFoundException -> 0x001a, all -> 0x0017 }
  251. com.epson.lib.escani2.I2LibScannerInfoAndCapability r4 = (com.epson.lib.escani2.I2LibScannerInfoAndCapability) r4 // Catch:{ FileNotFoundException -> 0x001c, IOException | ClassNotFoundException -> 0x001a, all -> 0x0017 }
  252. r1.close() // Catch:{ IOException -> 0x0015 }
  253. L_0x0015:
  254. r0 = r4
  255. goto L_0x0030
  256. L_0x0017:
  257. r4 = move-exception
  258. r0 = r1
  259. goto L_0x001f
  260. L_0x001a:
  261. goto L_0x0026
  262. L_0x001c:
  263. goto L_0x002d
  264. L_0x001e:
  265. r4 = move-exception
  266. L_0x001f:
  267. if (r0 == 0) goto L_0x0024
  268. r0.close() // Catch:{ IOException -> 0x0024 }
  269. L_0x0024:
  270. throw r4
  271. L_0x0025:
  272. r1 = r0
  273. L_0x0026:
  274. if (r1 == 0) goto L_0x0030
  275. L_0x0028:
  276. r1.close() // Catch:{ IOException -> 0x0030 }
  277. goto L_0x0030
  278. L_0x002c:
  279. r1 = r0
  280. L_0x002d:
  281. if (r1 == 0) goto L_0x0030
  282. goto L_0x0028
  283. L_0x0030:
  284. return r0
  285. */
  286. throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.loadI2AllInfoNonStatic(android.content.Context):com.epson.lib.escani2.I2LibScannerInfoAndCapability");
  287. }
  288. public static void deleteAllInfoFile(@NonNull Context context) {
  289. getInstance().deleteAllInfoFileNonStatic(context);
  290. }
  291. /* access modifiers changed from: protected */
  292. @VisibleForTesting
  293. public void deleteAllInfoFileNonStatic(@NonNull Context context) {
  294. File fileStreamPath = context.getFileStreamPath(I2SCAN_ALL_INFO_FILE_NAME);
  295. if (fileStreamPath.exists()) {
  296. fileStreamPath.delete();
  297. }
  298. }
  299. }