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 @Override
protected void onPause() { protected void onPause() {
super.onPause();
if (handler != null) { if (handler != null) {
handler.quitSynchronously(); handler.quitSynchronously();
handler = null; handler = null;
} }
inactivityTimer.onPause(); inactivityTimer.onPause();
cameraManager.closeDriver(); cameraManager.closeDriver();
if (!hasSurface) {
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
SurfaceHolder surfaceHolder = surfaceView.getHolder();
surfaceHolder.removeCallback(this);
}
super.onPause();
} }
@Override @Override

View file

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

View file

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