[Thread] initial Thread network service

This commit sets up the initial Thread network service for the
Android Thread feature which allows an Android device to create
a Thread network and being a Border Router.

See https://www.threadgroup.org/What-is-Thread for background of
Thread.

See b/235016403 for the Android Thread feature request.

Test: lunch aosp_cf_x86_64_tv-userdebug
      m && launch_cvd
      atest CtsThreadNetworkTestCases
Bug: 262683651
Change-Id: Ie1bb23084531f67165ec068ea3ca39592dbc01d1
diff --git a/thread/service/Android.bp b/thread/service/Android.bp
index fda206a..f1af653 100644
--- a/thread/service/Android.bp
+++ b/thread/service/Android.bp
@@ -32,5 +32,11 @@
     // (service-connectivity is only used on 31+) and use 31 here
     min_sdk_version: "30",
     srcs: [":service-thread-sources"],
+    libs: [
+        "framework-connectivity-t-pre-jarjar",
+    ],
+    static_libs: [
+        "net-utils-device-common",
+    ],
     apex_available: ["com.android.tethering"],
 }
diff --git a/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java b/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java
new file mode 100644
index 0000000..e8b95bc
--- /dev/null
+++ b/thread/service/java/com/android/server/thread/ThreadNetworkControllerService.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.thread;
+
+import static android.net.thread.ThreadNetworkController.THREAD_VERSION_1_3;
+
+import android.net.thread.IThreadNetworkController;
+import android.net.thread.ThreadNetworkController;
+
+/** Implementation of the {@link ThreadNetworkController} API. */
+public final class ThreadNetworkControllerService extends IThreadNetworkController.Stub {
+
+    @Override
+    public int getThreadVersion() {
+        return THREAD_VERSION_1_3;
+    }
+}
diff --git a/thread/service/java/com/android/server/thread/ThreadNetworkService.java b/thread/service/java/com/android/server/thread/ThreadNetworkService.java
new file mode 100644
index 0000000..c6d47df
--- /dev/null
+++ b/thread/service/java/com/android/server/thread/ThreadNetworkService.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.thread;
+
+import android.content.Context;
+import android.net.thread.IThreadNetworkController;
+import android.net.thread.IThreadNetworkManager;
+
+import com.android.server.SystemService;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Implementation of the Thread network service. This is the entry point of Android Thread feature.
+ */
+public class ThreadNetworkService extends IThreadNetworkManager.Stub {
+    private final ThreadNetworkControllerService mControllerService;
+
+    /** Creates a new {@link ThreadNetworkService} object. */
+    public ThreadNetworkService(Context context) {
+        this(context, new ThreadNetworkControllerService());
+    }
+
+    private ThreadNetworkService(
+            Context context, ThreadNetworkControllerService controllerService) {
+        mControllerService = controllerService;
+    }
+
+    /**
+     * Called by the service initializer.
+     *
+     * @see com.android.server.SystemService#onBootPhase
+     */
+    public void onBootPhase(int phase) {
+        if (phase == SystemService.PHASE_BOOT_COMPLETED) {
+            // TODO: initialize ThreadNetworkManagerService
+        }
+    }
+
+    @Override
+    public List<IThreadNetworkController> getAllThreadNetworkControllers() {
+        return Collections.singletonList(mControllerService);
+    }
+}