Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56f70781 authored by Roshan Pius's avatar Roshan Pius
Browse files

WifiStackClient: Register wifi API services from system_server

a) Expose AIDL methods in IWifiStackConnector to retrieve the various
wifi API service implementation from the WifiStack.apk.
b) WifiStackClient running on system_server will register the various
wifi services & trigger the initialization sequence of the various wifi
services.

Regardless of whether the wifi stack runs in system_server or
network_stack process, this ensures that binder service publish always
happens in system_server. This allows us to maintain a default set of
sepolicy rules regardless of which version of the APK is running
(mainline or non-mainline).

Bug: 135753701
Change-Id: I2c1c40d14d6ec822694d6a3250b81694ab6b2a81
Merged-In: I2c1c40d14d6ec822694d6a3250b81694ab6b2a81
Test: Verified that device boots up & connects to wifi networks with
both WifiStack.apk & InProcessWifiStack.apk.
Test: Will send for regression tests
parent 6f5338dd
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -16,5 +16,7 @@
package android.net.wifi;
package android.net.wifi;


/** @hide */
/** @hide */
oneway interface IWifiStackConnector {
interface IWifiStackConnector {
     IBinder retrieveApiServiceImpl(String serviceName);
     boolean startApiService(String serviceName);
}
}
+34 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.NonNull;
import android.content.Context;
import android.content.Context;
import android.net.ConnectivityModuleConnector;
import android.net.ConnectivityModuleConnector;
import android.os.IBinder;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.util.Log;
import android.util.Log;


@@ -54,7 +55,14 @@ public class WifiStackClient {
        @Override
        @Override
        public void onModuleServiceConnected(IBinder service) {
        public void onModuleServiceConnected(IBinder service) {
            Log.i(TAG, "Wifi stack connected");
            Log.i(TAG, "Wifi stack connected");

            registerWifiStackService(service);
            registerWifiStackService(service);
            IWifiStackConnector connector = IWifiStackConnector.Stub.asInterface(service);
            registerApiServiceAndStart(connector, Context.WIFI_SERVICE);
            registerApiServiceAndStart(connector, Context.WIFI_SCANNING_SERVICE);
            registerApiServiceAndStart(connector, Context.WIFI_P2P_SERVICE);
            registerApiServiceAndStart(connector, Context.WIFI_AWARE_SERVICE);
            registerApiServiceAndStart(connector, Context.WIFI_RTT_RANGING_SERVICE);
        }
        }
    }
    }


@@ -65,6 +73,32 @@ public class WifiStackClient {
        Log.i(TAG, "Wifi stack service registered");
        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.
     * Start the wifi stack. Should be called only once on device startup.
     *
     *