Fix some camera-related crashes on 3.71 that we may need to also put out a back-ported fix for

git-svn-id: https://zxing.googlecode.com/svn/trunk@2036 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2011-11-15 16:50:44 +00:00
parent 11f83b37e1
commit 505b14de04
3 changed files with 16 additions and 9 deletions

View file

@ -252,13 +252,18 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
@Override
protected void onPause() {
super.onPause();
if (handler != null) {
handler.quitSynchronously();
handler = null;
}
inactivityTimer.onPause();
cameraManager.closeDriver();
if (!hasSurface) {
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
SurfaceHolder surfaceHolder = surfaceView.getHolder();
surfaceHolder.removeCallback(this);
}
super.onPause();
}
@Override

View file

@ -73,13 +73,15 @@ final class DecodeHandler extends Handler {
long start = System.currentTimeMillis();
Result rawResult = null;
PlanarYUVLuminanceSource source = activity.getCameraManager().buildLuminanceSource(data, width, height);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
rawResult = multiFormatReader.decodeWithState(bitmap);
} catch (ReaderException re) {
// continue
} finally {
multiFormatReader.reset();
if (source != null) {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
rawResult = multiFormatReader.decodeWithState(bitmap);
} catch (ReaderException re) {
// continue
} finally {
multiFormatReader.reset();
}
}
Handler handler = activity.getHandler();

View file

@ -300,7 +300,7 @@ public final class CameraManager {
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {
Rect rect = getFramingRectInPreview();
if (rect == null) {
throw new IllegalStateException();
return null;
}
int previewFormat = configManager.getPreviewFormat();
String previewFormatString = configManager.getPreviewFormatString();