Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d89ad534 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

telephony: LGEStar: Fix NITZ on p990

The radio on the p990 appears to spew out localtime. Convert the raw
data to UTC before handing it over to the time registrants

Change-Id: Iecb52a9197b017ac2fbeddb6dfad372addb16ba3
parent cc91da0d
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -815,20 +815,31 @@ public class LGEStarRIL extends RIL implements CommandsInterface {
        String response;
        SimpleDateFormat dateFormatter;
        SimpleDateFormat dateParser;
        boolean isP990 = SystemProperties.get("ro.build.product").equals("p990");
        String[] tzIds;

        num = p.readInt(); // TZ diff in quarter-hours

        /* Get the actual date string */
        parceldata = p.readString();
        /* Filter out whatever it is LG is attaching here */
        if (SystemProperties.get("ro.build.product").equals("p990"))

        /* P990 needs some additional hax... */
        tzIds = TimeZone.getAvailableIDs((num/4)*3600*1000);
        if (isP990) {
            parceldata = parceldata.substring(0,(parceldata.lastIndexOf(",")));
        }

        /* WTH... Date may come with 4 digits in the year, reduce to 2 */
        try {
            dateFormatter = new SimpleDateFormat("yy/MM/dd,HH:mm:ss");
            dateParser = new SimpleDateFormat("yy/MM/dd,HH:mm:ss");

            /* P990 delivers localtime, convert to UTC */
            if (isP990) {
                dateFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
                dateParser.setTimeZone(TimeZone.getTimeZone(tzIds[0]));
            }

            response = dateFormatter.format(dateParser.parse(parceldata));

        } catch (java.text.ParseException tpe) {