summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlikaid <likaid@codeaurora.org>2015-06-30 11:17:57 +0800
committerMichael Bestas <mikeioannina@cyanogenmod.org>2016-01-14 18:43:07 +0200
commit8eeafc140e98e460c6aeb8a46ed2c91e76522210 (patch)
tree53475164d81690339ca178ba6b956212120c37d8 /src
parentcd142092a0b3c947d0c5e429ec15985271b16259 (diff)
downloadandroid_packages_apps_Snap-8eeafc140e98e460c6aeb8a46ed2c91e76522210.tar.gz
android_packages_apps_Snap-8eeafc140e98e460c6aeb8a46ed2c91e76522210.tar.bz2
android_packages_apps_Snap-8eeafc140e98e460c6aeb8a46ed2c91e76522210.zip
SnapdragonCamera: fix NumberFormatException when input value invalide
NumberFormatException occurred when converted the invalid input values, for example, user only input "." for some float values. Catch the NumberFormatException and show invalid input toast. Change-Id: Ie10b204950d43cca22a06532f04b9569fa545cbb CRs-Fixed: 862960
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/PhotoModule.java39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 9616961a1..8abeff197 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -3839,7 +3839,13 @@ public class PhotoModule
double focuspos = 0;
String focusStr = input.getText().toString();
if (focusStr.length() > 0) {
- focuspos = Double.parseDouble(focusStr);
+ try {
+ focuspos = Double.parseDouble(focusStr);
+ } catch (NumberFormatException e) {
+ Log.w(TAG, "Input foucspos " + focuspos + " is invalid");
+ focuspos = maxFocusPos + 1f;
+ }
+
} else {
RotateTextToast.makeText(mActivity, "Invalid focus position",
Toast.LENGTH_SHORT).show();
@@ -3978,10 +3984,20 @@ public class PhotoModule
String Rgain = Rinput.getText().toString();
String Ggain = Ginput.getText().toString();
String Bgain = Binput.getText().toString();
+ double Rgainf = -1;
+ double Ggainf = -1;
+ double Bgainf = -1;
if (Rgain.length() > 0 && Ggain.length() > 0 && Bgain.length() > 0) {
- double Rgainf = Double.parseDouble(Rgain);
- double Ggainf = Double.parseDouble(Ggain);
- double Bgainf = Double.parseDouble(Bgain);
+ try {
+ Rgainf = Double.parseDouble(Rgain);
+ Ggainf = Double.parseDouble(Ggain);
+ Bgainf = Double.parseDouble(Bgain);
+ } catch (NumberFormatException e) {
+ Log.w(TAG, "Input RGB gain is invalid");
+ Rgainf = maxGain + 1f;
+ Ggainf = maxGain + 1f;
+ Bgainf = maxGain + 1f;
+ }
String RGBGain = Rgain + "," + Ggain + "," + Bgain;
if (Rgainf <= maxGain && Rgainf >= minGain &&
Ggainf <= maxGain && Ggainf >= minGain &&
@@ -4105,7 +4121,12 @@ public class PhotoModule
double newExpTime = -1;
String expTime = ExpTimeInput.getText().toString();
if (expTime.length() > 0) {
- newExpTime = Double.parseDouble(expTime);
+ try {
+ newExpTime = Double.parseDouble(expTime);
+ } catch (NumberFormatException e) {
+ Log.w(TAG, "Input expTime " + expTime + " is invalid");
+ newExpTime = Double.parseDouble(maxExpTime) + 1f;
+ }
}
if (newExpTime <= Double.parseDouble(maxExpTime) &&
newExpTime >= Double.parseDouble(minExpTime)) {
@@ -4151,7 +4172,13 @@ public class PhotoModule
double newExpTime = -1;
String expTime = ExpTimeInput.getText().toString();
if (expTime.length() > 0) {
- newExpTime = Double.parseDouble(expTime);
+ try {
+ newExpTime = Double.parseDouble(expTime);
+ } catch (NumberFormatException e) {
+ Log.w(TAG, "input newExpTime " + newExpTime + " is invalid");
+ newExpTime = Double.parseDouble(maxExpTime) + 1f;
+ }
+
}
if (newISO <= maxISO && newISO >= minISO &&
newExpTime <= Double.parseDouble(maxExpTime) &&