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

Commit 4c05249d authored by Neil Fuller's avatar Neil Fuller
Browse files

Add resource config for the GeoTz feature

Add resource config for the Geolocation tz detection feature.

The feature can still be enabled for local dev via a persistent system
property, but the config is intended to be the "proper" way to turn the
feature on.

Bug: 172546738
Test: build / boot
Change-Id: Ia35dde9308274825d0d3c4afe908b6310aa834e4
parent 85036ff7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1602,6 +1602,9 @@
         config_timeZoneRulesUpdateTrackingEnabled are true.] -->
    <integer name="config_timeZoneRulesCheckRetryCount">5</integer>

    <!-- Whether the geolocation time zone detection feature is enabled. -->
    <bool name="config_enableGeolocationTimeZoneDetection" translatable="false">false</bool>

    <!-- Whether to enable primary location time zone provider overlay which allows the primary
         location time zone provider to be replaced by an app at run-time. When disabled, only the
         config_primaryLocationTimeZoneProviderPackageName package will be searched for the primary
+1 −0
Original line number Diff line number Diff line
@@ -2165,6 +2165,7 @@
  <java-symbol type="string" name="config_defaultNetworkScorerPackageName" />
  <java-symbol type="string" name="config_persistentDataPackageName" />
  <java-symbol type="string" name="config_deviceConfiguratorPackageName" />
  <java-symbol type="bool" name="config_enableGeolocationTimeZoneDetection" />
  <java-symbol type="bool" name="config_enablePrimaryLocationTimeZoneOverlay" />
  <java-symbol type="string" name="config_primaryLocationTimeZoneProviderPackageName" />
  <java-symbol type="bool" name="config_enableSecondaryLocationTimeZoneOverlay" />
+4 −3
Original line number Diff line number Diff line
@@ -79,8 +79,8 @@ public class LocationTimeZoneManagerService extends Binder {

        @Override
        public void onStart() {
            if (TimeZoneDetectorService.GEOLOCATION_TIME_ZONE_DETECTION_ENABLED) {
            Context context = getContext();
            if (TimeZoneDetectorService.isGeoLocationTimeZoneDetectionEnabled(context)) {
                mService = new LocationTimeZoneManagerService(context);

                // The service currently exposes no LocalService or Binder API, but it extends
@@ -93,7 +93,8 @@ public class LocationTimeZoneManagerService extends Binder {

        @Override
        public void onBootPhase(int phase) {
            if (TimeZoneDetectorService.GEOLOCATION_TIME_ZONE_DETECTION_ENABLED) {
            Context context = getContext();
            if (TimeZoneDetectorService.isGeoLocationTimeZoneDetectionEnabled(context)) {
                if (phase == PHASE_SYSTEM_SERVICES_READY) {
                    // The location service must be functioning after this boot phase.
                    mService.onSystemReady();
+21 −8
Original line number Diff line number Diff line
@@ -59,14 +59,25 @@ public final class TimeZoneDetectorService extends ITimeZoneDetectorService.Stub
    private static final String TAG = "TimeZoneDetectorService";

    /**
     * A "feature switch" for enabling / disabling location-based time zone detection. If this is
     * {@code false}, there should be few / little changes in behavior with previous releases and
     * little overhead associated with geolocation components.
     * TODO(b/151304765) Remove this when the feature is on for all.
     * A "feature switch" for location-based time zone detection. If this is {@code false}. It is
     * initialized and never refreshed; it affects what services are started on boot so consistency
     * is important.
     */
    public static final boolean GEOLOCATION_TIME_ZONE_DETECTION_ENABLED =
            SystemProperties.getBoolean(
    @Nullable
    private static Boolean sGeoLocationTimeZoneDetectionEnabled;

    /** Returns {@code true} if the location-based time zone detection feature is enabled. */
    public static boolean isGeoLocationTimeZoneDetectionEnabled(Context context) {
        if (sGeoLocationTimeZoneDetectionEnabled == null) {
            // The config value is expected to be the main switch. Platform developers can also
            // enable the feature using a persistent system property.
            sGeoLocationTimeZoneDetectionEnabled = context.getResources().getBoolean(
                    com.android.internal.R.bool.config_enableGeolocationTimeZoneDetection)
                    || SystemProperties.getBoolean(
                            "persist.sys.location_time_zone_detection_feature_enabled", false);
        }
        return sGeoLocationTimeZoneDetectionEnabled;
    }

    /**
     * Handles the service lifecycle for {@link TimeZoneDetectorService} and
@@ -84,9 +95,11 @@ public final class TimeZoneDetectorService extends ITimeZoneDetectorService.Stub
            Context context = getContext();
            Handler handler = FgThread.getHandler();

            boolean geolocationTimeZoneDetectionEnabled =
                    isGeoLocationTimeZoneDetectionEnabled(context);
            TimeZoneDetectorStrategy timeZoneDetectorStrategy =
                    TimeZoneDetectorStrategyImpl.create(
                            context, handler, GEOLOCATION_TIME_ZONE_DETECTION_ENABLED);
                            context, handler, geolocationTimeZoneDetectionEnabled);

            // Create and publish the local service for use by internal callers.
            TimeZoneDetectorInternal internal =