diff options
| -rwxr-xr-x | api/system-current.txt | 2 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 10 | ||||
| -rw-r--r-- | wifi/tests/src/android/net/wifi/WifiManagerTest.java | 18 |
3 files changed, 16 insertions, 14 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 132956b0e3b0..bfb41049352b 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5539,7 +5539,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 f85bb5f8ad59..b9eb3f2b9d04 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} * <p> * Applications should have the * {@link android.Manifest.permission#NETWORK_SETTINGS NETWORK_SETTINGS} permission. Callers * without the permission will trigger a {@link java.lang.SecurityException}. * <p> * - * @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 4260c20255ac..b130c1737c62 100644 --- a/wifi/tests/src/android/net/wifi/WifiManagerTest.java +++ b/wifi/tests/src/android/net/wifi/WifiManagerTest.java @@ -693,25 +693,27 @@ public class WifiManagerTest { } /** - * Verify an IllegalArgumentException is thrown if callback is not provided. + * Verify an IllegalArgumentException is thrown if executor is null. */ @Test - public void unregisterSoftApCallbackThrowsIllegalArgumentExceptionOnNullArgumentForCallback() { + public void registerSoftApCallbackThrowsIllegalArgumentExceptionOnNullArgumentForExecutor() { try { - mWifiManager.unregisterSoftApCallback(null); + mWifiManager.registerSoftApCallback(null, mSoftApCallback); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } } /** - * Verify main looper is used when handler is not provided. + * Verify an IllegalArgumentException is thrown if callback is not provided. */ @Test - public void registerSoftApCallbackUsesMainLooperOnNullArgumentForHandler() { - when(mContext.getMainLooper()).thenReturn(mLooper.getLooper()); - mWifiManager.registerSoftApCallback(null, mSoftApCallback); - verify(mContext).getMainExecutor(); + public void unregisterSoftApCallbackThrowsIllegalArgumentExceptionOnNullArgumentForCallback() { + try { + mWifiManager.unregisterSoftApCallback(null); + fail("expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } } /** |