Merge "Fix metrics test flakiness" into tm-dev am: d718e76f47 am: d5318be209
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17713903
Change-Id: I9dd049c42332bda3dc31ede3c860d07ce7bba94a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/services/core/java/com/android/server/timezonedetector/ServiceConfigAccessorImpl.java b/services/core/java/com/android/server/timezonedetector/ServiceConfigAccessorImpl.java
index ae52912..7173f60 100644
--- a/services/core/java/com/android/server/timezonedetector/ServiceConfigAccessorImpl.java
+++ b/services/core/java/com/android/server/timezonedetector/ServiceConfigAccessorImpl.java
@@ -59,6 +59,8 @@
*/
private static final Set<String> CONFIGURATION_INTERNAL_SERVER_FLAGS_KEYS_TO_WATCH = Set.of(
ServerFlags.KEY_LOCATION_TIME_ZONE_DETECTION_FEATURE_SUPPORTED,
+ ServerFlags.KEY_PRIMARY_LTZP_MODE_OVERRIDE,
+ ServerFlags.KEY_SECONDARY_LTZP_MODE_OVERRIDE,
ServerFlags.KEY_LOCATION_TIME_ZONE_DETECTION_RUN_IN_BACKGROUND_ENABLED,
ServerFlags.KEY_ENHANCED_METRICS_COLLECTION_ENABLED,
ServerFlags.KEY_LOCATION_TIME_ZONE_DETECTION_SETTING_ENABLED_DEFAULT,
@@ -443,6 +445,9 @@
mTestPrimaryLocationTimeZoneProviderMode =
mTestPrimaryLocationTimeZoneProviderPackageName == null
? PROVIDER_MODE_DISABLED : PROVIDER_MODE_ENABLED;
+ // Changing this state can affect the content of ConfigurationInternal, so listeners need to
+ // be informed.
+ mContext.getMainThreadHandler().post(this::handleConfigurationInternalChangeOnMainThread);
}
@Override
@@ -469,6 +474,9 @@
mTestSecondaryLocationTimeZoneProviderMode =
mTestSecondaryLocationTimeZoneProviderPackageName == null
? PROVIDER_MODE_DISABLED : PROVIDER_MODE_ENABLED;
+ // Changing this state can affect the content of ConfigurationInternal, so listeners need to
+ // be informed.
+ mContext.getMainThreadHandler().post(this::handleConfigurationInternalChangeOnMainThread);
}
@Override
@@ -573,6 +581,10 @@
mTestSecondaryLocationTimeZoneProviderPackageName = null;
mTestSecondaryLocationTimeZoneProviderMode = null;
mRecordStateChangesForTests = false;
+
+ // Changing LTZP config can affect the content of ConfigurationInternal, so listeners
+ // need to be informed.
+ mContext.getMainThreadHandler().post(this::handleConfigurationInternalChangeOnMainThread);
}
private boolean isTelephonyFallbackSupported() {
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java
index f75608e..898d02e 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java
@@ -336,13 +336,13 @@
boolean isTelephonyTimeZoneDetectionSupported() {
enforceManageTimeZoneDetectorPermission();
- return mServiceConfigAccessor.isTelephonyTimeZoneDetectionFeatureSupported();
+ return mTimeZoneDetectorStrategy.isTelephonyTimeZoneDetectionSupported();
}
boolean isGeoTimeZoneDetectionSupported() {
enforceManageTimeZoneDetectorPermission();
- return mServiceConfigAccessor.isGeoTimeZoneDetectionFeatureSupported();
+ return mTimeZoneDetectorStrategy.isGeoTimeZoneDetectionSupported();
}
/**
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java
index 6b04adf..95ebd68 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java
@@ -124,4 +124,10 @@
/** Generates a state snapshot for metrics. */
@NonNull
MetricsTimeZoneDetectorState generateMetricsState();
+
+ /** Returns {@code true} if the device supports telephony time zone detection. */
+ boolean isTelephonyTimeZoneDetectionSupported();
+
+ /** Returns {@code true} if the device supports geolocation time zone detection. */
+ boolean isGeoTimeZoneDetectionSupported();
}
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategyImpl.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategyImpl.java
index e21d0e4..66c23f5 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategyImpl.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategyImpl.java
@@ -396,6 +396,20 @@
getLatestGeolocationSuggestion());
}
+ @Override
+ public boolean isTelephonyTimeZoneDetectionSupported() {
+ synchronized (this) {
+ return mCurrentConfigurationInternal.isTelephonyDetectionSupported();
+ }
+ }
+
+ @Override
+ public boolean isGeoTimeZoneDetectionSupported() {
+ synchronized (this) {
+ return mCurrentConfigurationInternal.isGeoDetectionSupported();
+ }
+ }
+
private static int scoreTelephonySuggestion(@NonNull TelephonyTimeZoneSuggestion suggestion) {
int score;
if (suggestion.getZoneId() == null) {
diff --git a/services/tests/servicestests/src/com/android/server/timezonedetector/FakeTimeZoneDetectorStrategy.java b/services/tests/servicestests/src/com/android/server/timezonedetector/FakeTimeZoneDetectorStrategy.java
index 2d0dca2..c9fc033 100644
--- a/services/tests/servicestests/src/com/android/server/timezonedetector/FakeTimeZoneDetectorStrategy.java
+++ b/services/tests/servicestests/src/com/android/server/timezonedetector/FakeTimeZoneDetectorStrategy.java
@@ -61,6 +61,16 @@
}
@Override
+ public boolean isTelephonyTimeZoneDetectionSupported() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isGeoTimeZoneDetectionSupported() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public void dump(IndentingPrintWriter pw, String[] args) {
mDumpCalled = true;
}