mirror of
https://github.com/zxing/zxing.git
synced 2024-11-12 22:14:06 -08:00
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:
parent
11f83b37e1
commit
505b14de04
|
@ -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
|
||||||
|
|
|
@ -73,13 +73,15 @@ 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);
|
||||||
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
|
if (source != null) {
|
||||||
try {
|
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
|
||||||
rawResult = multiFormatReader.decodeWithState(bitmap);
|
try {
|
||||||
} catch (ReaderException re) {
|
rawResult = multiFormatReader.decodeWithState(bitmap);
|
||||||
// continue
|
} catch (ReaderException re) {
|
||||||
} finally {
|
// continue
|
||||||
multiFormatReader.reset();
|
} finally {
|
||||||
|
multiFormatReader.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Handler handler = activity.getHandler();
|
Handler handler = activity.getHandler();
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in a new issue