Added some log statement to help track down Acer issue

git-svn-id: https://zxing.googlecode.com/svn/trunk@1337 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-05-05 17:05:11 +00:00
parent 0ce1ed851f
commit 49adf3b556
5 changed files with 27 additions and 0 deletions

View file

@ -27,6 +27,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import java.util.Vector;
@ -37,6 +38,8 @@ import java.util.Vector;
*/
public final class CaptureActivityHandler extends Handler {
private static final String TAG = CaptureActivityHandler.class.getSimpleName();
private final CaptureActivity activity;
private final DecodeThread decodeThread;
private State state;
@ -68,6 +71,7 @@ public final class CaptureActivityHandler extends Handler {
public void handleMessage(Message message) {
switch (message.what) {
case R.id.auto_focus:
Log.v(TAG, "Got auto-focus message");
// When one auto focus pass finishes, start another. This is the closest thing to
// continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
if (state == State.PREVIEW) {
@ -75,24 +79,29 @@ public final class CaptureActivityHandler extends Handler {
}
break;
case R.id.restart_preview:
Log.v(TAG, "Got restart preview message");
restartPreviewAndDecode();
break;
case R.id.decode_succeeded:
Log.v(TAG, "Got decode succeeded message");
state = State.SUCCESS;
Bundle bundle = message.getData();
Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);
activity.handleDecode((Result) message.obj, barcode);
break;
case R.id.decode_failed:
Log.v(TAG, "Got decode failed message");
// We're decoding as fast as possible, so when one decode fails, start another.
state = State.PREVIEW;
CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
break;
case R.id.return_scan_result:
Log.v(TAG, "Got return scan result message");
activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
activity.finish();
break;
case R.id.launch_product_query:
Log.v(TAG, "Got product query message");
String url = (String) message.obj;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);

View file

@ -49,6 +49,7 @@ final class DecodeHandler extends Handler {
public void handleMessage(Message message) {
switch (message.what) {
case R.id.decode:
Log.v(TAG, "Got decode message");
decode((byte[]) message.obj, message.arg1, message.arg2);
break;
case R.id.quit:
@ -85,9 +86,11 @@ final class DecodeHandler extends Handler {
Bundle bundle = new Bundle();
bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap());
message.setData(bundle);
Log.v(TAG, "Sending decode succeeded message...");
message.sendToTarget();
} else {
Message message = Message.obtain(activity.getHandler(), R.id.decode_failed);
Log.v(TAG, "Sending decode failed message...");
message.sendToTarget();
}
}

View file

@ -19,9 +19,12 @@ package com.google.zxing.client.android.camera;
import android.hardware.Camera;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
final class AutoFocusCallback implements Camera.AutoFocusCallback {
private static final String TAG = AutoFocusCallback.class.getSimpleName();
private static final long AUTOFOCUS_INTERVAL_MS = 1500L;
private final CameraConfigurationManager configManager;
@ -43,12 +46,15 @@ final class AutoFocusCallback implements Camera.AutoFocusCallback {
Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success);
// Simulate continuous autofocus by sending a focus request every
// AUTOFOCUS_INTERVAL_MS milliseconds.
Log.v(TAG, "Got auto-focus callback; requesting another");
autoFocusHandler.sendMessageDelayed(message, AUTOFOCUS_INTERVAL_MS);
autoFocusHandler = null;
if (!reinitCamera) {
reinitCamera = true;
configManager.setDesiredCameraParameters(camera);
}
} else {
Log.v(TAG, "Got auto-focus callback, but no handler for it");
}
}

View file

@ -176,8 +176,10 @@ public final class CameraManager {
if (camera != null && previewing) {
previewCallback.setHandler(handler, message);
if (useOneShotPreviewCallback) {
Log.v(TAG, "Requesting one-shot preview callback");
camera.setOneShotPreviewCallback(previewCallback);
} else {
Log.v(TAG, "Requesting preview callback");
camera.setPreviewCallback(previewCallback);
}
}
@ -192,6 +194,7 @@ public final class CameraManager {
public void requestAutoFocus(Handler handler, int message) {
if (camera != null && previewing) {
autoFocusCallback.setHandler(handler, message);
Log.v(TAG, "Requesting auto-focus callback");
camera.autoFocus(autoFocusCallback);
}
}

View file

@ -20,9 +20,12 @@ import android.graphics.Point;
import android.hardware.Camera;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
final class PreviewCallback implements Camera.PreviewCallback {
private static final String TAG = PreviewCallback.class.getSimpleName();
private final CameraConfigurationManager configManager;
private final boolean useOneShotPreviewCallback;
private Handler previewHandler;
@ -46,8 +49,11 @@ final class PreviewCallback implements Camera.PreviewCallback {
if (previewHandler != null) {
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
cameraResolution.y, data);
Log.v(TAG, "Got preview callback; sending message to decoder");
message.sendToTarget();
previewHandler = null;
} else {
Log.v(TAG, "Got preview callback, but no handler for it");
}
}