OSDN Git Service

Initialize the NetworkStack before WiFi
authorRemi NGUYEN VAN <reminv@google.com>
Thu, 14 Mar 2019 23:21:27 +0000 (08:21 +0900)
committerRemi NGUYEN VAN <reminv@google.com>
Thu, 14 Mar 2019 23:24:07 +0000 (08:24 +0900)
The NetworkStack needs to be marked as start requested before any client
can use it from the system server, so it knows to queue requests until
it actually comes up.

This fixes a bug introduced in commit:
I93315ad31925bd436e21d1eabb21d5967e6aae60
where a client trying to use the network stack in the system server
before ActivityManager.systemReady() could block and eventually timeout,
resulting in a null INetworkStackConnector.

Test: booted, WiFi working
Bug: 128620654

Change-Id: Ieca2657373eba78195b387fb266fa0424fce8ada

services/java/com/android/server/SystemServer.java
services/net/java/android/net/NetworkStackClient.java

index d33d7f5..4125b92 100644 (file)
@@ -1118,6 +1118,14 @@ public final class SystemServer {
             mSystemServiceManager.startService(ClipboardService.class);
             traceEnd();
 
+            traceBeginAndSlog("InitNetworkStackClient");
+            try {
+                NetworkStackClient.getInstance().init();
+            } catch (Throwable e) {
+                reportWtf("initializing NetworkStackClient", e);
+            }
+            traceEnd();
+
             traceBeginAndSlog("StartNetworkManagementService");
             try {
                 networkManagement = NetworkManagementService.create(context);
index a8f4a77..fe447fc 100644 (file)
@@ -165,6 +165,15 @@ public class NetworkStackClient {
     }
 
     /**
+     * Initialize the network stack. Should be called only once on device startup, before any
+     * client attempts to use the network stack.
+     */
+    public void init() {
+        log("Network stack init");
+        mNetworkStackStartRequested = true;
+    }
+
+    /**
      * Start the network stack. Should be called only once on device startup.
      *
      * <p>This method will start the network stack either in the network stack process, or inside
@@ -174,8 +183,6 @@ public class NetworkStackClient {
      */
     public void start(Context context) {
         log("Starting network stack");
-        mNetworkStackStartRequested = true;
-
         final PackageManager pm = context.getPackageManager();
 
         // Try to bind in-process if the device was shipped with an in-process version