diff --git a/api/system-current.txt b/api/system-current.txt index 0e42ac1011a1a..2032697359c0f 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5531,7 +5531,7 @@ package android.net.wifi { method public boolean isPortableHotspotSupported(); method @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public boolean isWifiApEnabled(); method public boolean isWifiScannerSupported(); - method @RequiresPermission("android.permission.NETWORK_SETTINGS") public void registerSoftApCallback(@Nullable java.util.concurrent.Executor, @NonNull android.net.wifi.WifiManager.SoftApCallback); + method @RequiresPermission("android.permission.NETWORK_SETTINGS") public void registerSoftApCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.WifiManager.SoftApCallback); method @RequiresPermission("android.permission.WIFI_UPDATE_USABILITY_STATS_SCORE") public void removeOnWifiUsabilityStatsListener(@NonNull android.net.wifi.WifiManager.OnWifiUsabilityStatsListener); method @RequiresPermission(anyOf={"android.permission.NETWORK_SETTINGS", android.Manifest.permission.NETWORK_SETUP_WIZARD, "android.permission.NETWORK_STACK"}) public void save(@NonNull android.net.wifi.WifiConfiguration, @Nullable android.net.wifi.WifiManager.ActionListener); method @RequiresPermission("android.permission.WIFI_SET_DEVICE_MOBILITY_STATE") public void setDeviceMobilityState(int); diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index f85bb5f8ad59c..b9eb3f2b9d040 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -3194,27 +3194,27 @@ public class WifiManager { * soft AP state and number of connected devices immediately after a successful call to this API * via callback. Note that receiving an immediate WIFI_AP_STATE_FAILED value for soft AP state * indicates that the latest attempt to start soft AP has failed. Caller can unregister a - * previously registered callback using {@link unregisterSoftApCallback} + * previously registered callback using {@link #unregisterSoftApCallback} *
* Applications should have the * {@link android.Manifest.permission#NETWORK_SETTINGS NETWORK_SETTINGS} permission. Callers * without the permission will trigger a {@link java.lang.SecurityException}. *
* - * @param executor The executor to execute the callbacks of the {@code executor} - * object. If null, then the application's main executor will be used. + * @param executor The Executor on whose thread to execute the callbacks of the {@code callback} + * object. * @param callback Callback for soft AP events * * @hide */ @SystemApi @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) - public void registerSoftApCallback(@Nullable @CallbackExecutor Executor executor, + public void registerSoftApCallback(@NonNull @CallbackExecutor Executor executor, @NonNull SoftApCallback callback) { + if (executor == null) throw new IllegalArgumentException("executor cannot be null"); if (callback == null) throw new IllegalArgumentException("callback cannot be null"); Log.v(TAG, "registerSoftApCallback: callback=" + callback + ", executor=" + executor); - executor = (executor == null) ? mContext.getMainExecutor() : executor; Binder binder = new Binder(); try { mService.registerSoftApCallback(binder, new SoftApCallbackProxy(executor, callback), diff --git a/wifi/tests/src/android/net/wifi/WifiManagerTest.java b/wifi/tests/src/android/net/wifi/WifiManagerTest.java index 4260c20255ac0..b130c1737c629 100644 --- a/wifi/tests/src/android/net/wifi/WifiManagerTest.java +++ b/wifi/tests/src/android/net/wifi/WifiManagerTest.java @@ -692,6 +692,18 @@ public class WifiManagerTest { } } + /** + * Verify an IllegalArgumentException is thrown if executor is null. + */ + @Test + public void registerSoftApCallbackThrowsIllegalArgumentExceptionOnNullArgumentForExecutor() { + try { + mWifiManager.registerSoftApCallback(null, mSoftApCallback); + fail("expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + } + /** * Verify an IllegalArgumentException is thrown if callback is not provided. */ @@ -704,16 +716,6 @@ public class WifiManagerTest { } } - /** - * Verify main looper is used when handler is not provided. - */ - @Test - public void registerSoftApCallbackUsesMainLooperOnNullArgumentForHandler() { - when(mContext.getMainLooper()).thenReturn(mLooper.getLooper()); - mWifiManager.registerSoftApCallback(null, mSoftApCallback); - verify(mContext).getMainExecutor(); - } - /** * Verify the call to registerSoftApCallback goes to WifiServiceImpl. */