diff options
author | Irfan Sheriff <isheriff@google.com> | 2010-02-12 12:35:59 -0800 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2010-03-04 16:07:14 -0800 |
commit | 5321aef4a22daef6ed01ed48d936cdd82f2e38b7 (patch) | |
tree | 7c34f1bac696c3dfa056ac9a72613592ae908770 /wifi/java/android/net | |
parent | 23b7aa45fbb6397d6b1960cd8f1b832ef7d49fe5 (diff) | |
download | frameworks_base-5321aef4a22daef6ed01ed48d936cdd82f2e38b7.zip frameworks_base-5321aef4a22daef6ed01ed48d936cdd82f2e38b7.tar.gz frameworks_base-5321aef4a22daef6ed01ed48d936cdd82f2e38b7.tar.bz2 |
Wifi AP framework changes first pass
Bug: 2421638
Change-Id: Ic5ea8f7560a7fe5e1b0769daa5d92cc33eefc692
Diffstat (limited to 'wifi/java/android/net')
-rw-r--r-- | wifi/java/android/net/wifi/IWifiManager.aidl | 10 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 131 |
2 files changed, 137 insertions, 4 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index f3738e3..d833e33 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -29,7 +29,7 @@ import android.net.DhcpInfo; interface IWifiManager { List<WifiConfiguration> getConfiguredNetworks(); - + int addOrUpdateNetwork(in WifiConfiguration config); boolean removeNetwork(int netId); @@ -47,7 +47,7 @@ interface IWifiManager boolean disconnect(); boolean reconnect(); - + boolean reassociate(); WifiInfo getConnectionInfo(); @@ -61,7 +61,7 @@ interface IWifiManager boolean setNumAllowedChannels(int numChannels, boolean persist); int[] getValidChannelCounts(); - + boolean saveConfiguration(); DhcpInfo getDhcpInfo(); @@ -77,5 +77,9 @@ interface IWifiManager void acquireMulticastLock(IBinder binder, String tag); void releaseMulticastLock(); + + boolean setWifiApEnabled(in WifiConfiguration wifiConfig, boolean enable); + + int getWifiApEnabledState(); } diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 178f76e..9ef8ba1 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -123,7 +123,88 @@ public class WifiManager { * @see #getWifiState() */ public static final int WIFI_STATE_UNKNOWN = 4; - + + /** + * Broadcast intent action indicating that Wi-Fi AP has been enabled, disabled, + * enabling, disabling, or failed. + * + * @hide + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String WIFI_AP_STATE_CHANGED_ACTION = + "android.net.wifi.WIFI_AP_STATE_CHANGED"; + + /** + * The lookup key for an int that indicates whether Wi-Fi AP is enabled, + * disabled, enabling, disabling, or failed. Retrieve it with + * {@link android.content.Intent#getIntExtra(String,int)}. + * + * @see #WIFI_AP_STATE_DISABLED + * @see #WIFI_AP_STATE_DISABLING + * @see #WIFI_AP_STATE_ENABLED + * @see #WIFI_AP_STATE_ENABLING + * @see #WIFI_AP_STATE_FAILED + * + * @hide + */ + public static final String EXTRA_WIFI_AP_STATE = "wifi_state"; + /** + * The previous Wi-Fi state. + * + * @see #EXTRA_WIFI_AP_STATE + * + * @hide + */ + public static final String EXTRA_PREVIOUS_WIFI_AP_STATE = "previous_wifi_state"; + /** + * Wi-Fi AP is currently being disabled. The state will change to + * {@link #WIFI_AP_STATE_DISABLED} if it finishes successfully. + * + * @see #WIFI_AP_STATE_CHANGED_ACTION + * @see #getWifiApState() + * + * @hide + */ + public static final int WIFI_AP_STATE_DISABLING = 0; + /** + * Wi-Fi AP is disabled. + * + * @see #WIFI_AP_STATE_CHANGED_ACTION + * @see #getWifiState() + * + * @hide + */ + public static final int WIFI_AP_STATE_DISABLED = 1; + /** + * Wi-Fi AP is currently being enabled. The state will change to + * {@link #WIFI_AP_STATE_ENABLED} if it finishes successfully. + * + * @see #WIFI_AP_STATE_CHANGED_ACTION + * @see #getWifiApState() + * + * @hide + */ + public static final int WIFI_AP_STATE_ENABLING = 2; + /** + * Wi-Fi AP is enabled. + * + * @see #WIFI_AP_STATE_CHANGED_ACTION + * @see #getWifiApState() + * + * @hide + */ + public static final int WIFI_AP_STATE_ENABLED = 3; + /** + * Wi-Fi AP is in a failed state. This state will occur when an error occurs during + * enabling or disabling + * + * @see #WIFI_AP_STATE_CHANGED_ACTION + * @see #getWifiApState() + * + * @hide + */ + public static final int WIFI_AP_STATE_FAILED = 4; + /** * Broadcast intent action indicating that a connection to the supplicant has * been established (and it is now possible @@ -681,6 +762,54 @@ public class WifiManager { } /** + * Start AccessPoint mode with the specified + * configuration. If the radio is already running in + * AP mode, update the new configuration + * Note that starting in access point mode disables station + * mode operation + * @param wifiConfig SSID, security and channel details as + * part of WifiConfiguration + * @return {@code true} if the operation succeeds, {@code false} otherwise + * + * @hide Dont open up yet + */ + public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) { + try { + return mService.setWifiApEnabled(wifiConfig, enabled); + } catch (RemoteException e) { + return false; + } + } + + /** + * Gets the Wi-Fi enabled state. + * @return One of {@link #WIFI_AP_STATE_DISABLED}, + * {@link #WIFI_AP_STATE_DISABLING}, {@link #WIFI_AP_STATE_ENABLED}, + * {@link #WIFI_AP_STATE_ENABLING}, {@link #WIFI_AP_STATE_FAILED} + * @see #isWifiApEnabled() + * + * @hide Dont open yet + */ + public int getWifiApState() { + try { + return mService.getWifiApEnabledState(); + } catch (RemoteException e) { + return WIFI_AP_STATE_FAILED; + } + } + + /** + * Return whether Wi-Fi AP is enabled or disabled. + * @return {@code true} if Wi-Fi AP is enabled + * @see #getWifiApState() + * + * @hide Dont open yet + */ + public boolean isWifiApEnabled() { + return getWifiApState() == WIFI_AP_STATE_ENABLED; + } + + /** * Allows an application to keep the Wi-Fi radio awake. * Normally the Wi-Fi radio may turn off when the user has not used the device in a while. * Acquiring a WifiLock will keep the radio on until the lock is released. Multiple |