diff options
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/IWifiManager.aidl | 2 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiChannel.java | 5 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfiguration.java | 62 | ||||
-rwxr-xr-x | wifi/java/android/net/wifi/WifiDevice.aidl | 32 | ||||
-rwxr-xr-x | wifi/java/android/net/wifi/WifiDevice.java | 137 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 23 |
6 files changed, 250 insertions, 11 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index 0d95b38..160fd76 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -90,6 +90,8 @@ interface IWifiManager boolean isDualBandSupported(); + boolean isIbssSupported(); + boolean saveConfiguration(); DhcpInfo getDhcpInfo(); diff --git a/wifi/java/android/net/wifi/WifiChannel.java b/wifi/java/android/net/wifi/WifiChannel.java index 640481e..a526062 100644 --- a/wifi/java/android/net/wifi/WifiChannel.java +++ b/wifi/java/android/net/wifi/WifiChannel.java @@ -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; } diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index dc329e2..9d4f6e2 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -58,8 +58,15 @@ public class WifiConfiguration implements Parcelable { public static final String pmfVarName = "ieee80211w"; /** {@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"; + /** * Recognized key management schemes. @@ -302,6 +309,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. @@ -426,6 +445,12 @@ public class WifiConfiguration implements Parcelable { public String autoJoinBSSID; /** + * @hide + * sim number selected + */ + public int SIMNum; + + /** * @hide * Status of user approval for connection */ @@ -910,6 +935,8 @@ public class WifiConfiguration implements Parcelable { roamingConsortiumIds = new long[0]; priority = 0; hiddenSSID = false; + isIBSS = false; + frequency = 0; disableReason = DISABLED_UNKNOWN_REASON; allowedKeyManagement = new BitSet(); allowedProtocols = new BitSet(); @@ -929,6 +956,7 @@ public class WifiConfiguration implements Parcelable { mIpConfiguration = new IpConfiguration(); lastUpdateUid = -1; creatorUid = -1; + SIMNum = 0; } /** @@ -1088,6 +1116,10 @@ public class WifiConfiguration implements Parcelable { if (this.preSharedKey != null) { sbuf.append('*'); } + sbuf.append('\n').append(" sim_num "); + if (this.SIMNum > 0 ) { + sbuf.append('*'); + } sbuf.append("\nEnterprise config:\n"); sbuf.append(enterpriseConfig); @@ -1325,14 +1357,14 @@ public class WifiConfiguration implements Parcelable { key = FQDN + KeyMgmt.strings[KeyMgmt.WPA_EAP]; } else { if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { - key = SSID + KeyMgmt.strings[KeyMgmt.WPA_PSK]; + key = SSID + "-" + KeyMgmt.strings[KeyMgmt.WPA_PSK]; } else if (allowedKeyManagement.get(KeyMgmt.WPA_EAP) || allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { - key = SSID + KeyMgmt.strings[KeyMgmt.WPA_EAP]; + key = SSID + "-" + KeyMgmt.strings[KeyMgmt.WPA_EAP]; } else if (wepKeys[0] != null) { - key = SSID + "WEP"; + key = SSID + "-WEP"; } else { - key = SSID + KeyMgmt.strings[KeyMgmt.NONE]; + key = SSID + "-" + KeyMgmt.strings[KeyMgmt.NONE]; } mCachedConfigKey = key; } @@ -1354,17 +1386,16 @@ public class WifiConfiguration implements Parcelable { if (result.capabilities.contains("WEP")) { key = key + "-WEP"; - } - - if (result.capabilities.contains("PSK")) { + } else if (result.capabilities.contains("PSK")) { key = key + "-" + KeyMgmt.strings[KeyMgmt.WPA_PSK]; - } - - if (result.capabilities.contains("EAP")) { + } else if (result.capabilities.contains("EAP")|| + result.capabilities.contains("IEEE8021X")) { key = key + "-" + KeyMgmt.strings[KeyMgmt.WPA_EAP]; + } else { + key = key +"-" + KeyMgmt.strings[KeyMgmt.NONE]; } - return key; + return key; } /** @hide */ @@ -1453,6 +1484,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(); @@ -1522,6 +1555,7 @@ public class WifiConfiguration implements Parcelable { noInternetAccessExpected = source.noInternetAccessExpected; creationTime = source.creationTime; updateTime = source.updateTime; + SIMNum = source.SIMNum; } } @@ -1554,6 +1588,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); @@ -1601,6 +1637,7 @@ public class WifiConfiguration implements Parcelable { dest.writeInt(userApproved); dest.writeInt(numNoInternetAccessReports); dest.writeInt(noInternetAccessExpected ? 1 : 0); + dest.writeInt(SIMNum); } /** Implement the Parcelable interface {@hide} */ @@ -1630,6 +1667,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(); @@ -1677,6 +1716,7 @@ public class WifiConfiguration implements Parcelable { config.userApproved = in.readInt(); config.numNoInternetAccessReports = in.readInt(); config.noInternetAccessExpected = in.readInt() != 0; + config.SIMNum = in.readInt(); return config; } diff --git a/wifi/java/android/net/wifi/WifiDevice.aidl b/wifi/java/android/net/wifi/WifiDevice.aidl new file mode 100755 index 0000000..c1b186c --- /dev/null +++ b/wifi/java/android/net/wifi/WifiDevice.aidl @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package android.net.wifi; + +parcelable WifiDevice; diff --git a/wifi/java/android/net/wifi/WifiDevice.java b/wifi/java/android/net/wifi/WifiDevice.java new file mode 100755 index 0000000..163b559 --- /dev/null +++ b/wifi/java/android/net/wifi/WifiDevice.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package android.net.wifi; + +import android.os.Parcelable; +import android.os.Parcel; + +/** + * Describes information about a detected Wi-Fi STA. + * {@hide} + */ +public class WifiDevice implements Parcelable { + /** + * The device MAC address is the unique id of a Wi-Fi STA + */ + public String deviceAddress = ""; + + /** + * The device name is a readable string of a Wi-Fi STA + */ + public String deviceName = ""; + + /** + * The device state is the state of a Wi-Fi STA + */ + public int deviceState = 0; + + /** + * These definitions are for deviceState + */ + public static final int DISCONNECTED = 0; + public static final int CONNECTED = 1; + public static final int BLACKLISTED = 2; + + private static final String AP_STA_CONNECTED_STR = "AP-STA-CONNECTED"; + private static final String AP_STA_DISCONNECTED_STR = "AP-STA-DISCONNECTED"; + + /** {@hide} */ + public WifiDevice() {} + + /** + * @param string formats supported include + * + * AP-STA-CONNECTED 42:fc:89:a8:96:09 + * AP-STA-DISCONNECTED 42:fc:89:a8:96:09 + * + * Note: The events formats can be looked up in the hostapd code + * @hide + */ + public WifiDevice(String dataString) throws IllegalArgumentException { + String[] tokens = dataString.split(" "); + + if (tokens.length < 2) { + throw new IllegalArgumentException(); + } + + if (tokens[0].indexOf(AP_STA_CONNECTED_STR) != -1) { + deviceState = CONNECTED; + } else if (tokens[0].indexOf(AP_STA_DISCONNECTED_STR) != -1) { + deviceState = DISCONNECTED; + } else { + throw new IllegalArgumentException(); + } + + deviceAddress = tokens[1]; + } + + @Override + public boolean equals(Object obj) { + if (obj == null || !(obj instanceof WifiDevice)) { + return false; + } + + WifiDevice other = (WifiDevice) obj; + + if (deviceAddress == null) { + return (other.deviceAddress == null); + } else { + return deviceAddress.equals(other.deviceAddress); + } + } + + /** Implement the Parcelable interface {@hide} */ + public int describeContents() { + return 0; + } + + /** Implement the Parcelable interface {@hide} */ + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(deviceAddress); + dest.writeString(deviceName); + dest.writeInt(deviceState); + } + + /** Implement the Parcelable interface {@hide} */ + public static final Creator<WifiDevice> CREATOR = + new Creator<WifiDevice>() { + public WifiDevice createFromParcel(Parcel in) { + WifiDevice device = new WifiDevice(); + device.deviceAddress = in.readString(); + device.deviceName = in.readString(); + device.deviceState = in.readInt(); + return device; + } + + public WifiDevice[] newArray(int size) { + return new WifiDevice[size]; + } + }; +} diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index cf88df4..056ede1 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -1,4 +1,7 @@ /* + * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. + * Not a Contribution. + * * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,6 +22,7 @@ package android.net.wifi; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; +import android.app.AppOpsManager; import android.content.Context; import android.net.ConnectivityManager; import android.net.ConnectivityManager.NetworkCallback; @@ -623,6 +627,7 @@ public class WifiManager { private static final Object sThreadRefLock = new Object(); private static int sThreadRefCount; private static HandlerThread sHandlerThread; + private final AppOpsManager mAppOps; @GuardedBy("sCM") // TODO: Introduce refcounting and make this a per-process static callback, instead of a @@ -644,6 +649,7 @@ public class WifiManager { mService = service; mTargetSdkVersion = context.getApplicationInfo().targetSdkVersion; init(); + mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE); } /** @@ -1307,6 +1313,7 @@ public class WifiManager { * in order to get valid results. */ public List<ScanResult> getScanResults() { + android.util.SeempLog.record(55); try { return mService.getScanResults(mContext.getOpPackageName()); } catch (RemoteException e) { @@ -1421,6 +1428,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. * @return the DHCP information @@ -1440,6 +1460,9 @@ public class WifiManager { * is the same as the requested state). */ public boolean setWifiEnabled(boolean enabled) { + if (mAppOps.noteOp(AppOpsManager.OP_WIFI_CHANGE) != + AppOpsManager.MODE_ALLOWED) + return false; try { return mService.setWifiEnabled(enabled); } catch (RemoteException e) { |