/*     */ package com.seuic.scanner;
/*     */ 
/*     */ import android.content.Context;
/*     */ import android.os.Build;
/*     */ import android.text.TextUtils;
/*     */ import android.util.Log;
/*     */ import android.util.SparseIntArray;
/*     */ import com.zebra.adc.decoder.compatible.BarCodeReader;
/*     */ import java.io.UnsupportedEncodingException;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class SE4500Scanner
/*     */   extends Scanner
/*     */   implements BarCodeReader.DecodeCallback
/*     */ {
/*  20 */   private final String TYPE_NOT_FOUND = "Unknown Type";
/*  21 */   private final int[] TYPE_LENGTH = new int[] { 1, 3 };
/*     */ 
/*     */   
/*     */   static {
/*  25 */     System.loadLibrary("IAL");
/*  26 */     System.loadLibrary("SDL");
/*     */     
/*  28 */     if (Build.VERSION.SDK_INT >= 19) {
/*  29 */       System.loadLibrary("barcodereader44");
/*     */     }
/*  31 */     else if (Build.VERSION.SDK_INT >= 18) {
/*  32 */       System.loadLibrary("barcodereader43");
/*     */     } else {
/*  34 */       System.loadLibrary("barcodereader");
/*     */     } 
/*     */ 
/*     */     
/*  38 */     paramArray.put(257, 1);
/*  39 */     paramArray.put(258, 2);
/*  40 */     paramArray.put(259, 12);
/*  41 */     paramArray.put(260, 4);
/*  42 */     paramArray.put(261, 3);
/*  43 */     paramArray.put(262, 83);
/*  44 */     paramArray.put(263, 40);
/*  45 */     paramArray.put(264, 41);
/*  46 */     paramArray.put(265, 42);
/*  47 */     paramArray.put(266, 34);
/*  48 */     paramArray.put(267, 35);
/*  49 */     paramArray.put(268, 36);
/*  50 */     paramArray.put(269, 37);
/*  51 */     paramArray.put(270, 38);
/*  52 */     paramArray.put(271, 39);
/*  53 */     paramArray.put(272, 85);
/*     */ 
/*     */     
/*  56 */     paramArray.put(289, 8);
/*  57 */     paramArray.put(290, 209);
/*  58 */     paramArray.put(291, 210);
/*  59 */     paramArray.put(292, 84);
/*  60 */     paramArray.put(293, 14);
/*     */ 
/*     */     
/*  63 */     paramArray.put(305, 0);
/*  64 */     paramArray.put(306, 13);
/*  65 */     paramArray.put(307, 17);
/*  66 */     paramArray.put(308, 86);
/*  67 */     paramArray.put(309, 231);
/*  68 */     paramArray.put(310, 18);
/*  69 */     paramArray.put(311, 19);
/*  70 */     paramArray.put(312, 43);
/*  71 */     paramArray.put(313, 48);
/*     */ 
/*     */     
/*  74 */     paramArray.put(321, 9);
/*  75 */     paramArray.put(322, 26);
/*  76 */     paramArray.put(323, 27);
/*     */ 
/*     */     
/*  79 */     paramArray.put(337, 10);
/*  80 */     paramArray.put(338, 28);
/*  81 */     paramArray.put(339, 29);
/*  82 */     paramArray.put(340, 52);
/*  83 */     paramArray.put(341, 47);
/*     */ 
/*     */     
/*  86 */     paramArray.put(353, 6);
/*  87 */     paramArray.put(354, 22);
/*  88 */     paramArray.put(355, 23);
/*     */ 
/*     */     
/*  91 */     paramArray.put(369, 5);
/*  92 */     paramArray.put(370, 20);
/*  93 */     paramArray.put(371, 21);
/*     */ 
/*     */     
/*  96 */     paramArray.put(401, 7);
/*  97 */     paramArray.put(402, 24);
/*  98 */     paramArray.put(403, 25);
/*     */ 
/*     */     
/* 101 */     paramArray.put(513, 11);
/* 102 */     paramArray.put(514, 30);
/* 103 */     paramArray.put(515, 31);
/*     */ 
/*     */     
/* 106 */     paramArray.put(385, 408);
/*     */ 
/*     */     
/* 109 */     paramArray.put(593, 618);
/* 110 */     paramArray.put(594, 619);
/* 111 */     paramArray.put(595, 620);
/*     */ 
/*     */     
/* 114 */     paramArray.put(609, 89);
/* 115 */     paramArray.put(610, 90);
/* 116 */     paramArray.put(617, 95);
/* 117 */     paramArray.put(618, 95);
/* 118 */     paramArray.put(611, 91);
/* 119 */     paramArray.put(612, 290);
/* 120 */     paramArray.put(613, 291);
/* 121 */     paramArray.put(616, 326);
/* 122 */     paramArray.put(615, 592);
/* 123 */     paramArray.put(614, 611);
/*     */ 
/*     */     
/* 126 */     paramArray.put(625, 581);
/*     */ 
/*     */     
/* 129 */     paramArray.put(833, 341);
/* 130 */     paramArray.put(834, 342);
/* 131 */     paramArray.put(835, 371);
/*     */ 
/*     */     
/* 134 */     paramArray.put(705, 15);
/*     */ 
/*     */     
/* 137 */     paramArray.put(721, 227);
/*     */ 
/*     */     
/* 140 */     paramArray.put(737, 294);
/*     */ 
/*     */     
/* 143 */     paramArray.put(753, 574);
/* 144 */     paramArray.put(756, 589);
/*     */ 
/*     */     
/* 147 */     paramArray.put(545, 293);
/* 148 */     paramArray.put(548, 587);
/* 149 */     paramArray.put(549, 573);
/*     */ 
/*     */     
/* 152 */     paramArray.put(561, 292);
/* 153 */     paramArray.put(564, 588);
/* 154 */     paramArray.put(565, 537);
/*     */     
/* 156 */     paramArray.put(8, 716);
/* 157 */     paramArray.put(849, 45);
/*     */     
/* 159 */     paramArray.put(9, 764);
/*     */   }
/* 161 */   private static Map<String, String> mMapType = new HashMap<String, String>(); static {
/* 162 */     mMapType.put("A", "UPC-A/UPC-E/UPC-E1/EAN-8/EAN-13");
/* 163 */     mMapType.put("B", "Code 39/Code 32");
/* 164 */     mMapType.put("C", "Codabar");
/* 165 */     mMapType.put("D", "Code 128/ISBT 128/ISBT 128 Concatenated");
/* 166 */     mMapType.put("E", "Code 93");
/* 167 */     mMapType.put("F", "Interleaved 2 of 5");
/* 168 */     mMapType.put("G", "Discrete 2 of 5/Discrete 2 of 5 IATA");
/* 169 */     mMapType.put("H", "Code 11");
/* 170 */     mMapType.put("J", "MSI");
/* 171 */     mMapType.put("K", "GS1-128");
/* 172 */     mMapType.put("L", "Bookland EAN");
/* 173 */     mMapType.put("M", "Trioptic Code 39");
/* 174 */     mMapType.put("N", "Coupon Code");
/* 175 */     mMapType.put("R", "GS1 DataBar Family");
/* 176 */     mMapType.put("S", "Matrix 2 of 5");
/* 177 */     mMapType.put("T", "UCC Composite/TLC 39");
/* 178 */     mMapType.put("U", "Chinese 2 of 5");
/* 179 */     mMapType.put("V", "Korean 3 of 5");
/* 180 */     mMapType.put("X", "ISSN EAN/PDF417/Macro PDF417/Micro PDF417");
/* 181 */     mMapType.put("z", "Aztec/Aztec Rune");
/* 182 */     mMapType.put("P00", "Data Matrix");
/* 183 */     mMapType.put("P01", "QR Code/MicroQR");
/* 184 */     mMapType.put("P02", "Maxicode");
/* 185 */     mMapType.put("P03", "US Postnet");
/* 186 */     mMapType.put("P04", "US Planet");
/* 187 */     mMapType.put("P05", "Japan Postal");
/* 188 */     mMapType.put("P06", "UK Postal");
/* 189 */     mMapType.put("P08", "Netherlands KIX Code");
/* 190 */     mMapType.put("P09", "Australia Post");
/* 191 */     mMapType.put("P0A", "USPS 4CB/One Code/Intelligent Mail");
/* 192 */     mMapType.put("P0B", "UPU FICS Postal");
/* 193 */     mMapType.put("P0X", "Signature Capture");
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/* 202 */   private Boolean released = new Boolean(true);
/* 203 */   private static int decCount = 0; private DecodeCallback mDecodeCallBack;
/*     */   
/*     */   public SE4500Scanner(Context context) {
/* 206 */     super(context);
/*     */   }
/*     */   private DecodeInfoCallBack mInfoCallBack; private BarCodeReader mBcr;
/*     */   
/*     */   public boolean open() {
/* 211 */     synchronized (this.released) {
/* 212 */       if (!this.released.booleanValue()) {
/* 213 */         return true;
/*     */       }
/*     */       
/* 216 */       if (Build.VERSION.SDK_INT >= 18) {
/* 217 */         this.mBcr = BarCodeReader.open(this.mContext.getApplicationContext());
/*     */       } else {
/* 219 */         this.mBcr = BarCodeReader.open();
/*     */       } 
/*     */       
/* 222 */       if (this.mBcr == null) {
/* 223 */         return false;
/*     */       }
/*     */       
/* 226 */       this.mBcr.setDecodeCallback(this);
/* 227 */       this.mBcr.setParameter(45, 2);
/* 228 */       this.released = Boolean.valueOf(false);
/*     */     } 
/* 230 */     return true;
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public void close() {
/* 236 */     synchronized (this.released) {
/*     */       
/* 238 */       if (this.released.booleanValue()) {
/*     */         return;
/*     */       }
/*     */       
/* 242 */       if (this.mBcr != null) {
/* 243 */         this.mBcr.stopDecode();
/* 244 */         if (!this.released.booleanValue())
/* 245 */           this.mBcr.release(); 
/* 246 */         this.released = Boolean.valueOf(true);
/*     */       } 
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/*     */   public void startScan() {
/* 253 */     synchronized (this) {
/* 254 */       if (this.mBcr.scanFinished.booleanValue()) {
/* 255 */         Log.i("SE4500", "Start scan finished " + this.mBcr.scanFinished);
/* 256 */         this.mBcr.scanFinished = Boolean.valueOf(false);
/* 257 */         this.mBcr.startDecode();
/*     */       } 
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/*     */   public void stopScan() {
/* 264 */     this.mBcr.stopDecode();
/* 265 */     Log.i("SE4500", "Stop scan finished ");
/*     */     try {
/* 267 */       Thread.sleep(50L);
/* 268 */     } catch (InterruptedException e) {
/* 269 */       e.printStackTrace();
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/*     */   public boolean setParams(int num, int value) {
/* 275 */     if (paramArray.get(num, -1) == -1 && num != 801) {
/* 276 */       return false;
/*     */     }
/*     */ 
/*     */     
/* 280 */     if (num == 801) {
/* 281 */       setDefault();
/* 282 */       return true;
/*     */     } 
/*     */     
/* 285 */     if (this.mBcr.setParameter(paramArray.get(num), value) == 0) {
/* 286 */       return true;
/*     */     }
/*     */     
/* 289 */     return false;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private void setDefault() {
/* 297 */     close();
/*     */     
/* 299 */     open();
/*     */   }
/*     */ 
/*     */   
/*     */   public int getParams(int num) {
/* 304 */     if (paramArray.get(num, -1) == -1) {
/* 305 */       return -1;
/*     */     }
/*     */     
/* 308 */     return this.mBcr.getNumParameter(paramArray.get(num));
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public void onDecodeComplete(int symbology, int length, byte[] data, BarCodeReader reader) {
/* 314 */     synchronized (this) {
/*     */       
/* 316 */       if (length == -3) {
/* 317 */         decCount = symbology;
/*     */       } else {
/* 319 */         this.mBcr.scanFinished = Boolean.valueOf(true);
/*     */       } 
/* 321 */       Log.i("SE4500", "Decode complete finished " + this.mBcr.scanFinished);
/* 322 */       if (length > 0) {
/* 323 */         synchronized (this.released) {
/* 324 */           if (!this.released.booleanValue()) {
/* 325 */             this.mBcr.stopDecode();
/*     */           }
/*     */         } 
/*     */         
/* 329 */         ScanLed.setLed(1);
/* 330 */         if (symbology == 153) {
/*     */           
/* 332 */           symbology = data[0];
/* 333 */           int n = data[1];
/* 334 */           int s = 2;
/* 335 */           int d = 0;
/* 336 */           int len = 0;
/* 337 */           byte[] d99 = new byte[data.length];
/* 338 */           for (int i = 0; i < n; i++) {
/* 339 */             s += 2;
/* 340 */             len = data[s++];
/* 341 */             System.arraycopy(data, s, d99, d, len);
/* 342 */             s += len;
/* 343 */             d += len;
/*     */           } 
/* 345 */           d99[d] = 0;
/* 346 */           data = d99;
/*     */         } 
/*     */         
/* 349 */         String barcode = null;
/*     */         try {
/* 351 */           barcode = (new String(data, StringUtils.guessEncoding(data))).trim();
/* 352 */         } catch (UnsupportedEncodingException e1) {
/* 353 */           e1.printStackTrace();
/*     */         } 
/*     */         
/* 356 */         DecodeInfo info = getDecodeInfo(barcode);
/* 357 */         if (this.mDecodeCallBack != null) {
/* 358 */           this.mDecodeCallBack.onDecodeComplete(info.barcode);
/*     */         }
/*     */         
/* 361 */         if (this.mInfoCallBack != null) {
/* 362 */           this.mInfoCallBack.onDecodeComplete(info);
/*     */         }
/*     */       }
/*     */       else {
/*     */         
/* 367 */         switch (length) {
/*     */         
/*     */         } 
/*     */       } 
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private DecodeInfo getDecodeInfo(String barcode) {
/* 379 */     DecodeInfo info = new DecodeInfo();
/* 380 */     String type = null;
/* 381 */     int typelength = 0;
/* 382 */     if (barcode.length() > this.TYPE_LENGTH[0] && !TextUtils.isEmpty(type = mMapType.get(barcode.substring(0, this.TYPE_LENGTH[0])))) {
/* 383 */       info.codetype = type;
/* 384 */       typelength = this.TYPE_LENGTH[0];
/*     */     }
/* 386 */     else if (barcode.length() > this.TYPE_LENGTH[1] && !TextUtils.isEmpty(type = mMapType.get(barcode.substring(0, this.TYPE_LENGTH[1])))) {
/* 387 */       info.codetype = type;
/* 388 */       typelength = this.TYPE_LENGTH[1];
/*     */     } else {
/* 390 */       info.codetype = "Unknown Type";
/*     */     } 
/*     */     
/* 393 */     info.barcode = barcode.substring(typelength);
/* 394 */     info.length = info.barcode.length();
/* 395 */     return info;
/*     */   }
/*     */ 
/*     */   
/*     */   public void onEvent(int event, int info, byte[] data, BarCodeReader reader) {
/* 400 */     Log.i("SE4500", "onEvent " + event);
/* 401 */     switch (event) {
/*     */       
/*     */       case 7:
/*     */         
/*     */         try {
/*     */ 
/*     */           
/* 408 */           Thread.sleep(50L);
/* 409 */         } catch (InterruptedException e) {
/* 410 */           e.printStackTrace();
/*     */         } 
/*     */         break;
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public void setDecodeCallBack(DecodeCallback callBack) {
/* 420 */     this.mDecodeCallBack = callBack;
/*     */   }
/*     */ 
/*     */   
/*     */   public SparseIntArray getAllParams() {
/* 425 */     return paramArray;
/*     */   }
/*     */ 
/*     */   
/*     */   public void setDecodeInfoCallBack(DecodeInfoCallBack callback) {
/* 430 */     this.mInfoCallBack = callback;
/*     */   }
/*     */ }


/* Location:              E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\SE4500Scanner.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */