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

Commit 2551c033 authored by Neil Fuller's avatar Neil Fuller
Browse files

Add new module-lib APIs for MTS testing

Several android.timezone classes have already been exposed for the
telephony module work, so these tests provide coverage for those.
Additional APIs have been exposed for MTS testing, i.e. to provide
greater confidence that the tzdata module data is correct / is
being read correctly.

Also, small changes to existing code to make them consistent with new
classes. Small docs improvements.

Bug: 147884233
Test: see system/timezone change
Change-Id: I047b29f17a41993f859947a6d6c3685896fe4cb6
parent 391bc944
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -118,9 +118,31 @@ package android.timezone {
  }

  public final class TimeZoneFinder {
    method @Nullable public String getIanaVersion();
    method @NonNull public static android.timezone.TimeZoneFinder getInstance();
    method @Nullable public android.timezone.CountryTimeZones lookupCountryTimeZones(@NonNull String);
  }

  public final class TzDataSetVersion {
    method public static int currentFormatMajorVersion();
    method public static int currentFormatMinorVersion();
    method public int getFormatMajorVersion();
    method public int getFormatMinorVersion();
    method public int getRevision();
    method @NonNull public String getRulesVersion();
    method public static boolean isCompatibleWithThisDevice(android.timezone.TzDataSetVersion);
    method @NonNull public static android.timezone.TzDataSetVersion read() throws java.io.IOException, android.timezone.TzDataSetVersion.TzDataSetException;
  }

  public static class TzDataSetVersion.TzDataSetException extends java.lang.Exception {
    ctor public TzDataSetVersion.TzDataSetException(String);
    ctor public TzDataSetVersion.TzDataSetException(String, Throwable);
  }

  public final class ZoneInfoDb {
    method @NonNull public static android.timezone.ZoneInfoDb getInstance();
    method @NonNull public String getVersion();
  }

}
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ public final class CountryTimeZones {
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    public static final class TimeZoneMapping {

        @NonNull
        private libcore.timezone.CountryTimeZones.TimeZoneMapping mDelegate;

        TimeZoneMapping(libcore.timezone.CountryTimeZones.TimeZoneMapping delegate) {
+4 −5
Original line number Diff line number Diff line
@@ -36,12 +36,8 @@ public class TelephonyLookup {
    @GuardedBy("sLock")
    private static TelephonyLookup sInstance;

    @NonNull
    private final libcore.timezone.TelephonyLookup mDelegate;

    /**
     * Obtains an instance for use when resolving telephony time zone information. This method never
     * returns {@code null}.
     * Obtains an instance for use when resolving telephony time zone information.
     */
    @NonNull
    public static TelephonyLookup getInstance() {
@@ -53,6 +49,9 @@ public class TelephonyLookup {
        }
    }

    @NonNull
    private final libcore.timezone.TelephonyLookup mDelegate;

    private TelephonyLookup(@NonNull libcore.timezone.TelephonyLookup delegate) {
        mDelegate = Objects.requireNonNull(delegate);
    }
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import android.annotation.SystemApi;
import java.util.Objects;

/**
 * A class that can find telephony networks loaded via {@link TelephonyLookup}.
 * A class that can find telephony network information loaded via {@link TelephonyLookup}.
 *
 * @hide
 */
+20 −9
Original line number Diff line number Diff line
@@ -22,8 +22,10 @@ import android.annotation.SystemApi;

import com.android.internal.annotations.GuardedBy;

import java.util.Objects;

/**
 * A class that can be used to find time zones.
 * A class that can be used to find time zones using information like country and offset.
 *
 * @hide
 */
@@ -34,15 +36,8 @@ public final class TimeZoneFinder {
    @GuardedBy("sLock")
    private static TimeZoneFinder sInstance;

    private final libcore.timezone.TimeZoneFinder mDelegate;

    private TimeZoneFinder(libcore.timezone.TimeZoneFinder delegate) {
        mDelegate = delegate;
    }

    /**
     * Obtains an instance for use when resolving telephony time zone information. This method never
     * returns {@code null}.
     * Obtains the singleton instance.
     */
    @NonNull
    public static TimeZoneFinder getInstance() {
@@ -54,6 +49,22 @@ public final class TimeZoneFinder {
        return sInstance;
    }

    @NonNull
    private final libcore.timezone.TimeZoneFinder mDelegate;

    private TimeZoneFinder(@NonNull libcore.timezone.TimeZoneFinder delegate) {
        mDelegate = Objects.requireNonNull(delegate);
    }

    /**
     * Returns the IANA rules version associated with the data. If there is no version information
     * or there is a problem reading the file then {@code null} is returned.
     */
    @Nullable
    public String getIanaVersion() {
        return mDelegate.getIanaVersion();
    }

    /**
     * Returns a {@link CountryTimeZones} object associated with the specified country code.
     * Caching is handled as needed. If the country code is not recognized or there is an error
Loading