From 8d78ed903562038aa3fff47337aeef5416858750 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Sun, 24 Nov 2019 10:10:17 -0800 Subject: [WIFI][MAINLINE] Transition WificondControl interfaces: SignalPollResult, TxPacketCounters Transition WificondControl public interfaces to that class itself. Preparation for the class being extracted to an official API. Classes shifted: SignalPollResult, TxPacketCounters Bug: 140062898 Test: atest android.net.wifi Test: atest com.android.server.wifi Change-Id: Id59bff14ad9a58a182121b49af27ab0544ed1d42 --- .../com/android/server/wifi/ClientModeImpl.java | 4 +-- .../java/com/android/server/wifi/WifiNative.java | 27 ++---------------- .../com/android/server/wifi/WificondControl.java | 32 +++++++++++++++++++--- .../android/server/wifi/ClientModeImplTest.java | 2 +- .../com/android/server/wifi/WifiNativeTest.java | 10 +++---- 5 files changed, 38 insertions(+), 37 deletions(-) diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index f358e9acd..043f242c8 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -2233,7 +2233,7 @@ public class ClientModeImpl extends StateMachine { * Fetch RSSI, linkspeed, and frequency on current connection */ private void fetchRssiLinkSpeedAndFrequencyNative() { - WifiNative.SignalPollResult pollResult = mWifiNative.signalPoll(mInterfaceName); + WificondControl.SignalPollResult pollResult = mWifiNative.signalPoll(mInterfaceName); if (pollResult == null) { return; } @@ -4460,7 +4460,7 @@ public class ClientModeImpl extends StateMachine { break; case CMD_PKT_CNT_FETCH: callbackIdentifier = message.arg2; - WifiNative.TxPacketCounters counters = + WificondControl.TxPacketCounters counters = mWifiNative.getTxPacketCounters(mInterfaceName); if (counters != null) { sendTxPacketCountListenerSuccess( diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 7729d6157..73d072cbe 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -1310,29 +1310,6 @@ public class WifiNative { /******************************************************** * Wificond operations ********************************************************/ - /** - * Result of a signal poll. - */ - public static class SignalPollResult { - // RSSI value in dBM. - public int currentRssi; - //Transmission bit rate in Mbps. - public int txBitrate; - // Association frequency in MHz. - public int associationFrequency; - //Last received packet bit rate in Mbps. - public int rxBitrate; - } - - /** - * WiFi interface transimission counters. - */ - public static class TxPacketCounters { - // Number of successfully transmitted packets. - public int txSucceeded; - // Number of tramsmission failures. - public int txFailed; - } /** * Callback to notify wificond death. @@ -1351,7 +1328,7 @@ public class WifiNative { * Returns an SignalPollResult object. * Returns null on failure. */ - public SignalPollResult signalPoll(@NonNull String ifaceName) { + public WificondControl.SignalPollResult signalPoll(@NonNull String ifaceName) { return mWificondControl.signalPoll(ifaceName); } @@ -1361,7 +1338,7 @@ public class WifiNative { * Returns an TxPacketCounters object. * Returns null on failure. */ - public TxPacketCounters getTxPacketCounters(@NonNull String ifaceName) { + public WificondControl.TxPacketCounters getTxPacketCounters(@NonNull String ifaceName) { return mWificondControl.getTxPacketCounters(ifaceName); } diff --git a/service/java/com/android/server/wifi/WificondControl.java b/service/java/com/android/server/wifi/WificondControl.java index 6141b7b13..ee56aa440 100644 --- a/service/java/com/android/server/wifi/WificondControl.java +++ b/service/java/com/android/server/wifi/WificondControl.java @@ -129,6 +129,30 @@ public class WificondControl implements IBinder.DeathRecipient { } } + /** + * Result of a signal poll. + */ + public static class SignalPollResult { + // RSSI value in dBM. + public int currentRssi; + //Transmission bit rate in Mbps. + public int txBitrate; + // Association frequency in MHz. + public int associationFrequency; + //Last received packet bit rate in Mbps. + public int rxBitrate; + } + + /** + * WiFi interface transimission counters. + */ + public static class TxPacketCounters { + // Number of successfully transmitted packets. + public int txSucceeded; + // Number of tramsmission failures. + public int txFailed; + } + WificondControl(WifiInjector wifiInjector, WifiMonitor wifiMonitor, CarrierNetworkConfig carrierNetworkConfig, AlarmManager alarmManager, Handler handler, Clock clock) { @@ -505,7 +529,7 @@ public class WificondControl implements IBinder.DeathRecipient { * Returns an SignalPollResult object. * Returns null on failure. */ - public WifiNative.SignalPollResult signalPoll(@NonNull String ifaceName) { + public SignalPollResult signalPoll(@NonNull String ifaceName) { IClientInterface iface = getClientInterface(ifaceName); if (iface == null) { Log.e(TAG, "No valid wificond client interface handler"); @@ -523,7 +547,7 @@ public class WificondControl implements IBinder.DeathRecipient { Log.e(TAG, "Failed to do signal polling due to remote exception"); return null; } - WifiNative.SignalPollResult pollResult = new WifiNative.SignalPollResult(); + SignalPollResult pollResult = new SignalPollResult(); pollResult.currentRssi = resultArray[0]; pollResult.txBitrate = resultArray[1]; pollResult.associationFrequency = resultArray[2]; @@ -537,7 +561,7 @@ public class WificondControl implements IBinder.DeathRecipient { * Returns an TxPacketCounters object. * Returns null on failure. */ - public WifiNative.TxPacketCounters getTxPacketCounters(@NonNull String ifaceName) { + public TxPacketCounters getTxPacketCounters(@NonNull String ifaceName) { IClientInterface iface = getClientInterface(ifaceName); if (iface == null) { Log.e(TAG, "No valid wificond client interface handler"); @@ -555,7 +579,7 @@ public class WificondControl implements IBinder.DeathRecipient { Log.e(TAG, "Failed to do signal polling due to remote exception"); return null; } - WifiNative.TxPacketCounters counters = new WifiNative.TxPacketCounters(); + TxPacketCounters counters = new TxPacketCounters(); counters.txSucceeded = resultArray[0]; counters.txFailed = resultArray[1]; return counters; diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java index 61ca10e53..0e72a31a0 100644 --- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java @@ -2579,7 +2579,7 @@ public class ClientModeImplTest extends WifiBaseTest { WifiLinkLayerStats llStats = new WifiLinkLayerStats(); llStats.txmpdu_be = 1000; llStats.rxmpdu_bk = 2000; - WifiNative.SignalPollResult signalPollResult = new WifiNative.SignalPollResult(); + WificondControl.SignalPollResult signalPollResult = new WificondControl.SignalPollResult(); signalPollResult.currentRssi = -42; signalPollResult.txBitrate = 65; signalPollResult.associationFrequency = sFreq; diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java index 95d4d15ef..726dadda6 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeTest.java @@ -114,15 +114,15 @@ public class WifiNativeTest extends WifiBaseTest { new FateMapping(WifiLoggerHal.RX_PKT_FATE_DRV_DROP_OTHER, "driver dropped (other)"), new FateMapping((byte) 42, "42") }; - private static final WifiNative.SignalPollResult SIGNAL_POLL_RESULT = - new WifiNative.SignalPollResult() {{ + private static final WificondControl.SignalPollResult SIGNAL_POLL_RESULT = + new WificondControl.SignalPollResult() {{ currentRssi = -60; txBitrate = 12; associationFrequency = 5240; rxBitrate = 6; }}; - private static final WifiNative.TxPacketCounters PACKET_COUNTERS_RESULT = - new WifiNative.TxPacketCounters() {{ + private static final WificondControl.TxPacketCounters PACKET_COUNTERS_RESULT = + new WificondControl.TxPacketCounters() {{ txSucceeded = 2000; txFailed = 120; }}; @@ -518,7 +518,7 @@ public class WifiNativeTest extends WifiBaseTest { when(mWificondControl.signalPoll(WIFI_IFACE_NAME)) .thenReturn(SIGNAL_POLL_RESULT); - WifiNative.SignalPollResult pollResult = mWifiNative.signalPoll(WIFI_IFACE_NAME); + WificondControl.SignalPollResult pollResult = mWifiNative.signalPoll(WIFI_IFACE_NAME); assertEquals(SIGNAL_POLL_RESULT.currentRssi, pollResult.currentRssi); assertEquals(SIGNAL_POLL_RESULT.txBitrate, pollResult.txBitrate); assertEquals(SIGNAL_POLL_RESULT.associationFrequency, pollResult.associationFrequency); -- cgit v1.2.3