aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-08-10 02:06:40 -0700
committerSteve Kondik <steve@cyngn.com>2016-08-10 02:08:47 -0700
commitdb640a9648d7833eb0f9745b091c91e7f3768803 (patch)
treef94171a823c3a61c00520f467ef83d7e31569e34
parentc0dd46d30f10e1da31828b9f67b6e0ea51c2e674 (diff)
downloadvendor_cmsdk-db640a9648d7833eb0f9745b091c91e7f3768803.zip
vendor_cmsdk-db640a9648d7833eb0f9745b091c91e7f3768803.tar.gz
vendor_cmsdk-db640a9648d7833eb0f9745b091c91e7f3768803.tar.bz2
livedisplay: Float-to-string conversions considered harmful
* Force US locale when doing internal flattening of HSIC objects into strings. This would crash in the validator if the user's local uses commands instead of dots to format floats. Change-Id: I08f44238a486308a483205b97632114d2f7a77f1
-rw-r--r--sdk/src/java/cyanogenmod/hardware/HSIC.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/sdk/src/java/cyanogenmod/hardware/HSIC.java b/sdk/src/java/cyanogenmod/hardware/HSIC.java
index cd4f3ce..df6cb5f 100644
--- a/sdk/src/java/cyanogenmod/hardware/HSIC.java
+++ b/sdk/src/java/cyanogenmod/hardware/HSIC.java
@@ -18,9 +18,10 @@ package cyanogenmod.hardware;
import android.graphics.Color;
import android.os.Parcel;
import android.os.Parcelable;
-
import android.text.TextUtils;
+import java.util.Locale;
+
public class HSIC implements Parcelable {
private final float mHue;
@@ -59,7 +60,7 @@ public class HSIC implements Parcelable {
}
public String flatten() {
- return String.format("%f|%f|%f|%f|%f", mHue, mSaturation,
+ return String.format(Locale.US, "%f|%f|%f|%f|%f", mHue, mSaturation,
mIntensity, mContrast, mSaturationThreshold);
}
@@ -68,9 +69,9 @@ public class HSIC implements Parcelable {
if (unflat.length != 4 && unflat.length != 5) {
throw new NumberFormatException("Failed to unflatten HSIC values: " + flat);
}
- return new HSIC(Float.valueOf(unflat[0]), Float.valueOf(unflat[1]),
- Float.valueOf(unflat[2]), Float.valueOf(unflat[3]),
- unflat.length == 5 ? Float.valueOf(unflat[4]) : 0.0f);
+ return new HSIC(Float.parseFloat(unflat[0]), Float.parseFloat(unflat[1]),
+ Float.parseFloat(unflat[2]), Float.parseFloat(unflat[3]),
+ unflat.length == 5 ? Float.parseFloat(unflat[4]) : 0.0f);
}
public int[] toRGB() {
@@ -93,7 +94,7 @@ public class HSIC implements Parcelable {
@Override
public String toString() {
- return String.format("HSIC={ hue=%f saturation=%f intensity=%f " +
+ return String.format(Locale.US, "HSIC={ hue=%f saturation=%f intensity=%f " +
"contrast=%f saturationThreshold=%f }",
mHue, mSaturation, mIntensity, mContrast, mSaturationThreshold);
}