Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2009935 authored by Neil Fuller's avatar Neil Fuller Committed by Automerger Merge Worker
Browse files

Merge "Fix metrics test flakiness" into tm-dev am: d718e76f

parents 49b44608 d718e76f
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor {
     */
    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 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor {
        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 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor {
        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 @@ public final class ServiceConfigAccessorImpl implements ServiceConfigAccessor {
        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() {
+2 −2
Original line number Diff line number Diff line
@@ -336,13 +336,13 @@ public final class TimeZoneDetectorService extends ITimeZoneDetectorService.Stub
    boolean isTelephonyTimeZoneDetectionSupported() {
        enforceManageTimeZoneDetectorPermission();

        return mServiceConfigAccessor.isTelephonyTimeZoneDetectionFeatureSupported();
        return mTimeZoneDetectorStrategy.isTelephonyTimeZoneDetectionSupported();
    }

    boolean isGeoTimeZoneDetectionSupported() {
        enforceManageTimeZoneDetectorPermission();

        return mServiceConfigAccessor.isGeoTimeZoneDetectionFeatureSupported();
        return mTimeZoneDetectorStrategy.isGeoTimeZoneDetectionSupported();
    }

    /**
+6 −0
Original line number Diff line number Diff line
@@ -124,4 +124,10 @@ public interface TimeZoneDetectorStrategy extends Dumpable {
    /** 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();
}
+14 −0
Original line number Diff line number Diff line
@@ -396,6 +396,20 @@ public final class TimeZoneDetectorStrategyImpl implements TimeZoneDetectorStrat
                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) {
+10 −0
Original line number Diff line number Diff line
@@ -60,6 +60,16 @@ class FakeTimeZoneDetectorStrategy implements TimeZoneDetectorStrategy {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean isTelephonyTimeZoneDetectionSupported() {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean isGeoTimeZoneDetectionSupported() {
        throw new UnsupportedOperationException();
    }

    @Override
    public void dump(IndentingPrintWriter pw, String[] args) {
        mDumpCalled = true;