diff options
| author | 2021-05-17 16:16:40 +0000 | |
|---|---|---|
| committer | 2021-05-17 16:16:40 +0000 | |
| commit | 629d1f3ec2ea0e97ece8601e09780e292bc2a231 (patch) | |
| tree | b84b99b545d8a508fd3b2d9009cc5ce7f6493d67 | |
| parent | c1b0d9ac234b7cad9df041ea8d6bb2e176f6e6e6 (diff) | |
| parent | dd4d5619842a746455bc8cc379a5b8261cc0d5bf (diff) | |
Merge "Provide a new command line for host tests" into sc-dev
3 files changed, 27 insertions, 0 deletions
diff --git a/core/java/android/app/timezonedetector/TimeZoneDetector.java b/core/java/android/app/timezonedetector/TimeZoneDetector.java index b216e913b6ff..a71cffe5afc0 100644 --- a/core/java/android/app/timezonedetector/TimeZoneDetector.java +++ b/core/java/android/app/timezonedetector/TimeZoneDetector.java @@ -48,6 +48,13 @@ public interface TimeZoneDetector { String SHELL_COMMAND_SET_AUTO_DETECTION_ENABLED = "set_auto_detection_enabled"; /** + * A shell command that prints whether the telephony-based time zone detection feature is + * supported on the device. + * @hide + */ + String SHELL_COMMAND_IS_TELEPHONY_DETECTION_SUPPORTED = "is_telephony_detection_supported"; + + /** * A shell command that prints whether the geolocation-based time zone detection feature is * supported on the device. * @hide diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java index 457dc4325e62..b1b537be1d29 100644 --- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java +++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorService.java @@ -304,6 +304,13 @@ public final class TimeZoneDetectorService extends ITimeZoneDetectorService.Stub mHandler.post(() -> mTimeZoneDetectorStrategy.suggestTelephonyTimeZone(timeZoneSuggestion)); } + boolean isTelephonyTimeZoneDetectionSupported() { + enforceManageTimeZoneDetectorPermission(); + + return ServiceConfigAccessor.getInstance(mContext) + .isTelephonyTimeZoneDetectionFeatureSupported(); + } + boolean isGeoTimeZoneDetectionSupported() { enforceManageTimeZoneDetectorPermission(); diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorShellCommand.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorShellCommand.java index 9899b448ba07..a4a46a3c4c73 100644 --- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorShellCommand.java +++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorShellCommand.java @@ -18,6 +18,7 @@ package com.android.server.timezonedetector; import static android.app.timezonedetector.TimeZoneDetector.SHELL_COMMAND_IS_AUTO_DETECTION_ENABLED; import static android.app.timezonedetector.TimeZoneDetector.SHELL_COMMAND_IS_GEO_DETECTION_ENABLED; import static android.app.timezonedetector.TimeZoneDetector.SHELL_COMMAND_IS_GEO_DETECTION_SUPPORTED; +import static android.app.timezonedetector.TimeZoneDetector.SHELL_COMMAND_IS_TELEPHONY_DETECTION_SUPPORTED; import static android.app.timezonedetector.TimeZoneDetector.SHELL_COMMAND_SERVICE_NAME; import static android.app.timezonedetector.TimeZoneDetector.SHELL_COMMAND_SET_AUTO_DETECTION_ENABLED; import static android.app.timezonedetector.TimeZoneDetector.SHELL_COMMAND_SET_GEO_DETECTION_ENABLED; @@ -61,6 +62,8 @@ class TimeZoneDetectorShellCommand extends ShellCommand { return runIsAutoDetectionEnabled(); case SHELL_COMMAND_SET_AUTO_DETECTION_ENABLED: return runSetAutoDetectionEnabled(); + case SHELL_COMMAND_IS_TELEPHONY_DETECTION_SUPPORTED: + return runIsTelephonyDetectionSupported(); case SHELL_COMMAND_IS_GEO_DETECTION_SUPPORTED: return runIsGeoDetectionSupported(); case SHELL_COMMAND_IS_GEO_DETECTION_ENABLED: @@ -89,6 +92,13 @@ class TimeZoneDetectorShellCommand extends ShellCommand { return 0; } + private int runIsTelephonyDetectionSupported() { + final PrintWriter pw = getOutPrintWriter(); + boolean enabled = mInterface.isTelephonyTimeZoneDetectionSupported(); + pw.println(enabled); + return 0; + } + private int runIsGeoDetectionSupported() { final PrintWriter pw = getOutPrintWriter(); boolean enabled = mInterface.isGeoTimeZoneDetectionSupported(); @@ -169,6 +179,9 @@ class TimeZoneDetectorShellCommand extends ShellCommand { pw.printf(" Prints true/false according to the automatic time zone detection setting\n"); pw.printf(" %s true|false\n", SHELL_COMMAND_SET_AUTO_DETECTION_ENABLED); pw.printf(" Sets the automatic time zone detection setting.\n"); + pw.printf(" %s\n", SHELL_COMMAND_IS_TELEPHONY_DETECTION_SUPPORTED); + pw.printf(" Prints true/false according to whether telephony time zone detection is" + + " supported on this device.\n"); pw.printf(" %s\n", SHELL_COMMAND_IS_GEO_DETECTION_SUPPORTED); pw.printf(" Prints true/false according to whether geolocation time zone detection is" + " supported on this device.\n"); |