Merge "Reference tzdata3 for S, not tzdata2"
diff --git a/apex/tests/Android.bp b/apex/tests/Android.bp
index d5c524b..ef35edd 100644
--- a/apex/tests/Android.bp
+++ b/apex/tests/Android.bp
@@ -28,7 +28,7 @@
     // Tag this module as an mts test artifact
     test_suites: [
         "general-tests",
-        "mts",
+        "mts-tzdata",
     ],
     min_sdk_version: "29",
 }
diff --git a/geolocation/geotz_lookup/Android.bp b/geolocation/geotz_lookup/Android.bp
index 2ef2c15..e66517b 100644
--- a/geolocation/geotz_lookup/Android.bp
+++ b/geolocation/geotz_lookup/Android.bp
@@ -17,6 +17,7 @@
     name: "geotz_lookup",
     srcs: ["src/main/java/**/*.java"],
     sdk_version: "30",
+    libs: ["androidx.annotation_annotation"],
     static_libs: [
         "geotz_s2storage_ro",
         "s2-geometry-library-java",
diff --git a/geolocation/geotz_lookup/src/main/java/android/timezone/geolocation/GeoTimeZonesFinder.java b/geolocation/geotz_lookup/src/main/java/com/android/timezone/geotz/lookup/GeoTimeZonesFinder.java
similarity index 97%
rename from geolocation/geotz_lookup/src/main/java/android/timezone/geolocation/GeoTimeZonesFinder.java
rename to geolocation/geotz_lookup/src/main/java/com/android/timezone/geotz/lookup/GeoTimeZonesFinder.java
index cf6d013..16cfdaf 100644
--- a/geolocation/geotz_lookup/src/main/java/android/timezone/geolocation/GeoTimeZonesFinder.java
+++ b/geolocation/geotz_lookup/src/main/java/com/android/timezone/geotz/lookup/GeoTimeZonesFinder.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package android.timezone.geolocation;
+package com.android.timezone.geotz.lookup;
 
 import java.io.Closeable;
 import java.io.File;
@@ -36,7 +36,7 @@
      */
     // @NonNull
     public static GeoTimeZonesFinder create(File file) throws IOException {
-        return GeoTimeZonesFinderImpl.create(file);
+        return S2RangeFileBasedGeoTimeZonesFinder.create(file);
     }
 
     /**
diff --git a/geolocation/geotz_lookup/src/main/java/android/timezone/geolocation/GeoTimeZonesFinderImpl.java b/geolocation/geotz_lookup/src/main/java/com/android/timezone/geotz/lookup/S2RangeFileBasedGeoTimeZonesFinder.java
similarity index 85%
rename from geolocation/geotz_lookup/src/main/java/android/timezone/geolocation/GeoTimeZonesFinderImpl.java
rename to geolocation/geotz_lookup/src/main/java/com/android/timezone/geotz/lookup/S2RangeFileBasedGeoTimeZonesFinder.java
index f5bbfe4..26b9860 100644
--- a/geolocation/geotz_lookup/src/main/java/android/timezone/geolocation/GeoTimeZonesFinderImpl.java
+++ b/geolocation/geotz_lookup/src/main/java/com/android/timezone/geotz/lookup/S2RangeFileBasedGeoTimeZonesFinder.java
@@ -13,7 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package android.timezone.geolocation;
+package com.android.timezone.geotz.lookup;
+
+import androidx.annotation.NonNull;
 
 import com.android.timezone.geotz.storage.tzs2range.read.TzS2RangeFileReader;
 import com.google.common.geometry.S2CellId;
@@ -25,33 +27,32 @@
 import java.util.List;
 import java.util.Objects;
 
-import javax.annotation.Nullable;
-
 /**
  * An implementation of {@link GeoTimeZonesFinder} that uses {@link TzS2RangeFileReader}.
  */
-public final class GeoTimeZonesFinderImpl extends GeoTimeZonesFinder {
+final class S2RangeFileBasedGeoTimeZonesFinder extends GeoTimeZonesFinder {
 
-    @Nullable
+    @NonNull
     private final TzS2RangeFileReader mTzS2RangeFileReader;
 
     private final int mS2Level;
 
-    private GeoTimeZonesFinderImpl(TzS2RangeFileReader tzS2RangeFileReader, int s2Level) {
+    private S2RangeFileBasedGeoTimeZonesFinder(
+            @NonNull TzS2RangeFileReader tzS2RangeFileReader, int s2Level) {
         mTzS2RangeFileReader = Objects.requireNonNull(tzS2RangeFileReader);
         mS2Level = s2Level;
     }
 
     /**
-     * Returns a new {@link GeoTimeZonesFinderImpl} using the specified data file.
+     * Returns a new {@link S2RangeFileBasedGeoTimeZonesFinder} using the specified data file.
      *
      * @throws IOException in the event of a problem while reading the underlying file
      */
     // @NonNull
-    public static GeoTimeZonesFinderImpl create(File file) throws IOException {
+    public static S2RangeFileBasedGeoTimeZonesFinder create(File file) throws IOException {
         TzS2RangeFileReader reader = TzS2RangeFileReader.open(file);
         int s2Level = reader.getS2Level();
-        return new GeoTimeZonesFinderImpl(reader, s2Level);
+        return new S2RangeFileBasedGeoTimeZonesFinder(reader, s2Level);
     }
 
     // @NonNull
@@ -81,10 +82,6 @@
 
     // @NonNull
     private List<String> findTimeZonesForS2CellId(long s2CellId) throws IOException {
-        if (mTzS2RangeFileReader == null) {
-            return Collections.emptyList();
-        }
-
         TzS2RangeFileReader.Entry entry = mTzS2RangeFileReader.findEntryByCellId(s2CellId);
         if (entry == null) {
             return Collections.emptyList();
@@ -100,9 +97,6 @@
 
     @Override
     public void close() throws IOException {
-        if (mTzS2RangeFileReader == null) {
-            return;
-        }
         mTzS2RangeFileReader.close();
     }
 
diff --git a/geolocation/geotz_lookup/src/test/java/android/timezone/geolocation/GeoTimeZonesFinderTest.java b/geolocation/geotz_lookup/src/test/java/com/android/timezone/geotz/lookup/GeoTimeZonesFinderTest.java
similarity index 97%
rename from geolocation/geotz_lookup/src/test/java/android/timezone/geolocation/GeoTimeZonesFinderTest.java
rename to geolocation/geotz_lookup/src/test/java/com/android/timezone/geotz/lookup/GeoTimeZonesFinderTest.java
index 4ec817b..903b7fb 100644
--- a/geolocation/geotz_lookup/src/test/java/android/timezone/geolocation/GeoTimeZonesFinderTest.java
+++ b/geolocation/geotz_lookup/src/test/java/com/android/timezone/geotz/lookup/GeoTimeZonesFinderTest.java
@@ -13,12 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package android.timezone.geolocation;
+package com.android.timezone.geotz.lookup;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
-import android.timezone.geolocation.GeoTimeZonesFinder.LocationToken;
+import com.android.timezone.geotz.lookup.GeoTimeZonesFinder.LocationToken;
 
 import org.junit.After;
 import org.junit.Before;
diff --git a/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/EnvironmentImpl.java b/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/EnvironmentImpl.java
index 00b6ef1..60fc294 100644
--- a/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/EnvironmentImpl.java
+++ b/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/EnvironmentImpl.java
@@ -28,12 +28,12 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.os.SystemClock;
-import android.timezone.geolocation.GeoTimeZonesFinder;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
 import com.android.location.timezone.provider.LocationTimeZoneEventUnbundled;
+import com.android.timezone.geotz.lookup.GeoTimeZonesFinder;
 import com.android.timezone.geotz.provider.core.Cancellable;
 import com.android.timezone.geotz.provider.core.OfflineLocationTimeZoneDelegate;
 import com.android.timezone.geotz.provider.core.OfflineLocationTimeZoneDelegate.ListenModeEnum;
diff --git a/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/core/Mode.java b/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/core/Mode.java
index ad0f02b..2e8e9da 100644
--- a/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/core/Mode.java
+++ b/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/core/Mode.java
@@ -15,7 +15,7 @@
  */
 package com.android.timezone.geotz.provider.core;
 
-import static com.android.timezone.geotz.provider.core.OfflineLocationTimeZoneDelegate.LISTEN_MODE_NA;
+import static com.android.timezone.geotz.provider.core.OfflineLocationTimeZoneDelegate.LOCATION_LISTEN_MODE_NA;
 import static com.android.timezone.geotz.provider.core.OfflineLocationTimeZoneDelegate.LOCATION_LISTEN_MODE_HIGH;
 import static com.android.timezone.geotz.provider.core.OfflineLocationTimeZoneDelegate.LOCATION_LISTEN_MODE_LOW;
 import static com.android.timezone.geotz.provider.core.LogUtils.formatElapsedRealtimeMillis;
@@ -155,7 +155,7 @@
     private String mTimeoutToken;
 
     Mode(@ModeEnum int modeEnum, @NonNull String entryCause) {
-        this(modeEnum, entryCause, LISTEN_MODE_NA);
+        this(modeEnum, entryCause, LOCATION_LISTEN_MODE_NA);
     }
 
     Mode(@ModeEnum int modeEnum, @NonNull String entryCause,
@@ -268,7 +268,7 @@
     /** Returns a string representation of the {@link ListenModeEnum} value provided. */
     static String prettyPrintListenModeEnum(@ListenModeEnum int listenMode) {
         switch (listenMode) {
-            case LISTEN_MODE_NA:
+            case LOCATION_LISTEN_MODE_NA:
                 return "LISTEN_MODE_NA";
             case LOCATION_LISTEN_MODE_HIGH:
                 return "LOCATION_LISTEN_MODE_HIGH";
@@ -293,7 +293,7 @@
                 throw new IllegalArgumentException();
             }
         } else {
-            if (listenMode != LISTEN_MODE_NA) {
+            if (listenMode != LOCATION_LISTEN_MODE_NA) {
                 throw new IllegalArgumentException();
             }
         }
diff --git a/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/core/OfflineLocationTimeZoneDelegate.java b/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/core/OfflineLocationTimeZoneDelegate.java
index 42c3ad9..77b8865 100644
--- a/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/core/OfflineLocationTimeZoneDelegate.java
+++ b/geolocation/locationtzprovider/src/main/java/com/android/timezone/geotz/provider/core/OfflineLocationTimeZoneDelegate.java
@@ -28,8 +28,6 @@
 
 import android.location.Location;
 import android.os.SystemClock;
-import android.timezone.geolocation.GeoTimeZonesFinder;
-import android.timezone.geolocation.GeoTimeZonesFinder.LocationToken;
 
 import androidx.annotation.GuardedBy;
 import androidx.annotation.IntDef;
@@ -37,6 +35,8 @@
 import androidx.annotation.Nullable;
 
 import com.android.location.timezone.provider.LocationTimeZoneEventUnbundled;
+import com.android.timezone.geotz.lookup.GeoTimeZonesFinder;
+import com.android.timezone.geotz.lookup.GeoTimeZonesFinder.LocationToken;
 
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -81,7 +81,7 @@
 
     /** Use when location listen mode is not applicable. */
     @ListenModeEnum
-    public static final int LISTEN_MODE_NA = 0;
+    public static final int LOCATION_LISTEN_MODE_NA = 0;
 
     /** The most power-expensive and aggressive location detection mode. */
     @ListenModeEnum
diff --git a/geolocation/locationtzprovider/src/test/java/com/android/timezone/geotz/provider/core/OfflineLocationTimeZoneDelegateTest.java b/geolocation/locationtzprovider/src/test/java/com/android/timezone/geotz/provider/core/OfflineLocationTimeZoneDelegateTest.java
index d7df839..602eeb9 100644
--- a/geolocation/locationtzprovider/src/test/java/com/android/timezone/geotz/provider/core/OfflineLocationTimeZoneDelegateTest.java
+++ b/geolocation/locationtzprovider/src/test/java/com/android/timezone/geotz/provider/core/OfflineLocationTimeZoneDelegateTest.java
@@ -22,12 +22,12 @@
 import static org.junit.Assert.assertSame;
 
 import android.location.Location;
-import android.timezone.geolocation.GeoTimeZonesFinder;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
 import com.android.location.timezone.provider.LocationTimeZoneEventUnbundled;
+import com.android.timezone.geotz.lookup.GeoTimeZonesFinder;
 
 import org.junit.Before;
 import org.junit.Test;
diff --git a/geolocation/validation/geonames/src/main/java/com/android/timezone/geolocation/validation/GeonamesComparison.java b/geolocation/validation/geonames/src/main/java/com/android/timezone/geolocation/validation/GeonamesComparison.java
index 3b9334b..981e4a8 100644
--- a/geolocation/validation/geonames/src/main/java/com/android/timezone/geolocation/validation/GeonamesComparison.java
+++ b/geolocation/validation/geonames/src/main/java/com/android/timezone/geolocation/validation/GeonamesComparison.java
@@ -17,14 +17,13 @@
 
 import static java.util.stream.Collectors.toList;
 
-import android.timezone.geolocation.GeoTimeZonesFinder;
-
 import com.android.timezone.geolocation.validation.CitiesFile.City;
 import com.android.timezone.geolocation.validation.Types.KnownDifference;
 import com.android.timezone.geolocation.validation.Types.KnownDifferenceMismatch;
 import com.android.timezone.geolocation.validation.Types.KnownDifferences;
 import com.android.timezone.geolocation.validation.Types.Result;
 import com.android.timezone.geolocation.validation.Types.TestCaseId;
+import com.android.timezone.geotz.lookup.GeoTimeZonesFinder;
 import com.android.timezone.tzids.TimeZoneIds;
 import com.google.common.geometry.S2CellId;
 import com.google.common.geometry.S2LatLng;
@@ -43,8 +42,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.function.LongFunction;
-import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 /**