Merge changes from topic "tethering-systemapi"
am: 8e34d95a22
Change-Id: Id22196cdbecd66b018f5458417d99548bb3a251e
diff --git a/api/system-current.txt b/api/system-current.txt
index 5c38ed4..a261ee6 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -4700,8 +4700,11 @@
method @RequiresPermission(anyOf={"android.permission.NETWORK_SETTINGS", android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startEasyConnectAsConfiguratorInitiator(@NonNull String, int, int, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.EasyConnectStatusCallback);
method @RequiresPermission(anyOf={"android.permission.NETWORK_SETTINGS", android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startEasyConnectAsEnrolleeInitiator(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.EasyConnectStatusCallback);
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public boolean startScan(android.os.WorkSource);
+ method @RequiresPermission(anyOf={"android.permission.NETWORK_STACK", android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public boolean startSoftAp(@Nullable android.net.wifi.WifiConfiguration);
method @RequiresPermission(anyOf={"android.permission.NETWORK_SETTINGS", android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void startSubscriptionProvisioning(@NonNull android.net.wifi.hotspot2.OsuProvider, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.hotspot2.ProvisioningCallback);
method @RequiresPermission(anyOf={"android.permission.NETWORK_SETTINGS", android.Manifest.permission.NETWORK_SETUP_WIZARD}) public void stopEasyConnectSession();
+ method @RequiresPermission(anyOf={"android.permission.NETWORK_STACK", android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public boolean stopSoftAp();
+ method @RequiresPermission(anyOf={"android.permission.NETWORK_STACK", android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public void updateInterfaceIpState(@Nullable String, int);
method @RequiresPermission("android.permission.WIFI_UPDATE_USABILITY_STATS_SCORE") public void updateWifiUsabilityScore(int, int, int);
field public static final int CHANGE_REASON_ADDED = 0; // 0x0
field public static final int CHANGE_REASON_CONFIG_CHANGE = 2; // 0x2
@@ -4716,10 +4719,16 @@
field public static final String EXTRA_CHANGE_REASON = "changeReason";
field public static final String EXTRA_MULTIPLE_NETWORKS_CHANGED = "multipleChanges";
field public static final String EXTRA_PREVIOUS_WIFI_AP_STATE = "previous_wifi_state";
+ field public static final String EXTRA_WIFI_AP_INTERFACE_NAME = "android.net.wifi.extra.WIFI_AP_INTERFACE_NAME";
+ field public static final String EXTRA_WIFI_AP_MODE = "android.net.wifi.extra.WIFI_AP_MODE";
field public static final String EXTRA_WIFI_AP_STATE = "wifi_state";
field public static final String EXTRA_WIFI_CONFIGURATION = "wifiConfiguration";
field public static final String EXTRA_WIFI_CREDENTIAL_EVENT_TYPE = "et";
field public static final String EXTRA_WIFI_CREDENTIAL_SSID = "ssid";
+ field public static final int IFACE_IP_MODE_CONFIGURATION_ERROR = 0; // 0x0
+ field public static final int IFACE_IP_MODE_LOCAL_ONLY = 2; // 0x2
+ field public static final int IFACE_IP_MODE_TETHERED = 1; // 0x1
+ field public static final int IFACE_IP_MODE_UNSPECIFIED = -1; // 0xffffffff
field public static final int PASSPOINT_HOME_NETWORK = 0; // 0x0
field public static final int PASSPOINT_ROAMING_NETWORK = 1; // 0x1
field public static final String WIFI_AP_STATE_CHANGED_ACTION = "android.net.wifi.WIFI_AP_STATE_CHANGED";
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 77e02df..0d2e816 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -38,6 +38,7 @@
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
+import android.net.NetworkStack;
import android.net.wifi.hotspot2.IProvisioningCallback;
import android.net.wifi.hotspot2.OsuProvider;
import android.net.wifi.hotspot2.PasspointConfiguration;
@@ -532,19 +533,25 @@
@SystemApi
public static final String EXTRA_PREVIOUS_WIFI_AP_STATE = "previous_wifi_state";
/**
- * The interface used for the softap.
+ * The lookup key for a String extra that stores the interface name used for the Soft AP.
+ * This extra is included in the broadcast {@link #WIFI_AP_STATE_CHANGED_ACTION}.
+ * Retrieve its value with {@link android.content.Intent#getStringExtra(String)}.
*
* @hide
*/
- public static final String EXTRA_WIFI_AP_INTERFACE_NAME = "wifi_ap_interface_name";
+ @SystemApi
+ public static final String EXTRA_WIFI_AP_INTERFACE_NAME =
+ "android.net.wifi.extra.WIFI_AP_INTERFACE_NAME";
/**
- * The intended ip mode for this softap.
- * @see #IFACE_IP_MODE_TETHERED
- * @see #IFACE_IP_MODE_LOCAL_ONLY
+ * The lookup key for an int extra that stores the intended IP mode for this Soft AP.
+ * One of {@link #IFACE_IP_MODE_TETHERED} or {@link #IFACE_IP_MODE_LOCAL_ONLY}.
+ * This extra is included in the broadcast {@link #WIFI_AP_STATE_CHANGED_ACTION}.
+ * Retrieve its value with {@link android.content.Intent#getIntExtra(String, int)}.
*
* @hide
*/
- public static final String EXTRA_WIFI_AP_MODE = "wifi_ap_mode";
+ @SystemApi
+ public static final String EXTRA_WIFI_AP_MODE = "android.net.wifi.extra.WIFI_AP_MODE";
/** @hide */
@IntDef(flag = false, prefix = { "WIFI_AP_STATE_" }, value = {
@@ -634,40 +641,53 @@
*/
public static final int SAP_START_FAILURE_NO_CHANNEL = 1;
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"IFACE_IP_MODE_"}, value = {
+ IFACE_IP_MODE_UNSPECIFIED,
+ IFACE_IP_MODE_CONFIGURATION_ERROR,
+ IFACE_IP_MODE_TETHERED,
+ IFACE_IP_MODE_LOCAL_ONLY})
+ public @interface IfaceIpMode {}
+
/**
* Interface IP mode unspecified.
*
- * @see updateInterfaceIpState(String, int)
+ * @see #updateInterfaceIpState(String, int)
*
* @hide
*/
+ @SystemApi
public static final int IFACE_IP_MODE_UNSPECIFIED = -1;
/**
* Interface IP mode for configuration error.
*
- * @see updateInterfaceIpState(String, int)
+ * @see #updateInterfaceIpState(String, int)
*
* @hide
*/
+ @SystemApi
public static final int IFACE_IP_MODE_CONFIGURATION_ERROR = 0;
/**
* Interface IP mode for tethering.
*
- * @see updateInterfaceIpState(String, int)
+ * @see #updateInterfaceIpState(String, int)
*
* @hide
*/
+ @SystemApi
public static final int IFACE_IP_MODE_TETHERED = 1;
/**
* Interface IP mode for Local Only Hotspot.
*
- * @see updateInterfaceIpState(String, int)
+ * @see #updateInterfaceIpState(String, int)
*
* @hide
*/
+ @SystemApi
public static final int IFACE_IP_MODE_LOCAL_ONLY = 2;
/**
@@ -2538,16 +2558,21 @@
/**
* Call allowing ConnectivityService to update WifiService with interface mode changes.
*
- * The possible modes include: {@link IFACE_IP_MODE_TETHERED},
- * {@link IFACE_IP_MODE_LOCAL_ONLY},
- * {@link IFACE_IP_MODE_CONFIGURATION_ERROR}
- *
- * @param ifaceName String name of the updated interface
- * @param mode int representing the new mode
+ * @param ifaceName String name of the updated interface, or null to represent all interfaces
+ * @param mode int representing the new mode, one of:
+ * {@link #IFACE_IP_MODE_TETHERED},
+ * {@link #IFACE_IP_MODE_LOCAL_ONLY},
+ * {@link #IFACE_IP_MODE_CONFIGURATION_ERROR},
+ * {@link #IFACE_IP_MODE_UNSPECIFIED}
*
* @hide
*/
- public void updateInterfaceIpState(String ifaceName, int mode) {
+ @SystemApi
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.NETWORK_STACK,
+ NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK
+ })
+ public void updateInterfaceIpState(@Nullable String ifaceName, @IfaceIpMode int mode) {
try {
mService.updateInterfaceIpState(ifaceName, mode);
} catch (RemoteException e) {
@@ -2556,15 +2581,21 @@
}
/**
- * 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
+ * Start Soft AP (hotspot) mode with the specified configuration.
+ * Note that starting Soft AP mode may disable station mode operation if the device does not
+ * support concurrency.
+ * @param wifiConfig SSID, security and channel details as part of WifiConfiguration, or null to
+ * use the persisted Soft AP configuration that was previously set using
+ * {@link #setWifiApConfiguration(WifiConfiguration)}.
+ * @return {@code true} if the operation succeeded, {@code false} otherwise
*
* @hide
*/
+ @SystemApi
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.NETWORK_STACK,
+ NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK
+ })
public boolean startSoftAp(@Nullable WifiConfiguration wifiConfig) {
try {
return mService.startSoftAp(wifiConfig);
@@ -2580,6 +2611,11 @@
*
* @hide
*/
+ @SystemApi
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.NETWORK_STACK,
+ NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK
+ })
public boolean stopSoftAp() {
try {
return mService.stopSoftAp();