summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author James Mattis <jmattis@google.com> 2019-11-12 17:43:48 -0800
committer James Mattis <jmattis@google.com> 2019-11-13 21:08:33 -0800
commitcb157e8a331d2149dee0a45252b35ba72f399c05 (patch)
tree8d2511ba8714049c47e87e26e1c3314c1e7aa2aa
parent8416bcf87b77c9fbcfbfb03415ec4a545a553446 (diff)
Swap param order in registerSoftApCallback
Moving executor to be the first argument in registerSoftApCallback. Bug: 144379300 Test: atest FrameworksWifiApiTests:android.net.wifi.WifiManagerTest Manually on pixel 3 Change-Id: I7074278d16beac422ce7b29d4471b2794fa97825
-rw-r--r--api/system-current.txt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HotspotControllerImplTest.java8
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java8
-rw-r--r--wifi/tests/src/android/net/wifi/WifiManagerTest.java20
5 files changed, 22 insertions, 22 deletions
diff --git a/api/system-current.txt b/api/system-current.txt
index d5f544c5757a..f0ab301e27bd 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -4845,7 +4845,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(@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(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/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java
index 7587c8ca64fe..6331a2d6db1c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java
@@ -111,8 +111,8 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof
if (mWifiManager != null) {
if (mListening) {
if (mCallbacks.size() == 1) {
- mWifiManager.registerSoftApCallback(this,
- new HandlerExecutor(mMainHandler));
+ mWifiManager.registerSoftApCallback(new HandlerExecutor(mMainHandler),
+ this);
} else {
// mWifiManager#registerSoftApCallback triggers a call to
// onConnectedClientsChanged on the Main Handler. In order to always update
@@ -146,7 +146,7 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof
if (mListening || !listening) return;
mListening = true;
if (mCallbacks.size() >= 1) {
- mWifiManager.registerSoftApCallback(this, new HandlerExecutor(mMainHandler));
+ mWifiManager.registerSoftApCallback(new HandlerExecutor(mMainHandler), this);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HotspotControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HotspotControllerImplTest.java
index 0d1e1bd0bba1..811e6a06e607 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HotspotControllerImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HotspotControllerImplTest.java
@@ -70,11 +70,11 @@ public class HotspotControllerImplTest extends SysuiTestCase {
mContext.addMockSystemService(WifiManager.class, mWifiManager);
doAnswer((InvocationOnMock invocation) -> {
- ((WifiManager.SoftApCallback) invocation.getArgument(0))
+ ((WifiManager.SoftApCallback) invocation.getArgument(1))
.onConnectedClientsChanged(new ArrayList<>());
return null;
- }).when(mWifiManager).registerSoftApCallback(any(WifiManager.SoftApCallback.class),
- any(Executor.class));
+ }).when(mWifiManager).registerSoftApCallback(any(Executor.class),
+ any(WifiManager.SoftApCallback.class));
mController = new HotspotControllerImpl(mContext, new Handler(mLooper.getLooper()));
mController.handleSetListening(true);
@@ -85,7 +85,7 @@ public class HotspotControllerImplTest extends SysuiTestCase {
mController.addCallback(mCallback1);
mController.addCallback(mCallback2);
- verify(mWifiManager, times(1)).registerSoftApCallback(eq(mController), any());
+ verify(mWifiManager, times(1)).registerSoftApCallback(any(), eq(mController));
}
@Test
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 93960de89d89..d6e8d6aaa5ab 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -3351,7 +3351,7 @@ public class WifiManager {
/**
* 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
*/
@@ -3452,16 +3452,16 @@ public class WifiManager {
* without the permission will trigger a {@link java.lang.SecurityException}.
* <p>
*
- * @param callback Callback for soft AP events
* @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 callback Callback for soft AP events
*
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
- public void registerSoftApCallback(@NonNull SoftApCallback callback,
- @Nullable @CallbackExecutor Executor executor) {
+ public void registerSoftApCallback(@Nullable @CallbackExecutor Executor executor,
+ @NonNull SoftApCallback callback) {
if (callback == null) throw new IllegalArgumentException("callback cannot be null");
Log.v(TAG, "registerSoftApCallback: callback=" + callback + ", executor=" + executor);
diff --git a/wifi/tests/src/android/net/wifi/WifiManagerTest.java b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
index 17f3bb2b130b..1e9bc6081fa8 100644
--- a/wifi/tests/src/android/net/wifi/WifiManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
@@ -702,7 +702,7 @@ public class WifiManagerTest {
@Test
public void registerSoftApCallbackThrowsIllegalArgumentExceptionOnNullArgumentForCallback() {
try {
- mWifiManager.registerSoftApCallback(null, new HandlerExecutor(mHandler));
+ mWifiManager.registerSoftApCallback(new HandlerExecutor(mHandler), null);
fail("expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
@@ -726,7 +726,7 @@ public class WifiManagerTest {
@Test
public void registerSoftApCallbackUsesMainLooperOnNullArgumentForHandler() {
when(mContext.getMainLooper()).thenReturn(mLooper.getLooper());
- mWifiManager.registerSoftApCallback(mSoftApCallback, null);
+ mWifiManager.registerSoftApCallback(null, mSoftApCallback);
verify(mContext).getMainExecutor();
}
@@ -735,7 +735,7 @@ public class WifiManagerTest {
*/
@Test
public void registerSoftApCallbackCallGoesToWifiServiceImpl() throws Exception {
- mWifiManager.registerSoftApCallback(mSoftApCallback, new HandlerExecutor(mHandler));
+ mWifiManager.registerSoftApCallback(new HandlerExecutor(mHandler), mSoftApCallback);
verify(mWifiService).registerSoftApCallback(any(IBinder.class),
any(ISoftApCallback.Stub.class), anyInt());
}
@@ -746,7 +746,7 @@ public class WifiManagerTest {
@Test
public void unregisterSoftApCallbackCallGoesToWifiServiceImpl() throws Exception {
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),
any(ISoftApCallback.Stub.class), callbackIdentifier.capture());
@@ -761,7 +761,7 @@ public class WifiManagerTest {
public void softApCallbackProxyCallsOnStateChanged() throws Exception {
ArgumentCaptor<ISoftApCallback.Stub> callbackCaptor =
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(),
anyInt());
@@ -777,7 +777,7 @@ public class WifiManagerTest {
public void softApCallbackProxyCallsOnConnectedClientsChanged() throws Exception {
ArgumentCaptor<ISoftApCallback.Stub> callbackCaptor =
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(),
anyInt());
@@ -798,7 +798,7 @@ public class WifiManagerTest {
testSoftApInfo.setBandwidth(TEST_AP_BANDWIDTH);
ArgumentCaptor<ISoftApCallback.Stub> callbackCaptor =
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(),
anyInt());
@@ -817,7 +817,7 @@ public class WifiManagerTest {
testSoftApInfo.setBandwidth(TEST_AP_BANDWIDTH);
ArgumentCaptor<ISoftApCallback.Stub> callbackCaptor =
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(),
anyInt());
@@ -843,7 +843,7 @@ public class WifiManagerTest {
ArgumentCaptor.forClass(ISoftApCallback.Stub.class);
TestLooper altLooper = new TestLooper();
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(),
anyInt());
@@ -857,7 +857,7 @@ public class WifiManagerTest {
*/
@Test
public void testCorrectLooperIsUsedForSoftApCallbackHandler() throws Exception {
- mWifiManager.registerSoftApCallback(mSoftApCallback, new HandlerExecutor(mHandler));
+ mWifiManager.registerSoftApCallback(new HandlerExecutor(mHandler), mSoftApCallback);
mLooper.dispatchAll();
verify(mWifiService).registerSoftApCallback(any(IBinder.class),
any(ISoftApCallback.Stub.class), anyInt());