Loading core/java/android/app/timezonedetector/TelephonyTimeZoneSuggestion.java +43 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,9 @@ import java.util.Objects; * indicate that the telephony source has entered an "un-opinionated" state and any previous * suggestion from the same source is being withdrawn. * * <p>{@code countryIsoCode}. When not {@code null}, {@code countryIsoCode} contains the country of * the suggested time zone ID, e.g. "us". * * <p>{@code matchType} must be set to {@link #MATCH_TYPE_NA} when {@code zoneId} is {@code null}, * and one of the other {@code MATCH_TYPE_} values when it is not {@code null}. * Loading Loading @@ -143,6 +146,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { private final int mSlotIndex; @Nullable private final String mZoneId; @Nullable private final String mCountryIsoCode; @MatchType private final int mMatchType; @Quality private final int mQuality; @Nullable private List<String> mDebugInfo; Loading @@ -150,6 +154,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { private TelephonyTimeZoneSuggestion(Builder builder) { mSlotIndex = builder.mSlotIndex; mZoneId = builder.mZoneId; mCountryIsoCode = builder.mCountryIsoCode; mMatchType = builder.mMatchType; mQuality = builder.mQuality; mDebugInfo = builder.mDebugInfo != null ? new ArrayList<>(builder.mDebugInfo) : null; Loading @@ -161,6 +166,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { int slotIndex = in.readInt(); TelephonyTimeZoneSuggestion suggestion = new Builder(slotIndex) .setZoneId(in.readString()) .setCountryIsoCode(in.readString()) .setMatchType(in.readInt()) .setQuality(in.readInt()) .build(); Loading @@ -176,6 +182,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeInt(mSlotIndex); dest.writeString(mZoneId); dest.writeString(mCountryIsoCode); dest.writeInt(mMatchType); dest.writeInt(mQuality); dest.writeList(mDebugInfo); Loading Loading @@ -206,6 +213,17 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { return mZoneId; } /** * Returns the country where the time zone Olson ID was found, e.g. "gb". {@code null} means * that the caller is no longer sure what the current country is. * * <p>See {@link TelephonyTimeZoneSuggestion} for more information about {@code countryIsoCode}. */ @Nullable public String getCountryIsoCode() { return mCountryIsoCode; } /** * Returns information about how the suggestion was determined which could be used to rank * suggestions when several are available from different sources. Loading Loading @@ -274,12 +292,13 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { return mSlotIndex == that.mSlotIndex && mMatchType == that.mMatchType && mQuality == that.mQuality && Objects.equals(mZoneId, that.mZoneId); && Objects.equals(mZoneId, that.mZoneId) && Objects.equals(mCountryIsoCode, that.mCountryIsoCode); } @Override public int hashCode() { return Objects.hash(mSlotIndex, mZoneId, mMatchType, mQuality); return Objects.hash(mSlotIndex, mZoneId, mCountryIsoCode, mMatchType, mQuality); } @Override Loading @@ -287,6 +306,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { return "TelephonyTimeZoneSuggestion{" + "mSlotIndex=" + mSlotIndex + ", mZoneId='" + mZoneId + '\'' + ", mCountryIsoCode='" + mCountryIsoCode + '\'' + ", mMatchType=" + mMatchType + ", mQuality=" + mQuality + ", mDebugInfo=" + mDebugInfo Loading @@ -301,6 +321,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { public static final class Builder { private final int mSlotIndex; @Nullable private String mZoneId; @Nullable private String mCountryIsoCode; @MatchType private int mMatchType; @Quality private int mQuality; @Nullable private List<String> mDebugInfo; Loading @@ -325,6 +346,18 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { return this; } /** * Returns the builder for call chaining. * * <p>See {@link TelephonyTimeZoneSuggestion} for more information about {@code * countryIsoCode}. */ @Nullable public Builder setCountryIsoCode(@Nullable String countryIsoCode) { mCountryIsoCode = countryIsoCode; return this; } /** * Returns the builder for call chaining. * Loading Loading @@ -401,6 +434,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { throws IllegalArgumentException { Integer slotIndex = null; String zoneId = null; String countryIsoCode = null; Integer quality = null; Integer matchType = null; String opt; Loading @@ -414,6 +448,10 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { zoneId = cmd.getNextArgRequired(); break; } case "--country-iso-code": { countryIsoCode = cmd.getNextArgRequired(); break; } case "--quality": { quality = parseQualityCommandLineArg(cmd.getNextArgRequired()); break; Loading @@ -436,6 +474,9 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { if (!(TextUtils.isEmpty(zoneId) || "_".equals(zoneId))) { builder.setZoneId(zoneId); } if (!(TextUtils.isEmpty(countryIsoCode) || "_".equals(countryIsoCode))) { builder.setCountryIsoCode(countryIsoCode); } if (quality != null) { builder.setQuality(quality); } Loading core/java/android/timezone/CountryTimeZones.java +18 −7 Original line number Diff line number Diff line Loading @@ -96,11 +96,14 @@ public final class CountryTimeZones { public static final class OffsetResult { private final TimeZone mTimeZone; @Nullable private final String mCountryIsoCode; private final boolean mIsOnlyMatch; /** Creates an instance with the supplied information. */ public OffsetResult(@NonNull TimeZone timeZone, boolean isOnlyMatch) { public OffsetResult(@NonNull TimeZone timeZone, @Nullable String countryIsoCode, boolean isOnlyMatch) { mTimeZone = Objects.requireNonNull(timeZone); mCountryIsoCode = countryIsoCode; mIsOnlyMatch = isOnlyMatch; } Loading @@ -112,6 +115,12 @@ public final class CountryTimeZones { return mTimeZone; } /** Returns the country ISO code where the time zone matched. */ @Nullable public String getCountryIsoCode() { return mCountryIsoCode; } /** * Returns {@code true} if there is only one matching time zone for the supplied criteria. */ Loading @@ -129,18 +138,20 @@ public final class CountryTimeZones { } OffsetResult that = (OffsetResult) o; return mIsOnlyMatch == that.mIsOnlyMatch && mTimeZone.getID().equals(that.mTimeZone.getID()); && mTimeZone.getID().equals(that.mTimeZone.getID()) && Objects.equals(mCountryIsoCode, that.mCountryIsoCode); } @Override public int hashCode() { return Objects.hash(mTimeZone, mIsOnlyMatch); return Objects.hash(mTimeZone, mCountryIsoCode, mIsOnlyMatch); } @Override public String toString() { return "OffsetResult{" + "mTimeZone(ID)=" + mTimeZone.getID() + ", mCountryIsoCode=" + mCountryIsoCode + ", mIsOnlyMatch=" + mIsOnlyMatch + '}'; } Loading Loading @@ -225,8 +236,8 @@ public final class CountryTimeZones { mDelegate.lookupByOffsetWithBias( whenMillis, bias, totalOffsetMillis, isDst); return delegateOffsetResult == null ? null : new OffsetResult( delegateOffsetResult.getTimeZone(), delegateOffsetResult.isOnlyMatch()); new OffsetResult(delegateOffsetResult.getTimeZone(), mDelegate.getCountryIso(), delegateOffsetResult.isOnlyMatch()); } /** Loading @@ -247,8 +258,8 @@ public final class CountryTimeZones { com.android.i18n.timezone.CountryTimeZones.OffsetResult delegateOffsetResult = mDelegate.lookupByOffsetWithBias(whenMillis, bias, totalOffsetMillis); return delegateOffsetResult == null ? null : new OffsetResult( delegateOffsetResult.getTimeZone(), delegateOffsetResult.isOnlyMatch()); new OffsetResult(delegateOffsetResult.getTimeZone(), mDelegate.getCountryIso(), delegateOffsetResult.isOnlyMatch()); } /** Loading core/java/android/timezone/MobileCountries.java +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ import java.util.Set; * * @hide */ public final class MobileCountries { public class MobileCountries { @NonNull private final com.android.i18n.timezone.MobileCountries mDelegate; Loading Loading
core/java/android/app/timezonedetector/TelephonyTimeZoneSuggestion.java +43 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,9 @@ import java.util.Objects; * indicate that the telephony source has entered an "un-opinionated" state and any previous * suggestion from the same source is being withdrawn. * * <p>{@code countryIsoCode}. When not {@code null}, {@code countryIsoCode} contains the country of * the suggested time zone ID, e.g. "us". * * <p>{@code matchType} must be set to {@link #MATCH_TYPE_NA} when {@code zoneId} is {@code null}, * and one of the other {@code MATCH_TYPE_} values when it is not {@code null}. * Loading Loading @@ -143,6 +146,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { private final int mSlotIndex; @Nullable private final String mZoneId; @Nullable private final String mCountryIsoCode; @MatchType private final int mMatchType; @Quality private final int mQuality; @Nullable private List<String> mDebugInfo; Loading @@ -150,6 +154,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { private TelephonyTimeZoneSuggestion(Builder builder) { mSlotIndex = builder.mSlotIndex; mZoneId = builder.mZoneId; mCountryIsoCode = builder.mCountryIsoCode; mMatchType = builder.mMatchType; mQuality = builder.mQuality; mDebugInfo = builder.mDebugInfo != null ? new ArrayList<>(builder.mDebugInfo) : null; Loading @@ -161,6 +166,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { int slotIndex = in.readInt(); TelephonyTimeZoneSuggestion suggestion = new Builder(slotIndex) .setZoneId(in.readString()) .setCountryIsoCode(in.readString()) .setMatchType(in.readInt()) .setQuality(in.readInt()) .build(); Loading @@ -176,6 +182,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeInt(mSlotIndex); dest.writeString(mZoneId); dest.writeString(mCountryIsoCode); dest.writeInt(mMatchType); dest.writeInt(mQuality); dest.writeList(mDebugInfo); Loading Loading @@ -206,6 +213,17 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { return mZoneId; } /** * Returns the country where the time zone Olson ID was found, e.g. "gb". {@code null} means * that the caller is no longer sure what the current country is. * * <p>See {@link TelephonyTimeZoneSuggestion} for more information about {@code countryIsoCode}. */ @Nullable public String getCountryIsoCode() { return mCountryIsoCode; } /** * Returns information about how the suggestion was determined which could be used to rank * suggestions when several are available from different sources. Loading Loading @@ -274,12 +292,13 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { return mSlotIndex == that.mSlotIndex && mMatchType == that.mMatchType && mQuality == that.mQuality && Objects.equals(mZoneId, that.mZoneId); && Objects.equals(mZoneId, that.mZoneId) && Objects.equals(mCountryIsoCode, that.mCountryIsoCode); } @Override public int hashCode() { return Objects.hash(mSlotIndex, mZoneId, mMatchType, mQuality); return Objects.hash(mSlotIndex, mZoneId, mCountryIsoCode, mMatchType, mQuality); } @Override Loading @@ -287,6 +306,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { return "TelephonyTimeZoneSuggestion{" + "mSlotIndex=" + mSlotIndex + ", mZoneId='" + mZoneId + '\'' + ", mCountryIsoCode='" + mCountryIsoCode + '\'' + ", mMatchType=" + mMatchType + ", mQuality=" + mQuality + ", mDebugInfo=" + mDebugInfo Loading @@ -301,6 +321,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { public static final class Builder { private final int mSlotIndex; @Nullable private String mZoneId; @Nullable private String mCountryIsoCode; @MatchType private int mMatchType; @Quality private int mQuality; @Nullable private List<String> mDebugInfo; Loading @@ -325,6 +346,18 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { return this; } /** * Returns the builder for call chaining. * * <p>See {@link TelephonyTimeZoneSuggestion} for more information about {@code * countryIsoCode}. */ @Nullable public Builder setCountryIsoCode(@Nullable String countryIsoCode) { mCountryIsoCode = countryIsoCode; return this; } /** * Returns the builder for call chaining. * Loading Loading @@ -401,6 +434,7 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { throws IllegalArgumentException { Integer slotIndex = null; String zoneId = null; String countryIsoCode = null; Integer quality = null; Integer matchType = null; String opt; Loading @@ -414,6 +448,10 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { zoneId = cmd.getNextArgRequired(); break; } case "--country-iso-code": { countryIsoCode = cmd.getNextArgRequired(); break; } case "--quality": { quality = parseQualityCommandLineArg(cmd.getNextArgRequired()); break; Loading @@ -436,6 +474,9 @@ public final class TelephonyTimeZoneSuggestion implements Parcelable { if (!(TextUtils.isEmpty(zoneId) || "_".equals(zoneId))) { builder.setZoneId(zoneId); } if (!(TextUtils.isEmpty(countryIsoCode) || "_".equals(countryIsoCode))) { builder.setCountryIsoCode(countryIsoCode); } if (quality != null) { builder.setQuality(quality); } Loading
core/java/android/timezone/CountryTimeZones.java +18 −7 Original line number Diff line number Diff line Loading @@ -96,11 +96,14 @@ public final class CountryTimeZones { public static final class OffsetResult { private final TimeZone mTimeZone; @Nullable private final String mCountryIsoCode; private final boolean mIsOnlyMatch; /** Creates an instance with the supplied information. */ public OffsetResult(@NonNull TimeZone timeZone, boolean isOnlyMatch) { public OffsetResult(@NonNull TimeZone timeZone, @Nullable String countryIsoCode, boolean isOnlyMatch) { mTimeZone = Objects.requireNonNull(timeZone); mCountryIsoCode = countryIsoCode; mIsOnlyMatch = isOnlyMatch; } Loading @@ -112,6 +115,12 @@ public final class CountryTimeZones { return mTimeZone; } /** Returns the country ISO code where the time zone matched. */ @Nullable public String getCountryIsoCode() { return mCountryIsoCode; } /** * Returns {@code true} if there is only one matching time zone for the supplied criteria. */ Loading @@ -129,18 +138,20 @@ public final class CountryTimeZones { } OffsetResult that = (OffsetResult) o; return mIsOnlyMatch == that.mIsOnlyMatch && mTimeZone.getID().equals(that.mTimeZone.getID()); && mTimeZone.getID().equals(that.mTimeZone.getID()) && Objects.equals(mCountryIsoCode, that.mCountryIsoCode); } @Override public int hashCode() { return Objects.hash(mTimeZone, mIsOnlyMatch); return Objects.hash(mTimeZone, mCountryIsoCode, mIsOnlyMatch); } @Override public String toString() { return "OffsetResult{" + "mTimeZone(ID)=" + mTimeZone.getID() + ", mCountryIsoCode=" + mCountryIsoCode + ", mIsOnlyMatch=" + mIsOnlyMatch + '}'; } Loading Loading @@ -225,8 +236,8 @@ public final class CountryTimeZones { mDelegate.lookupByOffsetWithBias( whenMillis, bias, totalOffsetMillis, isDst); return delegateOffsetResult == null ? null : new OffsetResult( delegateOffsetResult.getTimeZone(), delegateOffsetResult.isOnlyMatch()); new OffsetResult(delegateOffsetResult.getTimeZone(), mDelegate.getCountryIso(), delegateOffsetResult.isOnlyMatch()); } /** Loading @@ -247,8 +258,8 @@ public final class CountryTimeZones { com.android.i18n.timezone.CountryTimeZones.OffsetResult delegateOffsetResult = mDelegate.lookupByOffsetWithBias(whenMillis, bias, totalOffsetMillis); return delegateOffsetResult == null ? null : new OffsetResult( delegateOffsetResult.getTimeZone(), delegateOffsetResult.isOnlyMatch()); new OffsetResult(delegateOffsetResult.getTimeZone(), mDelegate.getCountryIso(), delegateOffsetResult.isOnlyMatch()); } /** Loading
core/java/android/timezone/MobileCountries.java +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ import java.util.Set; * * @hide */ public final class MobileCountries { public class MobileCountries { @NonNull private final com.android.i18n.timezone.MobileCountries mDelegate; Loading