Merge "Make mMatchSubscriberIds as a NonNull variable"
diff --git a/service/mdns/com/android/server/connectivity/mdns/MdnsResponseDecoder.java b/service/mdns/com/android/server/connectivity/mdns/MdnsResponseDecoder.java
index 861acbb..6c2bc19 100644
--- a/service/mdns/com/android/server/connectivity/mdns/MdnsResponseDecoder.java
+++ b/service/mdns/com/android/server/connectivity/mdns/MdnsResponseDecoder.java
@@ -256,6 +256,9 @@
                         response = new MdnsResponse(now);
                         responses.add(response);
                     }
+                    // Set interface index earlier because some responses have PTR record only.
+                    // Need to know every response is getting from which interface.
+                    response.setInterfaceIndex(interfaceIndex);
                     response.addPointerRecord((MdnsPointerRecord) record);
                 }
             }
@@ -286,13 +289,13 @@
                     List<MdnsResponse> matchingResponses =
                             findResponsesWithHostName(responses, inetRecord.getName());
                     for (MdnsResponse response : matchingResponses) {
-                        assignInetRecord(response, inetRecord, interfaceIndex);
+                        assignInetRecord(response, inetRecord);
                     }
                 } else {
                     MdnsResponse response =
                             findResponseWithHostName(responses, inetRecord.getName());
                     if (response != null) {
-                        assignInetRecord(response, inetRecord, interfaceIndex);
+                        assignInetRecord(response, inetRecord);
                     }
                 }
             }
@@ -301,14 +304,11 @@
         return SUCCESS;
     }
 
-    private static void assignInetRecord(
-            MdnsResponse response, MdnsInetAddressRecord inetRecord, int interfaceIndex) {
+    private static void assignInetRecord(MdnsResponse response, MdnsInetAddressRecord inetRecord) {
         if (inetRecord.getInet4Address() != null) {
             response.setInet4AddressRecord(inetRecord);
-            response.setInterfaceIndex(interfaceIndex);
         } else if (inetRecord.getInet6Address() != null) {
             response.setInet6AddressRecord(inetRecord);
-            response.setInterfaceIndex(interfaceIndex);
         }
     }
 
diff --git a/service/mdns/com/android/server/connectivity/mdns/MdnsServiceBrowserListener.java b/service/mdns/com/android/server/connectivity/mdns/MdnsServiceBrowserListener.java
index 53e58d1..7a8fcc0 100644
--- a/service/mdns/com/android/server/connectivity/mdns/MdnsServiceBrowserListener.java
+++ b/service/mdns/com/android/server/connectivity/mdns/MdnsServiceBrowserListener.java
@@ -44,9 +44,9 @@
     /**
      * Called when an mDNS service instance is no longer valid and removed.
      *
-     * @param serviceInstanceName The service instance name of the removed mDNS service.
+     * @param serviceInfo The service instance of the removed mDNS service.
      */
-    void onServiceRemoved(@NonNull String serviceInstanceName);
+    void onServiceRemoved(@NonNull MdnsServiceInfo serviceInfo);
 
     /**
      * Called when searching for mDNS service has stopped because of an error.
diff --git a/service/mdns/com/android/server/connectivity/mdns/MdnsServiceTypeClient.java b/service/mdns/com/android/server/connectivity/mdns/MdnsServiceTypeClient.java
index 8ca71b9..0fd6025 100644
--- a/service/mdns/com/android/server/connectivity/mdns/MdnsServiceTypeClient.java
+++ b/service/mdns/com/android/server/connectivity/mdns/MdnsServiceTypeClient.java
@@ -91,8 +91,12 @@
 
     private static MdnsServiceInfo buildMdnsServiceInfoFromResponse(
             @NonNull MdnsResponse response, @NonNull String[] serviceTypeLabels) {
-        String[] hostName = response.getServiceRecord().getServiceHost();
-        int port = response.getServiceRecord().getServicePort();
+        String[] hostName = null;
+        int port = 0;
+        if (response.hasServiceRecord()) {
+            hostName = response.getServiceRecord().getServiceHost();
+            port = response.getServiceRecord().getServicePort();
+        }
 
         String ipv4Address = null;
         String ipv6Address = null;
@@ -104,15 +108,17 @@
             Inet6Address inet6Address = response.getInet6AddressRecord().getInet6Address();
             ipv6Address = (inet6Address == null) ? null : inet6Address.getHostAddress();
         }
-        if (ipv4Address == null && ipv6Address == null) {
-            throw new IllegalArgumentException(
-                    "Either ipv4Address or ipv6Address must be non-null");
-        }
         String serviceInstanceName = response.getServiceInstanceName();
         if (serviceInstanceName == null) {
             throw new IllegalStateException(
                     "mDNS response must have non-null service instance name");
         }
+        List<String> textStrings = null;
+        List<MdnsServiceInfo.TextEntry> textEntries = null;
+        if (response.hasTextRecord()) {
+            textStrings = response.getTextRecord().getStrings();
+            textEntries = response.getTextRecord().getEntries();
+        }
         // TODO: Throw an error message if response doesn't have Inet6 or Inet4 address.
         return new MdnsServiceInfo(
                 serviceInstanceName,
@@ -122,8 +128,8 @@
                 port,
                 ipv4Address,
                 ipv6Address,
-                response.getTextRecord().getStrings(),
-                response.getTextRecord().getEntries(),
+                textStrings,
+                textEntries,
                 response.getInterfaceIndex());
     }
 
@@ -246,12 +252,14 @@
     }
 
     private void onGoodbyeReceived(@Nullable String serviceInstanceName) {
-        if (serviceInstanceName == null) {
+        final MdnsResponse response = instanceNameToResponse.remove(serviceInstanceName);
+        if (response == null) {
             return;
         }
-        instanceNameToResponse.remove(serviceInstanceName);
         for (MdnsServiceBrowserListener listener : listeners) {
-            listener.onServiceRemoved(serviceInstanceName);
+            final MdnsServiceInfo serviceInfo =
+                    buildMdnsServiceInfoFromResponse(response, serviceTypeLabels);
+            listener.onServiceRemoved(serviceInfo);
         }
     }
 
@@ -425,7 +433,10 @@
                                 String serviceInstanceName =
                                         existingResponse.getServiceInstanceName();
                                 if (serviceInstanceName != null) {
-                                    listener.onServiceRemoved(serviceInstanceName);
+                                    final MdnsServiceInfo serviceInfo =
+                                            buildMdnsServiceInfoFromResponse(
+                                                    existingResponse, serviceTypeLabels);
+                                    listener.onServiceRemoved(serviceInfo);
                                 }
                             }
                         }
diff --git a/tests/unit/java/com/android/server/connectivity/mdns/MdnsServiceTypeClientTests.java b/tests/unit/java/com/android/server/connectivity/mdns/MdnsServiceTypeClientTests.java
index 6b10c71..6f8b85a 100644
--- a/tests/unit/java/com/android/server/connectivity/mdns/MdnsServiceTypeClientTests.java
+++ b/tests/unit/java/com/android/server/connectivity/mdns/MdnsServiceTypeClientTests.java
@@ -24,6 +24,7 @@
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.argThat;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -35,6 +36,7 @@
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import android.annotation.NonNull;
+import android.text.TextUtils;
 
 import com.android.server.connectivity.mdns.MdnsServiceInfo.TextEntry;
 import com.android.server.connectivity.mdns.MdnsServiceTypeClient.QueryTaskConfig;
@@ -57,6 +59,7 @@
 import java.net.Inet6Address;
 import java.net.SocketAddress;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -71,6 +74,7 @@
 public class MdnsServiceTypeClientTests {
 
     private static final String SERVICE_TYPE = "_googlecast._tcp.local";
+    private static final String[] SERVICE_TYPE_LABELS = TextUtils.split(SERVICE_TYPE, "\\.");
 
     @Mock
     private MdnsServiceBrowserListener mockListenerOne;
@@ -491,17 +495,43 @@
     }
 
     @Test
-    public void processResponse_goodBye() {
+    public void processResponse_goodBye() throws Exception {
         client.startSendAndReceive(mockListenerOne, MdnsSearchOptions.getDefaultOptions());
         client.startSendAndReceive(mockListenerTwo, MdnsSearchOptions.getDefaultOptions());
 
+        final String serviceName = "service-instance-1";
+        final String ipV6Address = "2000:3333::da6c:63ff:fe7c:7483";
+        final int interfaceIndex = 999;
+        // Process the initial response.
+        final MdnsResponse initialResponse =
+                createResponse(
+                        serviceName,
+                        ipV6Address,
+                        5353 /* port */,
+                        Collections.singletonList("ABCDE"),
+                        Collections.emptyMap(),
+                        interfaceIndex);
+        client.processResponse(initialResponse);
         MdnsResponse response = mock(MdnsResponse.class);
-        when(response.getServiceInstanceName()).thenReturn("goodbye-service-instance-name");
-        when(response.isGoodbye()).thenReturn(true);
+        doReturn("goodbye-service").when(response).getServiceInstanceName();
+        doReturn(interfaceIndex).when(response).getInterfaceIndex();
+        doReturn(true).when(response).isGoodbye();
         client.processResponse(response);
+        // Verify onServiceRemoved won't be called if the service is not existed.
+        verify(mockListenerOne, never()).onServiceRemoved(any());
+        verify(mockListenerTwo, never()).onServiceRemoved(any());
 
-        verify(mockListenerOne).onServiceRemoved("goodbye-service-instance-name");
-        verify(mockListenerTwo).onServiceRemoved("goodbye-service-instance-name");
+        // Verify onServiceRemoved would be called.
+        doReturn(serviceName).when(response).getServiceInstanceName();
+        client.processResponse(response);
+        verify(mockListenerOne).onServiceRemoved(argThat(
+                info -> serviceName.equals(info.getServiceInstanceName())
+                        && Arrays.equals(SERVICE_TYPE_LABELS, info.getServiceType())
+                        && info.getInterfaceIndex() == interfaceIndex));
+        verify(mockListenerTwo).onServiceRemoved(argThat(
+                info -> serviceName.equals(info.getServiceInstanceName())
+                        && Arrays.equals(SERVICE_TYPE_LABELS, info.getServiceType())
+                        && info.getInterfaceIndex() == interfaceIndex));
     }
 
     @Test
@@ -563,7 +593,7 @@
         firstMdnsTask.run();
 
         // Verify onServiceRemoved was not called.
-        verify(mockListenerOne, never()).onServiceRemoved(serviceInstanceName);
+        verify(mockListenerOne, never()).onServiceRemoved(any());
     }
 
     @Test
@@ -586,7 +616,7 @@
         MdnsResponse initialResponse =
                 createResponse(
                         serviceInstanceName, "192.168.1.1", 5353, List.of("ABCDE"),
-                        Map.of());
+                        Map.of(), 999 /* interfaceIndex */);
         client.processResponse(initialResponse);
 
         // Clear the scheduled runnable.
@@ -597,14 +627,17 @@
         firstMdnsTask.run();
 
         // Verify onServiceRemoved was not called.
-        verify(mockListenerOne, never()).onServiceRemoved(serviceInstanceName);
+        verify(mockListenerOne, never()).onServiceRemoved(any());
 
         // Simulate the case where the response is after TTL.
         when(initialResponse.getServiceRecord().getRemainingTTL(anyLong())).thenReturn((long) 0);
         firstMdnsTask.run();
 
         // Verify onServiceRemoved was called.
-        verify(mockListenerOne, times(1)).onServiceRemoved(serviceInstanceName);
+        verify(mockListenerOne, times(1)).onServiceRemoved(argThat(
+                info -> serviceInstanceName.equals(info.getServiceInstanceName())
+                        && Arrays.equals(SERVICE_TYPE_LABELS, info.getServiceType())
+                        && info.getInterfaceIndex() == 999));
     }
 
     @Test
@@ -636,7 +669,7 @@
         firstMdnsTask.run();
 
         // Verify onServiceRemoved was not called.
-        verify(mockListenerOne, never()).onServiceRemoved(serviceInstanceName);
+        verify(mockListenerOne, never()).onServiceRemoved(any());
     }
 
     @Test
@@ -659,7 +692,7 @@
         MdnsResponse initialResponse =
                 createResponse(
                         serviceInstanceName, "192.168.1.1", 5353, List.of("ABCDE"),
-                        Map.of());
+                        Map.of(), 999 /* interfaceIndex */);
         client.processResponse(initialResponse);
 
         // Clear the scheduled runnable.
@@ -669,8 +702,11 @@
         when(initialResponse.getServiceRecord().getRemainingTTL(anyLong())).thenReturn((long) 0);
         firstMdnsTask.run();
 
-        // Verify onServiceRemoved was not called.
-        verify(mockListenerOne, times(1)).onServiceRemoved(serviceInstanceName);
+        // Verify onServiceRemoved was called.
+        verify(mockListenerOne, times(1)).onServiceRemoved(argThat(
+                info -> serviceInstanceName.equals(info.getServiceInstanceName())
+                        && Arrays.equals(SERVICE_TYPE_LABELS, info.getServiceType())
+                        && info.getInterfaceIndex() == 999));
     }
 
     // verifies that the right query was enqueued with the right delay, and send query by executing
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 886b4a9..e3060a2 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -32,6 +32,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator:buildflags__android_arm64
@@ -52,6 +55,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator:buildflags__android_x86
@@ -72,6 +78,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator:buildflags__android_x86_64
@@ -92,6 +101,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator:buildflags__host
@@ -114,6 +126,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:chromecast_buildflags__android_arm
@@ -134,6 +149,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:chromecast_buildflags__android_arm64
@@ -154,6 +172,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:chromecast_buildflags__android_x86
@@ -174,6 +195,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:chromecast_buildflags__android_x86_64
@@ -194,6 +218,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:chromecast_buildflags__host
@@ -216,6 +243,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:chromeos_buildflags__android_arm
@@ -236,6 +266,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:chromeos_buildflags__android_arm64
@@ -256,6 +289,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:chromeos_buildflags__android_x86
@@ -276,6 +312,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:chromeos_buildflags__android_x86_64
@@ -296,6 +335,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:chromeos_buildflags__host
@@ -318,6 +360,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:debugging_buildflags__android_arm
@@ -338,6 +383,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:debugging_buildflags__android_arm64
@@ -358,6 +406,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:debugging_buildflags__android_x86
@@ -378,6 +429,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:debugging_buildflags__android_x86_64
@@ -398,6 +452,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:debugging_buildflags__host
@@ -420,6 +477,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:logging_buildflags__android_arm
@@ -440,6 +500,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:logging_buildflags__android_arm64
@@ -460,6 +523,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:logging_buildflags__android_x86
@@ -480,6 +546,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:logging_buildflags__android_x86_64
@@ -500,6 +569,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:logging_buildflags__host
@@ -522,6 +594,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:partition_alloc
@@ -787,6 +862,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:partition_alloc_buildflags__android_arm64
@@ -807,6 +885,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:partition_alloc_buildflags__android_x86
@@ -827,6 +908,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:partition_alloc_buildflags__android_x86_64
@@ -847,6 +931,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/allocator/partition_allocator:partition_alloc_buildflags__host
@@ -869,6 +956,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:anchor_functions_buildflags__android_arm
@@ -889,6 +979,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:anchor_functions_buildflags__android_arm64
@@ -909,6 +1002,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:anchor_functions_buildflags__android_x86
@@ -929,6 +1025,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:anchor_functions_buildflags__android_x86_64
@@ -949,6 +1048,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:anchor_functions_buildflags__host
@@ -971,6 +1073,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:android_runtime_jni_headers__android_arm
@@ -978,8 +1083,6 @@
     name: "cronet_aml_base_android_runtime_jni_headers__android_arm",
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/base/android_runtime_jni_headers " +
          "--includes " +
@@ -1008,6 +1111,9 @@
         "build/gn_helpers.py",
         "third_party/android_sdk/public/platforms/android-33/android.jar",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:android_runtime_jni_headers__android_arm64
@@ -1015,8 +1121,6 @@
     name: "cronet_aml_base_android_runtime_jni_headers__android_arm64",
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/base/android_runtime_jni_headers " +
          "--includes " +
@@ -1045,6 +1149,9 @@
         "build/gn_helpers.py",
         "third_party/android_sdk/public/platforms/android-33/android.jar",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:android_runtime_jni_headers__android_x86
@@ -1052,8 +1159,6 @@
     name: "cronet_aml_base_android_runtime_jni_headers__android_x86",
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/base/android_runtime_jni_headers " +
          "--includes " +
@@ -1082,6 +1187,9 @@
         "build/gn_helpers.py",
         "third_party/android_sdk/public/platforms/android-33/android.jar",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:android_runtime_jni_headers__android_x86_64
@@ -1089,8 +1197,6 @@
     name: "cronet_aml_base_android_runtime_jni_headers__android_x86_64",
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/base/android_runtime_jni_headers " +
          "--includes " +
@@ -1119,6 +1225,9 @@
         "build/gn_helpers.py",
         "third_party/android_sdk/public/platforms/android-33/android.jar",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:base
@@ -2268,8 +2377,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/base/base_jni_headers " +
          "--includes " +
@@ -2484,6 +2591,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:base_jni_headers__android_arm64
@@ -2533,8 +2643,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/base/base_jni_headers " +
          "--includes " +
@@ -2749,6 +2857,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:base_jni_headers__android_x86
@@ -2798,8 +2909,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/base/base_jni_headers " +
          "--includes " +
@@ -3014,6 +3123,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:base_jni_headers__android_x86_64
@@ -3063,8 +3175,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/base/base_jni_headers " +
          "--includes " +
@@ -3279,6 +3389,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:base_static
@@ -3399,6 +3512,9 @@
     tool_files: [
         "build/write_build_date_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:build_date__android_arm64
@@ -3412,6 +3528,9 @@
     tool_files: [
         "build/write_build_date_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:build_date__android_x86
@@ -3425,6 +3544,9 @@
     tool_files: [
         "build/write_build_date_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:build_date__android_x86_64
@@ -3438,6 +3560,9 @@
     tool_files: [
         "build/write_build_date_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:build_date__host
@@ -3453,6 +3578,9 @@
     tool_files: [
         "build/write_build_date_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:cfi_buildflags__android_arm
@@ -3473,6 +3601,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:cfi_buildflags__android_arm64
@@ -3493,6 +3624,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:cfi_buildflags__android_x86
@@ -3513,6 +3647,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:cfi_buildflags__android_x86_64
@@ -3533,6 +3670,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:cfi_buildflags__host
@@ -3555,6 +3695,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:clang_profiling_buildflags__android_arm
@@ -3575,6 +3718,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:clang_profiling_buildflags__android_arm64
@@ -3595,6 +3741,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:clang_profiling_buildflags__android_x86
@@ -3615,6 +3764,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:clang_profiling_buildflags__android_x86_64
@@ -3635,6 +3787,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:clang_profiling_buildflags__host
@@ -3657,6 +3812,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:debugging_buildflags__android_arm
@@ -3677,6 +3835,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:debugging_buildflags__android_arm64
@@ -3697,6 +3858,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:debugging_buildflags__android_x86
@@ -3717,6 +3881,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:debugging_buildflags__android_x86_64
@@ -3737,6 +3904,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:debugging_buildflags__host
@@ -3759,6 +3929,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:feature_list_buildflags__android_arm
@@ -3779,6 +3952,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:feature_list_buildflags__android_arm64
@@ -3799,6 +3975,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:feature_list_buildflags__android_x86
@@ -3819,6 +3998,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:feature_list_buildflags__android_x86_64
@@ -3839,6 +4021,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:feature_list_buildflags__host
@@ -3861,6 +4046,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:ios_cronet_buildflags__android_arm
@@ -3881,6 +4069,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:ios_cronet_buildflags__android_arm64
@@ -3901,6 +4092,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:ios_cronet_buildflags__android_x86
@@ -3921,6 +4115,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:ios_cronet_buildflags__android_x86_64
@@ -3941,6 +4138,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:ios_cronet_buildflags__host
@@ -3963,6 +4163,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:logging_buildflags__android_arm
@@ -3983,6 +4186,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:logging_buildflags__android_arm64
@@ -4003,6 +4209,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:logging_buildflags__android_x86
@@ -4023,6 +4232,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:logging_buildflags__android_x86_64
@@ -4043,6 +4255,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:logging_buildflags__host
@@ -4065,6 +4280,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:message_pump_buildflags__android_arm
@@ -4085,6 +4303,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:message_pump_buildflags__android_arm64
@@ -4105,6 +4326,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:message_pump_buildflags__android_x86
@@ -4125,6 +4349,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:message_pump_buildflags__android_x86_64
@@ -4145,6 +4372,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:message_pump_buildflags__host
@@ -4167,6 +4397,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/numerics:base_numerics
@@ -4261,6 +4494,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:orderfile_buildflags__android_arm64
@@ -4281,6 +4517,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:orderfile_buildflags__android_x86
@@ -4301,6 +4540,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:orderfile_buildflags__android_x86_64
@@ -4321,6 +4563,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:orderfile_buildflags__host
@@ -4343,6 +4588,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:parsing_buildflags__android_arm
@@ -4363,6 +4611,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:parsing_buildflags__android_arm64
@@ -4383,6 +4634,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:parsing_buildflags__android_x86
@@ -4403,6 +4657,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:parsing_buildflags__android_x86_64
@@ -4423,6 +4680,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:parsing_buildflags__host
@@ -4445,6 +4705,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:power_monitor_buildflags__android_arm
@@ -4465,6 +4728,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:power_monitor_buildflags__android_arm64
@@ -4485,6 +4751,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:power_monitor_buildflags__android_x86
@@ -4505,6 +4774,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:power_monitor_buildflags__android_x86_64
@@ -4525,6 +4797,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:power_monitor_buildflags__host
@@ -4547,6 +4822,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:profiler_buildflags__android_arm
@@ -4567,6 +4845,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:profiler_buildflags__android_arm64
@@ -4587,6 +4868,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:profiler_buildflags__android_x86
@@ -4607,6 +4891,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:profiler_buildflags__android_x86_64
@@ -4627,6 +4914,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:profiler_buildflags__host
@@ -4649,6 +4939,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:sanitizer_buildflags__android_arm
@@ -4669,6 +4962,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:sanitizer_buildflags__android_arm64
@@ -4689,6 +4985,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:sanitizer_buildflags__android_x86
@@ -4709,6 +5008,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:sanitizer_buildflags__android_x86_64
@@ -4729,6 +5031,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:sanitizer_buildflags__host
@@ -4751,6 +5056,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:synchronization_buildflags__android_arm
@@ -4771,6 +5079,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:synchronization_buildflags__android_arm64
@@ -4791,6 +5102,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:synchronization_buildflags__android_x86
@@ -4811,6 +5125,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:synchronization_buildflags__android_x86_64
@@ -4831,6 +5148,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:synchronization_buildflags__host
@@ -4853,6 +5173,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base/third_party/double_conversion:double_conversion
@@ -5163,6 +5486,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:tracing_buildflags__android_arm64
@@ -5183,6 +5509,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:tracing_buildflags__android_x86
@@ -5203,6 +5532,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:tracing_buildflags__android_x86_64
@@ -5223,6 +5555,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //base:tracing_buildflags__host
@@ -5245,6 +5580,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:branding_buildflags__android_arm
@@ -5265,6 +5603,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:branding_buildflags__android_arm64
@@ -5285,6 +5626,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:branding_buildflags__android_x86
@@ -5305,6 +5649,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:branding_buildflags__android_x86_64
@@ -5325,6 +5672,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:branding_buildflags__host
@@ -5347,6 +5697,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:buildflag_header_h
@@ -5441,6 +5794,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:chromecast_buildflags__android_arm64
@@ -5461,6 +5817,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:chromecast_buildflags__android_x86
@@ -5481,6 +5840,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:chromecast_buildflags__android_x86_64
@@ -5501,6 +5863,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:chromecast_buildflags__host
@@ -5523,6 +5888,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:chromeos_buildflags__android_arm
@@ -5543,6 +5911,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:chromeos_buildflags__android_arm64
@@ -5563,6 +5934,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:chromeos_buildflags__android_x86
@@ -5583,6 +5957,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:chromeos_buildflags__android_x86_64
@@ -5603,6 +5980,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build:chromeos_buildflags__host
@@ -5625,6 +6005,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build/config/compiler:compiler_buildflags__android_arm
@@ -5645,6 +6028,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build/config/compiler:compiler_buildflags__android_arm64
@@ -5665,6 +6051,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build/config/compiler:compiler_buildflags__android_x86
@@ -5685,6 +6074,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build/config/compiler:compiler_buildflags__android_x86_64
@@ -5705,6 +6097,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //build/config/compiler:compiler_buildflags__host
@@ -5727,6 +6122,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //buildtools/third_party/libc++:libc++
@@ -6042,6 +6440,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:buildflags__android_arm64
@@ -6062,6 +6463,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:buildflags__android_x86
@@ -6082,6 +6486,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:buildflags__android_x86_64
@@ -6102,6 +6509,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:cronet
@@ -6192,6 +6602,7 @@
     linker_scripts: [
         "base/android/library_loader/anchor_functions.lds",
     ],
+    stem: "libcronet.109.0.5386.0",
     target: {
         android_arm: {
             generated_headers: [
@@ -6310,8 +6721,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/components/cronet/android/cronet_jni_headers " +
          "--includes " +
@@ -6351,6 +6760,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:cronet_jni_headers__android_arm64
@@ -6365,8 +6777,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/components/cronet/android/cronet_jni_headers " +
          "--includes " +
@@ -6406,6 +6816,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:cronet_jni_headers__android_x86
@@ -6420,8 +6833,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/components/cronet/android/cronet_jni_headers " +
          "--includes " +
@@ -6461,6 +6872,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:cronet_jni_headers__android_x86_64
@@ -6475,8 +6889,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/components/cronet/android/cronet_jni_headers " +
          "--includes " +
@@ -6516,6 +6928,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:cronet_jni_registration__android_arm
@@ -6809,8 +7224,6 @@
          "--header-path " +
          "$(genDir)/components/cronet/android/cronet_jni_registration.h " +
          "--manual_jni_registration " +
-         " " +
-         " " +
          ";sed -i -e 's/OUT_SOONG_.TEMP_SBOX_.*_OUT/GEN/g'  " +
          "$(genDir)/components/cronet/android/cronet_jni_registration.h",
     out: [
@@ -6824,6 +7237,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:cronet_jni_registration__android_arm64
@@ -7117,8 +7533,6 @@
          "--header-path " +
          "$(genDir)/components/cronet/android/cronet_jni_registration.h " +
          "--manual_jni_registration " +
-         " " +
-         " " +
          ";sed -i -e 's/OUT_SOONG_.TEMP_SBOX_.*_OUT/GEN/g'  " +
          "$(genDir)/components/cronet/android/cronet_jni_registration.h",
     out: [
@@ -7132,6 +7546,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:cronet_jni_registration__android_x86
@@ -7425,8 +7842,6 @@
          "--header-path " +
          "$(genDir)/components/cronet/android/cronet_jni_registration.h " +
          "--manual_jni_registration " +
-         " " +
-         " " +
          ";sed -i -e 's/OUT_SOONG_.TEMP_SBOX_.*_OUT/GEN/g'  " +
          "$(genDir)/components/cronet/android/cronet_jni_registration.h",
     out: [
@@ -7440,6 +7855,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:cronet_jni_registration__android_x86_64
@@ -7733,8 +8151,6 @@
          "--header-path " +
          "$(genDir)/components/cronet/android/cronet_jni_registration.h " +
          "--manual_jni_registration " +
-         " " +
-         " " +
          ";sed -i -e 's/OUT_SOONG_.TEMP_SBOX_.*_OUT/GEN/g'  " +
          "$(genDir)/components/cronet/android/cronet_jni_registration.h",
     out: [
@@ -7748,6 +8164,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet/android:cronet_static
@@ -7913,6 +8332,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet:cronet_buildflags__android_arm64
@@ -7933,6 +8355,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet:cronet_buildflags__android_x86
@@ -7953,6 +8378,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet:cronet_buildflags__android_x86_64
@@ -7973,6 +8401,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet:cronet_common
@@ -8155,7 +8586,6 @@
          "$(location chrome/VERSION) " +
          "-e " +
          "VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
-         " " +
          "-o " +
          "$(out) " +
          "$(location components/cronet/version.h.in)",
@@ -8169,6 +8599,9 @@
         "chrome/VERSION",
         "components/cronet/version.h.in",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet:cronet_version_header_action__android_arm64
@@ -8178,7 +8611,6 @@
          "$(location chrome/VERSION) " +
          "-e " +
          "VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
-         " " +
          "-o " +
          "$(out) " +
          "$(location components/cronet/version.h.in)",
@@ -8192,6 +8624,9 @@
         "chrome/VERSION",
         "components/cronet/version.h.in",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet:cronet_version_header_action__android_x86
@@ -8201,7 +8636,6 @@
          "$(location chrome/VERSION) " +
          "-e " +
          "VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
-         " " +
          "-o " +
          "$(out) " +
          "$(location components/cronet/version.h.in)",
@@ -8215,6 +8649,9 @@
         "chrome/VERSION",
         "components/cronet/version.h.in",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet:cronet_version_header_action__android_x86_64
@@ -8224,7 +8661,6 @@
          "$(location chrome/VERSION) " +
          "-e " +
          "VERSION_FULL='\"%s.%s.%s.%s\" % (MAJOR,MINOR,BUILD,PATCH)' " +
-         " " +
          "-o " +
          "$(out) " +
          "$(location components/cronet/version.h.in)",
@@ -8238,6 +8674,9 @@
         "chrome/VERSION",
         "components/cronet/version.h.in",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/cronet:metrics_util
@@ -8713,6 +9152,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/prefs/android:jni_headers__android_arm
@@ -8723,8 +9165,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/components/prefs/android/jni_headers " +
          "--includes " +
@@ -8744,6 +9184,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/prefs/android:jni_headers__android_arm64
@@ -8754,8 +9197,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/components/prefs/android/jni_headers " +
          "--includes " +
@@ -8775,6 +9216,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/prefs/android:jni_headers__android_x86
@@ -8785,8 +9229,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/components/prefs/android/jni_headers " +
          "--includes " +
@@ -8806,6 +9248,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/prefs/android:jni_headers__android_x86_64
@@ -8816,8 +9261,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/components/prefs/android/jni_headers " +
          "--includes " +
@@ -8837,6 +9280,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //components/prefs:prefs
@@ -8995,6 +9441,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //crypto:buildflags__android_arm64
@@ -9015,6 +9464,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //crypto:buildflags__android_x86
@@ -9035,6 +9487,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //crypto:buildflags__android_x86_64
@@ -9055,6 +9510,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //crypto:buildflags__host
@@ -9077,6 +9535,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //crypto:crypto
@@ -9263,6 +9724,10 @@
         "-fvisibility=hidden",
     ],
     stl: "none",
+    apex_available: [
+        "com.android.tethering",
+    ],
+    min_sdk_version: "29",
     target: {
         android: {
             header_libs: [
@@ -9652,6 +10117,9 @@
         "net/base/registry_controlled_domains/effective_tld_names_unittest6.gperf",
         "net/tools/dafsa/make_dafsa.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net/base/registry_controlled_domains:registry_controlled_domains__android_arm64
@@ -9703,6 +10171,9 @@
         "net/base/registry_controlled_domains/effective_tld_names_unittest6.gperf",
         "net/tools/dafsa/make_dafsa.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net/base/registry_controlled_domains:registry_controlled_domains__android_x86
@@ -9754,6 +10225,9 @@
         "net/base/registry_controlled_domains/effective_tld_names_unittest6.gperf",
         "net/tools/dafsa/make_dafsa.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net/base/registry_controlled_domains:registry_controlled_domains__android_x86_64
@@ -9805,6 +10279,9 @@
         "net/base/registry_controlled_domains/effective_tld_names_unittest6.gperf",
         "net/tools/dafsa/make_dafsa.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:buildflags__android_arm
@@ -9825,6 +10302,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:buildflags__android_arm64
@@ -9845,6 +10325,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:buildflags__android_x86
@@ -9865,6 +10348,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:buildflags__android_x86_64
@@ -9885,6 +10371,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:constants
@@ -9970,6 +10459,9 @@
         "net/data/ssl/chrome_root_store/root_store.certs",
         "net/data/ssl/chrome_root_store/root_store.textproto",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net/data/ssl/chrome_root_store:gen_root_store_inc__android_arm64
@@ -9993,6 +10485,9 @@
         "net/data/ssl/chrome_root_store/root_store.certs",
         "net/data/ssl/chrome_root_store/root_store.textproto",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net/data/ssl/chrome_root_store:gen_root_store_inc__android_x86
@@ -10016,6 +10511,9 @@
         "net/data/ssl/chrome_root_store/root_store.certs",
         "net/data/ssl/chrome_root_store/root_store.textproto",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net/data/ssl/chrome_root_store:gen_root_store_inc__android_x86_64
@@ -10039,6 +10537,9 @@
         "net/data/ssl/chrome_root_store/root_store.certs",
         "net/data/ssl/chrome_root_store/root_store.textproto",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net/dns:dns
@@ -11011,6 +11512,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:ios_cronet_buildflags__android_arm64
@@ -11031,6 +11535,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:ios_cronet_buildflags__android_x86
@@ -11051,6 +11558,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:ios_cronet_buildflags__android_x86_64
@@ -11071,6 +11581,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:isolation_info_proto
@@ -11086,6 +11599,9 @@
     out: [
         "external/chromium_org/net/base/isolation_info.pb.cc",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:isolation_info_proto
@@ -11106,6 +11622,9 @@
         "net/base",
         "protos",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:net
@@ -11982,8 +12501,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/net/net_jni_headers " +
          "--includes " +
@@ -12063,6 +12580,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:net_jni_headers__android_arm64
@@ -12085,8 +12605,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/net/net_jni_headers " +
          "--includes " +
@@ -12166,6 +12684,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:net_jni_headers__android_x86
@@ -12188,8 +12709,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/net/net_jni_headers " +
          "--includes " +
@@ -12269,6 +12788,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:net_jni_headers__android_x86_64
@@ -12291,8 +12813,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/net/net_jni_headers " +
          "--includes " +
@@ -12372,6 +12892,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:net_nqe_proto
@@ -12387,6 +12910,9 @@
     out: [
         "external/chromium_org/net/nqe/proto/network_id_proto.pb.cc",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:net_nqe_proto
@@ -12407,6 +12933,9 @@
         "net/nqe/proto",
         "protos",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net:net_public_deps
@@ -12596,6 +13125,9 @@
         "external/chromium_org/net/third_party/quiche/src/quiche/quic/core/proto/crypto_server_config.pb.cc",
         "external/chromium_org/net/third_party/quiche/src/quiche/quic/core/proto/source_address_token.pb.cc",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net/third_party/quiche:net_quic_proto
@@ -12620,6 +13152,9 @@
         "net/third_party/quiche/src",
         "protos",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net/third_party/quiche:net_quic_test_tools_proto
@@ -12635,6 +13170,9 @@
     out: [
         "external/chromium_org/net/third_party/quiche/src/quiche/quic/test_tools/send_algorithm_test_result.pb.cc",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net/third_party/quiche:net_quic_test_tools_proto
@@ -12655,6 +13193,9 @@
         "net/third_party/quiche/src/quiche/quic/test_tools",
         "protos",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //net/third_party/quiche:quiche
@@ -23510,6 +24051,9 @@
         "external/chromium_org/third_party/metrics_proto/user_action_event.pb.cc",
         "external/chromium_org/third_party/metrics_proto/user_demographics.pb.cc",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //third_party/metrics_proto:metrics_proto
@@ -23582,6 +24126,9 @@
         "protos",
         "third_party/metrics_proto",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //third_party/modp_b64:modp_b64
@@ -24673,6 +25220,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //url:buildflags__android_arm64
@@ -24693,6 +25243,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //url:buildflags__android_x86
@@ -24713,6 +25266,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //url:buildflags__android_x86_64
@@ -24733,6 +25289,9 @@
     tool_files: [
         "build/write_buildflag_header.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //url:url
@@ -24891,8 +25450,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/url/url_jni_headers " +
          "--includes " +
@@ -24917,6 +25474,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //url:url_jni_headers__android_arm64
@@ -24928,8 +25488,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/url/url_jni_headers " +
          "--includes " +
@@ -24954,6 +25512,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //url:url_jni_headers__android_x86
@@ -24965,8 +25526,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/url/url_jni_headers " +
          "--includes " +
@@ -24991,6 +25550,9 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
 // GN: //url:url_jni_headers__android_x86_64
@@ -25002,8 +25564,6 @@
     ],
     cmd: "$(location base/android/jni_generator/jni_generator.py) --ptr_type " +
          "long " +
-         " " +
-         " " +
          "--output_dir " +
          "$(genDir)/url/url_jni_headers " +
          "--includes " +
@@ -25028,5 +25588,8 @@
         "build/android/gyp/util/build_utils.py",
         "build/gn_helpers.py",
     ],
+    apex_available: [
+        "com.android.tethering",
+    ],
 }
 
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 466eaf4..fe2e924 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -29,6 +29,7 @@
 import collections
 import json
 import logging as log
+import operator
 import os
 import re
 import sys
@@ -142,6 +143,9 @@
         lambda x: None,
 }
 
+# Name of tethering apex module
+tethering_apex = "com.android.tethering"
+
 # ----------------------------------------------------------------------------
 # End of configuration.
 # ----------------------------------------------------------------------------
@@ -305,6 +309,8 @@
     self.stubs = {}
     self.cppflags = set()
     self.rtti = False
+    # Name of the output. Used for setting .so file name for libcronet
+    self.stem = None
 
   def to_string(self, output):
     if self.comment:
@@ -351,6 +357,7 @@
     self._output_field(output, 'proto')
     self._output_field(output, 'linker_scripts')
     self._output_field(output, 'cppflags')
+    self._output_field(output, 'stem')
     if self.rtti:
       self._output_field(output, 'rtti')
 
@@ -546,6 +553,9 @@
   # without explictily exporting the include dir.
   header_module.export_include_dirs.add(target.proto_in_dir)
 
+  # This function does not return header_module so setting apex_available attribute here.
+  header_module.apex_available.add(tethering_apex)
+
   source_module.genrule_srcs.add(':' + source_module.name)
   source_module.genrule_headers.add(header_module.name)
 
@@ -608,6 +618,190 @@
 
   blueprint.add_module(module)
 
+
+class BaseActionSanitizer():
+  def __init__(self, target):
+    # Just to be on the safe side, create a deep-copy.
+    self.target = copy.deepcopy(target)
+    # Convert ['--param=value'] to ['--param', 'value'] for consistency.
+    self.target.args = [str for it in self.target.args for str in it.split('=')]
+
+  # There are three types of args:
+  # - flags (--flag)
+  # - value args (--arg value)
+  # - list args (--arg value1 --arg value2)
+  # Note that the set of list args contains the set of value args.
+  # value args must have exactly one arg value pair but list args could have one arg value pair.
+  # This is because list args with one arg value pair and value args can not be distinguished only
+  # from the desc.json
+  # Some functions provide special implementations for each type, while others
+  # work on all of them.
+  def _has_arg(self, arg):
+    return arg in self.target.args
+
+  def _get_arg_indices(self, target_arg):
+    return [i for i, arg in enumerate(self.target.args) if arg == target_arg]
+
+  # Whether an arg value pair appears once or more times
+  def _is_list_arg(self, arg):
+    indices = self._get_arg_indices(arg)
+    return len(indices) > 0 and all([not self.target.args[i + 1].startswith('--') for i in indices])
+
+  def _update_list_arg(self, arg, func, throw_if_absent = True):
+    if self._should_fail_silently(arg, throw_if_absent):
+      return
+    assert(self._is_list_arg(arg))
+    indices = self._get_arg_indices(arg)
+    for i in indices:
+      self._set_arg_at(i + 1, func(self.target.args[i + 1]))
+
+  # Whether an arg value pair appears exactly once
+  def _is_value_arg(self, arg):
+    if operator.countOf(self.target.args, arg) != 1:
+      return False
+    i = self.target.args.index(arg)
+    return not self.target.args[i + 1].startswith('--')
+
+  def _get_value_arg(self, arg):
+    assert(self._is_value_arg(arg))
+    i = self.target.args.index(arg)
+    return self.target.args[i + 1]
+
+  # used to check whether a function call should cause an error when an arg is
+  # missing.
+  def _should_fail_silently(self, arg, throw_if_absent):
+    return not throw_if_absent and not self._has_arg(arg)
+
+  def _set_value_arg(self, arg, value, throw_if_absent = True):
+    if self._should_fail_silently(arg, throw_if_absent):
+      return
+    assert(self._is_value_arg(arg))
+    i = self.target.args.index(arg)
+    self.target.args[i + 1] = value
+
+  def _update_value_arg(self, arg, func, throw_if_absent = True):
+    if self._should_fail_silently(arg, throw_if_absent):
+      return
+    self._set_value_arg(arg, func(self._get_value_arg(arg)))
+
+  def _set_arg_at(self, position, value):
+    self.target.args[position] = value
+
+  def _delete_value_arg(self, arg, throw_if_absent = True):
+    if self._should_fail_silently(arg, throw_if_absent):
+      return
+    assert(self._is_value_arg(arg))
+    i = self.target.args.index(arg)
+    self.target.args.pop(i)
+    self.target.args.pop(i)
+
+  def _append_arg(self, arg, value):
+    self.target.args.append(arg)
+    self.target.args.append(value)
+
+  # wrap filename in location tag.
+  def _add_location_tag(self, filename):
+    return '$(location %s)' % filename
+
+  # applies common directory transformation that *should* be universally applicable.
+  # TODO: verify if it actually *is* universally applicable.
+  def _sanitize_filepath(self, filepath):
+    # Careful, order matters!
+    # delete all leading ../
+    filepath = re.sub('^(\.\./)+', '', filepath)
+    filepath = re.sub('^gen/jni_headers', '$(genDir)', filepath)
+    filepath = re.sub('^gen', '$(genDir)', filepath)
+    return filepath
+
+  # Iterate through all the args and apply function
+  def _update_all_args(self, func):
+    self.target.args = [func(arg) for arg in self.target.args]
+
+  def get_args(self):
+    return self.target.args
+
+class WriteBuildDateHeaderSanitizer(BaseActionSanitizer):
+  def get_args(self):
+    self._set_arg_at(0, '$(out)')
+    return super().get_args()
+
+class WriteBuildFlagHeaderSanitizer(BaseActionSanitizer):
+  def get_args(self):
+    self._set_value_arg('--gen-dir', '.')
+    self._set_value_arg('--output', '$(out)')
+    return super().get_args()
+
+class JniGeneratorSanitizer(BaseActionSanitizer):
+  def _add_location_tag_to_filepath(self, arg):
+    if not arg.endswith('.class'):
+      # --input_file supports both .class specifiers or source files as arguments.
+      # Only source files need to be wrapped inside a $(location <label>) tag.
+      arg = self._add_location_tag(arg)
+    return arg
+
+  def get_args(self):
+    self._update_value_arg('--jar_file', self._sanitize_filepath, False)
+    self._update_value_arg('--jar_file', self._add_location_tag, False)
+    if self._has_arg('--jar_file'):
+      self._append_arg('--javap', '$$(find out/.path -name javap)')
+    self._update_value_arg('--output_dir', self._sanitize_filepath)
+    self._update_value_arg('--includes', self._sanitize_filepath, False)
+    self._delete_value_arg('--prev_output_dir', False)
+    self._update_list_arg('--input_file', self._sanitize_filepath)
+    self._update_list_arg('--input_file', self._add_location_tag_to_filepath)
+    return super().get_args()
+
+class JniRegistrationGeneratorSanitizer(BaseActionSanitizer):
+  def get_args(self):
+    self._update_value_arg('--depfile', self._sanitize_filepath)
+    self._update_value_arg('--srcjar-path', self._sanitize_filepath)
+    self._update_value_arg('--header-path', self._sanitize_filepath)
+    self._set_value_arg('--sources-files', '$(genDir)/java.sources')
+    # update_jni_registration_module removes them from the srcs of the module
+    # It might be better to remove sources by '--sources-exclusions'
+    self._delete_value_arg('--sources-exclusions')
+    return super().get_args()
+
+class VersionSanitizer(BaseActionSanitizer):
+  def _sanitize_version_filepath(self, arg):
+    if arg.startswith('../../'):
+      arg = self._sanitize_filepath(arg)
+      arg = self._add_location_tag(arg)
+    return arg
+
+  def _sanitize_eval(self):
+    assert (self._is_value_arg('-e'))
+    # arg for -e EVAL option should be passed in -e PATCH_HI=int(PATCH)//256 format.
+    index = self.target.args.index('-e')
+    value = '%s=\'%s\'' % (self.target.args[index + 1], self.target.args[index + 2])
+    # escape '"' in the value
+    value = value.replace('"', r'\"')
+    self._set_arg_at(index + 1, value)
+    self.target.args.pop(index + 2)
+
+  def get_args(self):
+    self._set_value_arg('-o', '$(out)')
+    # args for the version.py contain file path without leading --arg key. So apply sanitize
+    # function for all the args.
+    self._update_all_args(self._sanitize_version_filepath)
+    self._sanitize_eval()
+    return super().get_args()
+
+def get_action_sanitizer(target):
+  if target.script == "//build/write_buildflag_header.py":
+    return WriteBuildFlagHeaderSanitizer(target)
+  elif target.script == "//build/write_build_date_header.py":
+    return WriteBuildDateHeaderSanitizer(target)
+  elif target.script == '//base/android/jni_generator/jni_generator.py':
+    return JniGeneratorSanitizer(target)
+  elif target.script == '//base/android/jni_generator/jni_registration_generator.py':
+    return JniRegistrationGeneratorSanitizer(target)
+  elif target.script == "//build/util/version.py":
+    return VersionSanitizer(target)
+  else:
+    # TODO: throw exception here once all script hacks have been converted.
+    return BaseActionSanitizer(target)
+
 def create_action_foreach_modules(blueprint, target):
   """ The following assumes that rebase_path exists in the args.
   The args of an action_foreach contains hints about which output files are generated
@@ -645,57 +839,17 @@
   bp_module_name = label_to_module_name(target.name)
   module = Module('cc_genrule', bp_module_name, target.name)
 
-  # Convert ['--param=value'] to ['--param', 'value'] for consistency.
-  # TODO: we may want to only do this for python scripts arguments. If argparse
-  # is used, this transformation is safe.
-  target.args = [str for it in target.args for str in it.split('=')]
+  sanitizer = get_action_sanitizer(target)
+  target.args = sanitizer.get_args()
 
-  if target.script == "//build/write_buildflag_header.py":
-    # write_buildflag_header.py writes result to args.genDir/args.output
-    # So, override args.genDir by '.' so that args.output=$(out) works
-    for i, val in enumerate(target.args):
-      if val == '--gen-dir':
-        target.args[i + 1] = '.'
-      elif val == '--output':
-        target.args[i + 1] = '$(out)'
-
-  elif target.script == '//build/write_build_date_header.py':
-    target.args[0] = '$(out)'
-
-  elif target.script == '//base/android/jni_generator/jni_generator.py':
-    needs_javap = False
-    for i, val in enumerate(target.args):
-      if val == '--output_dir':
-        # replace --output_dir gen/jni_headers/... with --output_dir $(genDir)/...
-        target.args[i + 1] = re.sub('^gen/jni_headers', '$(genDir)', target.args[i + 1])
-      elif val == '--input_file':
-        # --input_file supports both .class specifiers or source files as arguments.
-        # Only source files need to be wrapped inside a $(location <label>) tag.
-        if re.match('.*\.class$', target.args[i + 1]):
-          continue
-        # replace --input_file ../../... with --input_file $(location ...)
-        # TODO: put inside function
-        filename = re.sub('^\.\./\.\./', '', target.args[i + 1])
-        target.args[i + 1] = '$(location %s)' % filename
-      elif val == '--includes' and 'jni_generator_helper' in target.args[i + 1]:
-        # delete all leading ../
-        target.args[i + 1] = re.sub('^(\.\./)+', '', target.args[i + 1])
-      elif val == '--prev_output_dir':
-        # this is not needed for aosp builds.
-        target.args[i] = ''
-        target.args[i + 1] = ''
-      elif val == '--jar_file':
-        # delete leading ../../ and add path to javap
-        filename = re.sub('^\.\./\.\./', '', target.args[i + 1])
-        target.args[i + 1] = '$(location %s)' % filename
-        needs_javap = True
-
-    if needs_javap:
-      target.args.append('--javap')
-      target.args.append('$$(find out/.path -name javap)')
+  if target.script == '//base/android/jni_generator/jni_generator.py':
     # fix target.output directory to match #include statements.
     target.outputs = [re.sub('^jni_headers/', '', out) for out in target.outputs]
 
+    # android_jar.classes should be part of the tools as it list implicit classes
+    # for the script to generate JNI headers.
+    module.tool_files.add("base/android/jni_generator/android_jar.classes")
+
   elif target.script == '//base/android/jni_generator/jni_registration_generator.py':
     # jni_registration_generator.py pulls in some config dependencies that we
     # do not handle. Remove them.
@@ -703,16 +857,6 @@
     target.deps.clear()
 
     target.inputs = [file for file in target.inputs if not file.startswith('//out/')]
-    for i, val in enumerate(target.args):
-      if val in ['--depfile', '--srcjar-path', '--header-path']:
-        target.args[i + 1] = re.sub('^gen', '$(genDir)', target.args[i + 1])
-      if val == '--sources-files':
-        target.args[i + 1] = '$(genDir)/java.sources'
-      elif val == '--sources-exclusions':
-        # update_jni_registration_module removes them from the srcs of the module
-        # It might be better to remove sources by '--sources-exclusions'
-        target.args[i] = ''
-        target.args[i + 1] = ''
   elif target.script == "//net/tools/dafsa/make_dafsa.py":
     # This script generates .cc files but source (registry_controlled_domain.cc) in the target that
     # depends on this target includes .cc file this script generates.
@@ -720,16 +864,6 @@
   elif target.script == "//build/util/version.py":
     # android_chrome_version.py is not specified in anywhere but version.py imports this file
     module.tool_files.add('build/util/android_chrome_version.py')
-    for i, val in enumerate(target.args):
-      if val.startswith('../../'):
-        filename = re.sub('^\.\./\.\./', '', val)
-        target.args[i] = '$(location %s)' % filename
-      elif val == '-e':
-        # arg for -e EVAL option should be passed in -e PATCH_HI=int(PATCH)//256 format.
-        target.args[i + 1] = '%s=\'%s\'' % (target.args[i + 1], target.args[i + 2])
-        target.args[i + 2] = ''
-      elif val == '-o':
-        target.args[i + 1] = '$(out)'
 
   script = gn_utils.label_to_path(target.script)
   module.tool_files.add(script)
@@ -742,12 +876,6 @@
     # Replace {{response_file_contents}} with /dev/stdin
     target.args = ['/dev/stdin' if it == response_file else it for it in target.args]
 
-  # escape " and \$ in target.args.
-  # once all actions are properly implemented, this may not be necessary anymore.
-  # TODO: is this the right place to do this?
-  target.args = [arg.replace('"', r'\"') for arg in target.args]
-  target.args = [arg.replace(r'\$', r'\\$') for arg in target.args]
-
   # put all args on a new line for better diffs.
   NEWLINE = ' " +\n         "'
   arg_string = NEWLINE.join(target.args)
@@ -776,11 +904,7 @@
 
   module.out.update(target.outputs)
 
-  if target.script == "//base/android/jni_generator/jni_generator.py":
-    # android_jar.classes should be part of the tools as it list implicit classes
-    # for the script to generate JNI headers.
-    module.tool_files.add("base/android/jni_generator/android_jar.classes")
-  elif target.script == '//base/android/jni_generator/jni_registration_generator.py':
+  if target.script == '//base/android/jni_generator/jni_registration_generator.py':
     # jni_registration_generator.py doesn't work with python2
     module.cmd = "python3 " + module.cmd
     # Path in the original sources file does not work in genrule.
@@ -931,6 +1055,9 @@
   module.host_supported = target.host_supported()
   module.device_supported = target.device_supported()
 
+  if module.is_genrule():
+    module.apex_available.add(tethering_apex)
+
   if module.is_compiled():
     # Don't try to inject library/source dependencies into genrules or
     # filegroups because they are not compiled in the traditional sense.
@@ -954,6 +1081,13 @@
   if module.type == 'cc_library_static':
     module.export_generated_headers = module.generated_headers
 
+  if module.name == 'cronet_aml_components_cronet_android_cronet':
+    if target.output_name is None:
+      raise Error('Failed to get output_name for libcronet name')
+    # .so file name needs to match with CronetLibraryLoader.java (e.g. libcronet.109.0.5386.0.so)
+    # So setting the output name based on the output_name from the desc.json
+    module.stem = 'lib' + target.output_name
+
   # dep_name is an unmangled GN target name (e.g. //foo:bar(toolchain)).
   # Currently, only one module is generated from target even target has multiple toolchains.
   # And module is generated based on the first visited target.
@@ -1104,6 +1238,8 @@
       '-UANDROID',
   ]
   defaults.stl = 'none'
+  defaults.min_sdk_version = 29
+  defaults.apex_available.add(tethering_apex)
   blueprint.add_module(defaults)
 
   for target in targets:
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index 71d0d23..80c90f6 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -155,6 +155,9 @@
       self.is_finalized = False
       self.arch = dict()
 
+      # This is used to get the name/version of libcronet
+      self.output_name = None
+
     def host_supported(self):
       return 'host' in self.arch
 
@@ -347,6 +350,7 @@
     target.ldflags.update(desc.get('ldflags', []))
     target.arch[arch].defines.update(desc.get('defines', []))
     target.arch[arch].include_dirs.update(desc.get('include_dirs', []))
+    target.output_name = desc.get('output_name', None)
     if "-frtti" in target.arch[arch].cflags:
       target.rtti = True