From 610e7ac947d7a71e41b4221e4ccb8157e868d982 Mon Sep 17 00:00:00 2001 From: weijiew Date: Mon, 5 Sep 2016 14:04:48 +0800 Subject: SnapdragonCamera:Force close when set video high framerate as HSR240 Camera can't support all the video high framerate. When it's not supported, the value of framerate getting from camera device is "off".It will cause number format exception when parsing "off" to integer. Change-Id: Ie6d4840f96de4eeecad4bcf6a71ca2404ff8834a CRs-Fixed: 1063218 --- src/com/android/camera/VideoModule.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/com/android/camera/VideoModule.java') diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index bae16bde6..bbe4c421a 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -80,6 +80,7 @@ import java.util.Iterator; import java.util.List; import java.util.HashMap; import java.lang.reflect.Method; +import java.util.regex.Pattern; public class VideoModule implements CameraModule, VideoController, @@ -2547,10 +2548,9 @@ public class VideoModule implements CameraModule, mActivity.getString(R.string.pref_video_time_lapse_frame_interval_default)); int timeLapseInterval = Integer.parseInt(frameIntervalStr); int rate = 0; - if (!hfr.equals("off")) - rate = Integer.parseInt(hfr); - else - rate = Integer.parseInt(hsr); + if ( isDigit(highFrameRate.substring(3)) ) { + rate = Integer.parseInt(highFrameRate.substring(3)); + } Log.v(TAG, "rate = "+rate); if ( (timeLapseInterval != 0) || (disMode.equals("enable") && (rate > PERSIST_EIS_MAX_FPS)) || @@ -2604,6 +2604,12 @@ public class VideoModule implements CameraModule, } } + private boolean isDigit(String input) { + String ruler = "[1-9][0-9]*"; + Pattern pattern = Pattern.compile(ruler); + return pattern.matcher(input).matches(); + } + @SuppressWarnings("deprecation") private void setCameraParameters(boolean isFlashDelay) { Log.d(TAG,"Preview dimension in App->"+mDesiredPreviewWidth+"X"+mDesiredPreviewHeight); -- cgit v1.2.3