diff options
author | Roshan Pius <rpius@google.com> | 2019-10-25 12:35:58 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2019-10-26 14:47:18 -0700 |
commit | bda99994b4efd25d0b59af53ee10cceedc2b061c (patch) | |
tree | e929b2a5e5cce404a8352197e875398f5e2ca7b8 | |
parent | c8305dfa608b0e03e20a780dac0ff85945ef72b7 (diff) |
ActiveModeWarden: Remove redundant SoftApCallback
Bug: 139157226
Test: atest com.android.server.wifi
Change-Id: I3b31a5e2b1b054c6931e1c00d1f0a7a49e3fb201
-rw-r--r-- | service/java/com/android/server/wifi/ActiveModeWarden.java | 39 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java | 34 |
2 files changed, 3 insertions, 70 deletions
diff --git a/service/java/com/android/server/wifi/ActiveModeWarden.java b/service/java/com/android/server/wifi/ActiveModeWarden.java index 8209de91b..7539c18c6 100644 --- a/service/java/com/android/server/wifi/ActiveModeWarden.java +++ b/service/java/com/android/server/wifi/ActiveModeWarden.java @@ -25,7 +25,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.location.LocationManager; -import android.net.wifi.WifiClient; import android.net.wifi.WifiManager; import android.os.BatteryStats; import android.os.Handler; @@ -262,7 +261,9 @@ public class ActiveModeWarden { Preconditions.checkState(softApConfig.getTargetMode() == IFACE_IP_MODE_LOCAL_ONLY || softApConfig.getTargetMode() == IFACE_IP_MODE_TETHERED); - SoftApCallbackImpl callback = new SoftApCallbackImpl(softApConfig.getTargetMode()); + WifiManager.SoftApCallback callback = + softApConfig.getTargetMode() == IFACE_IP_MODE_LOCAL_ONLY + ? mLohsCallback : mSoftApCallback; SoftApListener listener = new SoftApListener(); ActiveModeManager manager = mWifiInjector.makeSoftApManager(listener, callback, softApConfig); @@ -413,40 +414,6 @@ public class ActiveModeWarden { } } - private class SoftApCallbackImpl implements WifiManager.SoftApCallback { - private final int mIpMode; - - SoftApCallbackImpl(int mode) { - Preconditions.checkArgument(mode == IFACE_IP_MODE_TETHERED - || mode == IFACE_IP_MODE_LOCAL_ONLY); - mIpMode = mode; - } - - @Override - public void onStateChanged(int state, int reason) { - switch (mIpMode) { - case IFACE_IP_MODE_TETHERED: - if (mSoftApCallback != null) mSoftApCallback.onStateChanged(state, reason); - break; - case IFACE_IP_MODE_LOCAL_ONLY: - if (mLohsCallback != null) mLohsCallback.onStateChanged(state, reason); - break; - } - } - - @Override - public void onConnectedClientsChanged(List<WifiClient> clients) { - switch (mIpMode) { - case IFACE_IP_MODE_TETHERED: - if (mSoftApCallback != null) mSoftApCallback.onConnectedClientsChanged(clients); - break; - case IFACE_IP_MODE_LOCAL_ONLY: - if (mLohsCallback != null) mLohsCallback.onConnectedClientsChanged(clients); - break; - } - } - } - private void updateBatteryStats() { updateBatteryStatsWifiState(hasAnyModeManager()); if (areAllClientModeManagersInScanOnlyRole()) { diff --git a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java index 8510807a8..f332ce272 100644 --- a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java @@ -644,23 +644,6 @@ public class ActiveModeWardenTest extends WifiBaseTest { } /** - * Verifies that triggering a state change update will not crash if the callback to - * WifiServiceImpl is null. - */ - @Test - public void testNullCallbackToWifiServiceImplForStateChange() throws Exception { - //set the callback to null - mActiveModeWarden.registerSoftApCallback(null); - - enterSoftApActiveMode(); - - mSoftApManagerCallback.onStateChanged(WifiManager.WIFI_AP_STATE_DISABLING, 0); - mLooper.dispatchAll(); - - verify(mSoftApStateMachineCallback, never()).onStateChanged(anyInt(), anyInt()); - } - - /** * Verifies that NumClientsChanged event is being passed from SoftApManager to WifiServiceImpl */ @Test @@ -674,23 +657,6 @@ public class ActiveModeWardenTest extends WifiBaseTest { } /** - * Verifies that triggering a number of clients changed update will not crash if the callback to - * WifiServiceImpl is null. - */ - @Test - public void testNullCallbackToWifiServiceImplForConnectedClientsChanged() throws Exception { - final List<WifiClient> testClients = new ArrayList(); - - //set the callback to null - mActiveModeWarden.registerSoftApCallback(null); - - enterSoftApActiveMode(); - mSoftApManagerCallback.onConnectedClientsChanged(testClients); - - verify(mSoftApStateMachineCallback, never()).onConnectedClientsChanged(any()); - } - - /** * Test that we remain in the active state when we get a state change update that scan mode is * active. */ |