From 42ae52899fbbbb7ffc958be1092a383f1283d19e Mon Sep 17 00:00:00 2001 From: Rebecca Silberstein Date: Thu, 23 Mar 2017 15:05:39 -0700 Subject: [PATCH] WifiManager: add new methods to start softap Add two new methods to start/stop softap in WifiService. These are internal calls that allow WifiService and ConnectivityService to coordinate the switch to and from softap mode. These calls will not be callable by apps and are protected by the NETWORK_STACK permission. The calls are added in this CL, but are not used at this time. Bug: 36540346 Test: compiles Change-Id: Idabdba7f779cbac999ff88d8993b2f4b1f4a1624 Merged-In: Idabdba7f779cbac999ff88d8993b2f4b1f4a1624 Merged-In: Ie2476bbae3554bd9fc203c478d25cb2e2898c8e3 --- wifi/java/android/net/wifi/IWifiManager.aidl | 4 +++ wifi/java/android/net/wifi/WifiManager.java | 34 ++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index 1852feb8afc92..229aa97c92479 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -125,6 +125,10 @@ interface IWifiManager void setWifiApEnabled(in WifiConfiguration wifiConfig, boolean enable); + boolean startSoftAp(in WifiConfiguration wifiConfig); + + boolean stopSoftAp(); + int getWifiApEnabledState(); WifiConfiguration getWifiApConfiguration(); diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 7268ee53820fd..ed54c3b3f192d 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -16,6 +16,7 @@ package android.net.wifi; +import android.annotation.Nullable; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; @@ -1730,6 +1731,39 @@ public class WifiManager { } } + /** + * Start SoftAp mode with the specified 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 + */ + public boolean startSoftAp(@Nullable WifiConfiguration wifiConfig) { + try { + return mService.startSoftAp(wifiConfig); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Stop SoftAp mode. + * Note that stopping softap mode will restore the previous wifi mode. + * @return {@code true} if the operation succeeds, {@code false} otherwise + * + * @hide + */ + public boolean stopSoftAp() { + try { + return mService.stopSoftAp(); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + /** * Gets the Wi-Fi enabled state. * @return One of {@link #WIFI_AP_STATE_DISABLED},