summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2012-04-12 15:11:59 -0700
committerWink Saville <wink@google.com>2012-04-12 15:11:59 -0700
commit335ef47968ea3ecc00546c7e60736b4e0dcfb0f8 (patch)
treec57832c13322e900a18ff3666d635b2cfaa915bb /telephony
parentdecd3039ca71e5340ec01027170941637bf9876e (diff)
downloadframeworks_base-335ef47968ea3ecc00546c7e60736b4e0dcfb0f8.zip
frameworks_base-335ef47968ea3ecc00546c7e60736b4e0dcfb0f8.tar.gz
frameworks_base-335ef47968ea3ecc00546c7e60736b4e0dcfb0f8.tar.bz2
Fix phone is sometimes in America/Dawson canadian time zone
Add code that updates the time zone whenever the country code or time zone changes. In bug 6269708 the device initially reported the mcc as 001 and then a short time later it got the correct code, 311. This could cause the time zone to be reported as America/Dawson instead of America/Los_Angeles. Bug: 6269708 Change-Id: Ibfb40ea1158d3b99c121ed9960a1f0b1a45980bd
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java21
-rwxr-xr-xtelephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java48
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java41
3 files changed, 83 insertions, 27 deletions
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
index 98a106a0..ff7a0810 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
@@ -28,6 +28,7 @@ import android.telephony.ServiceState;
import android.telephony.cdma.CdmaCellLocation;
import android.os.AsyncResult;
import android.os.Message;
+import android.os.SystemProperties;
import android.provider.Telephony.Intents;
import android.text.TextUtils;
@@ -370,14 +371,23 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ALPHA,
ss.getOperatorAlphaLong());
+ String prevOperatorNumeric =
+ SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, "");
operatorNumeric = ss.getOperatorNumeric();
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, operatorNumeric);
if (operatorNumeric == null) {
+ if (DBG) {
+ log("pollStateDone: operatorNumeric=" + operatorNumeric +
+ " prevOperatorNumeric=" + prevOperatorNumeric +
+ " mNeedFixZone=" + mNeedFixZone +
+ " clear PROPERTY_OPERATOR_ISO_COUNTRY");
+ }
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, "");
mGotCountryCode = false;
} else {
String isoCountryCode = "";
+ String mcc = operatorNumeric.substring(0, 3);
try {
isoCountryCode = MccTable.countryCodeForMcc(Integer.parseInt(operatorNumeric
.substring(0, 3)));
@@ -386,11 +396,20 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
} catch (StringIndexOutOfBoundsException ex) {
loge("countryCodeForMcc error" + ex);
}
+ if (DBG) {
+ log("pollStateDone: operatorNumeric=" + operatorNumeric +
+ " prevOperatorNumeric=" + prevOperatorNumeric +
+ " mNeedFixZone=" + mNeedFixZone +
+ " mcc=" + mcc + " iso-cc=" + isoCountryCode);
+ }
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY,
isoCountryCode);
mGotCountryCode = true;
- if (mNeedFixZone) {
+
+ // Fix the time zone If the operator changed or we need to fix it because
+ // when the NITZ time came in we didn't know the country code.
+ if ( ! operatorNumeric.equals(prevOperatorNumeric) || mNeedFixZone) {
fixTimeZone(isoCountryCode);
}
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
index 9f27696..b694e0a 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
@@ -866,6 +866,12 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
// If the offset is (0, false) and the time zone property
// is set, use the time zone property rather than GMT.
String zoneName = SystemProperties.get(TIMEZONE_PROPERTY);
+ if (DBG) {
+ log("fixTimeZone zoneName='" + zoneName +
+ "' mZoneOffset=" + mZoneOffset + " mZoneDst=" + mZoneDst +
+ " iso-cc='" + isoCountryCode +
+ "' iso-cc-idx=" + Arrays.binarySearch(GMT_COUNTRY_CODES, isoCountryCode));
+ }
if ((mZoneOffset == 0) && (mZoneDst == false) && (zoneName != null)
&& (zoneName.length() > 0)
&& (Arrays.binarySearch(GMT_COUNTRY_CODES, isoCountryCode) < 0)) {
@@ -880,19 +886,25 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
// Adjust the saved NITZ time to account for tzOffset.
mSavedTime = mSavedTime - tzOffset;
}
+ if (DBG) log("fixTimeZone: using default TimeZone");
} else if (isoCountryCode.equals("")) {
// Country code not found. This is likely a test network.
// Get a TimeZone based only on the NITZ parameters (best guess).
zone = getNitzTimeZone(mZoneOffset, mZoneDst, mZoneTime);
+ if (DBG) log("fixTimeZone: using NITZ TimeZone");
} else {
zone = TimeUtils.getTimeZone(mZoneOffset, mZoneDst, mZoneTime, isoCountryCode);
+ if (DBG) log("fixTimeZone: using getTimeZone(off, dst, time, iso)");
}
mNeedFixZone = false;
if (zone != null) {
+ log("fixTimeZone: zone != null zone.getID=" + zone.getID());
if (getAutoTimeZone()) {
setAndBroadcastNetworkSetTimeZone(zone.getID());
+ } else {
+ log("fixTimeZone: zone == null");
}
saveNitzTimeZone(zone.getID());
}
@@ -985,14 +997,23 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ALPHA,
ss.getOperatorAlphaLong());
+ String prevOperatorNumeric =
+ SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, "");
operatorNumeric = ss.getOperatorNumeric();
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, operatorNumeric);
if (operatorNumeric == null) {
+ if (DBG) {
+ log("pollStateDone: operatorNumeric=" + operatorNumeric +
+ " prevOperatorNumeric=" + prevOperatorNumeric +
+ " mNeedFixZone=" + mNeedFixZone +
+ " clear PROPERTY_OPERATOR_ISO_COUNTRY");
+ }
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, "");
mGotCountryCode = false;
} else {
String isoCountryCode = "";
+ String mcc = operatorNumeric.substring(0, 3);
try{
isoCountryCode = MccTable.countryCodeForMcc(Integer.parseInt(
operatorNumeric.substring(0,3)));
@@ -1001,11 +1022,20 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
} catch ( StringIndexOutOfBoundsException ex) {
loge("pollStateDone: countryCodeForMcc error" + ex);
}
+ if (DBG) {
+ log("pollStateDone: operatorNumeric=" + operatorNumeric +
+ " prevOperatorNumeric=" + prevOperatorNumeric +
+ " mNeedFixZone=" + mNeedFixZone +
+ " mcc=" + mcc + " iso-cc=" + isoCountryCode);
+ }
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY,
isoCountryCode);
mGotCountryCode = true;
- if (mNeedFixZone) {
+
+ // Fix the time zone If the operator changed or we need to fix it because
+ // when the NITZ time came in we didn't know the country code.
+ if ( ! operatorNumeric.equals(prevOperatorNumeric) || mNeedFixZone) {
fixTimeZone(isoCountryCode);
}
}
@@ -1316,7 +1346,6 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
String iso = SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY);
if (zone == null) {
-
if (mGotCountryCode) {
if (iso != null && iso.length() > 0) {
zone = TimeUtils.getTimeZone(tzOffset, dst != 0,
@@ -1332,16 +1361,21 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
}
}
- if (zone == null) {
- // We got the time before the country, so we don't know
- // how to identify the DST rules yet. Save the information
- // and hope to fix it up later.
+ if ((zone == null) || (mZoneOffset != tzOffset) || (mZoneDst != (dst != 0))){
+ // We got the time before the country or the zone has changed
+ // so we don't know how to identify the DST rules yet. Save
+ // the information and hope to fix it up later.
mNeedFixZone = true;
mZoneOffset = tzOffset;
mZoneDst = dst != 0;
mZoneTime = c.getTimeInMillis();
}
+ if (DBG) {
+ log("NITZ: tzOffset=" + tzOffset + " dst=" + dst + " zone=" + zone.getID() +
+ " iso=" + iso + " mGotCountryCode=" + mGotCountryCode +
+ " mNeedFixZone=" + mNeedFixZone);
+ }
if (zone != null) {
if (getAutoTimeZone()) {
@@ -1461,6 +1495,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
* @param zoneId timezone set by carrier
*/
private void setAndBroadcastNetworkSetTimeZone(String zoneId) {
+ if (DBG) log("setAndBroadcastNetworkSetTimeZone: setTimeZone=" + zoneId);
AlarmManager alarm =
(AlarmManager) phone.getContext().getSystemService(Context.ALARM_SERVICE);
alarm.setTimeZone(zoneId);
@@ -1477,6 +1512,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
* @param time time set by network
*/
private void setAndBroadcastNetworkSetTime(long time) {
+ if (DBG) log("setAndBroadcastNetworkSetTime: time=" + time + "ms");
SystemClock.setCurrentTimeMillis(time);
Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIME);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
index 662f1f6..c0acf5b 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
@@ -852,12 +852,16 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ALPHA,
ss.getOperatorAlphaLong());
+ String prevOperatorNumeric =
+ SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, "");
operatorNumeric = ss.getOperatorNumeric();
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, operatorNumeric);
if (operatorNumeric == null) {
if (DBG) {
- log("pollStateDone: operatorNumeric is null:" +
+ log("pollStateDone: operatorNumeric=" + operatorNumeric +
+ " prevOperatorNumeric=" + prevOperatorNumeric +
+ " mNeedFixZone=" + mNeedFixZone +
" clear PROPERTY_OPERATOR_ISO_COUNTRY");
}
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, "");
@@ -875,7 +879,9 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
}
if (DBG) {
log("pollStateDone: operatorNumeric=" + operatorNumeric +
- " mcc=" + mcc + " iso=" + iso);
+ " prevOperatorNumeric=" + prevOperatorNumeric +
+ " mNeedFixZone=" + mNeedFixZone +
+ " mcc=" + mcc + " iso-cc=" + iso);
}
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, iso);
@@ -895,7 +901,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
if ((uniqueZones.size() == 1) || testOneUniqueOffsetPath) {
zone = uniqueZones.get(0);
if (DBG) {
- log("pollStateDone: no nitz but one TZ for iso=" + iso +
+ log("pollStateDone: no nitz but one TZ for iso-cc=" + iso +
" with zone.getID=" + zone.getID() +
" testOneUniqueOffsetPath=" + testOneUniqueOffsetPath);
}
@@ -903,22 +909,24 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
} else {
if (DBG) {
log("pollStateDone: there are " + uniqueZones.size() +
- " unique offsets for iso='" + iso +
+ " unique offsets for iso-cc='" + iso +
" testOneUniqueOffsetPath=" + testOneUniqueOffsetPath +
"', do nothing");
}
}
}
- if (mNeedFixZone) {
+ // Fix the time zone If the operator changed or we need to fix it because
+ // when the NITZ time came in we didn't know the country code.
+ if ( ! operatorNumeric.equals(prevOperatorNumeric) || mNeedFixZone) {
// If the offset is (0, false) and the timezone property
// is set, use the timezone property rather than
// GMT.
String zoneName = SystemProperties.get(TIMEZONE_PROPERTY);
if (DBG) {
- log("pollStateDone: mNeedFixZone==true zoneName='" + zoneName +
+ log("pollStateDone: fix time zone zoneName='" + zoneName +
"' mZoneOffset=" + mZoneOffset + " mZoneDst=" + mZoneDst +
- " iso='" + iso +
+ " iso-cc='" + iso +
"' iso-cc-idx=" + Arrays.binarySearch(GMT_COUNTRY_CODES, iso));
}
if ((mZoneOffset == 0) && (mZoneDst == false) &&
@@ -957,15 +965,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
} else {
log("pollStateDone: zone == null");
}
- } else {
- if (DBG) {
- String zoneName = SystemProperties.get(TIMEZONE_PROPERTY);
- zone = TimeZone.getDefault();
- log("pollStateDone: mNeedFixZone==false zoneName='" + zoneName +
- "' mZoneOffset=" + mZoneOffset + " mZoneDst=" + mZoneDst +
- " iso='" + iso +
- "' iso-cc-idx=" + Arrays.binarySearch(GMT_COUNTRY_CODES, iso));
- }
}
}
@@ -1442,10 +1441,10 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
}
}
- if (zone == null) {
- // We got the time before the country, so we don't know
- // how to identify the DST rules yet. Save the information
- // and hope to fix it up later.
+ if ((zone == null) || (mZoneOffset != tzOffset) || (mZoneDst != (dst != 0))){
+ // We got the time before the country or the zone has changed
+ // so we don't know how to identify the DST rules yet. Save
+ // the information and hope to fix it up later.
mNeedFixZone = true;
mZoneOffset = tzOffset;
@@ -1556,6 +1555,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
* @param zoneId timezone set by carrier
*/
private void setAndBroadcastNetworkSetTimeZone(String zoneId) {
+ if (DBG) log("setAndBroadcastNetworkSetTimeZone: setTimeZone=" + zoneId);
AlarmManager alarm =
(AlarmManager) phone.getContext().getSystemService(Context.ALARM_SERVICE);
alarm.setTimeZone(zoneId);
@@ -1576,6 +1576,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
* @param time time set by network
*/
private void setAndBroadcastNetworkSetTime(long time) {
+ if (DBG) log("setAndBroadcastNetworkSetTime: time=" + time + "ms");
SystemClock.setCurrentTimeMillis(time);
Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIME);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);