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

Commit a4f8e739 authored by Vishal Mahaveer's avatar Vishal Mahaveer Committed by Steve Kondik
Browse files

framework - HotSpot/softAP changes for enabling UI

Framework changes for supporting HotSpot UI with OMAP_ENHANCEMENT flag

Change-Id: I653739c4801165e908a479143df8c7e2a50b2e34
parent 80ee87b9
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -108,6 +108,18 @@ static jboolean android_net_wifi_unloadDriver(JNIEnv* env, jobject clazz)
    return (jboolean)(::wifi_unload_driver() == 0);
}

#ifdef OMAP_ENHANCEMENT
static jboolean android_net_hotspot_loadDriver(JNIEnv* env, jobject clazz)
{
    return (jboolean)(::hotspot_load_driver() == 0);
}

static jboolean android_net_hotspot_unloadDriver(JNIEnv* env, jobject clazz)
{
    return (jboolean)(::hotspot_unload_driver() == 0);
}
#endif /*OMAP_ENHANCEMENT*/

static jboolean android_net_wifi_startSupplicant(JNIEnv* env, jobject clazz)
{
    return (jboolean)(::wifi_start_supplicant() == 0);
@@ -532,6 +544,10 @@ static JNINativeMethod gWifiMethods[] = {

    { "loadDriver", "()Z",  (void *)android_net_wifi_loadDriver },
    { "unloadDriver", "()Z",  (void *)android_net_wifi_unloadDriver },
#ifdef OMAP_ENHANCEMENT
    { "loadHotspotDriver", "()Z",  (void *)android_net_hotspot_loadDriver },
    { "unloadHotspotDriver", "()Z",  (void *)android_net_hotspot_unloadDriver },
#endif /*OMAP_ENHANCEMENT*/
    { "startSupplicant", "()Z",  (void *)android_net_wifi_startSupplicant },
    { "stopSupplicant", "()Z",  (void *)android_net_wifi_stopSupplicant },
    { "connectToSupplicant", "()Z",  (void *)android_net_wifi_connectToSupplicant },
+12 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.IntentFilter;
import android.content.res.Resources;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.net.NetworkUtils;
import android.net.InterfaceConfiguration;
import android.net.INetworkManagementEventObserver;
import android.net.wifi.WifiConfiguration;
@@ -605,9 +606,15 @@ class NetworkManagementService extends INetworkManagementService.Stub {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.CHANGE_WIFI_STATE, "NetworkManagementService");
        try {
            if(SystemProperties.OMAP_ENHANCEMENT) {
                mConnector.doCommand(String.format("softap start " + softapIface));
                mConnector.doCommand(String.format("softap startap " + softapIface));
                NetworkUtils.enableInterface(softapIface);
            } else {
                mConnector.doCommand(String.format("softap stop " + wlanIface));
                mConnector.doCommand(String.format("softap fwreload " + wlanIface + " AP"));
                mConnector.doCommand(String.format("softap start " + wlanIface));
            }
            if (wifiConfig == null) {
                mConnector.doCommand(String.format("softap set " + wlanIface + " " + softapIface));
            } else {
@@ -629,6 +636,7 @@ class NetworkManagementService extends INetworkManagementService.Stub {
                                           convertQuotedString(wifiConfig.preSharedKey));
                mConnector.doCommand(str);
            }
            if(!SystemProperties.OMAP_ENHANCEMENT)
                mConnector.doCommand(String.format("softap startap"));
        } catch (NativeDaemonConnectorException e) {
            throw new IllegalStateException("Error communicating to native daemon to start softap", e);
+45 −13
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import android.os.PowerManager;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.WorkSource;
import android.provider.Settings;
import android.util.Slog;
@@ -99,6 +100,7 @@ public class WifiService extends IWifiManager.Stub {
    private final WifiStateTracker mWifiStateTracker;
    /* TODO: fetch a configurable interface */
    private static final String SOFTAP_IFACE = "wl0.1";
    private static final String TI_SOFTAP_IFACE = "tiap0";

    private Context mContext;
    private int mWifiApState;
@@ -681,8 +683,13 @@ public class WifiService extends IWifiManager.Stub {
            /* Configuration changed on a running access point */
            if(enable && (wifiConfig != null)) {
                try {
                    if(SystemProperties.OMAP_ENHANCEMENT) {
                        nwService.setAccessPoint(wifiConfig, mWifiStateTracker.getInterfaceName(),
                                                 TI_SOFTAP_IFACE);
                    } else {
                        nwService.setAccessPoint(wifiConfig, mWifiStateTracker.getInterfaceName(),
                                                 SOFTAP_IFACE);
                    }
                    setWifiApConfiguration(wifiConfig);
                    return true;
                } catch(Exception e) {
@@ -720,15 +727,28 @@ public class WifiService extends IWifiManager.Stub {
                wifiConfig.allowedKeyManagement.set(KeyMgmt.NONE);
            }

            if (SystemProperties.OMAP_ENHANCEMENT) {
                if (!mWifiStateTracker.loadHotspotDriver()) {
                    Slog.e(TAG, "Failed to load Wi-Fi driver for AP mode");
                    setWifiApEnabledState(WIFI_AP_STATE_FAILED, uid, DriverAction.NO_DRIVER_UNLOAD);
                    return false;
                }
            } else {
                if (!mWifiStateTracker.loadDriver()) {
                    Slog.e(TAG, "Failed to load Wi-Fi driver for AP mode");
                    setWifiApEnabledState(WIFI_AP_STATE_FAILED, uid, DriverAction.NO_DRIVER_UNLOAD);
                    return false;
                }
            }

            try {
                if(SystemProperties.OMAP_ENHANCEMENT) {
                    nwService.startAccessPoint(wifiConfig, mWifiStateTracker.getInterfaceName(),
                                               TI_SOFTAP_IFACE);
                } else {
                    nwService.startAccessPoint(wifiConfig, mWifiStateTracker.getInterfaceName(),
                                               SOFTAP_IFACE);
                }
            } catch(Exception e) {
                Slog.e(TAG, "Exception in startAccessPoint()");
                setWifiApEnabledState(WIFI_AP_STATE_FAILED, uid, DriverAction.DRIVER_UNLOAD);
@@ -747,12 +767,20 @@ public class WifiService extends IWifiManager.Stub {
                return false;
            }

            if(SystemProperties.OMAP_ENHANCEMENT) {
                if (!mWifiStateTracker.unloadHotspotDriver()) {
                    Slog.e(TAG, "Failed to unload Wi-Fi driver for AP mode");
                    setWifiApEnabledState(WIFI_AP_STATE_FAILED, uid, DriverAction.NO_DRIVER_UNLOAD);
                    return false;
                }
            } else {
                if (!mWifiStateTracker.unloadDriver()) {
                    Slog.e(TAG, "Failed to unload Wi-Fi driver for AP mode");
                    setWifiApEnabledState(WIFI_AP_STATE_FAILED, uid, DriverAction.NO_DRIVER_UNLOAD);
                    return false;
                }
            }
        }

        setWifiApEnabledState(eventualWifiApState, uid, DriverAction.NO_DRIVER_UNLOAD);
        return true;
@@ -778,8 +806,12 @@ public class WifiService extends IWifiManager.Stub {
         * Unload the driver if going to a failed state
         */
        if ((mWifiApState == WIFI_AP_STATE_FAILED) && (flag == DriverAction.DRIVER_UNLOAD)) {
            if(SystemProperties.OMAP_ENHANCEMENT) {
                mWifiStateTracker.unloadHotspotDriver();
            } else {
                mWifiStateTracker.unloadDriver();
            }
        }

        long ident = Binder.clearCallingIdentity();
        try {
+4 −0
Original line number Diff line number Diff line
@@ -44,6 +44,10 @@ public class WifiNative {
    
    public native static boolean unloadDriver();

    public native static boolean loadHotspotDriver();

    public native static boolean unloadHotspotDriver();

    public native static boolean startSupplicant();
    
    public native static boolean stopSupplicant();
+18 −0
Original line number Diff line number Diff line
@@ -1671,6 +1671,24 @@ public class WifiStateTracker extends NetworkStateTracker {
        return WifiNative.unloadDriver();
    }

    /**
     * Load the Hotspot driver and firmware
     *
     * @return {@code true} if the operation succeeds, {@code false} otherwise
     */
    public synchronized boolean loadHotspotDriver() {
        return WifiNative.loadHotspotDriver();
    }

    /**
     * Unload the Hotspot driver and firmware
     *
     * @return {@code true} if the operation succeeds, {@code false} otherwise
     */
    public synchronized boolean unloadHotspotDriver() {
        return WifiNative.unloadHotspotDriver();
    }

    /**
     * Check the supplicant config and
     * start the supplicant daemon