diff options
author | Sang Tae Park <pastime1971@gmail.com> | 2012-02-15 21:36:02 -0800 |
---|---|---|
committer | Sang Tae Park <pastime1971@gmail.com> | 2012-02-16 09:11:16 -0800 |
commit | 866fe0d156ff3e054cfb30dee0364078e4f5dfa9 (patch) | |
tree | c8d1a0df1d213424fedc45d704794fd974419a39 | |
parent | ecd87a0342a62252456251551d6fd7ff013be6ce (diff) | |
download | frameworks_base-866fe0d156ff3e054cfb30dee0364078e4f5dfa9.zip frameworks_base-866fe0d156ff3e054cfb30dee0364078e4f5dfa9.tar.gz frameworks_base-866fe0d156ff3e054cfb30dee0364078e4f5dfa9.tar.bz2 |
LGEStarRIL: fix DST handling exception
current implementation of NITZ assumes that it is in the form of OFFSET,"DATE,TIME,DST"
and split it into OFFSET and "DATE,TIME" and "DST" and assign DST to parcelextra.
some carriers send NITZ without DST flag, string parsing splits DATE and TIME
and assign TIME for DST, which leads to throwing integer parsing exception,
and then possibly RIL crash
this commit utilize String.split(",") to split NITZ and reconstruct it correctly,
and handle DST as optional.
(also moved offset evaluation to inside only where it is needed.)
Change-Id: I9e2a7d992b3054be0782216152a3e4c04f87fdcb
-rw-r--r-- | telephony/java/com/android/internal/telephony/LGEStarRIL.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/telephony/java/com/android/internal/telephony/LGEStarRIL.java b/telephony/java/com/android/internal/telephony/LGEStarRIL.java index 40dd31c..4b84f57 100644 --- a/telephony/java/com/android/internal/telephony/LGEStarRIL.java +++ b/telephony/java/com/android/internal/telephony/LGEStarRIL.java @@ -1009,14 +1009,12 @@ public class LGEStarRIL extends RIL implements CommandsInterface { /* Infineon modems need some additional hax... */ if (isIfx) { - /* Store DST before cropping */ - parcelextra = parceldata.substring(parceldata.lastIndexOf(",")+1); - if (parcelextra != null) dst = Integer.parseInt(parcelextra); - parceldata = parceldata.substring(0,(parceldata.lastIndexOf(","))); + String [] parcelitem = parceldata.split(","); + parceldata = parcelitem[0] + "," + parcelitem[1]; // assuming there is always one comma at least + parcelextra = (parcelitem.length > 2 ? parcelitem[2] : "0"); + dst = Integer.parseInt(parcelextra); } - int offset = num*15*60*1000; // DST corrected - /* WTH... Date may come with 4 digits in the year, reduce to 2 */ try { dateFormatter = new SimpleDateFormat("yy/MM/dd,HH:mm:ss"); @@ -1025,6 +1023,7 @@ public class LGEStarRIL extends RIL implements CommandsInterface { /* Ifx delivers localtime, convert to UTC */ if (usesLocalTime) { /* Directly calculate UTC time using DST Offset */ + int offset = num*15*60*1000; // DST corrected long when = dateParser.parse(parceldata).getTime() - offset; Date d = new Date(when); response = dateFormatter.format(d); |