From 26e1a02ba3183aba2ba262c6f60602e10dd792e3 Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Thu, 10 May 2012 16:23:39 -0700 Subject: Add additional debug for time zone handling. Change-Id: Ie46bba7e0ef7737a865f7efadbf963c2d14e488f --- .../android/internal/telephony/DataConnection.java | 20 +++----------------- .../internal/telephony/ServiceStateTracker.java | 5 ++++- .../telephony/cdma/CdmaServiceStateTracker.java | 12 +++++++++--- .../telephony/gsm/GsmServiceStateTracker.java | 12 +++++++++--- 4 files changed, 25 insertions(+), 24 deletions(-) (limited to 'telephony') diff --git a/telephony/java/com/android/internal/telephony/DataConnection.java b/telephony/java/com/android/internal/telephony/DataConnection.java index da03f76..7c70a7e 100644 --- a/telephony/java/com/android/internal/telephony/DataConnection.java +++ b/telephony/java/com/android/internal/telephony/DataConnection.java @@ -31,6 +31,7 @@ import android.os.AsyncResult; import android.os.Message; import android.os.SystemProperties; import android.text.TextUtils; +import android.util.TimeUtils; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -1225,21 +1226,6 @@ public abstract class DataConnection extends StateMachine { } /** - * Convert a System.currentTimeMillis() value to a time of day value. - * - * @param millis since the epoch (1/1/1970) - * @return String representation of the time. - */ - private String timeMillisToTimeOfDay(long millis) { - Calendar c = Calendar.getInstance(); - if (millis >= 0) { - c.setTimeInMillis(millis); - return String.format("%tm-%td %tH:%tM:%tS.%tL", c, c, c, c, c, c); - } else { - return Long.toString(millis); - } - } - /** * Dump the current state. * * @param fd @@ -1263,8 +1249,8 @@ public abstract class DataConnection extends StateMachine { pw.println(" mLinkProperties=" + mLinkProperties); pw.flush(); pw.println(" mCapabilities=" + mCapabilities); - pw.println(" createTime=" + timeMillisToTimeOfDay(createTime)); - pw.println(" lastFailTime=" + timeMillisToTimeOfDay(lastFailTime)); + pw.println(" createTime=" + TimeUtils.logTimeOfDay(createTime)); + pw.println(" lastFailTime=" + TimeUtils.logTimeOfDay(lastFailTime)); pw.println(" lastFailCause=" + lastFailCause); pw.flush(); pw.println(" mRetryOverride=" + mRetryOverride); diff --git a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java index bd78065..69dd666 100644 --- a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java @@ -23,6 +23,7 @@ import android.os.Registrant; import android.os.RegistrantList; import android.telephony.ServiceState; import android.telephony.SignalStrength; +import android.util.TimeUtils; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -507,13 +508,15 @@ public abstract class ServiceStateTracker extends Handler { // Determine retVal boolean retVal = ((iccCardExist && (mcc != prevMcc)) || needToFixTimeZone); if (DBG) { + long ctm = System.currentTimeMillis(); log("shouldFixTimeZoneNow: retVal=" + retVal + " iccCard=" + iccCard + " iccCard.state=" + (iccCard == null ? "null" : iccCard.getState().toString()) + " iccCardExist=" + iccCardExist + " operatorNumeric=" + operatorNumeric + " mcc=" + mcc + " prevOperatorNumeric=" + prevOperatorNumeric + " prevMcc=" + prevMcc + - " needToFixTimeZone=" + needToFixTimeZone); + " needToFixTimeZone=" + needToFixTimeZone + + " ltod=" + TimeUtils.logTimeOfDay(ctm)); } return retVal; } diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java index ba2e51a..e4287c0 100755 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java @@ -878,13 +878,19 @@ public class CdmaServiceStateTracker extends ServiceStateTracker { // For NITZ string without time zone, // need adjust time to reflect default time zone setting zone = TimeZone.getDefault(); - long tzOffset; - tzOffset = zone.getOffset(System.currentTimeMillis()); + long ctm = System.currentTimeMillis(); + long tzOffset = zone.getOffset(ctm); + if (DBG) { + log("fixTimeZone: tzOffset=" + tzOffset + " ltod=" + TimeUtils.logTimeOfDay(ctm)); + } if (getAutoTime()) { - setAndBroadcastNetworkSetTime(System.currentTimeMillis() - tzOffset); + long adj = ctm - tzOffset; + if (DBG) log("fixTimeZone: adj ltod=" + TimeUtils.logTimeOfDay(adj)); + setAndBroadcastNetworkSetTime(adj); } else { // Adjust the saved NITZ time to account for tzOffset. mSavedTime = mSavedTime - tzOffset; + if (DBG) log("fixTimeZone: adj mSavedTime=" + mSavedTime); } if (DBG) log("fixTimeZone: using default TimeZone"); } else if (isoCountryCode.equals("")) { diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java index 4235577..1aa17c7 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java @@ -923,10 +923,16 @@ final class GsmServiceStateTracker extends ServiceStateTracker { zone = TimeZone.getDefault(); // For NITZ string without timezone, // need adjust time to reflect default timezone setting - long tzOffset; - tzOffset = zone.getOffset(System.currentTimeMillis()); + long ctm = System.currentTimeMillis(); + long tzOffset = zone.getOffset(ctm); + if (DBG) { + log("pollStateDone: tzOffset=" + tzOffset + " ltod=" + + TimeUtils.logTimeOfDay(ctm)); + } if (getAutoTime()) { - setAndBroadcastNetworkSetTime(System.currentTimeMillis() - tzOffset); + long adj = ctm - tzOffset; + if (DBG) log("pollStateDone: adj ltod=" + TimeUtils.logTimeOfDay(adj)); + setAndBroadcastNetworkSetTime(adj); } else { // Adjust the saved NITZ time to account for tzOffset. mSavedTime = mSavedTime - tzOffset; -- cgit v1.1