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

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

Merge "Swap param order in registerSoftApCallback"

am: 1dcfd692

Change-Id: Icfb927efccdab7adda38ca71c30564a29cad785f
parents 910d4e98 1dcfd692
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -4719,7 +4719,7 @@ package android.net.wifi {
    method public boolean isPortableHotspotSupported();
    method public boolean isPortableHotspotSupported();
    method @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public boolean isWifiApEnabled();
    method @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public boolean isWifiApEnabled();
    method public boolean isWifiScannerSupported();
    method public boolean isWifiScannerSupported();
    method @RequiresPermission("android.permission.NETWORK_SETTINGS") public void registerSoftApCallback(@NonNull android.net.wifi.WifiManager.SoftApCallback, @Nullable java.util.concurrent.Executor);
    method @RequiresPermission("android.permission.NETWORK_SETTINGS") public void registerSoftApCallback(@Nullable 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("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(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);
    method @RequiresPermission("android.permission.WIFI_SET_DEVICE_MOBILITY_STATE") public void setDeviceMobilityState(int);
+2 −2
Original line number Original line Diff line number Diff line
@@ -110,8 +110,7 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof
            mCallbacks.add(callback);
            mCallbacks.add(callback);
            if (mWifiManager != null) {
            if (mWifiManager != null) {
                if (mCallbacks.size() == 1) {
                if (mCallbacks.size() == 1) {
                    mWifiManager.registerSoftApCallback(this,
                    mWifiManager.registerSoftApCallback(new HandlerExecutor(mMainHandler), this);
                            new HandlerExecutor(mMainHandler));
                } else {
                } else {
                    // mWifiManager#registerSoftApCallback triggers a call to
                    // mWifiManager#registerSoftApCallback triggers a call to
                    // onConnectedClientsChanged on the Main Handler. In order to always update
                    // onConnectedClientsChanged on the Main Handler. In order to always update
@@ -120,6 +119,7 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof
                    mMainHandler.post(() ->
                    mMainHandler.post(() ->
                            callback.onHotspotChanged(isHotspotEnabled(),
                            callback.onHotspotChanged(isHotspotEnabled(),
                                    mNumConnectedDevices));
                                    mNumConnectedDevices));

                }
                }
            }
            }
        }
        }
+4 −4
Original line number Original line Diff line number Diff line
@@ -70,11 +70,11 @@ public class HotspotControllerImplTest extends SysuiTestCase {
        mContext.addMockSystemService(WifiManager.class, mWifiManager);
        mContext.addMockSystemService(WifiManager.class, mWifiManager);


        doAnswer((InvocationOnMock invocation) -> {
        doAnswer((InvocationOnMock invocation) -> {
            ((WifiManager.SoftApCallback) invocation.getArgument(0))
            ((WifiManager.SoftApCallback) invocation.getArgument(1))
                    .onConnectedClientsChanged(new ArrayList<>());
                    .onConnectedClientsChanged(new ArrayList<>());
            return null;
            return null;
        }).when(mWifiManager).registerSoftApCallback(any(WifiManager.SoftApCallback.class),
        }).when(mWifiManager).registerSoftApCallback(any(Executor.class),
                any(Executor.class));
                any(WifiManager.SoftApCallback.class));


        mController = new HotspotControllerImpl(mContext, new Handler(mLooper.getLooper()));
        mController = new HotspotControllerImpl(mContext, new Handler(mLooper.getLooper()));
    }
    }
@@ -84,7 +84,7 @@ public class HotspotControllerImplTest extends SysuiTestCase {
        mController.addCallback(mCallback1);
        mController.addCallback(mCallback1);
        mController.addCallback(mCallback2);
        mController.addCallback(mCallback2);


        verify(mWifiManager, times(1)).registerSoftApCallback(eq(mController), any());
        verify(mWifiManager, times(1)).registerSoftApCallback(any(), eq(mController));
    }
    }


    @Test
    @Test
+4 −4
Original line number Original line Diff line number Diff line
@@ -3117,7 +3117,7 @@ public class WifiManager {


    /**
    /**
     * Base class for soft AP callback. Should be extended by applications and set when calling
     * Base class for soft AP callback. Should be extended by applications and set when calling
     * {@link WifiManager#registerSoftApCallback(SoftApCallback, Handler)}.
     * {@link WifiManager#registerSoftApCallback(Executor, SoftApCallback)}.
     *
     *
     * @hide
     * @hide
     */
     */
@@ -3197,16 +3197,16 @@ public class WifiManager {
     * without the permission will trigger a {@link java.lang.SecurityException}.
     * without the permission will trigger a {@link java.lang.SecurityException}.
     * <p>
     * <p>
     *
     *
     * @param callback Callback for soft AP events
     * @param executor The executor to execute the callbacks of the {@code executor}
     * @param executor The executor to execute the callbacks of the {@code executor}
     *                 object. If null, then the application's main executor will be used.
     *                 object. If null, then the application's main executor will be used.
     * @param callback Callback for soft AP events
     *
     *
     * @hide
     * @hide
     */
     */
    @SystemApi
    @SystemApi
    @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
    @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
    public void registerSoftApCallback(@NonNull SoftApCallback callback,
    public void registerSoftApCallback(@Nullable @CallbackExecutor Executor executor,
                                       @Nullable @CallbackExecutor Executor executor) {
                                       @NonNull SoftApCallback callback) {
        if (callback == null) throw new IllegalArgumentException("callback cannot be null");
        if (callback == null) throw new IllegalArgumentException("callback cannot be null");
        Log.v(TAG, "registerSoftApCallback: callback=" + callback + ", executor=" + executor);
        Log.v(TAG, "registerSoftApCallback: callback=" + callback + ", executor=" + executor);


+9 −9
Original line number Original line Diff line number Diff line
@@ -686,7 +686,7 @@ public class WifiManagerTest {
    @Test
    @Test
    public void registerSoftApCallbackThrowsIllegalArgumentExceptionOnNullArgumentForCallback() {
    public void registerSoftApCallbackThrowsIllegalArgumentExceptionOnNullArgumentForCallback() {
        try {
        try {
            mWifiManager.registerSoftApCallback(null, new HandlerExecutor(mHandler));
            mWifiManager.registerSoftApCallback(new HandlerExecutor(mHandler), null);
            fail("expected IllegalArgumentException");
            fail("expected IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
        } catch (IllegalArgumentException expected) {
        }
        }
@@ -710,7 +710,7 @@ public class WifiManagerTest {
    @Test
    @Test
    public void registerSoftApCallbackUsesMainLooperOnNullArgumentForHandler() {
    public void registerSoftApCallbackUsesMainLooperOnNullArgumentForHandler() {
        when(mContext.getMainLooper()).thenReturn(mLooper.getLooper());
        when(mContext.getMainLooper()).thenReturn(mLooper.getLooper());
        mWifiManager.registerSoftApCallback(mSoftApCallback, null);
        mWifiManager.registerSoftApCallback(null, mSoftApCallback);
        verify(mContext).getMainExecutor();
        verify(mContext).getMainExecutor();
    }
    }


@@ -719,7 +719,7 @@ public class WifiManagerTest {
     */
     */
    @Test
    @Test
    public void registerSoftApCallbackCallGoesToWifiServiceImpl() throws Exception {
    public void registerSoftApCallbackCallGoesToWifiServiceImpl() throws Exception {
        mWifiManager.registerSoftApCallback(mSoftApCallback, new HandlerExecutor(mHandler));
        mWifiManager.registerSoftApCallback(new HandlerExecutor(mHandler), mSoftApCallback);
        verify(mWifiService).registerSoftApCallback(any(IBinder.class),
        verify(mWifiService).registerSoftApCallback(any(IBinder.class),
                any(ISoftApCallback.Stub.class), anyInt());
                any(ISoftApCallback.Stub.class), anyInt());
    }
    }
@@ -730,7 +730,7 @@ public class WifiManagerTest {
    @Test
    @Test
    public void unregisterSoftApCallbackCallGoesToWifiServiceImpl() throws Exception {
    public void unregisterSoftApCallbackCallGoesToWifiServiceImpl() throws Exception {
        ArgumentCaptor<Integer> callbackIdentifier = ArgumentCaptor.forClass(Integer.class);
        ArgumentCaptor<Integer> callbackIdentifier = ArgumentCaptor.forClass(Integer.class);
        mWifiManager.registerSoftApCallback(mSoftApCallback, new HandlerExecutor(mHandler));
        mWifiManager.registerSoftApCallback(new HandlerExecutor(mHandler), mSoftApCallback);
        verify(mWifiService).registerSoftApCallback(any(IBinder.class),
        verify(mWifiService).registerSoftApCallback(any(IBinder.class),
                any(ISoftApCallback.Stub.class), callbackIdentifier.capture());
                any(ISoftApCallback.Stub.class), callbackIdentifier.capture());


@@ -745,7 +745,7 @@ public class WifiManagerTest {
    public void softApCallbackProxyCallsOnStateChanged() throws Exception {
    public void softApCallbackProxyCallsOnStateChanged() throws Exception {
        ArgumentCaptor<ISoftApCallback.Stub> callbackCaptor =
        ArgumentCaptor<ISoftApCallback.Stub> callbackCaptor =
                ArgumentCaptor.forClass(ISoftApCallback.Stub.class);
                ArgumentCaptor.forClass(ISoftApCallback.Stub.class);
        mWifiManager.registerSoftApCallback(mSoftApCallback, new HandlerExecutor(mHandler));
        mWifiManager.registerSoftApCallback(new HandlerExecutor(mHandler), mSoftApCallback);
        verify(mWifiService).registerSoftApCallback(any(IBinder.class), callbackCaptor.capture(),
        verify(mWifiService).registerSoftApCallback(any(IBinder.class), callbackCaptor.capture(),
                anyInt());
                anyInt());


@@ -761,7 +761,7 @@ public class WifiManagerTest {
    public void softApCallbackProxyCallsOnConnectedClientsChanged() throws Exception {
    public void softApCallbackProxyCallsOnConnectedClientsChanged() throws Exception {
        ArgumentCaptor<ISoftApCallback.Stub> callbackCaptor =
        ArgumentCaptor<ISoftApCallback.Stub> callbackCaptor =
                ArgumentCaptor.forClass(ISoftApCallback.Stub.class);
                ArgumentCaptor.forClass(ISoftApCallback.Stub.class);
        mWifiManager.registerSoftApCallback(mSoftApCallback, new HandlerExecutor(mHandler));
        mWifiManager.registerSoftApCallback(new HandlerExecutor(mHandler), mSoftApCallback);
        verify(mWifiService).registerSoftApCallback(any(IBinder.class), callbackCaptor.capture(),
        verify(mWifiService).registerSoftApCallback(any(IBinder.class), callbackCaptor.capture(),
                anyInt());
                anyInt());


@@ -778,7 +778,7 @@ public class WifiManagerTest {
    public void softApCallbackProxyCallsOnMultipleUpdates() throws Exception {
    public void softApCallbackProxyCallsOnMultipleUpdates() throws Exception {
        ArgumentCaptor<ISoftApCallback.Stub> callbackCaptor =
        ArgumentCaptor<ISoftApCallback.Stub> callbackCaptor =
                ArgumentCaptor.forClass(ISoftApCallback.Stub.class);
                ArgumentCaptor.forClass(ISoftApCallback.Stub.class);
        mWifiManager.registerSoftApCallback(mSoftApCallback, new HandlerExecutor(mHandler));
        mWifiManager.registerSoftApCallback(new HandlerExecutor(mHandler), mSoftApCallback);
        verify(mWifiService).registerSoftApCallback(any(IBinder.class), callbackCaptor.capture(),
        verify(mWifiService).registerSoftApCallback(any(IBinder.class), callbackCaptor.capture(),
                anyInt());
                anyInt());


@@ -802,7 +802,7 @@ public class WifiManagerTest {
                ArgumentCaptor.forClass(ISoftApCallback.Stub.class);
                ArgumentCaptor.forClass(ISoftApCallback.Stub.class);
        TestLooper altLooper = new TestLooper();
        TestLooper altLooper = new TestLooper();
        Handler altHandler = new Handler(altLooper.getLooper());
        Handler altHandler = new Handler(altLooper.getLooper());
        mWifiManager.registerSoftApCallback(mSoftApCallback, new HandlerExecutor(altHandler));
        mWifiManager.registerSoftApCallback(new HandlerExecutor(altHandler), mSoftApCallback);
        verify(mWifiService).registerSoftApCallback(any(IBinder.class), callbackCaptor.capture(),
        verify(mWifiService).registerSoftApCallback(any(IBinder.class), callbackCaptor.capture(),
                anyInt());
                anyInt());


@@ -816,7 +816,7 @@ public class WifiManagerTest {
     */
     */
    @Test
    @Test
    public void testCorrectLooperIsUsedForSoftApCallbackHandler() throws Exception {
    public void testCorrectLooperIsUsedForSoftApCallbackHandler() throws Exception {
        mWifiManager.registerSoftApCallback(mSoftApCallback, new HandlerExecutor(mHandler));
        mWifiManager.registerSoftApCallback(new HandlerExecutor(mHandler), mSoftApCallback);
        mLooper.dispatchAll();
        mLooper.dispatchAll();
        verify(mWifiService).registerSoftApCallback(any(IBinder.class),
        verify(mWifiService).registerSoftApCallback(any(IBinder.class),
                any(ISoftApCallback.Stub.class), anyInt());
                any(ISoftApCallback.Stub.class), anyInt());