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

Commit 6d899388 authored by Bruno Randolf's avatar Bruno Randolf Committed by Steve Kondik
Browse files

wifi: Framework support for Ad-Hoc WiFi (IBSS mode)



 * Backport from previous CM releases, adapted to new API

Change-Id: Id175bbfb7500329d5f8abfe645106854c201b2fb
Signed-off-by: default avatarSteve Kondik <steve@cyngn.com>
parent 7dd76023
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -86,6 +86,8 @@ interface IWifiManager

    boolean isDualBandSupported();

    boolean isIbssSupported();

    boolean saveConfiguration();

    DhcpInfo getDhcpInfo();
+5 −0
Original line number Diff line number Diff line
@@ -43,6 +43,9 @@ public class WifiChannel implements Parcelable {
    /** is it a DFS channel? */
    public boolean isDFS;

    /** is IBSS allowed? */
    public boolean ibssAllowed;

    /** public constructor */
    public WifiChannel() { }

@@ -65,6 +68,7 @@ public class WifiChannel implements Parcelable {
        out.writeInt(freqMHz);
        out.writeInt(channelNum);
        out.writeInt(isDFS ? 1 : 0);
        out.writeInt(ibssAllowed ? 1 : 0);
    }

    /** implement Parcelable interface */
@@ -76,6 +80,7 @@ public class WifiChannel implements Parcelable {
            channel.freqMHz = in.readInt();
            channel.channelNum = in.readInt();
            channel.isDFS = in.readInt() != 0;
            channel.ibssAllowed = in.readInt() != 0;
            return channel;
        }

+24 −0
Original line number Diff line number Diff line
@@ -58,6 +58,10 @@ public class WifiConfiguration implements Parcelable {
    /** {@hide} */
    public static final String updateIdentiferVarName = "update_identifier";
     /** {@hide} */
    public static final String modeVarName = "mode";
    /** {@hide} */
    public static final String frequencyVarName = "frequency";
    /** {@hide} */
    public static final int INVALID_NETWORK_ID = -1;
    /** {@hide} */
    public static final String SIMNumVarName = "sim_num";
@@ -293,6 +297,18 @@ public class WifiConfiguration implements Parcelable {
     */
    public String updateIdentifier;

   /**
     * This is an Ad-Hoc (IBSS) network
     * {@hide}
     */
    public boolean isIBSS;

    /**
     * Frequency of the Ad-Hoc (IBSS) network, if newly created
     * {@hide}
     */
    public int frequency;

    /**
     * The set of key management protocols supported by this configuration.
     * See {@link KeyMgmt} for descriptions of the values.
@@ -908,6 +924,8 @@ public class WifiConfiguration implements Parcelable {
        naiRealm = null;
        priority = 0;
        hiddenSSID = false;
        isIBSS = false;
        frequency = 0;
        disableReason = DISABLED_UNKNOWN_REASON;
        allowedKeyManagement = new BitSet();
        allowedProtocols = new BitSet();
@@ -1558,6 +1576,8 @@ public class WifiConfiguration implements Parcelable {
            wepTxKeyIndex = source.wepTxKeyIndex;
            priority = source.priority;
            hiddenSSID = source.hiddenSSID;
            isIBSS = source.isIBSS;
            frequency = source.frequency;
            allowedKeyManagement   = (BitSet) source.allowedKeyManagement.clone();
            allowedProtocols       = (BitSet) source.allowedProtocols.clone();
            allowedAuthAlgorithms  = (BitSet) source.allowedAuthAlgorithms.clone();
@@ -1654,6 +1674,8 @@ public class WifiConfiguration implements Parcelable {
        dest.writeInt(wepTxKeyIndex);
        dest.writeInt(priority);
        dest.writeInt(hiddenSSID ? 1 : 0);
        dest.writeInt(isIBSS ? 1 : 0);
        dest.writeInt(frequency);
        dest.writeInt(requirePMF ? 1 : 0);
        dest.writeString(updateIdentifier);

@@ -1720,6 +1742,8 @@ public class WifiConfiguration implements Parcelable {
                config.wepTxKeyIndex = in.readInt();
                config.priority = in.readInt();
                config.hiddenSSID = in.readInt() != 0;
                config.isIBSS = in.readInt() != 0;
                config.frequency = in.readInt();
                config.requirePMF = in.readInt() != 0;
                config.updateIdentifier = in.readString();

+13 −0
Original line number Diff line number Diff line
@@ -1302,6 +1302,19 @@ public class WifiManager {
        }
    }

    /**
     * Check if the chipset supports IBSS (Adhoc) mode
     * @return {@code true} if supported, {@code false} otherwise.
     * @hide
     */
    public boolean isIbssSupported() {
        try {
            return mService.isIbssSupported();
        } catch (RemoteException e) {
            return false;
        }
    }

    /**
     * Return the DHCP-assigned addresses from the last successful DHCP request,
     * if any.