Loading core/res/res/values/config.xml +15 −8 Original line number Diff line number Diff line Loading @@ -1613,21 +1613,28 @@ <!-- Whether the geolocation time zone detection feature is enabled. --> <bool name="config_enableGeolocationTimeZoneDetection" translatable="false">true</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 <!-- Whether the primary LocationTimeZoneProvider is enabled device. Ignored if config_enableGeolocationTimeZoneDetection is false --> <bool name="config_enablePrimaryLocationTimeZoneProvider" translatable="false">false</bool> <!-- Used when enablePrimaryLocationTimeZoneProvider is true. Controls 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 location time zone provider, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> disable the runtime overlay mechanism can set it to false. --> <bool name="config_enablePrimaryLocationTimeZoneOverlay" translatable="false">false</bool> <!-- Package name providing the primary location time zone provider. Used only when config_enablePrimaryLocationTimeZoneOverlay is false. --> <string name="config_primaryLocationTimeZoneProviderPackageName" translatable="false">@null</string> <!-- Whether to enable secondary location time zone provider overlay which allows the secondary location time zone provider to be replaced by an app at run-time. When disabled, only the config_secondaryLocationTimeZoneProviderPackageName package will be searched for the secondary location time zone provider, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <!-- Whether the secondary LocationTimeZoneProvider is enabled device. Ignored if config_enableGeolocationTimeZoneDetection is false --> <bool name="config_enableSecondaryLocationTimeZoneProvider" translatable="false">true</bool> <!-- Used when enableSecondaryLocationTimeZoneProvider is true. Controls whether to enable secondary location time zone provider overlay which allows the primary location time zone provider to config_secondaryLocationTimeZoneProviderPackageName package will be searched for the secondary location time zone provider, otherwise any system package is eligible. Anyone who wants to disable the runtime overlay mechanism can set it to false. --> <bool name="config_enableSecondaryLocationTimeZoneOverlay" translatable="false">false</bool> <!-- Package name providing the secondary location time zone provider. Used only when config_enableSecondaryLocationTimeZoneOverlay is false. Loading core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -2168,8 +2168,10 @@ <java-symbol type="string" name="config_deviceConfiguratorPackageName" /> <java-symbol type="array" name="config_autoTimeSourcesPriority" /> <java-symbol type="bool" name="config_enableGeolocationTimeZoneDetection" /> <java-symbol type="bool" name="config_enablePrimaryLocationTimeZoneProvider" /> <java-symbol type="bool" name="config_enablePrimaryLocationTimeZoneOverlay" /> <java-symbol type="string" name="config_primaryLocationTimeZoneProviderPackageName" /> <java-symbol type="bool" name="config_enableSecondaryLocationTimeZoneProvider" /> <java-symbol type="bool" name="config_enableSecondaryLocationTimeZoneOverlay" /> <java-symbol type="string" name="config_secondaryLocationTimeZoneProviderPackageName" /> Loading services/core/java/com/android/server/location/timezone/BinderLocationTimeZoneProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ class BinderLocationTimeZoneProvider extends LocationTimeZoneProvider { @Override void onInitialize() { mProxy.setListener(new LocationTimeZoneProviderProxy.Listener() { mProxy.initialize(new LocationTimeZoneProviderProxy.Listener() { @Override public void onReportLocationTimeZoneEvent( @NonNull LocationTimeZoneEvent locationTimeZoneEvent) { Loading services/core/java/com/android/server/location/timezone/LocationTimeZoneManagerService.java +20 −24 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.location.timezone; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.content.res.Resources; import android.os.Binder; import android.os.ResultReceiver; import android.os.ShellCallback; Loading @@ -27,6 +28,7 @@ import android.util.IndentingPrintWriter; import android.util.Log; import android.util.Slog; import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.util.DumpUtils; import com.android.server.FgThread; Loading Loading @@ -179,36 +181,45 @@ public class LocationTimeZoneManagerService extends Binder { } private LocationTimeZoneProvider createPrimaryProvider() { Resources resources = mContext.getResources(); if (!resources.getBoolean(R.bool.config_enablePrimaryLocationTimeZoneProvider)) { return new NullLocationTimeZoneProvider(mThreadingDomain, PRIMARY_PROVIDER_NAME); } LocationTimeZoneProviderProxy proxy; if (isInSimulationMode(PRIMARY_PROVIDER_NAME)) { proxy = new SimulatedLocationTimeZoneProviderProxy(mContext, mThreadingDomain); } else { proxy = RealLocationTimeZoneProviderProxy.createAndRegister( proxy = new RealLocationTimeZoneProviderProxy( mContext, mThreadingDomain, PRIMARY_LOCATION_TIME_ZONE_SERVICE_ACTION, com.android.internal.R.bool.config_enablePrimaryLocationTimeZoneOverlay, com.android.internal.R.string.config_primaryLocationTimeZoneProviderPackageName R.bool.config_enablePrimaryLocationTimeZoneOverlay, R.string.config_primaryLocationTimeZoneProviderPackageName ); } return createLocationTimeZoneProvider(PRIMARY_PROVIDER_NAME, proxy); return new BinderLocationTimeZoneProvider(mThreadingDomain, PRIMARY_PROVIDER_NAME, proxy); } private LocationTimeZoneProvider createSecondaryProvider() { Resources resources = mContext.getResources(); if (!resources.getBoolean(R.bool.config_enableSecondaryLocationTimeZoneProvider)) { return new NullLocationTimeZoneProvider(mThreadingDomain, SECONDARY_PROVIDER_NAME); } LocationTimeZoneProviderProxy proxy; if (isInSimulationMode(SECONDARY_PROVIDER_NAME)) { proxy = new SimulatedLocationTimeZoneProviderProxy(mContext, mThreadingDomain); } else { proxy = RealLocationTimeZoneProviderProxy.createAndRegister( proxy = new RealLocationTimeZoneProviderProxy( mContext, mThreadingDomain, SECONDARY_LOCATION_TIME_ZONE_SERVICE_ACTION, com.android.internal.R.bool.config_enableSecondaryLocationTimeZoneOverlay, com.android.internal.R.string .config_secondaryLocationTimeZoneProviderPackageName R.bool.config_enableSecondaryLocationTimeZoneOverlay, R.string.config_secondaryLocationTimeZoneProviderPackageName ); } return createLocationTimeZoneProvider(SECONDARY_PROVIDER_NAME, proxy); return new BinderLocationTimeZoneProvider(mThreadingDomain, SECONDARY_PROVIDER_NAME, proxy); } private boolean isInSimulationMode(String providerName) { Loading @@ -216,21 +227,6 @@ public class LocationTimeZoneManagerService extends Binder { SIMULATION_MODE_SYSTEM_PROPERTY_PREFIX + providerName, false); } private LocationTimeZoneProvider createLocationTimeZoneProvider( @NonNull String providerName, @NonNull LocationTimeZoneProviderProxy proxy) { LocationTimeZoneProvider provider; if (proxy != null) { debugLog("LocationTimeZoneProvider found for providerName=" + providerName); provider = new BinderLocationTimeZoneProvider(mThreadingDomain, providerName, proxy); } else { debugLog("No LocationTimeZoneProvider found for providerName=" + providerName + ": stubbing"); provider = new NullLocationTimeZoneProvider(mThreadingDomain, providerName); } return provider; } @Override public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err, String[] args, ShellCallback callback, Loading services/core/java/com/android/server/location/timezone/LocationTimeZoneProviderProxy.java +10 −2 Original line number Diff line number Diff line Loading @@ -70,9 +70,11 @@ abstract class LocationTimeZoneProviderProxy implements Dumpable { } /** * Sets the listener. The listener can expect to receive all events after this point. * Initializes the proxy. The supplied listener can expect to receive all events after this * point. This method also calls {@link #onInitialize()} for subclasses to handle their own * initialization. */ void setListener(@NonNull Listener listener) { void initialize(@NonNull Listener listener) { Objects.requireNonNull(listener); synchronized (mSharedLock) { if (mListener != null) { Loading @@ -80,8 +82,14 @@ abstract class LocationTimeZoneProviderProxy implements Dumpable { } this.mListener = listener; } onInitialize(); } /** * Initializes the proxy. This is called after {@link #mListener} is set. */ abstract void onInitialize(); /** * Sets a new request for the provider. */ Loading Loading
core/res/res/values/config.xml +15 −8 Original line number Diff line number Diff line Loading @@ -1613,21 +1613,28 @@ <!-- Whether the geolocation time zone detection feature is enabled. --> <bool name="config_enableGeolocationTimeZoneDetection" translatable="false">true</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 <!-- Whether the primary LocationTimeZoneProvider is enabled device. Ignored if config_enableGeolocationTimeZoneDetection is false --> <bool name="config_enablePrimaryLocationTimeZoneProvider" translatable="false">false</bool> <!-- Used when enablePrimaryLocationTimeZoneProvider is true. Controls 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 location time zone provider, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> disable the runtime overlay mechanism can set it to false. --> <bool name="config_enablePrimaryLocationTimeZoneOverlay" translatable="false">false</bool> <!-- Package name providing the primary location time zone provider. Used only when config_enablePrimaryLocationTimeZoneOverlay is false. --> <string name="config_primaryLocationTimeZoneProviderPackageName" translatable="false">@null</string> <!-- Whether to enable secondary location time zone provider overlay which allows the secondary location time zone provider to be replaced by an app at run-time. When disabled, only the config_secondaryLocationTimeZoneProviderPackageName package will be searched for the secondary location time zone provider, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <!-- Whether the secondary LocationTimeZoneProvider is enabled device. Ignored if config_enableGeolocationTimeZoneDetection is false --> <bool name="config_enableSecondaryLocationTimeZoneProvider" translatable="false">true</bool> <!-- Used when enableSecondaryLocationTimeZoneProvider is true. Controls whether to enable secondary location time zone provider overlay which allows the primary location time zone provider to config_secondaryLocationTimeZoneProviderPackageName package will be searched for the secondary location time zone provider, otherwise any system package is eligible. Anyone who wants to disable the runtime overlay mechanism can set it to false. --> <bool name="config_enableSecondaryLocationTimeZoneOverlay" translatable="false">false</bool> <!-- Package name providing the secondary location time zone provider. Used only when config_enableSecondaryLocationTimeZoneOverlay is false. Loading
core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -2168,8 +2168,10 @@ <java-symbol type="string" name="config_deviceConfiguratorPackageName" /> <java-symbol type="array" name="config_autoTimeSourcesPriority" /> <java-symbol type="bool" name="config_enableGeolocationTimeZoneDetection" /> <java-symbol type="bool" name="config_enablePrimaryLocationTimeZoneProvider" /> <java-symbol type="bool" name="config_enablePrimaryLocationTimeZoneOverlay" /> <java-symbol type="string" name="config_primaryLocationTimeZoneProviderPackageName" /> <java-symbol type="bool" name="config_enableSecondaryLocationTimeZoneProvider" /> <java-symbol type="bool" name="config_enableSecondaryLocationTimeZoneOverlay" /> <java-symbol type="string" name="config_secondaryLocationTimeZoneProviderPackageName" /> Loading
services/core/java/com/android/server/location/timezone/BinderLocationTimeZoneProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ class BinderLocationTimeZoneProvider extends LocationTimeZoneProvider { @Override void onInitialize() { mProxy.setListener(new LocationTimeZoneProviderProxy.Listener() { mProxy.initialize(new LocationTimeZoneProviderProxy.Listener() { @Override public void onReportLocationTimeZoneEvent( @NonNull LocationTimeZoneEvent locationTimeZoneEvent) { Loading
services/core/java/com/android/server/location/timezone/LocationTimeZoneManagerService.java +20 −24 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.location.timezone; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.content.res.Resources; import android.os.Binder; import android.os.ResultReceiver; import android.os.ShellCallback; Loading @@ -27,6 +28,7 @@ import android.util.IndentingPrintWriter; import android.util.Log; import android.util.Slog; import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.util.DumpUtils; import com.android.server.FgThread; Loading Loading @@ -179,36 +181,45 @@ public class LocationTimeZoneManagerService extends Binder { } private LocationTimeZoneProvider createPrimaryProvider() { Resources resources = mContext.getResources(); if (!resources.getBoolean(R.bool.config_enablePrimaryLocationTimeZoneProvider)) { return new NullLocationTimeZoneProvider(mThreadingDomain, PRIMARY_PROVIDER_NAME); } LocationTimeZoneProviderProxy proxy; if (isInSimulationMode(PRIMARY_PROVIDER_NAME)) { proxy = new SimulatedLocationTimeZoneProviderProxy(mContext, mThreadingDomain); } else { proxy = RealLocationTimeZoneProviderProxy.createAndRegister( proxy = new RealLocationTimeZoneProviderProxy( mContext, mThreadingDomain, PRIMARY_LOCATION_TIME_ZONE_SERVICE_ACTION, com.android.internal.R.bool.config_enablePrimaryLocationTimeZoneOverlay, com.android.internal.R.string.config_primaryLocationTimeZoneProviderPackageName R.bool.config_enablePrimaryLocationTimeZoneOverlay, R.string.config_primaryLocationTimeZoneProviderPackageName ); } return createLocationTimeZoneProvider(PRIMARY_PROVIDER_NAME, proxy); return new BinderLocationTimeZoneProvider(mThreadingDomain, PRIMARY_PROVIDER_NAME, proxy); } private LocationTimeZoneProvider createSecondaryProvider() { Resources resources = mContext.getResources(); if (!resources.getBoolean(R.bool.config_enableSecondaryLocationTimeZoneProvider)) { return new NullLocationTimeZoneProvider(mThreadingDomain, SECONDARY_PROVIDER_NAME); } LocationTimeZoneProviderProxy proxy; if (isInSimulationMode(SECONDARY_PROVIDER_NAME)) { proxy = new SimulatedLocationTimeZoneProviderProxy(mContext, mThreadingDomain); } else { proxy = RealLocationTimeZoneProviderProxy.createAndRegister( proxy = new RealLocationTimeZoneProviderProxy( mContext, mThreadingDomain, SECONDARY_LOCATION_TIME_ZONE_SERVICE_ACTION, com.android.internal.R.bool.config_enableSecondaryLocationTimeZoneOverlay, com.android.internal.R.string .config_secondaryLocationTimeZoneProviderPackageName R.bool.config_enableSecondaryLocationTimeZoneOverlay, R.string.config_secondaryLocationTimeZoneProviderPackageName ); } return createLocationTimeZoneProvider(SECONDARY_PROVIDER_NAME, proxy); return new BinderLocationTimeZoneProvider(mThreadingDomain, SECONDARY_PROVIDER_NAME, proxy); } private boolean isInSimulationMode(String providerName) { Loading @@ -216,21 +227,6 @@ public class LocationTimeZoneManagerService extends Binder { SIMULATION_MODE_SYSTEM_PROPERTY_PREFIX + providerName, false); } private LocationTimeZoneProvider createLocationTimeZoneProvider( @NonNull String providerName, @NonNull LocationTimeZoneProviderProxy proxy) { LocationTimeZoneProvider provider; if (proxy != null) { debugLog("LocationTimeZoneProvider found for providerName=" + providerName); provider = new BinderLocationTimeZoneProvider(mThreadingDomain, providerName, proxy); } else { debugLog("No LocationTimeZoneProvider found for providerName=" + providerName + ": stubbing"); provider = new NullLocationTimeZoneProvider(mThreadingDomain, providerName); } return provider; } @Override public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err, String[] args, ShellCallback callback, Loading
services/core/java/com/android/server/location/timezone/LocationTimeZoneProviderProxy.java +10 −2 Original line number Diff line number Diff line Loading @@ -70,9 +70,11 @@ abstract class LocationTimeZoneProviderProxy implements Dumpable { } /** * Sets the listener. The listener can expect to receive all events after this point. * Initializes the proxy. The supplied listener can expect to receive all events after this * point. This method also calls {@link #onInitialize()} for subclasses to handle their own * initialization. */ void setListener(@NonNull Listener listener) { void initialize(@NonNull Listener listener) { Objects.requireNonNull(listener); synchronized (mSharedLock) { if (mListener != null) { Loading @@ -80,8 +82,14 @@ abstract class LocationTimeZoneProviderProxy implements Dumpable { } this.mListener = listener; } onInitialize(); } /** * Initializes the proxy. This is called after {@link #mListener} is set. */ abstract void onInitialize(); /** * Sets a new request for the provider. */ Loading