Merge changes from topic "cts-wifimanagertest-hide-apis"

* changes:
  Remove WifiManager CTS test using TxPacketCountListener
  CtsNetTestCases: fix Wifi @hide usages
diff --git a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java
index 3a01d11..a05679e 100644
--- a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -32,11 +32,7 @@
 import android.net.wifi.SoftApConfiguration;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiManager;
-import android.net.wifi.WifiManager.TxPacketCountListener;
 import android.net.wifi.WifiManager.WifiLock;
-import android.net.wifi.hotspot2.PasspointConfiguration;
-import android.net.wifi.hotspot2.pps.Credential;
-import android.net.wifi.hotspot2.pps.HomeSp;
 import android.os.Process;
 import android.os.SystemClock;
 import android.os.UserHandle;
@@ -52,18 +48,11 @@
 
 import com.android.compatibility.common.util.SystemUtil;
 
-import java.lang.StringBuilder;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.security.MessageDigest;
-import java.security.cert.X509Certificate;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 @AppModeFull(reason = "Cannot get WifiManager in instant app mode")
@@ -232,21 +221,14 @@
 
     // Get the current scan status from sticky broadcast.
     private boolean isScanCurrentlyAvailable() {
-        boolean isAvailable = false;
         IntentFilter intentFilter = new IntentFilter();
-        intentFilter.addAction(WifiManager.WIFI_SCAN_AVAILABLE);
+        intentFilter.addAction(WifiManager.ACTION_WIFI_SCAN_AVAILABLE);
         Intent intent = mContext.registerReceiver(null, intentFilter);
         assertNotNull(intent);
-        if (intent.getAction().equals(WifiManager.WIFI_SCAN_AVAILABLE)) {
-            int state = intent.getIntExtra(
-                    WifiManager.EXTRA_SCAN_AVAILABLE, WifiManager.WIFI_STATE_UNKNOWN);
-            if (state == WifiManager.WIFI_STATE_ENABLED) {
-                isAvailable = true;
-            } else if (state == WifiManager.WIFI_STATE_DISABLED) {
-                isAvailable = false;
-            }
+        if (intent.getAction().equals(WifiManager.ACTION_WIFI_SCAN_AVAILABLE)) {
+            return intent.getBooleanExtra(WifiManager.EXTRA_SCAN_AVAILABLE, false);
         }
-        return isAvailable;
+        return false;
     }
 
     private void startScan() throws Exception {
@@ -441,90 +423,6 @@
         assertTrue(WifiManager.compareSignalLevel(rssiA, rssiB) > 0);
     }
 
-    private int getTxPacketCount() throws Exception {
-        final AtomicInteger ret = new AtomicInteger(-1);
-
-        mWifiManager.getTxPacketCount(new TxPacketCountListener() {
-            @Override
-            public void onSuccess(int count) {
-                ret.set(count);
-            }
-            @Override
-            public void onFailure(int reason) {
-                ret.set(0);
-            }
-        });
-
-        long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
-        while (ret.get() < 0 && System.currentTimeMillis() < timeout)
-            Thread.sleep(WAIT_MSEC);
-        assertTrue(ret.get() >= 0);
-        return ret.get();
-    }
-
-    /**
-     * The new WiFi watchdog requires kernel/driver to export some packet loss
-     * counters. This CTS tests whether those counters are correctly exported.
-     * To pass this CTS test, a connected WiFi link is required.
-     */
-    public void testWifiWatchdog() throws Exception {
-        if (!WifiFeature.isWifiSupported(getContext())) {
-            // skip the test if WiFi is not supported
-            return;
-        }
-        // Make sure WiFi is enabled
-        if (!mWifiManager.isWifiEnabled()) {
-            setWifiEnabled(true);
-            Thread.sleep(DURATION);
-        }
-        assertTrue(mWifiManager.isWifiEnabled());
-
-        // give the test a chance to autoconnect
-        Thread.sleep(DURATION);
-        if (mNetworkInfo.getState() != NetworkInfo.State.CONNECTED) {
-            // this test requires a connectable network be configured
-            fail("This test requires a wifi network connection.");
-        }
-
-        // This will generate a distinct stack trace if the initial connection fails.
-        connectWifi();
-
-        int i = 0;
-        for (; i < 15; i++) {
-            // Wait for a WiFi connection
-            connectWifi();
-
-            // Read TX packet counter
-            int txcount1 = getTxPacketCount();
-
-            // Do some network operations
-            HttpURLConnection connection = null;
-            try {
-                URL url = new URL("http://www.google.com/");
-                connection = (HttpURLConnection) url.openConnection();
-                connection.setInstanceFollowRedirects(false);
-                connection.setConnectTimeout(TIMEOUT_MSEC);
-                connection.setReadTimeout(TIMEOUT_MSEC);
-                connection.setUseCaches(false);
-                connection.getInputStream();
-            } catch (Exception e) {
-                // ignore
-            } finally {
-                if (connection != null) connection.disconnect();
-            }
-
-            // Read TX packet counter again and make sure it increases
-            int txcount2 = getTxPacketCount();
-
-            if (txcount2 > txcount1) {
-                break;
-            } else {
-                Thread.sleep(DURATION);
-            }
-        }
-        assertTrue(i < 15);
-    }
-
     private static class TestLocalOnlyHotspotCallback extends WifiManager.LocalOnlyHotspotCallback {
         Object hotspotLock;
         WifiManager.LocalOnlyHotspotReservation reservation = null;
diff --git a/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java b/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java
index f71cadb..44a9cc2 100644
--- a/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java
+++ b/tests/cts/net/src/android/net/wifi/rtt/cts/WifiRttTest.java
@@ -16,6 +16,8 @@
 
 package android.net.wifi.rtt.cts;
 
+import static org.mockito.Mockito.mock;
+
 import android.net.wifi.ScanResult;
 import android.net.wifi.rtt.RangingRequest;
 import android.net.wifi.rtt.RangingResult;
@@ -185,7 +187,7 @@
             return;
         }
 
-        ScanResult dummy = new ScanResult();
+        ScanResult dummy = mock(ScanResult.class);
         dummy.BSSID = "00:01:02:03:04:05";
 
         RangingRequest.Builder builder = new RangingRequest.Builder();