Loading services/wifi/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,9 @@ java_library_static { "java/**/*.java", "java/**/*.aidl", ], aidl: { local_include_dirs: ["java"] }, libs: [ "services.net", ], Loading services/wifi/java/android/net/wifi/IWifiStackConnector.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -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(); } services/wifi/java/android/net/wifi/WifiApiServiceInfo.aidl 0 → 100644 +23 −0 Original line number Diff line number Diff line /* * 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; } services/wifi/java/android/net/wifi/WifiStackClient.java +17 −40 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -56,21 +57,23 @@ public class WifiStackClient { @Override public void onModuleServiceConnected(IBinder service) { Log.i(TAG, "Wifi stack connected"); // 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); thread.quitSafely(); }); List<WifiApiServiceInfo> wifiApiServiceInfos; try { wifiApiServiceInfos = connector.getWifiApiServiceInfos(); } catch (RemoteException e) { throw new RuntimeException("Failed to getWifiApiServiceInfos()", e); } for (WifiApiServiceInfo wifiApiServiceInfo : wifiApiServiceInfos) { String serviceName = wifiApiServiceInfo.name; IBinder binder = wifiApiServiceInfo.binder; Log.i(TAG, "Registering " + serviceName); ServiceManager.addService(serviceName, binder); } } } Loading @@ -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. * Loading Loading
services/wifi/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,9 @@ java_library_static { "java/**/*.java", "java/**/*.aidl", ], aidl: { local_include_dirs: ["java"] }, libs: [ "services.net", ], Loading
services/wifi/java/android/net/wifi/IWifiStackConnector.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -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(); }
services/wifi/java/android/net/wifi/WifiApiServiceInfo.aidl 0 → 100644 +23 −0 Original line number Diff line number Diff line /* * 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; }
services/wifi/java/android/net/wifi/WifiStackClient.java +17 −40 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -56,21 +57,23 @@ public class WifiStackClient { @Override public void onModuleServiceConnected(IBinder service) { Log.i(TAG, "Wifi stack connected"); // 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); thread.quitSafely(); }); List<WifiApiServiceInfo> wifiApiServiceInfos; try { wifiApiServiceInfos = connector.getWifiApiServiceInfos(); } catch (RemoteException e) { throw new RuntimeException("Failed to getWifiApiServiceInfos()", e); } for (WifiApiServiceInfo wifiApiServiceInfo : wifiApiServiceInfos) { String serviceName = wifiApiServiceInfo.name; IBinder binder = wifiApiServiceInfo.binder; Log.i(TAG, "Registering " + serviceName); ServiceManager.addService(serviceName, binder); } } } Loading @@ -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. * Loading