Time can become incorrect when no sim is present or mcc changes.
bug: 6393147
Change-Id: I07ad74998b03af532ccf704a8a7e4844f5829b14
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user