summaryrefslogtreecommitdiff
path: root/services/wifi/java
diff options
context:
space:
mode:
authorDavid Su <dysu@google.com>2019-09-20 15:34:14 -0700
committerDavid Su <dysu@google.com>2019-09-23 17:39:42 +0000
commitcbde8ce73fa8bdaa59b428f67760b1e2137e1f1c (patch)
tree392660cc68167d509f4252e34e5a0cfb66a011c4 /services/wifi/java
parent8e3fc9daba006b5d378a76ad369043eb682d1eae (diff)
Start Wifi only after boot completes
Listen to boot complete in WifiStackService and perform expensive initialization tasks afterwards. WifiStackClient no longer drives the initialization order of services. Instead it receives a list of services and only registers them with ServiceManager. Bug: 141003116 Test: atest FrameworksWifiTests Test: device boots Test: atest google/perf/boottime/boottime-test -v Change-Id: If1f2a409f6dc72469b95d4fb491e408ae81b3a74
Diffstat (limited to 'services/wifi/java')
-rw-r--r--services/wifi/java/android/net/wifi/IWifiStackConnector.aidl5
-rw-r--r--services/wifi/java/android/net/wifi/WifiApiServiceInfo.aidl23
-rw-r--r--services/wifi/java/android/net/wifi/WifiStackClient.java57
3 files changed, 43 insertions, 42 deletions
diff --git a/services/wifi/java/android/net/wifi/IWifiStackConnector.aidl b/services/wifi/java/android/net/wifi/IWifiStackConnector.aidl
index eadc7260e81b..3af4666b8d9c 100644
--- a/services/wifi/java/android/net/wifi/IWifiStackConnector.aidl
+++ b/services/wifi/java/android/net/wifi/IWifiStackConnector.aidl
@@ -15,8 +15,9 @@
*/
package android.net.wifi;
+import android.net.wifi.WifiApiServiceInfo;
+
/** @hide */
interface IWifiStackConnector {
- IBinder retrieveApiServiceImpl(String serviceName);
- boolean startApiService(String serviceName);
+ List<WifiApiServiceInfo> getWifiApiServiceInfos();
}
diff --git a/services/wifi/java/android/net/wifi/WifiApiServiceInfo.aidl b/services/wifi/java/android/net/wifi/WifiApiServiceInfo.aidl
new file mode 100644
index 000000000000..45e4c69102f0
--- /dev/null
+++ b/services/wifi/java/android/net/wifi/WifiApiServiceInfo.aidl
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2019 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 android.net.wifi;
+
+/** @hide */
+parcelable WifiApiServiceInfo {
+ String name;
+ IBinder binder;
+}
diff --git a/services/wifi/java/android/net/wifi/WifiStackClient.java b/services/wifi/java/android/net/wifi/WifiStackClient.java
index 64af7a8845a7..dcdfbc54687c 100644
--- a/services/wifi/java/android/net/wifi/WifiStackClient.java
+++ b/services/wifi/java/android/net/wifi/WifiStackClient.java
@@ -21,12 +21,13 @@ import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL;
import android.annotation.NonNull;
import android.content.Context;
import android.net.ConnectivityModuleConnector;
-import android.os.HandlerThread;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
+import java.util.List;
+
/**
* Service used to communicate with the wifi stack, which could be running in a separate
* module.
@@ -56,21 +57,23 @@ public class WifiStackClient {
@Override
public void onModuleServiceConnected(IBinder service) {
Log.i(TAG, "Wifi stack connected");
+ registerWifiStackService(service);
+
+ IWifiStackConnector connector = IWifiStackConnector.Stub.asInterface(service);
- // spin up a new thread to not block system_server main thread
- HandlerThread thread = new HandlerThread("InitWifiServicesThread");
- thread.start();
- thread.getThreadHandler().post(() -> {
- registerWifiStackService(service);
- IWifiStackConnector connector = IWifiStackConnector.Stub.asInterface(service);
- registerApiServiceAndStart(connector, Context.WIFI_SCANNING_SERVICE);
- registerApiServiceAndStart(connector, Context.WIFI_SERVICE);
- registerApiServiceAndStart(connector, Context.WIFI_P2P_SERVICE);
- registerApiServiceAndStart(connector, Context.WIFI_AWARE_SERVICE);
- registerApiServiceAndStart(connector, Context.WIFI_RTT_RANGING_SERVICE);
+ List<WifiApiServiceInfo> wifiApiServiceInfos;
+ try {
+ wifiApiServiceInfos = connector.getWifiApiServiceInfos();
+ } catch (RemoteException e) {
+ throw new RuntimeException("Failed to getWifiApiServiceInfos()", e);
+ }
- thread.quitSafely();
- });
+ for (WifiApiServiceInfo wifiApiServiceInfo : wifiApiServiceInfos) {
+ String serviceName = wifiApiServiceInfo.name;
+ IBinder binder = wifiApiServiceInfo.binder;
+ Log.i(TAG, "Registering " + serviceName);
+ ServiceManager.addService(serviceName, binder);
+ }
}
}
@@ -81,32 +84,6 @@ public class WifiStackClient {
Log.i(TAG, "Wifi stack service registered");
}
- private void registerApiServiceAndStart(
- IWifiStackConnector stackConnector, String serviceName) {
- IBinder service = null;
- try {
- service = stackConnector.retrieveApiServiceImpl(serviceName);
- } catch (RemoteException e) {
- throw new RuntimeException("Failed to retrieve service impl " + serviceName, e);
- }
- if (service == null) {
- Log.i(TAG, "Service " + serviceName + " not available");
- return;
- }
- Log.i(TAG, "Registering " + serviceName);
- ServiceManager.addService(serviceName, service);
-
- boolean success = false;
- try {
- success = stackConnector.startApiService(serviceName);
- } catch (RemoteException e) {
- throw new RuntimeException("Failed to start service " + serviceName, e);
- }
- if (!success) {
- throw new RuntimeException("Service " + serviceName + " start failed");
- }
- }
-
/**
* Start the wifi stack. Should be called only once on device startup.
*