<item type="id" name="set_decode_all_mode"/>
<item type="id" name="set_decode_1D_mode"/>
<item type="id" name="set_decode_QR_mode"/>
+ <item type="id" name="toggle_tracing"/>
<item type="id" name="decode_started"/>
<item type="id" name="decode_succeeded"/>
<item type="id" name="decode_failed"/>
import android.app.Application;
import android.graphics.Bitmap;
+import android.os.Debug;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
private final CameraManager cameraManager;
private Hashtable<DecodeHintType, Object> hints;
private Handler cameraThreadHandler;
+ private int methodTraceCount;
+ private boolean tracing;
DecodeThread(BarcodeReaderCaptureActivity activity, CameraManager cameraManager) {
this.activity = activity;
this.cameraManager = cameraManager;
+ methodTraceCount = 0;
+ tracing = false;
}
@Override
case R.id.set_decode_QR_mode:
setDecodeQRMode();
break;
+ case R.id.toggle_tracing:
+ tracing = !tracing;
+ break;
}
}
};
Message restart = Message.obtain(cameraThreadHandler, R.id.decode_started);
restart.sendToTarget();
- Result rawResult;
+ if (tracing) {
+ Debug.startMethodTracing("/sdcard/ZXingDecodeThread" + methodTraceCount);
+ methodTraceCount++;
+ }
+ boolean success;
+ Result rawResult = null;
try {
MonochromeBitmapSource source = new RGBMonochromeBitmapSource(bitmap);
rawResult = new MultiFormatReader().decode(source, hints);
+ success = true;
} catch (ReaderException e) {
- Message failure = Message.obtain(cameraThreadHandler, R.id.decode_failed);
- failure.sendToTarget();
- return;
+ success = false;
+ }
+ if (tracing) {
+ Debug.stopMethodTracing();
}
Date endDate = new Date();
- Message success = Message.obtain(cameraThreadHandler, R.id.decode_succeeded, rawResult);
- success.arg1 = (int) (endDate.getTime() - startDate.getTime());
- success.sendToTarget();
+
+ if (success) {
+ Message message = Message.obtain(cameraThreadHandler, R.id.decode_succeeded, rawResult);
+ message.arg1 = (int) (endDate.getTime() - startDate.getTime());
+ message.sendToTarget();
+ } else {
+ Message message = Message.obtain(cameraThreadHandler, R.id.decode_failed);
+ message.sendToTarget();
+ }
}
/**
<string name="menu_about">About...</string>
<string name="menu_help">Help...</string>
<string name="msg_about">ZXing Barcode Reader v@VERSION@\nhttp://code.google.com/p/zxing</string>
- <string name="msg_help">A: Decode all barcodes\nC: Capture and save a JPEG\nP: Use the preview image for decoding\nQ: Decode only QR Codes\nS: Use a still image for decoding\nU: Decode only UPC/1D barcodes</string>
+ <string name="msg_help">A: Decode all barcodes\nC: Capture and save a JPEG\nP: Use the preview image for decoding\nQ: Decode only QR Codes\nS: Use a still image for decoding\nT: Toggle debug method tracing\nU: Decode only UPC/1D barcodes</string>
<string name="title_about">About</string>
<string name="title_add_contact">Add Contact?</string>
<string name="title_barcode_detected">Barcode Detected</string>