Loading src/java/com/android/internal/telephony/NitzStateMachine.java +2 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,8 @@ public interface NitzStateMachine { void handleNetworkAvailable(); /** * Informs the {@link NitzStateMachine} that the network has become unavailable. * Informs the {@link NitzStateMachine} that the network has become unavailable. Any network * state, i.e. NITZ, should be cleared. */ void handleNetworkUnavailable(); Loading src/java/com/android/internal/telephony/NitzStateMachineImpl.java +15 −7 Original line number Diff line number Diff line Loading @@ -319,20 +319,28 @@ public final class NitzStateMachineImpl implements NitzStateMachine { mSavedNitzTime = null; mTimeLog.log("handleNetworkUnavailable: NITZ state cleared."); TimestampedValue<NitzData> oldNitzSignal = mLatestNitzSignal; mLatestNitzSignal = null; mNitzTimeZoneDetectionSuccessful = false; mSavedTimeZoneId = null; mTimeZoneLog.log("handleNetworkUnavailable: NITZ state cleared."); // mSavedTimeZoneId has been cleared but it might be sufficient to detect the time zone // using only the country information that is left. // Avoid doing country-only detection work unnecessarily: if the mLatestNitzSignal was // already null we have nothing to do as it will have been done last time the // mLatestNitzSignal was cleared. if (oldNitzSignal == null) { return; } // mSavedTimeZoneId has been cleared but using only the country information that is left // might be sufficient to detect the time zone. String isoCountryCode = mCountryIsoCode; if (isoCountryCode != null) { // We don't need to do country-based time zone detection if the isoCountryCode is null // (unknown) or empty (test cell). TextUtils.isEmpty() does both checks in one. if (!TextUtils.isEmpty(isoCountryCode)) { updateTimeZoneFromNetworkCountryCode(isoCountryCode); } } } @Override public void handleCountryUnavailable() { Loading @@ -348,7 +356,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { @Override public void handleNitzReceived(TimestampedValue<NitzData> nitzSignal) { // Always store the latest NITZ signal received. mLatestNitzSignal = nitzSignal; mLatestNitzSignal = Objects.requireNonNull(nitzSignal); updateTimeZoneFromCountryAndNitz(); updateTimeFromNitz(); Loading src/java/com/android/internal/telephony/ServiceStateTracker.java +6 −3 Original line number Diff line number Diff line Loading @@ -728,7 +728,8 @@ public class ServiceStateTracker extends Handler { mMin = null; mPrlVersion = null; mIsMinInfoReady = false; mNitzState.handleCountryUnavailable(); mLastNitzData = null; mNitzState.handleNetworkUnavailable(); mCellIdentity = null; mNewCellIdentity = null; mSignalStrengthUpdatedTime = System.currentTimeMillis(); Loading Loading @@ -3014,7 +3015,8 @@ public class ServiceStateTracker extends Handler { mNewSS.setStateOutOfService(); mNewCellIdentity = null; setSignalStrengthDefaultValues(); mNitzState.handleCountryUnavailable(); mLastNitzData = null; mNitzState.handleNetworkUnavailable(); pollStateDone(); break; Loading @@ -3022,7 +3024,8 @@ public class ServiceStateTracker extends Handler { mNewSS.setStateOff(); mNewCellIdentity = null; setSignalStrengthDefaultValues(); mNitzState.handleCountryUnavailable(); mLastNitzData = null; mNitzState.handleNetworkUnavailable(); // 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 +14 −4 Original line number Diff line number Diff line Loading @@ -172,16 +172,26 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { } private void clearNetworkStateAndRerunDetection(String reason) { // Assume any previous NITZ signals received are now invalid. if (mLatestNitzSignal == null) { // The network state is already empty so there's no need to do anything. if (DBG) { Rlog.d(LOG_TAG, reason + ": mLatestNitzSignal was already null. Nothing to do."); } return; } // The previous NITZ signal received is now invalid so clear it. mLatestNitzSignal = null; // countryIsoCode can be assigned null here, in which case the doTimeZoneDetection() call // below will do nothing, which is ok as nothing will have changed. String countryIsoCode = mCountryIsoCode; if (DBG) { Rlog.d(LOG_TAG, reason + ": countryIsoCode=" + countryIsoCode); } // Generate a new time zone suggestion and update the service as needed. // Generate a new time zone suggestion (which could be an empty suggestion) and update the // service as needed. doTimeZoneDetection(countryIsoCode, null /* nitzSignal */, reason); // Generate a new time suggestion and update the service as needed. Loading Loading @@ -258,7 +268,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { // will be made after airplane mode is re-enabled as the device re-establishes network // connectivity. // Clear time zone detection state. // Clear country detection state. mCountryIsoCode = null; String reason = "handleAirplaneModeChanged(" + on + ")"; Loading tests/telephonytests/src/com/android/internal/telephony/nitz/NewNitzStateMachineImplTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -322,8 +322,8 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Simulate airplane mode being turned off. script.toggleAirplaneMode(false); // Verify the time zone suggestion was withdrawn. script.verifyOnlyTimeZoneWasSuggestedAndReset(EMPTY_TIME_ZONE_SUGGESTION); // Verify nothing was suggested: The last suggestion was empty so nothing has changed. script.verifyNothingWasSuggested(); // Check the state that NitzStateMachine must expose. assertNull(mNitzStateMachineImpl.getCachedNitzData()); Loading Loading
src/java/com/android/internal/telephony/NitzStateMachine.java +2 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,8 @@ public interface NitzStateMachine { void handleNetworkAvailable(); /** * Informs the {@link NitzStateMachine} that the network has become unavailable. * Informs the {@link NitzStateMachine} that the network has become unavailable. Any network * state, i.e. NITZ, should be cleared. */ void handleNetworkUnavailable(); Loading
src/java/com/android/internal/telephony/NitzStateMachineImpl.java +15 −7 Original line number Diff line number Diff line Loading @@ -319,20 +319,28 @@ public final class NitzStateMachineImpl implements NitzStateMachine { mSavedNitzTime = null; mTimeLog.log("handleNetworkUnavailable: NITZ state cleared."); TimestampedValue<NitzData> oldNitzSignal = mLatestNitzSignal; mLatestNitzSignal = null; mNitzTimeZoneDetectionSuccessful = false; mSavedTimeZoneId = null; mTimeZoneLog.log("handleNetworkUnavailable: NITZ state cleared."); // mSavedTimeZoneId has been cleared but it might be sufficient to detect the time zone // using only the country information that is left. // Avoid doing country-only detection work unnecessarily: if the mLatestNitzSignal was // already null we have nothing to do as it will have been done last time the // mLatestNitzSignal was cleared. if (oldNitzSignal == null) { return; } // mSavedTimeZoneId has been cleared but using only the country information that is left // might be sufficient to detect the time zone. String isoCountryCode = mCountryIsoCode; if (isoCountryCode != null) { // We don't need to do country-based time zone detection if the isoCountryCode is null // (unknown) or empty (test cell). TextUtils.isEmpty() does both checks in one. if (!TextUtils.isEmpty(isoCountryCode)) { updateTimeZoneFromNetworkCountryCode(isoCountryCode); } } } @Override public void handleCountryUnavailable() { Loading @@ -348,7 +356,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { @Override public void handleNitzReceived(TimestampedValue<NitzData> nitzSignal) { // Always store the latest NITZ signal received. mLatestNitzSignal = nitzSignal; mLatestNitzSignal = Objects.requireNonNull(nitzSignal); updateTimeZoneFromCountryAndNitz(); updateTimeFromNitz(); Loading
src/java/com/android/internal/telephony/ServiceStateTracker.java +6 −3 Original line number Diff line number Diff line Loading @@ -728,7 +728,8 @@ public class ServiceStateTracker extends Handler { mMin = null; mPrlVersion = null; mIsMinInfoReady = false; mNitzState.handleCountryUnavailable(); mLastNitzData = null; mNitzState.handleNetworkUnavailable(); mCellIdentity = null; mNewCellIdentity = null; mSignalStrengthUpdatedTime = System.currentTimeMillis(); Loading Loading @@ -3014,7 +3015,8 @@ public class ServiceStateTracker extends Handler { mNewSS.setStateOutOfService(); mNewCellIdentity = null; setSignalStrengthDefaultValues(); mNitzState.handleCountryUnavailable(); mLastNitzData = null; mNitzState.handleNetworkUnavailable(); pollStateDone(); break; Loading @@ -3022,7 +3024,8 @@ public class ServiceStateTracker extends Handler { mNewSS.setStateOff(); mNewCellIdentity = null; setSignalStrengthDefaultValues(); mNitzState.handleCountryUnavailable(); mLastNitzData = null; mNitzState.handleNetworkUnavailable(); // 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 +14 −4 Original line number Diff line number Diff line Loading @@ -172,16 +172,26 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { } private void clearNetworkStateAndRerunDetection(String reason) { // Assume any previous NITZ signals received are now invalid. if (mLatestNitzSignal == null) { // The network state is already empty so there's no need to do anything. if (DBG) { Rlog.d(LOG_TAG, reason + ": mLatestNitzSignal was already null. Nothing to do."); } return; } // The previous NITZ signal received is now invalid so clear it. mLatestNitzSignal = null; // countryIsoCode can be assigned null here, in which case the doTimeZoneDetection() call // below will do nothing, which is ok as nothing will have changed. String countryIsoCode = mCountryIsoCode; if (DBG) { Rlog.d(LOG_TAG, reason + ": countryIsoCode=" + countryIsoCode); } // Generate a new time zone suggestion and update the service as needed. // Generate a new time zone suggestion (which could be an empty suggestion) and update the // service as needed. doTimeZoneDetection(countryIsoCode, null /* nitzSignal */, reason); // Generate a new time suggestion and update the service as needed. Loading Loading @@ -258,7 +268,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { // will be made after airplane mode is re-enabled as the device re-establishes network // connectivity. // Clear time zone detection state. // Clear country detection state. mCountryIsoCode = null; String reason = "handleAirplaneModeChanged(" + on + ")"; Loading
tests/telephonytests/src/com/android/internal/telephony/nitz/NewNitzStateMachineImplTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -322,8 +322,8 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Simulate airplane mode being turned off. script.toggleAirplaneMode(false); // Verify the time zone suggestion was withdrawn. script.verifyOnlyTimeZoneWasSuggestedAndReset(EMPTY_TIME_ZONE_SUGGESTION); // Verify nothing was suggested: The last suggestion was empty so nothing has changed. script.verifyNothingWasSuggested(); // Check the state that NitzStateMachine must expose. assertNull(mNitzStateMachineImpl.getCachedNitzData()); Loading