Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef9a466f authored by James Mattis's avatar James Mattis Committed by android-build-merger
Browse files

Merge "DO NOT MERGE registerSoftApCallback Executor param"

am: db46c349

Change-Id: I5bedf30e2fb968e0192acd6419a13d1b9ccc4d40
parents f38016bd db46c349
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
+5 −5
Original line number Diff line number Diff line
@@ -3195,27 +3195,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),
+10 −8
Original line number Diff line number Diff line
@@ -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) {
        }
    }

    /**