Improve debug logging for bug reports
Add extra debug info when location providers stop by including the reason why they are stopping. Also add "time zone change" logging TimeZoneDetectorStrategyImpl for telephony fallback state and ConfigurationInternal changes. Bug: 197624972 Test: Manual inspection using adb shell dumpsys time_zone_detector Change-Id: I80b5653896ac33c0e813ce2e7de339bcbf7e7bb8
This commit is contained in:
@@ -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.
|
||||
@@ -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
|
||||
@@ -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")
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
@@ -267,7 +268,7 @@ class LocationTimeZoneProviderController implements Dumpable {
|
||||
mThreadingDomain.assertCurrentThread();
|
||||
|
||||
synchronized (mSharedLock) {
|
||||
stopProviders();
|
||||
stopProviders("destroy()");
|
||||
|
||||
// Enter destroyed state.
|
||||
mPrimaryProvider.destroy();
|
||||
@@ -292,7 +293,7 @@ class LocationTimeZoneProviderController implements Dumpable {
|
||||
}
|
||||
|
||||
@GuardedBy("mSharedLock")
|
||||
private void stopProviders() {
|
||||
private void stopProviders(@NonNull String reason) {
|
||||
stopProviderIfStarted(mPrimaryProvider);
|
||||
stopProviderIfStarted(mSecondaryProvider);
|
||||
|
||||
@@ -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);
|
||||
@@ -404,7 +406,7 @@ class LocationTimeZoneProviderController implements Dumpable {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stopProviders();
|
||||
stopProviders("Geo detection behavior disabled");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user