/*     */ package com.seuic.scanner;
/*     */ 
/*     */ import android.content.Context;
/*     */ import android.os.Handler;
/*     */ import android.os.Message;
/*     */ import android.util.Log;
/*     */ import android.util.SparseIntArray;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ class Scanner1D
/*     */   extends Scanner
/*     */ {
/*     */   private static final String LOG_TAG = "Scanner1D";
/*     */   private static DecodeCallback callback;
/*     */   private static DecodeInfoCallBack infoCallBack;
/*     */   private Thread mThread;
/*     */   public boolean isOpened = false;
/*     */   protected int laser_time;
/*     */   
/*     */   static {
/*  45 */     System.loadLibrary("Scanner1D");
/*     */     
/*  47 */     paramArray.put(1, 1);
/*  48 */     paramArray.put(3, 3);
/*  49 */     paramArray.put(4, 4);
/*  50 */     paramArray.put(6, 5);
/*     */     
/*  52 */     paramArray.put(257, 145);
/*  53 */     paramArray.put(258, 146);
/*  54 */     paramArray.put(259, 147);
/*  55 */     paramArray.put(260, 148);
/*  56 */     paramArray.put(261, 149);
/*  57 */     paramArray.put(262, 150);
/*  58 */     paramArray.put(263, 151);
/*  59 */     paramArray.put(264, 152);
/*  60 */     paramArray.put(265, 153);
/*  61 */     paramArray.put(266, 154);
/*  62 */     paramArray.put(267, 155);
/*  63 */     paramArray.put(268, 156);
/*  64 */     paramArray.put(269, 157);
/*  65 */     paramArray.put(270, 158);
/*  66 */     paramArray.put(272, 159);
/*     */     
/*  68 */     paramArray.put(289, 273);
/*  69 */     paramArray.put(292, 275);
/*  70 */     paramArray.put(293, 274);
/*     */     
/*  72 */     paramArray.put(305, 289);
/*  73 */     paramArray.put(306, 290);
/*  74 */     paramArray.put(307, 291);
/*  75 */     paramArray.put(308, 292);
/*  76 */     paramArray.put(309, 293);
/*  77 */     paramArray.put(310, 294);
/*  78 */     paramArray.put(311, 295);
/*  79 */     paramArray.put(312, 296);
/*  80 */     paramArray.put(313, 297);
/*     */     
/*  82 */     paramArray.put(321, 305);
/*  83 */     paramArray.put(322, 306);
/*  84 */     paramArray.put(323, 307);
/*     */     
/*  86 */     paramArray.put(337, 321);
/*  87 */     paramArray.put(338, 322);
/*  88 */     paramArray.put(339, 323);
/*  89 */     paramArray.put(340, 324);
/*  90 */     paramArray.put(341, 325);
/*     */     
/*  92 */     paramArray.put(353, 337);
/*  93 */     paramArray.put(354, 338);
/*  94 */     paramArray.put(355, 339);
/*     */     
/*  96 */     paramArray.put(513, 353);
/*  97 */     paramArray.put(514, 354);
/*  98 */     paramArray.put(515, 355);
/*     */     
/* 100 */     paramArray.put(401, 369);
/* 101 */     paramArray.put(402, 370);
/* 102 */     paramArray.put(403, 371);
/*     */     
/* 104 */     paramArray.put(369, 385);
/* 105 */     paramArray.put(370, 386);
/* 106 */     paramArray.put(371, 387);
/*     */     
/* 108 */     paramArray.put(385, 401);
/* 109 */     paramArray.put(386, 402);
/* 110 */     paramArray.put(387, 403);
/*     */   }
/*     */   
/*     */   public SparseIntArray getAllParams() {
/* 114 */     return paramArray;
/*     */   }
/*     */   
/* 117 */   private Runnable runnable = new Runnable()
/*     */     {
/*     */       public void run()
/*     */       {
/*     */         while (true) {
/* 122 */           synchronized (Scanner1D.this.runnable) {
/*     */             try {
/* 124 */               Scanner1D.this.runnable.wait();
/* 125 */             } catch (InterruptedException e) {
/* 126 */               Log.i("Scanner1D", "Error:" + e.getMessage());
/*     */             } 
/* 128 */             Scanner1D.this.decode();
/*     */           } 
/*     */         } 
/*     */       }
/*     */     };
/*     */   
/* 134 */   private Handler mHandler = new DecodeHandler();
/*     */   
/*     */   Scanner1D(Context context) {
/* 137 */     super(context);
/*     */   }
/*     */ 
/*     */   
/*     */   public boolean open() {
/* 142 */     if (this.isOpened) {
/* 143 */       return true;
/*     */     }
/*     */     
/* 146 */     if (JNIOpen()) {
/* 147 */       this.isOpened = true;
/* 148 */       this.laser_time = getLaserTime();
/* 149 */       this.mThread = new Thread(this.runnable);
/* 150 */       this.mThread.start();
/* 151 */       return true;
/*     */     } 
/* 153 */     return false;
/*     */   }
/*     */   
/*     */   public void close() {
/* 157 */     JNIClose();
/* 158 */     this.isOpened = false;
/*     */   }
/*     */ 
/*     */   
/*     */   public void startScan() {
/* 163 */     scan();
/*     */   }
/*     */   
/*     */   void scan() {
/* 167 */     if (!scanFinished.booleanValue()) {
/*     */       return;
/*     */     }
/*     */     
/* 171 */     synchronized (this.runnable) {
/* 172 */       this.runnable.notify();
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/* 177 */   static Boolean scanFinished = Boolean.valueOf(true);
/*     */   private void decode() {
/* 179 */     synchronized (this) {
/* 180 */       scanFinished = Boolean.valueOf(false);
/* 181 */       BarcodeInfo barcodeInfo = new BarcodeInfo();
/*     */       
/* 183 */       if (this.isEnabled && 
/* 184 */         JNIGetBarcode(barcodeInfo, this.laser_time)) {
/*     */         
/* 186 */         ScanLed.setLed(1);
/* 187 */         Message msg = this.mHandler.obtainMessage();
/* 188 */         msg.obj = barcodeInfo;
/* 189 */         this.mHandler.sendMessage(msg);
/*     */       } 
/*     */       
/* 192 */       scanFinished = Boolean.valueOf(true);
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/*     */   public void stopScan() {
/* 198 */     JNIStopScan();
/*     */   }
/*     */ 
/*     */   
/*     */   public void enable() {
/* 203 */     JNIEnableScan();
/* 204 */     this.isEnabled = true;
/*     */   }
/*     */ 
/*     */   
/*     */   public void disable() {
/* 209 */     JNIDisableScan();
/* 210 */     this.isEnabled = false;
/*     */   }
/*     */ 
/*     */   
/*     */   public boolean setParams(int id, int value) {
/* 215 */     if (paramArray.get(id, -1) == -1 && id != 801) {
/* 216 */       return false;
/*     */     }
/*     */     
/* 219 */     boolean ret = false;
/*     */     
/* 221 */     if (id == 801) {
/* 222 */       ret = JNIFactoryDefault();
/* 223 */       if (ret) {
/*     */         
/*     */         try {
/* 226 */           Thread.sleep(500L);
/* 227 */           this.laser_time = getLaserTime();
/* 228 */         } catch (Exception exception) {}
/*     */       }
/*     */ 
/*     */       
/* 232 */       return ret;
/*     */     } 
/*     */     
/* 235 */     ScanParam param = new ScanParam();
/* 236 */     param.id = paramArray.get(id);
/* 237 */     param.value = value;
/* 238 */     ret = JNISetParam(param);
/* 239 */     if (ret && id == 1) {
/* 240 */       setLaserTime(value);
/*     */     }
/* 242 */     return ret;
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public int getParams(int id) {
/* 248 */     if (paramArray.get(id, -1) == -1) {
/* 249 */       return -1;
/*     */     }
/*     */     
/* 252 */     ScanParam param = new ScanParam();
/* 253 */     param.id = paramArray.get(id);
/* 254 */     boolean ret = JNIGetParam(param);
/*     */     
/* 256 */     if (ret) {
/* 257 */       return param.value;
/*     */     }
/* 259 */     return -1;
/*     */   }
/*     */   
/*     */   private class BarcodeInfo {
/*     */     public String data;
/*     */     public int length;
/*     */     public String type;
/*     */     
/*     */     private BarcodeInfo() {} }
/*     */   
/*     */   public void setDecodeCallBack(DecodeCallback decodeCallback) {
/* 270 */     callback = decodeCallback;
/*     */   }
/*     */   
/*     */   static class DecodeHandler extends Handler {
/*     */     public void handleMessage(Message msg) {
/* 275 */       BarcodeInfo barcodeInfo = (BarcodeInfo)msg.obj;
/* 276 */       if (Scanner1D.callback != null && !"".equals(barcodeInfo.data)) {
/* 277 */         Scanner1D.callback.onDecodeComplete(barcodeInfo.data);
/*     */       }
/*     */       
/* 280 */       if (Scanner1D.infoCallBack != null && !"".equals(barcodeInfo.data)) {
/* 281 */         DecodeInfo info = new DecodeInfo();
/* 282 */         info.barcode = barcodeInfo.data;
/* 283 */         info.codetype = barcodeInfo.type;
/* 284 */         info.length = barcodeInfo.length;
/* 285 */         Scanner1D.infoCallBack.onDecodeComplete(info);
/*     */       } 
/*     */     }
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public void setDecodeInfoCallBack(DecodeInfoCallBack callback) {
/* 293 */     infoCallBack = callback;
/*     */   }
/*     */   
/*     */   protected int getLaserTime() {
/* 297 */     return -1;
/*     */   }
/*     */   
/*     */   protected void setLaserTime(int time) {
/* 301 */     this.laser_time = time;
/*     */   }
/*     */   
/*     */   public final native boolean JNIOpen();
/*     */   
/*     */   public final native void JNIClose();
/*     */   
/*     */   public final native boolean JNIGetBarcode(BarcodeInfo paramBarcodeInfo, int paramInt);
/*     */   
/*     */   public final native boolean JNIStopScan();
/*     */   
/*     */   public final native boolean JNISetParam(ScanParam paramScanParam);
/*     */   
/*     */   public final native boolean JNIGetParam(ScanParam paramScanParam);
/*     */   
/*     */   public final native void JNIEnableScan();
/*     */   
/*     */   public final native void JNIDisableScan();
/*     */   
/*     */   private final native boolean JNIFactoryDefault();
/*     */ }


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