mirror of
https://github.com/zxing/zxing.git
synced 2024-11-09 20:44:03 -08:00
Add defensive checks for bad setFPS API behavior
This commit is contained in:
parent
9e08da655e
commit
de6e9dbc52
|
@ -28,6 +28,7 @@ import android.view.WindowManager;
|
|||
import com.google.zxing.client.android.PreferencesActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -93,8 +94,14 @@ final class CameraConfigurationManager {
|
|||
|
||||
// Required for Glass compatibility; also improves battery/CPU performance a tad
|
||||
List<int[]> supportedPreviewFpsRanges = parameters.getSupportedPreviewFpsRange();
|
||||
if (supportedPreviewFpsRanges != null && !supportedPreviewFpsRanges.isEmpty()) {
|
||||
int[] currentFpsRange = new int[2];
|
||||
parameters.getPreviewFpsRange(currentFpsRange);
|
||||
int[] minimumPreviewFpsRange = supportedPreviewFpsRanges.get(0);
|
||||
if (!Arrays.equals(currentFpsRange, minimumPreviewFpsRange)) {
|
||||
parameters.setPreviewFpsRange(minimumPreviewFpsRange[0], minimumPreviewFpsRange[1]);
|
||||
}
|
||||
}
|
||||
|
||||
String focusMode = null;
|
||||
if (prefs.getBoolean(PreferencesActivity.KEY_AUTO_FOCUS, true)) {
|
||||
|
|
Loading…
Reference in a new issue