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

Commit 68ef972e authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Ad-hoc network support (framework part)" into ics

parents 0fc18594 aff66a2b
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -1025,6 +1025,32 @@ class WifiConfigStore {
                break setVariables;
            }

            // Android sometimes call this function with infrastructure
            // configuration for ad-hoc networks (from selectNetwork),
            // so we only set the variable if the mode is ad-hoc.
            // (Infrastructure is default and does not have to be set.)
            if (config.mode == WifiConfiguration.Mode.ADHOC) {
                if (!WifiNative.setNetworkVariableCommand(
                            netId,
                            WifiConfiguration.Mode.varName,
                            Integer.toString(config.mode))) {
                    loge(config.SSID + ": failed to set mode: "
                            +config.mode);
                    break setVariables;
                }

                // Some drivers/wpa_supplicant require the frequency
                // to be set for ad-hoc networks, even though it will
                // not actually be used. Set it to Channel 11.
                if (!WifiNative.setNetworkVariableCommand(
                            netId,
                            "frequency",
                            "2462")) {
                    loge(config.SSID + ": failed to set frequency: 2462");
                    break setVariables;
                }
            }

            for (WifiConfiguration.EnterpriseField field
                    : config.enterpriseFields) {
                String varName = field.varName();
@@ -1246,6 +1272,15 @@ class WifiConfigStore {
            }
        }

        value = WifiNative.getNetworkVariableCommand(netId, WifiConfiguration.Mode.varName);
        config.mode = WifiConfiguration.Mode.INFRASTRUCTURE;
        if (!TextUtils.isEmpty(value)) {
            try {
                config.mode = Integer.parseInt(value);
            } catch (NumberFormatException ignore) {
            }
        }

        value = WifiNative.getNetworkVariableCommand(netId, WifiConfiguration.wepTxKeyIdxVarName);
        config.wepTxKeyIndex = -1;
        if (!TextUtils.isEmpty(value)) {
+27 −0
Original line number Diff line number Diff line
@@ -211,6 +211,23 @@ public class WifiConfiguration implements Parcelable {
        public static final String[] strings = { "current", "disabled", "enabled" };
    }

    /**
     * Possible modes of a network configuration.
     * @hide
     */
    public static class Mode {
        private Mode() { }

        /** this is an infrastructure network */
        public static final int INFRASTRUCTURE = 0;
        /** this is an ad-hoc network */
        public static final int ADHOC = 1;

        public static final String varName = "mode";

        public static final String[] strings = { "infrastructure", "ad-hoc" };
    }

    /** @hide */
    public static final int DISABLED_UNKNOWN_REASON                         = 0;
    /** @hide */
@@ -290,6 +307,12 @@ public class WifiConfiguration implements Parcelable {
     */
    public boolean hiddenSSID;

    /**
     * The mode this access point operates on (infrastructure or ad-hoc)
     * @hide
     */
    public int mode;

    /**
     * The set of key management protocols supported by this configuration.
     * See {@link KeyMgmt} for descriptions of the values.
@@ -368,6 +391,7 @@ public class WifiConfiguration implements Parcelable {
        BSSID = null;
        priority = 0;
        hiddenSSID = false;
        mode = Mode.INFRASTRUCTURE;
        disableReason = DISABLED_UNKNOWN_REASON;
        allowedKeyManagement = new BitSet();
        allowedProtocols = new BitSet();
@@ -542,6 +566,7 @@ public class WifiConfiguration implements Parcelable {
            wepTxKeyIndex = source.wepTxKeyIndex;
            priority = source.priority;
            hiddenSSID = source.hiddenSSID;
            mode = source.mode;
            allowedKeyManagement   = (BitSet) source.allowedKeyManagement.clone();
            allowedProtocols       = (BitSet) source.allowedProtocols.clone();
            allowedAuthAlgorithms  = (BitSet) source.allowedAuthAlgorithms.clone();
@@ -570,6 +595,7 @@ public class WifiConfiguration implements Parcelable {
        dest.writeInt(wepTxKeyIndex);
        dest.writeInt(priority);
        dest.writeInt(hiddenSSID ? 1 : 0);
        dest.writeInt(mode);

        writeBitSet(dest, allowedKeyManagement);
        writeBitSet(dest, allowedProtocols);
@@ -601,6 +627,7 @@ public class WifiConfiguration implements Parcelable {
                config.wepTxKeyIndex = in.readInt();
                config.priority = in.readInt();
                config.hiddenSSID = in.readInt() != 0;
                config.mode = in.readInt();
                config.allowedKeyManagement   = readBitSet(in);
                config.allowedProtocols       = readBitSet(in);
                config.allowedAuthAlgorithms  = readBitSet(in);