Loading src/java/com/android/internal/telephony/LocaleTracker.java +3 −7 Original line number Diff line number Diff line Loading @@ -489,7 +489,6 @@ public class LocaleTracker extends Handler { log("updateLocale: countryIso = " + countryIso + ", countryIsoDebugInfo = " + countryIsoDebugInfo); boolean countryChanged = false; if (!Objects.equals(countryIso, mCurrentCountryIso)) { String msg = "updateLocale: Change the current country to \"" + countryIso + "\", countryIsoDebugInfo = " + countryIsoDebugInfo Loading @@ -511,24 +510,21 @@ public class LocaleTracker extends Handler { intent.putExtra(TelephonyManager.EXTRA_NETWORK_COUNTRY, countryIso); SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId()); mPhone.getContext().sendBroadcast(intent); countryChanged = true; } // For a test cell, the NitzStateMachine requires handleNetworkCountryCodeSet(true) to pass // For a test cell, the NitzStateMachine requires handleCountryDetected("") to pass // compliance tests. http://b/142840879 boolean isTestMcc = false; if (!TextUtils.isEmpty(mOperatorNumeric)) { if (mOperatorNumeric.startsWith("001")) { isTestMcc = true; countryIso = ""; countryChanged = true; } } if (TextUtils.isEmpty(countryIso) && !isTestMcc) { mNitzStateMachine.handleNetworkCountryCodeUnavailable(); mNitzStateMachine.handleCountryUnavailable(); } else { mNitzStateMachine.handleNetworkCountryCodeSet(countryChanged); mNitzStateMachine.handleCountryDetected(countryIso); } } Loading src/java/com/android/internal/telephony/NitzStateMachine.java +7 −24 Original line number Diff line number Diff line Loading @@ -17,13 +17,11 @@ package com.android.internal.telephony; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ContentResolver; import android.content.Context; import android.os.SystemClock; import android.os.SystemProperties; import android.provider.Settings; import android.telephony.TelephonyManager; import android.util.TimestampedValue; import com.android.internal.util.IndentingPrintWriter; Loading @@ -40,13 +38,12 @@ import java.io.PrintWriter; public interface NitzStateMachine { /** * Called when the network country is set on the Phone. Although set, the network country code * may be invalid. * Called when the country suitable for time zone detection is detected. * * @param countryChanged true when the country code is known to have changed, false if it * probably hasn't * @param countryIsoCode the countryIsoCode to use for time zone detection, may be "" for test * cells only, otherwise {@link #handleCountryUnavailable()} should be called */ void handleNetworkCountryCodeSet(boolean countryChanged); void handleCountryDetected(@NonNull String countryIsoCode); /** * Informs the {@link NitzStateMachine} that the network has become available. Loading @@ -59,10 +56,10 @@ public interface NitzStateMachine { void handleNetworkUnavailable(); /** * Informs the {@link NitzStateMachine} that the country code from network has become * unavailable. * Informs the {@link NitzStateMachine} that any previously detected country supplied via * {@link #handleCountryDetected(String)} is no longer valid. */ void handleNetworkCountryCodeUnavailable(); void handleCountryUnavailable(); /** * Handle a new NITZ signal being received. Loading Loading @@ -108,8 +105,6 @@ public interface NitzStateMachine { */ boolean getIgnoreNitz(); @Nullable String getNetworkCountryIsoForPhone(); /** * Returns the same value as {@link SystemClock#elapsedRealtime()}. */ Loading @@ -133,16 +128,10 @@ public interface NitzStateMachine { private static final int NITZ_UPDATE_DIFF_DEFAULT = 2000; private final int mNitzUpdateDiff; private final Phone mPhone; private final TelephonyManager mTelephonyManager; private final ContentResolver mCr; public DeviceStateImpl(Phone phone) { mPhone = phone; Context context = phone.getContext(); mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); mCr = context.getContentResolver(); mNitzUpdateSpacing = SystemProperties.getInt("ro.nitz_update_spacing", NITZ_UPDATE_SPACING_DEFAULT); Loading @@ -167,12 +156,6 @@ public interface NitzStateMachine { return ignoreNitz != null && ignoreNitz.equals("yes"); } @Override @Nullable public String getNetworkCountryIsoForPhone() { return mTelephonyManager.getNetworkCountryIso(mPhone.getPhoneId()); } @Override public long elapsedRealtime() { return SystemClock.elapsedRealtime(); Loading src/java/com/android/internal/telephony/NitzStateMachineImpl.java +20 −22 Original line number Diff line number Diff line Loading @@ -56,13 +56,11 @@ public final class NitzStateMachineImpl implements NitzStateMachine { private TimestampedValue<NitzData> mLatestNitzSignal; /** * Records whether the device should have a country code available via * {@link DeviceState#getNetworkCountryIsoForPhone()}. Before this an NITZ signal * received is (almost always) not enough to determine time zone. On test networks the country * code should be available but can still be an empty string but this flag indicates that the * information available is unlikely to improve. * Records the country to use for time zone detection. It can be a valid ISO 3166 alpha-2 code * (lower case), empty (test network) or null (no country detected). A country code is required * to determine time zone except when on a test network. */ private boolean mGotCountryCode = false; private String mCountryIsoCode; /** * The last time zone ID that has been determined. It may not have been set as the device time Loading @@ -82,7 +80,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { /** * Boolean is {@code true} if NITZ has been used to determine a time zone (which may not * ultimately have been used due to user settings). Cleared by {@link * #handleNetworkAvailable()}, {@link #handleNetworkCountryCodeUnavailable()}, * #handleNetworkAvailable()}, {@link #handleCountryUnavailable()}, * {@link #handleNetworkUnavailable()}, and {@link #handleAirplaneModeChanged(boolean)}. The * flag can be used when historic NITZ data may no longer be valid. {@code false} indicates it * is reasonable to try to set the time zone using less reliable algorithms than NITZ-based Loading Loading @@ -132,16 +130,16 @@ public final class NitzStateMachineImpl implements NitzStateMachine { } @Override public void handleNetworkCountryCodeSet(boolean countryChanged) { boolean hadCountryCode = mGotCountryCode; mGotCountryCode = true; public void handleCountryDetected(String countryIsoCode) { String oldCountryIsoCode = mCountryIsoCode; mCountryIsoCode = Objects.requireNonNull(countryIsoCode); String isoCountryCode = mDeviceState.getNetworkCountryIsoForPhone(); if (!TextUtils.isEmpty(isoCountryCode) && !mNitzTimeZoneDetectionSuccessful) { updateTimeZoneFromNetworkCountryCode(isoCountryCode); if (!TextUtils.isEmpty(countryIsoCode) && !mNitzTimeZoneDetectionSuccessful) { updateTimeZoneFromNetworkCountryCode(countryIsoCode); } if (mLatestNitzSignal != null && (countryChanged || !hadCountryCode)) { boolean countryChanged = Objects.equals(oldCountryIsoCode, countryIsoCode); if (mLatestNitzSignal != null && (countryChanged || oldCountryIsoCode == null)) { updateTimeZoneFromCountryAndNitz(); } } Loading @@ -150,7 +148,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { // This method must only be called after mLatestNitzSignal has been set to a non-null // value. TimestampedValue<NitzData> nitzSignal = Objects.requireNonNull(mLatestNitzSignal); String isoCountryCode = mDeviceState.getNetworkCountryIsoForPhone(); String isoCountryCode = mCountryIsoCode; // TimeZone.getDefault() returns a default zone (GMT) even when time zone have never // been set which makes it difficult to tell if it's what the user / time zone detection Loading @@ -172,7 +170,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { String zoneId; if (nitzData.getEmulatorHostTimeZone() != null) { zoneId = nitzData.getEmulatorHostTimeZone().getID(); } else if (!mGotCountryCode) { } else if (isoCountryCode == null) { // We don't have a country code so we won't try to look up the time zone. zoneId = null; } else if (TextUtils.isEmpty(isoCountryCode)) { Loading Loading @@ -328,8 +326,8 @@ public final class NitzStateMachineImpl implements NitzStateMachine { // mSavedTimeZoneId has been cleared but it might be sufficient to detect the time zone // using only the country information that is left. if (mGotCountryCode) { String isoCountryCode = mDeviceState.getNetworkCountryIsoForPhone(); String isoCountryCode = mCountryIsoCode; if (isoCountryCode != null) { if (!TextUtils.isEmpty(isoCountryCode)) { updateTimeZoneFromNetworkCountryCode(isoCountryCode); } Loading @@ -337,13 +335,13 @@ public final class NitzStateMachineImpl implements NitzStateMachine { } @Override public void handleNetworkCountryCodeUnavailable() { public void handleCountryUnavailable() { if (DBG) { Rlog.d(LOG_TAG, "handleNetworkCountryCodeUnavailable"); } mSavedTimeZoneId = null; mGotCountryCode = false; mCountryIsoCode = null; mNitzTimeZoneDetectionSuccessful = false; } Loading Loading @@ -377,7 +375,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { mSavedNitzTime = null; mTimeLog.log("handleAirplaneModeChanged(" + on + "): Time state cleared."); mGotCountryCode = false; mCountryIsoCode = null; mLatestNitzSignal = null; mNitzTimeZoneDetectionSuccessful = false; mSavedTimeZoneId = null; Loading Loading @@ -521,7 +519,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { // Time Zone Detection State pw.println(" mLatestNitzSignal=" + mLatestNitzSignal); pw.println(" mGotCountryCode=" + mGotCountryCode); pw.println(" mCountryIsoCode=" + mCountryIsoCode); pw.println(" mSavedTimeZoneId=" + mSavedTimeZoneId); pw.println(" mNitzTimeZoneDetectionSuccessful=" + mNitzTimeZoneDetectionSuccessful); Loading src/java/com/android/internal/telephony/ServiceStateTracker.java +3 −3 Original line number Diff line number Diff line Loading @@ -727,7 +727,7 @@ public class ServiceStateTracker extends Handler { mMin = null; mPrlVersion = null; mIsMinInfoReady = false; mNitzState.handleNetworkCountryCodeUnavailable(); mNitzState.handleCountryUnavailable(); mCellIdentity = null; mNewCellIdentity = null; mSignalStrengthUpdatedTime = System.currentTimeMillis(); Loading Loading @@ -3016,7 +3016,7 @@ public class ServiceStateTracker extends Handler { mNewSS.setStateOutOfService(); mNewCellIdentity = null; setSignalStrengthDefaultValues(); mNitzState.handleNetworkCountryCodeUnavailable(); mNitzState.handleCountryUnavailable(); pollStateDone(); break; Loading @@ -3024,7 +3024,7 @@ public class ServiceStateTracker extends Handler { mNewSS.setStateOff(); mNewCellIdentity = null; setSignalStrengthDefaultValues(); mNitzState.handleNetworkCountryCodeUnavailable(); mNitzState.handleCountryUnavailable(); // don't poll when device is shutting down or the poll was not modemTrigged // (they sent us new radio data) and current network is not IWLAN if (mDeviceShuttingDown || Loading src/java/com/android/internal/telephony/nitz/NewNitzStateMachineImpl.java +23 −28 Original line number Diff line number Diff line Loading @@ -100,8 +100,6 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { // Miscellaneous dependencies and helpers not related to detection state. private final int mPhoneId; /** Accesses global information about the device. */ private final DeviceState mDeviceState; /** Applied to NITZ signals during input filtering. */ private final NitzSignalInputFilterPredicate mNitzSignalInputFilter; /** Creates {@link PhoneTimeZoneSuggestion} for passing to the time zone detection service. */ Loading @@ -122,13 +120,11 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { // Time Zone detection state. /** * Records whether the device should have a country code available via * {@link DeviceState#getNetworkCountryIsoForPhone()}. Before this an NITZ signal * received is (almost always) not enough to determine time zone. On test networks the country * code should be available but can still be an empty string but this flag indicates that the * information available is unlikely to improve. * Records the country to use for time zone detection. It can be a valid ISO 3166 alpha-2 code * (lower case), empty (test network) or null (no country detected). A country code is required * to determine time zone except when on a test network. */ private boolean mGotCountryCode = false; private String mCountryIsoCode; /** * Creates an instance for the supplied {@link Phone}. Loading @@ -145,7 +141,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { NitzSignalInputFilterPredicate nitzSignalFilter = NitzSignalInputFilterPredicateFactory.create(phone.getContext(), deviceState); return new NewNitzStateMachineImpl( phoneId, nitzSignalFilter, timeZoneSuggester, newTimeServiceHelper, deviceState); phoneId, nitzSignalFilter, timeZoneSuggester, newTimeServiceHelper); } /** Loading @@ -156,11 +152,10 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { public NewNitzStateMachineImpl(int phoneId, @NonNull NitzSignalInputFilterPredicate nitzSignalInputFilter, @NonNull TimeZoneSuggester timeZoneSuggester, @NonNull NewTimeServiceHelper newTimeServiceHelper, @NonNull DeviceState deviceState) { @NonNull NewTimeServiceHelper newTimeServiceHelper) { mPhoneId = phoneId; mTimeZoneSuggester = Objects.requireNonNull(timeZoneSuggester); mNewTimeServiceHelper = Objects.requireNonNull(newTimeServiceHelper); mDeviceState = Objects.requireNonNull(deviceState); mNitzSignalInputFilter = Objects.requireNonNull(nitzSignalInputFilter); } Loading @@ -180,8 +175,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { // Assume any previous NITZ signals received are now invalid. mLatestNitzSignal = null; String countryIsoCode = mGotCountryCode ? mDeviceState.getNetworkCountryIsoForPhone() : null; String countryIsoCode = mCountryIsoCode; if (DBG) { Rlog.d(LOG_TAG, reason + ": countryIsoCode=" + countryIsoCode); Loading @@ -195,30 +189,32 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { } @Override public void handleNetworkCountryCodeSet(boolean countryChanged) { public void handleCountryDetected(@NonNull String countryIsoCode) { if (DBG) { Rlog.d(LOG_TAG, "handleNetworkCountryCodeSet: countryChanged=" + countryChanged Rlog.d(LOG_TAG, "handleCountryDetected: countryIsoCode=" + countryIsoCode + ", mLatestNitzSignal=" + mLatestNitzSignal); } mGotCountryCode = true; String oldCountryIsoCode = mCountryIsoCode; mCountryIsoCode = Objects.requireNonNull(countryIsoCode); if (!Objects.equals(oldCountryIsoCode, mCountryIsoCode)) { // Generate a new time zone suggestion and update the service as needed. String countryIsoCode = mDeviceState.getNetworkCountryIsoForPhone(); doTimeZoneDetection(countryIsoCode, mLatestNitzSignal, "handleNetworkCountryCodeSet(" + countryChanged + ")"); "handleCountryDetected(\"" + countryIsoCode + "\")"); } } @Override public void handleNetworkCountryCodeUnavailable() { public void handleCountryUnavailable() { if (DBG) { Rlog.d(LOG_TAG, "handleNetworkCountryCodeUnavailable:" Rlog.d(LOG_TAG, "handleCountryUnavailable:" + " mLatestNitzSignal=" + mLatestNitzSignal); } mGotCountryCode = false; mCountryIsoCode = null; // Generate a new time zone suggestion and update the service as needed. doTimeZoneDetection(null /* countryIsoCode */, mLatestNitzSignal, "handleNetworkCountryCodeUnavailable()"); "handleCountryUnavailable()"); } @Override Loading @@ -240,8 +236,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { String reason = "handleNitzReceived(" + nitzSignal + ")"; // Generate a new time zone suggestion and update the service as needed. String countryIsoCode = mGotCountryCode ? mDeviceState.getNetworkCountryIsoForPhone() : null; String countryIsoCode = mCountryIsoCode; doTimeZoneDetection(countryIsoCode, nitzSignal, reason); // Generate a new time suggestion and update the service as needed. Loading @@ -264,7 +259,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { // connectivity. // Clear time zone detection state. mGotCountryCode = false; mCountryIsoCode = null; String reason = "handleAirplaneModeChanged(" + on + ")"; clearNetworkStateAndRerunDetection(reason); Loading Loading @@ -334,7 +329,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { @Override public void dumpState(PrintWriter pw) { pw.println(" NewNitzStateMachineImpl.mLatestNitzSignal=" + mLatestNitzSignal); pw.println(" NewNitzStateMachineImpl.mGotCountryCode=" + mGotCountryCode); pw.println(" NewNitzStateMachineImpl.mCountryIsoCode=" + mCountryIsoCode); mNewTimeServiceHelper.dumpState(pw); pw.flush(); } Loading Loading
src/java/com/android/internal/telephony/LocaleTracker.java +3 −7 Original line number Diff line number Diff line Loading @@ -489,7 +489,6 @@ public class LocaleTracker extends Handler { log("updateLocale: countryIso = " + countryIso + ", countryIsoDebugInfo = " + countryIsoDebugInfo); boolean countryChanged = false; if (!Objects.equals(countryIso, mCurrentCountryIso)) { String msg = "updateLocale: Change the current country to \"" + countryIso + "\", countryIsoDebugInfo = " + countryIsoDebugInfo Loading @@ -511,24 +510,21 @@ public class LocaleTracker extends Handler { intent.putExtra(TelephonyManager.EXTRA_NETWORK_COUNTRY, countryIso); SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId()); mPhone.getContext().sendBroadcast(intent); countryChanged = true; } // For a test cell, the NitzStateMachine requires handleNetworkCountryCodeSet(true) to pass // For a test cell, the NitzStateMachine requires handleCountryDetected("") to pass // compliance tests. http://b/142840879 boolean isTestMcc = false; if (!TextUtils.isEmpty(mOperatorNumeric)) { if (mOperatorNumeric.startsWith("001")) { isTestMcc = true; countryIso = ""; countryChanged = true; } } if (TextUtils.isEmpty(countryIso) && !isTestMcc) { mNitzStateMachine.handleNetworkCountryCodeUnavailable(); mNitzStateMachine.handleCountryUnavailable(); } else { mNitzStateMachine.handleNetworkCountryCodeSet(countryChanged); mNitzStateMachine.handleCountryDetected(countryIso); } } Loading
src/java/com/android/internal/telephony/NitzStateMachine.java +7 −24 Original line number Diff line number Diff line Loading @@ -17,13 +17,11 @@ package com.android.internal.telephony; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ContentResolver; import android.content.Context; import android.os.SystemClock; import android.os.SystemProperties; import android.provider.Settings; import android.telephony.TelephonyManager; import android.util.TimestampedValue; import com.android.internal.util.IndentingPrintWriter; Loading @@ -40,13 +38,12 @@ import java.io.PrintWriter; public interface NitzStateMachine { /** * Called when the network country is set on the Phone. Although set, the network country code * may be invalid. * Called when the country suitable for time zone detection is detected. * * @param countryChanged true when the country code is known to have changed, false if it * probably hasn't * @param countryIsoCode the countryIsoCode to use for time zone detection, may be "" for test * cells only, otherwise {@link #handleCountryUnavailable()} should be called */ void handleNetworkCountryCodeSet(boolean countryChanged); void handleCountryDetected(@NonNull String countryIsoCode); /** * Informs the {@link NitzStateMachine} that the network has become available. Loading @@ -59,10 +56,10 @@ public interface NitzStateMachine { void handleNetworkUnavailable(); /** * Informs the {@link NitzStateMachine} that the country code from network has become * unavailable. * Informs the {@link NitzStateMachine} that any previously detected country supplied via * {@link #handleCountryDetected(String)} is no longer valid. */ void handleNetworkCountryCodeUnavailable(); void handleCountryUnavailable(); /** * Handle a new NITZ signal being received. Loading Loading @@ -108,8 +105,6 @@ public interface NitzStateMachine { */ boolean getIgnoreNitz(); @Nullable String getNetworkCountryIsoForPhone(); /** * Returns the same value as {@link SystemClock#elapsedRealtime()}. */ Loading @@ -133,16 +128,10 @@ public interface NitzStateMachine { private static final int NITZ_UPDATE_DIFF_DEFAULT = 2000; private final int mNitzUpdateDiff; private final Phone mPhone; private final TelephonyManager mTelephonyManager; private final ContentResolver mCr; public DeviceStateImpl(Phone phone) { mPhone = phone; Context context = phone.getContext(); mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); mCr = context.getContentResolver(); mNitzUpdateSpacing = SystemProperties.getInt("ro.nitz_update_spacing", NITZ_UPDATE_SPACING_DEFAULT); Loading @@ -167,12 +156,6 @@ public interface NitzStateMachine { return ignoreNitz != null && ignoreNitz.equals("yes"); } @Override @Nullable public String getNetworkCountryIsoForPhone() { return mTelephonyManager.getNetworkCountryIso(mPhone.getPhoneId()); } @Override public long elapsedRealtime() { return SystemClock.elapsedRealtime(); Loading
src/java/com/android/internal/telephony/NitzStateMachineImpl.java +20 −22 Original line number Diff line number Diff line Loading @@ -56,13 +56,11 @@ public final class NitzStateMachineImpl implements NitzStateMachine { private TimestampedValue<NitzData> mLatestNitzSignal; /** * Records whether the device should have a country code available via * {@link DeviceState#getNetworkCountryIsoForPhone()}. Before this an NITZ signal * received is (almost always) not enough to determine time zone. On test networks the country * code should be available but can still be an empty string but this flag indicates that the * information available is unlikely to improve. * Records the country to use for time zone detection. It can be a valid ISO 3166 alpha-2 code * (lower case), empty (test network) or null (no country detected). A country code is required * to determine time zone except when on a test network. */ private boolean mGotCountryCode = false; private String mCountryIsoCode; /** * The last time zone ID that has been determined. It may not have been set as the device time Loading @@ -82,7 +80,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { /** * Boolean is {@code true} if NITZ has been used to determine a time zone (which may not * ultimately have been used due to user settings). Cleared by {@link * #handleNetworkAvailable()}, {@link #handleNetworkCountryCodeUnavailable()}, * #handleNetworkAvailable()}, {@link #handleCountryUnavailable()}, * {@link #handleNetworkUnavailable()}, and {@link #handleAirplaneModeChanged(boolean)}. The * flag can be used when historic NITZ data may no longer be valid. {@code false} indicates it * is reasonable to try to set the time zone using less reliable algorithms than NITZ-based Loading Loading @@ -132,16 +130,16 @@ public final class NitzStateMachineImpl implements NitzStateMachine { } @Override public void handleNetworkCountryCodeSet(boolean countryChanged) { boolean hadCountryCode = mGotCountryCode; mGotCountryCode = true; public void handleCountryDetected(String countryIsoCode) { String oldCountryIsoCode = mCountryIsoCode; mCountryIsoCode = Objects.requireNonNull(countryIsoCode); String isoCountryCode = mDeviceState.getNetworkCountryIsoForPhone(); if (!TextUtils.isEmpty(isoCountryCode) && !mNitzTimeZoneDetectionSuccessful) { updateTimeZoneFromNetworkCountryCode(isoCountryCode); if (!TextUtils.isEmpty(countryIsoCode) && !mNitzTimeZoneDetectionSuccessful) { updateTimeZoneFromNetworkCountryCode(countryIsoCode); } if (mLatestNitzSignal != null && (countryChanged || !hadCountryCode)) { boolean countryChanged = Objects.equals(oldCountryIsoCode, countryIsoCode); if (mLatestNitzSignal != null && (countryChanged || oldCountryIsoCode == null)) { updateTimeZoneFromCountryAndNitz(); } } Loading @@ -150,7 +148,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { // This method must only be called after mLatestNitzSignal has been set to a non-null // value. TimestampedValue<NitzData> nitzSignal = Objects.requireNonNull(mLatestNitzSignal); String isoCountryCode = mDeviceState.getNetworkCountryIsoForPhone(); String isoCountryCode = mCountryIsoCode; // TimeZone.getDefault() returns a default zone (GMT) even when time zone have never // been set which makes it difficult to tell if it's what the user / time zone detection Loading @@ -172,7 +170,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { String zoneId; if (nitzData.getEmulatorHostTimeZone() != null) { zoneId = nitzData.getEmulatorHostTimeZone().getID(); } else if (!mGotCountryCode) { } else if (isoCountryCode == null) { // We don't have a country code so we won't try to look up the time zone. zoneId = null; } else if (TextUtils.isEmpty(isoCountryCode)) { Loading Loading @@ -328,8 +326,8 @@ public final class NitzStateMachineImpl implements NitzStateMachine { // mSavedTimeZoneId has been cleared but it might be sufficient to detect the time zone // using only the country information that is left. if (mGotCountryCode) { String isoCountryCode = mDeviceState.getNetworkCountryIsoForPhone(); String isoCountryCode = mCountryIsoCode; if (isoCountryCode != null) { if (!TextUtils.isEmpty(isoCountryCode)) { updateTimeZoneFromNetworkCountryCode(isoCountryCode); } Loading @@ -337,13 +335,13 @@ public final class NitzStateMachineImpl implements NitzStateMachine { } @Override public void handleNetworkCountryCodeUnavailable() { public void handleCountryUnavailable() { if (DBG) { Rlog.d(LOG_TAG, "handleNetworkCountryCodeUnavailable"); } mSavedTimeZoneId = null; mGotCountryCode = false; mCountryIsoCode = null; mNitzTimeZoneDetectionSuccessful = false; } Loading Loading @@ -377,7 +375,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { mSavedNitzTime = null; mTimeLog.log("handleAirplaneModeChanged(" + on + "): Time state cleared."); mGotCountryCode = false; mCountryIsoCode = null; mLatestNitzSignal = null; mNitzTimeZoneDetectionSuccessful = false; mSavedTimeZoneId = null; Loading Loading @@ -521,7 +519,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { // Time Zone Detection State pw.println(" mLatestNitzSignal=" + mLatestNitzSignal); pw.println(" mGotCountryCode=" + mGotCountryCode); pw.println(" mCountryIsoCode=" + mCountryIsoCode); pw.println(" mSavedTimeZoneId=" + mSavedTimeZoneId); pw.println(" mNitzTimeZoneDetectionSuccessful=" + mNitzTimeZoneDetectionSuccessful); Loading
src/java/com/android/internal/telephony/ServiceStateTracker.java +3 −3 Original line number Diff line number Diff line Loading @@ -727,7 +727,7 @@ public class ServiceStateTracker extends Handler { mMin = null; mPrlVersion = null; mIsMinInfoReady = false; mNitzState.handleNetworkCountryCodeUnavailable(); mNitzState.handleCountryUnavailable(); mCellIdentity = null; mNewCellIdentity = null; mSignalStrengthUpdatedTime = System.currentTimeMillis(); Loading Loading @@ -3016,7 +3016,7 @@ public class ServiceStateTracker extends Handler { mNewSS.setStateOutOfService(); mNewCellIdentity = null; setSignalStrengthDefaultValues(); mNitzState.handleNetworkCountryCodeUnavailable(); mNitzState.handleCountryUnavailable(); pollStateDone(); break; Loading @@ -3024,7 +3024,7 @@ public class ServiceStateTracker extends Handler { mNewSS.setStateOff(); mNewCellIdentity = null; setSignalStrengthDefaultValues(); mNitzState.handleNetworkCountryCodeUnavailable(); mNitzState.handleCountryUnavailable(); // don't poll when device is shutting down or the poll was not modemTrigged // (they sent us new radio data) and current network is not IWLAN if (mDeviceShuttingDown || Loading
src/java/com/android/internal/telephony/nitz/NewNitzStateMachineImpl.java +23 −28 Original line number Diff line number Diff line Loading @@ -100,8 +100,6 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { // Miscellaneous dependencies and helpers not related to detection state. private final int mPhoneId; /** Accesses global information about the device. */ private final DeviceState mDeviceState; /** Applied to NITZ signals during input filtering. */ private final NitzSignalInputFilterPredicate mNitzSignalInputFilter; /** Creates {@link PhoneTimeZoneSuggestion} for passing to the time zone detection service. */ Loading @@ -122,13 +120,11 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { // Time Zone detection state. /** * Records whether the device should have a country code available via * {@link DeviceState#getNetworkCountryIsoForPhone()}. Before this an NITZ signal * received is (almost always) not enough to determine time zone. On test networks the country * code should be available but can still be an empty string but this flag indicates that the * information available is unlikely to improve. * Records the country to use for time zone detection. It can be a valid ISO 3166 alpha-2 code * (lower case), empty (test network) or null (no country detected). A country code is required * to determine time zone except when on a test network. */ private boolean mGotCountryCode = false; private String mCountryIsoCode; /** * Creates an instance for the supplied {@link Phone}. Loading @@ -145,7 +141,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { NitzSignalInputFilterPredicate nitzSignalFilter = NitzSignalInputFilterPredicateFactory.create(phone.getContext(), deviceState); return new NewNitzStateMachineImpl( phoneId, nitzSignalFilter, timeZoneSuggester, newTimeServiceHelper, deviceState); phoneId, nitzSignalFilter, timeZoneSuggester, newTimeServiceHelper); } /** Loading @@ -156,11 +152,10 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { public NewNitzStateMachineImpl(int phoneId, @NonNull NitzSignalInputFilterPredicate nitzSignalInputFilter, @NonNull TimeZoneSuggester timeZoneSuggester, @NonNull NewTimeServiceHelper newTimeServiceHelper, @NonNull DeviceState deviceState) { @NonNull NewTimeServiceHelper newTimeServiceHelper) { mPhoneId = phoneId; mTimeZoneSuggester = Objects.requireNonNull(timeZoneSuggester); mNewTimeServiceHelper = Objects.requireNonNull(newTimeServiceHelper); mDeviceState = Objects.requireNonNull(deviceState); mNitzSignalInputFilter = Objects.requireNonNull(nitzSignalInputFilter); } Loading @@ -180,8 +175,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { // Assume any previous NITZ signals received are now invalid. mLatestNitzSignal = null; String countryIsoCode = mGotCountryCode ? mDeviceState.getNetworkCountryIsoForPhone() : null; String countryIsoCode = mCountryIsoCode; if (DBG) { Rlog.d(LOG_TAG, reason + ": countryIsoCode=" + countryIsoCode); Loading @@ -195,30 +189,32 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { } @Override public void handleNetworkCountryCodeSet(boolean countryChanged) { public void handleCountryDetected(@NonNull String countryIsoCode) { if (DBG) { Rlog.d(LOG_TAG, "handleNetworkCountryCodeSet: countryChanged=" + countryChanged Rlog.d(LOG_TAG, "handleCountryDetected: countryIsoCode=" + countryIsoCode + ", mLatestNitzSignal=" + mLatestNitzSignal); } mGotCountryCode = true; String oldCountryIsoCode = mCountryIsoCode; mCountryIsoCode = Objects.requireNonNull(countryIsoCode); if (!Objects.equals(oldCountryIsoCode, mCountryIsoCode)) { // Generate a new time zone suggestion and update the service as needed. String countryIsoCode = mDeviceState.getNetworkCountryIsoForPhone(); doTimeZoneDetection(countryIsoCode, mLatestNitzSignal, "handleNetworkCountryCodeSet(" + countryChanged + ")"); "handleCountryDetected(\"" + countryIsoCode + "\")"); } } @Override public void handleNetworkCountryCodeUnavailable() { public void handleCountryUnavailable() { if (DBG) { Rlog.d(LOG_TAG, "handleNetworkCountryCodeUnavailable:" Rlog.d(LOG_TAG, "handleCountryUnavailable:" + " mLatestNitzSignal=" + mLatestNitzSignal); } mGotCountryCode = false; mCountryIsoCode = null; // Generate a new time zone suggestion and update the service as needed. doTimeZoneDetection(null /* countryIsoCode */, mLatestNitzSignal, "handleNetworkCountryCodeUnavailable()"); "handleCountryUnavailable()"); } @Override Loading @@ -240,8 +236,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { String reason = "handleNitzReceived(" + nitzSignal + ")"; // Generate a new time zone suggestion and update the service as needed. String countryIsoCode = mGotCountryCode ? mDeviceState.getNetworkCountryIsoForPhone() : null; String countryIsoCode = mCountryIsoCode; doTimeZoneDetection(countryIsoCode, nitzSignal, reason); // Generate a new time suggestion and update the service as needed. Loading @@ -264,7 +259,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { // connectivity. // Clear time zone detection state. mGotCountryCode = false; mCountryIsoCode = null; String reason = "handleAirplaneModeChanged(" + on + ")"; clearNetworkStateAndRerunDetection(reason); Loading Loading @@ -334,7 +329,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { @Override public void dumpState(PrintWriter pw) { pw.println(" NewNitzStateMachineImpl.mLatestNitzSignal=" + mLatestNitzSignal); pw.println(" NewNitzStateMachineImpl.mGotCountryCode=" + mGotCountryCode); pw.println(" NewNitzStateMachineImpl.mCountryIsoCode=" + mCountryIsoCode); mNewTimeServiceHelper.dumpState(pw); pw.flush(); } Loading