Add Thread resource overlay support

This CL adds resource overlay support to allow developers to
change the default configuration of using the location country code.

Bug: b/311324956
Test: Set the resource overlay in cuttlefish, check the default
      configuration via the command `dumpsys thread_network`.

Change-Id: Ide853975e8244f06a382b2eda4844e030539b95d
diff --git a/thread/service/Android.bp b/thread/service/Android.bp
index 92cdedc..b5fee95 100644
--- a/thread/service/Android.bp
+++ b/thread/service/Android.bp
@@ -37,6 +37,7 @@
         "framework-connectivity-t-pre-jarjar",
         "framework-location.stubs.module_lib",
         "service-connectivity-pre-jarjar",
+        "ServiceConnectivityResources",
     ],
     static_libs: [
         "modules-utils-shell-command-handler",
diff --git a/thread/service/java/com/android/server/thread/ThreadNetworkCountryCode.java b/thread/service/java/com/android/server/thread/ThreadNetworkCountryCode.java
index b05183c..df2c56e 100644
--- a/thread/service/java/com/android/server/thread/ThreadNetworkCountryCode.java
+++ b/thread/service/java/com/android/server/thread/ThreadNetworkCountryCode.java
@@ -27,7 +27,9 @@
 import android.os.Build;
 import android.util.Log;
 
+import com.android.connectivity.resources.R;
 import com.android.internal.annotations.VisibleForTesting;
+import com.android.server.connectivity.ConnectivityResources;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
@@ -73,6 +75,7 @@
     private static final CountryCodeInfo DEFAULT_COUNTRY_CODE_INFO =
             new CountryCodeInfo(DEFAULT_COUNTRY_CODE, COUNTRY_CODE_SOURCE_DEFAULT);
 
+    private final ConnectivityResources mResources;
     private final LocationManager mLocationManager;
     @Nullable private final Geocoder mGeocoder;
     private final ThreadNetworkControllerService mThreadNetworkControllerService;
@@ -123,17 +126,20 @@
     }
 
     private boolean isLocationUseForCountryCodeEnabled() {
-        // TODO: b/311324956 read the configuration from the overlay configuration.
-        return true;
+        return mResources
+                .get()
+                .getBoolean(R.bool.config_thread_location_use_for_country_code_enabled);
     }
 
     public ThreadNetworkCountryCode(
             LocationManager locationManager,
             ThreadNetworkControllerService threadNetworkControllerService,
-            @Nullable Geocoder geocoder) {
+            @Nullable Geocoder geocoder,
+            ConnectivityResources resources) {
         mLocationManager = locationManager;
         mThreadNetworkControllerService = threadNetworkControllerService;
         mGeocoder = geocoder;
+        mResources = resources;
     }
 
     /** Sets up this country code module to listen to location country code changes. */
diff --git a/thread/service/java/com/android/server/thread/ThreadNetworkService.java b/thread/service/java/com/android/server/thread/ThreadNetworkService.java
index 287bb8a..95c7256 100644
--- a/thread/service/java/com/android/server/thread/ThreadNetworkService.java
+++ b/thread/service/java/com/android/server/thread/ThreadNetworkService.java
@@ -29,6 +29,7 @@
 import android.os.ParcelFileDescriptor;
 
 import com.android.server.SystemService;
+import com.android.server.connectivity.ConnectivityResources;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
@@ -62,8 +63,10 @@
                     new ThreadNetworkCountryCode(
                             mContext.getSystemService(LocationManager.class),
                             mControllerService,
-                            Geocoder.isPresent() ? new Geocoder(mContext) : null);
+                            Geocoder.isPresent() ? new Geocoder(mContext) : null,
+                            new ConnectivityResources(mContext));
             mCountryCode.initialize();
+
             mShellCommand = new ThreadNetworkShellCommand(mCountryCode);
         }
     }