Merge "DO NOT MERGE registerSoftApCallback Executor param"
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user