Revert CountryDetector changes

-Revert detectCountry() to UnsupportedAppUsage
-Revert addCountryListener & removeCountryListener to UnsupportedAppUsage
-Revert countryListener to UnsupportedAppUsage
-Revert getCountryIso() to UnsupportedAppUsage to support api with new naming convention

Bug: 252989268
Test: manual test && make update-api
Change-Id: I5c5978f4460eb6bce8d3ed97458b5cc6ac6d788d
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 014c4ee..3a98dfa 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -5609,7 +5609,6 @@
 
   public final class Country implements android.os.Parcelable {
     method public int describeContents();
-    method @NonNull public String getCountryIso();
     method public int getSource();
     method public void writeToParcel(@NonNull android.os.Parcel, int);
     field public static final int COUNTRY_SOURCE_LOCALE = 3; // 0x3
@@ -5619,16 +5618,6 @@
     field @NonNull public static final android.os.Parcelable.Creator<android.location.Country> CREATOR;
   }
 
-  public class CountryDetector {
-    method public void addCountryListener(@NonNull android.location.CountryListener, @Nullable android.os.Looper);
-    method @Nullable public android.location.Country detectCountry();
-    method public void removeCountryListener(@NonNull android.location.CountryListener);
-  }
-
-  public interface CountryListener {
-    method public void onCountryDetected(@NonNull android.location.Country);
-  }
-
   public final class GnssCapabilities implements android.os.Parcelable {
     method @Deprecated public boolean hasMeasurementCorrectionsReflectingPane();
     method @Deprecated public boolean hasNavMessages();
diff --git a/core/api/system-lint-baseline.txt b/core/api/system-lint-baseline.txt
index 47588d9..025e862 100644
--- a/core/api/system-lint-baseline.txt
+++ b/core/api/system-lint-baseline.txt
@@ -3,10 +3,6 @@
     Method should return Collection<CharSequence> (or subclass) instead of raw array; was `java.lang.CharSequence[]`
 
 
-ExecutorRegistration: android.location.CountryDetector#addCountryListener(android.location.CountryListener, android.os.Looper):
-    Registration methods should have overload that accepts delivery Executor: `addCountryListener`
-
-
 GenericException: android.app.prediction.AppPredictor#finalize():
     Methods must not throw generic exceptions (`java.lang.Throwable`)
 GenericException: android.hardware.location.ContextHubClient#finalize():
@@ -131,8 +127,6 @@
     SAM-compatible parameters (such as parameter 1, "pw", in android.content.pm.PackageItemInfo.dumpFront) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions
 SamShouldBeLast: android.content.pm.ResolveInfo#dump(android.util.Printer, String):
     SAM-compatible parameters (such as parameter 1, "pw", in android.content.pm.ResolveInfo.dump) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions
-SamShouldBeLast: android.location.CountryDetector#addCountryListener(android.location.CountryListener, android.os.Looper):
-    SAM-compatible parameters (such as parameter 1, "listener", in android.location.CountryDetector.addCountryListener) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions
 SamShouldBeLast: android.location.Location#dump(android.util.Printer, String):
     SAM-compatible parameters (such as parameter 1, "pw", in android.location.Location.dump) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions
 SamShouldBeLast: android.location.LocationManager#addNmeaListener(android.location.OnNmeaMessageListener, android.os.Handler):
diff --git a/location/java/android/location/Country.java b/location/java/android/location/Country.java
index 8e1bb1f0..62f4891 100644
--- a/location/java/android/location/Country.java
+++ b/location/java/android/location/Country.java
@@ -33,34 +33,22 @@
  */
 @SystemApi(client = SystemApi.Client.PRIVILEGED_APPS)
 public final class Country implements Parcelable {
-    /**
-     * The country code came from the mobile network
-     */
+    /** The country code came from the mobile network */
     public static final int COUNTRY_SOURCE_NETWORK = 0;
 
-    /**
-     * The country code came from the location service
-     */
+    /** The country code came from the location service */
     public static final int COUNTRY_SOURCE_LOCATION = 1;
 
-    /**
-     * The country code was read from the SIM card
-     */
+    /** The country code was read from the SIM card */
     public static final int COUNTRY_SOURCE_SIM = 2;
 
-    /**
-     * The country code came from the system locale setting
-     */
+    /** The country code came from the system locale setting */
     public static final int COUNTRY_SOURCE_LOCALE = 3;
 
-    /**
-     * The ISO 3166-1 two letters country code.
-     */
+    /** The ISO 3166-1 two letters country code. */
     private final String mCountryIso;
 
-    /**
-     * Where the country code came from.
-     */
+    /** Where the country code came from. */
     private final int mSource;
 
     private int mHashCode;
@@ -73,21 +61,21 @@
 
     /**
      * @param countryIso the ISO 3166-1 two letters country code.
-     * @param source where the countryIso came from, could be one of below
-     *        values
-     *        <p>
-     *        <ul>
-     *        <li>{@link #COUNTRY_SOURCE_NETWORK}</li>
-     *        <li>{@link #COUNTRY_SOURCE_LOCATION}</li>
-     *        <li>{@link #COUNTRY_SOURCE_SIM}</li>
-     *        <li>{@link #COUNTRY_SOURCE_LOCALE}</li>
-     *        </ul>
+     * @param source where the countryIso came from, could be one of below values
+     *     <p>
+     *     <ul>
+     *       <li>{@link #COUNTRY_SOURCE_NETWORK}
+     *       <li>{@link #COUNTRY_SOURCE_LOCATION}
+     *       <li>{@link #COUNTRY_SOURCE_SIM}
+     *       <li>{@link #COUNTRY_SOURCE_LOCALE}
+     *     </ul>
      *
      * @hide
      */
     @UnsupportedAppUsage
-    public Country(final String countryIso, final int source) {
-        if (countryIso == null || source < COUNTRY_SOURCE_NETWORK
+    public Country(@NonNull final String countryIso, final int source) {
+        if (countryIso == null
+                || source < COUNTRY_SOURCE_NETWORK
                 || source > COUNTRY_SOURCE_LOCALE) {
             throw new IllegalArgumentException();
         }
@@ -97,7 +85,8 @@
     }
 
     private Country(final String countryIso, final int source, long timestamp) {
-        if (countryIso == null || source < COUNTRY_SOURCE_NETWORK
+        if (countryIso == null
+                || source < COUNTRY_SOURCE_NETWORK
                 || source > COUNTRY_SOURCE_LOCALE) {
             throw new IllegalArgumentException();
         }
@@ -115,21 +104,22 @@
 
     /**
      * @return the ISO 3166-1 two letters country code
+     * @hide
      */
-    @NonNull
+    @UnsupportedAppUsage
     public String getCountryIso() {
         return mCountryIso;
     }
 
     /**
      * @return where the country code came from, could be one of below values
-     *         <p>
-     *         <ul>
-     *         <li>{@link #COUNTRY_SOURCE_NETWORK}</li>
-     *         <li>{@link #COUNTRY_SOURCE_LOCATION}</li>
-     *         <li>{@link #COUNTRY_SOURCE_SIM}</li>
-     *         <li>{@link #COUNTRY_SOURCE_LOCALE}</li>
-     *         </ul>
+     *     <p>
+     *     <ul>
+     *       <li>{@link #COUNTRY_SOURCE_NETWORK}
+     *       <li>{@link #COUNTRY_SOURCE_LOCATION}
+     *       <li>{@link #COUNTRY_SOURCE_SIM}
+     *       <li>{@link #COUNTRY_SOURCE_LOCALE}
+     *     </ul>
      */
     public int getSource() {
         return mSource;
@@ -146,15 +136,16 @@
     }
 
     @android.annotation.NonNull
-    public static final Parcelable.Creator<Country> CREATOR = new Parcelable.Creator<Country>() {
-        public Country createFromParcel(Parcel in) {
-            return new Country(in.readString(), in.readInt(), in.readLong());
-        }
+    public static final Parcelable.Creator<Country> CREATOR =
+            new Parcelable.Creator<Country>() {
+                public Country createFromParcel(Parcel in) {
+                    return new Country(in.readString(), in.readInt(), in.readLong());
+                }
 
-        public Country[] newArray(int size) {
-            return new Country[size];
-        }
-    };
+                public Country[] newArray(int size) {
+                    return new Country[size];
+                }
+            };
 
     @Override
     public int describeContents() {
@@ -169,10 +160,9 @@
     }
 
     /**
-     * Returns true if this {@link Country} is equivalent to the given object. This ignores
-     * the timestamp value and just checks for equivalence of countryIso and source values.
-     * Returns false otherwise.
-     *
+     * Returns true if this {@link Country} is equivalent to the given object. This ignores the
+     * timestamp value and just checks for equivalence of countryIso and source values. Returns
+     * false otherwise.
      */
     @Override
     public boolean equals(@Nullable Object object) {
@@ -200,13 +190,12 @@
     }
 
     /**
-     * Compare the specified country to this country object ignoring the source
-     * and timestamp fields, return true if the countryIso fields are equal
+     * Compare the specified country to this country object ignoring the source and timestamp
+     * fields, return true if the countryIso fields are equal
      *
      * @param country the country to compare
-     * @return true if the specified country's countryIso field is equal to this
-     *         country's, false otherwise.
-     *
+     * @return true if the specified country's countryIso field is equal to this country's, false
+     *     otherwise.
      * @hide
      */
     public boolean equalsIgnoreSource(Country country) {
diff --git a/location/java/android/location/CountryDetector.java b/location/java/android/location/CountryDetector.java
index 3a0edfc..2592a28 100644
--- a/location/java/android/location/CountryDetector.java
+++ b/location/java/android/location/CountryDetector.java
@@ -16,9 +16,6 @@
 
 package android.location;
 
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.annotation.SystemApi;
 import android.annotation.SystemService;
 import android.compat.annotation.UnsupportedAppUsage;
 import android.content.Context;
@@ -31,35 +28,35 @@
 import java.util.HashMap;
 
 /**
- * This class provides access to the system country detector service. This
- * service allows applications to obtain the country that the user is in.
- * <p>
- * The country will be detected in order of reliability, like
+ * This class provides access to the system country detector service. This service allows
+ * applications to obtain the country that the user is in.
+ *
+ * <p>The country will be detected in order of reliability, like
+ *
  * <ul>
- * <li>Mobile network</li>
- * <li>Location</li>
- * <li>SIM's country</li>
- * <li>Phone's locale</li>
+ *   <li>Mobile network
+ *   <li>Location
+ *   <li>SIM's country
+ *   <li>Phone's locale
  * </ul>
- * <p>
- * Call the {@link #detectCountry()} to get the available country immediately.
- * <p>
- * To be notified of the future country change, use the
- * {@link #addCountryListener}
+ *
+ * <p>Call the {@link #detectCountry()} to get the available country immediately.
+ *
+ * <p>To be notified of the future country change, use the {@link #addCountryListener}
+ *
  * <p>
  *
  * @hide
  */
-@SystemApi(client = SystemApi.Client.PRIVILEGED_APPS)
 @SystemService(Context.COUNTRY_DETECTOR)
 public class CountryDetector {
 
     /**
-     * The class to wrap the ICountryListener.Stub and CountryListener objects
-     * together. The CountryListener will be notified through the specific
-     * looper once the country changed and detected.
+     * The class to wrap the ICountryListener.Stub and CountryListener objects together. The
+     * CountryListener will be notified through the specific looper once the country changed and
+     * detected.
      */
-    private final static class ListenerTransport extends ICountryListener.Stub {
+    private static final class ListenerTransport extends ICountryListener.Stub {
 
         private final CountryListener mListener;
 
@@ -75,23 +72,23 @@
         }
 
         public void onCountryDetected(final Country country) {
-            mHandler.post(new Runnable() {
-                public void run() {
-                    mListener.onCountryDetected(country);
-                }
-            });
+            mHandler.post(
+                    new Runnable() {
+                        public void run() {
+                            mListener.onCountryDetected(country);
+                        }
+                    });
         }
     }
 
-    private final static String TAG = "CountryDetector";
+    private static final String TAG = "CountryDetector";
     private final ICountryDetector mService;
     private final HashMap<CountryListener, ListenerTransport> mListeners;
 
     /**
-     * @hide - hide this constructor because it has a parameter of type
-     *       ICountryDetector, which is a system private class. The right way to
-     *       create an instance of this class is using the factory
-     *       Context.getSystemService.
+     * @hide - hide this constructor because it has a parameter of type ICountryDetector, which is a
+     *     system private class. The right way to create an instance of this class is using the
+     *     factory Context.getSystemService.
      */
     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
     public CountryDetector(ICountryDetector service) {
@@ -102,10 +99,9 @@
     /**
      * Start detecting the country that the user is in.
      *
-     * @return the country if it is available immediately, otherwise null will
-     *         be returned.
+     * @return the country if it is available immediately, otherwise null will be returned.
      */
-    @Nullable
+    @UnsupportedAppUsage
     public Country detectCountry() {
         try {
             return mService.detectCountry();
@@ -116,15 +112,14 @@
     }
 
     /**
-     * Add a listener to receive the notification when the country is detected
-     * or changed.
+     * Add a listener to receive the notification when the country is detected or changed.
      *
      * @param listener will be called when the country is detected or changed.
-     * @param looper a Looper object whose message queue will be used to
-     *        implement the callback mechanism. If looper is null then the
-     *        callbacks will be called on the main thread.
+     * @param looper a Looper object whose message queue will be used to implement the callback
+     *     mechanism. If looper is null then the callbacks will be called on the main thread.
      */
-    public void addCountryListener(@NonNull CountryListener listener, @Nullable Looper looper) {
+    @UnsupportedAppUsage
+    public void addCountryListener(CountryListener listener, Looper looper) {
         synchronized (mListeners) {
             if (!mListeners.containsKey(listener)) {
                 ListenerTransport transport = new ListenerTransport(listener, looper);
@@ -138,10 +133,9 @@
         }
     }
 
-    /**
-     * Remove the listener
-     */
-    public void removeCountryListener(@NonNull CountryListener listener) {
+    /** Remove the listener */
+    @UnsupportedAppUsage
+    public void removeCountryListener(CountryListener listener) {
         synchronized (mListeners) {
             ListenerTransport transport = mListeners.get(listener);
             if (transport != null) {
diff --git a/location/java/android/location/CountryListener.java b/location/java/android/location/CountryListener.java
index 5c06d82..eb67205 100644
--- a/location/java/android/location/CountryListener.java
+++ b/location/java/android/location/CountryListener.java
@@ -16,8 +16,7 @@
 
 package android.location;
 
-import android.annotation.NonNull;
-import android.annotation.SystemApi;
+import android.compat.annotation.UnsupportedAppUsage;
 
 /**
  * The listener for receiving the notification when the country is detected or
@@ -25,11 +24,10 @@
  *
  * @hide
  */
-@SystemApi(client = SystemApi.Client.PRIVILEGED_APPS)
 public interface CountryListener {
     /**
      * @param country the changed or detected country.
-     *
      */
-    void onCountryDetected(@NonNull Country country);
+    @UnsupportedAppUsage
+    void onCountryDetected(Country country);
 }