Loading services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategyImpl.java +21 −13 Original line number Diff line number Diff line Loading @@ -341,15 +341,16 @@ public final class TimeZoneDetectorStrategyImpl implements TimeZoneDetectorStrat // Only do any work if fallback is currently not enabled. if (!mTelephonyTimeZoneFallbackEnabled.getValue()) { ConfigurationInternal currentUserConfig = mCurrentConfigurationInternal; if (DBG) { Slog.d(LOG_TAG, "enableTelephonyTimeZoneFallbackMode" + ": currentUserConfig=" + currentUserConfig); } final boolean fallbackEnabled = true; mTelephonyTimeZoneFallbackEnabled = new TimestampedValue<>( mEnvironment.elapsedRealtimeMillis(), fallbackEnabled); String logMsg = "enableTelephonyTimeZoneFallbackMode" + ": currentUserConfig=" + currentUserConfig + ", mTelephonyTimeZoneFallbackEnabled=" + mTelephonyTimeZoneFallbackEnabled; logTimeZoneDetectorChange(logMsg); // mTelephonyTimeZoneFallbackEnabled and mLatestGeoLocationSuggestion interact. // If there is currently a certain geolocation suggestion, then the telephony fallback // value needs to be considered after changing it. Loading Loading @@ -533,10 +534,22 @@ public final class TimeZoneDetectorStrategyImpl implements TimeZoneDetectorStrat final boolean fallbackEnabled = false; mTelephonyTimeZoneFallbackEnabled = new TimestampedValue<>( mEnvironment.elapsedRealtimeMillis(), fallbackEnabled); String logMsg = "disableTelephonyFallbackIfNeeded" + ": mTelephonyTimeZoneFallbackEnabled=" + mTelephonyTimeZoneFallbackEnabled; logTimeZoneDetectorChange(logMsg); } } } private void logTimeZoneDetectorChange(@NonNull String logMsg) { if (DBG) { Slog.d(LOG_TAG, logMsg); } mTimeZoneChangesLog.log(logMsg); } /** * Detects the time zone using the latest available telephony time zone suggestions. * Finds the best available time zone suggestion from all slotIndexes. If it is high-enough Loading Loading @@ -603,14 +616,11 @@ public final class TimeZoneDetectorStrategyImpl implements TimeZoneDetectorStrat } mEnvironment.setDeviceTimeZone(newZoneId); String msg = "Set device time zone." String logMsg = "Set device time zone." + ", currentZoneId=" + currentZoneId + ", newZoneId=" + newZoneId + ", cause=" + cause; if (DBG) { Slog.d(LOG_TAG, msg); } mTimeZoneChangesLog.log(msg); logTimeZoneDetectorChange(logMsg); } @GuardedBy("this") Loading Loading @@ -662,9 +672,7 @@ public final class TimeZoneDetectorStrategyImpl implements TimeZoneDetectorStrat String logMsg = "handleConfigurationInternalChanged:" + " oldConfiguration=" + mCurrentConfigurationInternal + ", newConfiguration=" + currentUserConfig; if (DBG) { Slog.d(LOG_TAG, logMsg); } logTimeZoneDetectorChange(logMsg); mCurrentConfigurationInternal = currentUserConfig; // The configuration change may have changed available suggestions or the way suggestions Loading services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneProviderController.java +9 −7 Original line number Diff line number Diff line Loading @@ -239,9 +239,10 @@ class LocationTimeZoneProviderController implements Dumpable { if (newConfig.getUserId() != oldConfig.getUserId()) { // If the user changed, stop the providers if needed. They may be re-started // for the new user immediately afterwards if their settings allow. debugLog("User changed. old=" + oldConfig.getUserId() + ", new=" + newConfig.getUserId() + ": Stopping providers"); stopProviders(); String reason = "User changed. old=" + oldConfig.getUserId() + ", new=" + newConfig.getUserId(); debugLog("Stopping providers: " + reason); stopProviders(reason); alterProvidersStartedStateIfRequired(null /* oldConfiguration */, newConfig); } else { Loading @@ -267,7 +268,7 @@ class LocationTimeZoneProviderController implements Dumpable { mThreadingDomain.assertCurrentThread(); synchronized (mSharedLock) { stopProviders(); stopProviders("destroy()"); // Enter destroyed state. mPrimaryProvider.destroy(); Loading @@ -292,7 +293,7 @@ class LocationTimeZoneProviderController implements Dumpable { } @GuardedBy("mSharedLock") private void stopProviders() { private void stopProviders(@NonNull String reason) { stopProviderIfStarted(mPrimaryProvider); stopProviderIfStarted(mSecondaryProvider); Loading @@ -305,7 +306,8 @@ class LocationTimeZoneProviderController implements Dumpable { // re-started). if (Objects.equals(mState.get(), STATE_CERTAIN)) { GeolocationTimeZoneSuggestion suggestion = createUncertainSuggestion( mEnvironment.elapsedRealtimeMillis(), "Providers are stopping"); mEnvironment.elapsedRealtimeMillis(), "Withdraw previous suggestion, providers are stopping: " + reason); makeSuggestion(suggestion, STATE_UNCERTAIN); } setState(STATE_STOPPED); Loading Loading @@ -404,7 +406,7 @@ class LocationTimeZoneProviderController implements Dumpable { } } } else { stopProviders(); stopProviders("Geo detection behavior disabled"); } } Loading Loading
services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategyImpl.java +21 −13 Original line number Diff line number Diff line Loading @@ -341,15 +341,16 @@ public final class TimeZoneDetectorStrategyImpl implements TimeZoneDetectorStrat // Only do any work if fallback is currently not enabled. if (!mTelephonyTimeZoneFallbackEnabled.getValue()) { ConfigurationInternal currentUserConfig = mCurrentConfigurationInternal; if (DBG) { Slog.d(LOG_TAG, "enableTelephonyTimeZoneFallbackMode" + ": currentUserConfig=" + currentUserConfig); } final boolean fallbackEnabled = true; mTelephonyTimeZoneFallbackEnabled = new TimestampedValue<>( mEnvironment.elapsedRealtimeMillis(), fallbackEnabled); String logMsg = "enableTelephonyTimeZoneFallbackMode" + ": currentUserConfig=" + currentUserConfig + ", mTelephonyTimeZoneFallbackEnabled=" + mTelephonyTimeZoneFallbackEnabled; logTimeZoneDetectorChange(logMsg); // mTelephonyTimeZoneFallbackEnabled and mLatestGeoLocationSuggestion interact. // If there is currently a certain geolocation suggestion, then the telephony fallback // value needs to be considered after changing it. Loading Loading @@ -533,10 +534,22 @@ public final class TimeZoneDetectorStrategyImpl implements TimeZoneDetectorStrat final boolean fallbackEnabled = false; mTelephonyTimeZoneFallbackEnabled = new TimestampedValue<>( mEnvironment.elapsedRealtimeMillis(), fallbackEnabled); String logMsg = "disableTelephonyFallbackIfNeeded" + ": mTelephonyTimeZoneFallbackEnabled=" + mTelephonyTimeZoneFallbackEnabled; logTimeZoneDetectorChange(logMsg); } } } private void logTimeZoneDetectorChange(@NonNull String logMsg) { if (DBG) { Slog.d(LOG_TAG, logMsg); } mTimeZoneChangesLog.log(logMsg); } /** * Detects the time zone using the latest available telephony time zone suggestions. * Finds the best available time zone suggestion from all slotIndexes. If it is high-enough Loading Loading @@ -603,14 +616,11 @@ public final class TimeZoneDetectorStrategyImpl implements TimeZoneDetectorStrat } mEnvironment.setDeviceTimeZone(newZoneId); String msg = "Set device time zone." String logMsg = "Set device time zone." + ", currentZoneId=" + currentZoneId + ", newZoneId=" + newZoneId + ", cause=" + cause; if (DBG) { Slog.d(LOG_TAG, msg); } mTimeZoneChangesLog.log(msg); logTimeZoneDetectorChange(logMsg); } @GuardedBy("this") Loading Loading @@ -662,9 +672,7 @@ public final class TimeZoneDetectorStrategyImpl implements TimeZoneDetectorStrat String logMsg = "handleConfigurationInternalChanged:" + " oldConfiguration=" + mCurrentConfigurationInternal + ", newConfiguration=" + currentUserConfig; if (DBG) { Slog.d(LOG_TAG, logMsg); } logTimeZoneDetectorChange(logMsg); mCurrentConfigurationInternal = currentUserConfig; // The configuration change may have changed available suggestions or the way suggestions Loading
services/core/java/com/android/server/timezonedetector/location/LocationTimeZoneProviderController.java +9 −7 Original line number Diff line number Diff line Loading @@ -239,9 +239,10 @@ class LocationTimeZoneProviderController implements Dumpable { if (newConfig.getUserId() != oldConfig.getUserId()) { // If the user changed, stop the providers if needed. They may be re-started // for the new user immediately afterwards if their settings allow. debugLog("User changed. old=" + oldConfig.getUserId() + ", new=" + newConfig.getUserId() + ": Stopping providers"); stopProviders(); String reason = "User changed. old=" + oldConfig.getUserId() + ", new=" + newConfig.getUserId(); debugLog("Stopping providers: " + reason); stopProviders(reason); alterProvidersStartedStateIfRequired(null /* oldConfiguration */, newConfig); } else { Loading @@ -267,7 +268,7 @@ class LocationTimeZoneProviderController implements Dumpable { mThreadingDomain.assertCurrentThread(); synchronized (mSharedLock) { stopProviders(); stopProviders("destroy()"); // Enter destroyed state. mPrimaryProvider.destroy(); Loading @@ -292,7 +293,7 @@ class LocationTimeZoneProviderController implements Dumpable { } @GuardedBy("mSharedLock") private void stopProviders() { private void stopProviders(@NonNull String reason) { stopProviderIfStarted(mPrimaryProvider); stopProviderIfStarted(mSecondaryProvider); Loading @@ -305,7 +306,8 @@ class LocationTimeZoneProviderController implements Dumpable { // re-started). if (Objects.equals(mState.get(), STATE_CERTAIN)) { GeolocationTimeZoneSuggestion suggestion = createUncertainSuggestion( mEnvironment.elapsedRealtimeMillis(), "Providers are stopping"); mEnvironment.elapsedRealtimeMillis(), "Withdraw previous suggestion, providers are stopping: " + reason); makeSuggestion(suggestion, STATE_UNCERTAIN); } setState(STATE_STOPPED); Loading Loading @@ -404,7 +406,7 @@ class LocationTimeZoneProviderController implements Dumpable { } } } else { stopProviders(); stopProviders("Geo detection behavior disabled"); } } Loading