summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2012-05-03 09:26:25 -0700
committerWink Saville <wink@google.com>2012-05-03 09:26:25 -0700
commitf0f43227a7dbaab111f6984d8a013776754e6f38 (patch)
treee28b932212020ba7964740c768ec218db7924f6a /telephony
parent427db9b3d10d5c203d0351e683c3cddfd270250c (diff)
downloadframeworks_base-f0f43227a7dbaab111f6984d8a013776754e6f38.zip
frameworks_base-f0f43227a7dbaab111f6984d8a013776754e6f38.tar.gz
frameworks_base-f0f43227a7dbaab111f6984d8a013776754e6f38.tar.bz2
Time can become incorrect when no sim is present or mcc changes.
bug: 6393147 Change-Id: I07ad74998b03af532ccf704a8a7e4844f5829b14
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/com/android/internal/telephony/ServiceStateTracker.java55
-rw-r--r--telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java18
-rwxr-xr-xtelephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java22
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java22
4 files changed, 69 insertions, 48 deletions
diff --git a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
index 75eb226..190d909 100644
--- a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
@@ -463,6 +463,61 @@ public abstract class ServiceStateTracker extends Handler {
pollingContext = new int[1];
}
+ /**
+ * Return true if time zone needs fixing.
+ *
+ * @param phoneBase
+ * @param operatorNumeric
+ * @param prevOperatorNumeric
+ * @param needToFixTimeZone
+ * @return true if time zone needs to be fixed
+ */
+ protected boolean isTimeZoneFixNeeded(PhoneBase phoneBase, String operatorNumeric,
+ String prevOperatorNumeric, boolean needToFixTimeZone) {
+ // Return false if the mcc isn't valid as we don't know where we are.
+ // Return true if we have an IccCard and the mcc changed or we
+ // need to fix it because when the NITZ time came in we didn't
+ // know the country code.
+
+ // If mcc is invalid then we'll return false
+ int mcc;
+ try {
+ mcc = Integer.parseInt(operatorNumeric.substring(0, 3));
+ } catch (Exception e) {
+ if (DBG) {
+ log("isTimeZoneFixNeeded: no mcc, operatorNumeric=" + operatorNumeric +
+ " retVal=false");
+ }
+ return false;
+ }
+
+ // If prevMcc is invalid will make it different from mcc
+ // so we'll return true if the card exists.
+ int prevMcc;
+ try {
+ prevMcc = Integer.parseInt(prevOperatorNumeric.substring(0, 3));
+ } catch (Exception e) {
+ prevMcc = mcc + 1;
+ }
+
+ // Determine if the Icc card exists
+ IccCard iccCard = phoneBase.getIccCard();
+ boolean iccCardExist = (iccCard != null) && iccCard.getState().iccCardExist();
+
+ // Determine retVal
+ boolean retVal = ((iccCardExist && (mcc != prevMcc)) || needToFixTimeZone);
+ if (DBG) {
+ log("isTimeZoneFixNeeded: retVal=" + retVal +
+ " iccCard=" + iccCard +
+ " iccCard.state=" + (iccCard == null ? "null" : iccCard.getState().toString()) +
+ " iccCardExist=" + iccCardExist +
+ " operatorNumeric=" + operatorNumeric + " mcc=" + mcc +
+ " prevOperatorNumeric=" + prevOperatorNumeric + " prevMcc=" + prevMcc +
+ " needToFixTimeZone=" + needToFixTimeZone);
+ }
+ return retVal;
+ }
+
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
pw.println("ServiceStateTracker:");
pw.println(" ss=" + ss);
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
index ff7a0810..5a0df99 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
@@ -377,12 +377,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
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");
- }
+ if (DBG) log("operatorNumeric is null");
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, "");
mGotCountryCode = false;
} else {
@@ -396,20 +391,13 @@ 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;
- // 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 (isTimeZoneFixNeeded(phone, operatorNumeric, 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 b694e0a..dd188e9 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
@@ -904,9 +904,11 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
if (getAutoTimeZone()) {
setAndBroadcastNetworkSetTimeZone(zone.getID());
} else {
- log("fixTimeZone: zone == null");
+ log("fixTimeZone: skip changing zone as getAutoTimeZone was false");
}
saveNitzTimeZone(zone.getID());
+ } else {
+ log("fixTimeZone: zone == null, do nothing for zone");
}
}
@@ -1003,12 +1005,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
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");
- }
+ if (DBG) log("operatorNumeric is null");
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, "");
mGotCountryCode = false;
} else {
@@ -1022,20 +1019,13 @@ 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;
- // 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 (isTimeZoneFixNeeded(phone, operatorNumeric, prevOperatorNumeric,
+ mNeedFixZone)) {
fixTimeZone(isoCountryCode);
}
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
index c0acf5b..bded25a 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
@@ -21,6 +21,7 @@ import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.DataConnectionTracker;
import com.android.internal.telephony.EventLogTags;
import com.android.internal.telephony.IccCard;
+import com.android.internal.telephony.IccCardStatus;
import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.RestrictedState;
@@ -645,8 +646,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
String opNames[] = (String[])ar.result;
if (opNames != null && opNames.length >= 3) {
- newSS.setOperatorName (
- opNames[0], opNames[1], opNames[2]);
+ newSS.setOperatorName (opNames[0], opNames[1], opNames[2]);
}
break;
@@ -858,12 +858,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
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");
- }
+ if (DBG) log("operatorNumeric is null");
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, "");
mGotCountryCode = false;
mNitzUpdatedTime = false;
@@ -877,12 +872,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
} catch ( StringIndexOutOfBoundsException ex) {
loge("pollStateDone: countryCodeForMcc error" + ex);
}
- if (DBG) {
- log("pollStateDone: operatorNumeric=" + operatorNumeric +
- " prevOperatorNumeric=" + prevOperatorNumeric +
- " mNeedFixZone=" + mNeedFixZone +
- " mcc=" + mcc + " iso-cc=" + iso);
- }
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, iso);
mGotCountryCode = true;
@@ -916,9 +905,8 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
}
}
- // 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 (isTimeZoneFixNeeded(phone, operatorNumeric, prevOperatorNumeric,
+ mNeedFixZone)) {
// If the offset is (0, false) and the timezone property
// is set, use the timezone property rather than
// GMT.