From 4720cf0309790373259ab04a523f96037fa257ed Mon Sep 17 00:00:00 2001 From: Neil Fuller Date: Tue, 28 Jan 2020 15:05:35 +0000 Subject: [PATCH] Tidy up libcore.timezone APIs Tidy up the libcore.timezone APIs to make them as close as possible to android.timezone. In future, these classes should be repackages to be the actual android.timezone classes, so the APIs need to be in sync. Bug: 148086409 Test: treehugger Change-Id: Ia520abcf00e691f4a1b5549dafec44b76075e31a --- core/java/android/timezone/CountryTimeZones.java | 7 ++++--- core/java/android/timezone/TzDataSetVersion.java | 8 ++++---- core/java/android/util/TimeUtils.java | 6 +++--- .../src/com/android/settingslib/datetime/ZoneGetter.java | 2 +- .../com/android/server/timezone/RulesManagerService.java | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/java/android/timezone/CountryTimeZones.java b/core/java/android/timezone/CountryTimeZones.java index e5bbdf4b6eeaa..5875761bb1c96 100644 --- a/core/java/android/timezone/CountryTimeZones.java +++ b/core/java/android/timezone/CountryTimeZones.java @@ -56,7 +56,7 @@ public final class CountryTimeZones { */ @NonNull public String getTimeZoneId() { - return mDelegate.timeZoneId; + return mDelegate.getTimeZoneId(); } /** @@ -187,7 +187,7 @@ public final class CountryTimeZones { * would be a good choice generally when there's no other information available. */ public boolean isDefaultTimeZoneBoosted() { - return mDelegate.getDefaultTimeZoneBoost(); + return mDelegate.isDefaultTimeZoneBoosted(); } /** @@ -220,7 +220,8 @@ public final class CountryTimeZones { mDelegate.lookupByOffsetWithBias( totalOffsetMillis, isDst, dstOffsetMillis, whenMillis, bias); return delegateOffsetResult == null ? null : - new OffsetResult(delegateOffsetResult.mTimeZone, delegateOffsetResult.mOneMatch); + new OffsetResult( + delegateOffsetResult.getTimeZone(), delegateOffsetResult.isOnlyMatch()); } /** diff --git a/core/java/android/timezone/TzDataSetVersion.java b/core/java/android/timezone/TzDataSetVersion.java index 605155e76c2cb..efe50a07da98a 100644 --- a/core/java/android/timezone/TzDataSetVersion.java +++ b/core/java/android/timezone/TzDataSetVersion.java @@ -111,23 +111,23 @@ public final class TzDataSetVersion { /** Returns the major version number. See {@link TzDataSetVersion}. */ public int getFormatMajorVersion() { - return mDelegate.formatMajorVersion; + return mDelegate.getFormatMajorVersion(); } /** Returns the minor version number. See {@link TzDataSetVersion}. */ public int getFormatMinorVersion() { - return mDelegate.formatMinorVersion; + return mDelegate.getFormatMinorVersion(); } /** Returns the tzdb version string. See {@link TzDataSetVersion}. */ @NonNull public String getRulesVersion() { - return mDelegate.rulesVersion; + return mDelegate.getRulesVersion(); } /** Returns the Android revision. See {@link TzDataSetVersion}. */ public int getRevision() { - return mDelegate.revision; + return mDelegate.getRevision(); } @Override diff --git a/core/java/android/util/TimeUtils.java b/core/java/android/util/TimeUtils.java index dbd3f69e214e3..c1596bf803538 100644 --- a/core/java/android/util/TimeUtils.java +++ b/core/java/android/util/TimeUtils.java @@ -80,7 +80,7 @@ public class TimeUtils { } CountryTimeZones.OffsetResult offsetResult = countryTimeZones.lookupByOffsetWithBias( offsetMillis, isDst, null /* dstOffsetMillis */, whenMillis, bias); - return offsetResult != null ? offsetResult.mTimeZone : null; + return offsetResult != null ? offsetResult.getTimeZone() : null; } /** @@ -108,8 +108,8 @@ public class TimeUtils { List timeZoneIds = new ArrayList<>(); for (TimeZoneMapping timeZoneMapping : countryTimeZones.getTimeZoneMappings()) { - if (timeZoneMapping.showInPicker) { - timeZoneIds.add(timeZoneMapping.timeZoneId); + if (timeZoneMapping.isShownInPicker()) { + timeZoneIds.add(timeZoneMapping.getTimeZoneId()); } } return Collections.unmodifiableList(timeZoneIds); diff --git a/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java b/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java index aac7fc3c927a4..d48aa246ecbaf 100644 --- a/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java +++ b/packages/SettingsLib/src/com/android/settingslib/datetime/ZoneGetter.java @@ -402,7 +402,7 @@ public class ZoneGetter { private static List extractTimeZoneIds(List timeZoneMappings) { final List zoneIds = new ArrayList<>(timeZoneMappings.size()); for (TimeZoneMapping timeZoneMapping : timeZoneMappings) { - zoneIds.add(timeZoneMapping.timeZoneId); + zoneIds.add(timeZoneMapping.getTimeZoneId()); } return Collections.unmodifiableList(zoneIds); } diff --git a/services/core/java/com/android/server/timezone/RulesManagerService.java b/services/core/java/com/android/server/timezone/RulesManagerService.java index 9347d2194b684..a0dc8a05124d7 100644 --- a/services/core/java/com/android/server/timezone/RulesManagerService.java +++ b/services/core/java/com/android/server/timezone/RulesManagerService.java @@ -198,7 +198,7 @@ public final class RulesManagerService extends IRulesManager.Stub { Slog.w(TAG, "Failed to read staged distro.", e); } } - return new RulesState(baseVersion.rulesVersion, DISTRO_FORMAT_VERSION_SUPPORTED, + return new RulesState(baseVersion.getRulesVersion(), DISTRO_FORMAT_VERSION_SUPPORTED, operationInProgress, stagedOperationStatus, stagedDistroRulesVersion, distroStatus, installedDistroRulesVersion); }