diff --git a/tests/cts/net/src/android/net/wifi/cts/ScanResultTest.java b/tests/cts/net/src/android/net/wifi/cts/ScanResultTest.java
index c9b82ee..26cfff8 100644
--- a/tests/cts/net/src/android/net/wifi/cts/ScanResultTest.java
+++ b/tests/cts/net/src/android/net/wifi/cts/ScanResultTest.java
@@ -26,7 +26,6 @@
 import android.net.wifi.WifiManager;
 import android.net.wifi.WifiManager.WifiLock;
 import android.test.AndroidTestCase;
-import android.util.Log;
 
 public class ScanResultTest extends AndroidTestCase {
     private static class MySync {
@@ -40,14 +39,11 @@
     private static final int STATE_NULL = 0;
     private static final int STATE_WIFI_CHANGING = 1;
     private static final int STATE_WIFI_CHANGED = 2;
-    private static final int STATE_START_SCAN = 3;
-    private static final int STATE_SCAN_RESULTS_AVAILABLE = 4;
 
     private static final String TAG = "WifiInfoTest";
     private static final int TIMEOUT_MSEC = 6000;
     private static final int WAIT_MSEC = 60;
-    private static final int ENABLE_WAIT_MSEC = 10000;
-    private static final int SCAN_WAIT_MSEC = 10000;
+    private static final int DURATION = 10000;
     private IntentFilter mIntentFilter;
     private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
         @Override
@@ -58,11 +54,6 @@
                     mMySync.expectedState = STATE_WIFI_CHANGED;
                     mMySync.notify();
                 }
-            } else if (action.equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) {
-                synchronized (mMySync) {
-                    mMySync.expectedState = STATE_SCAN_RESULTS_AVAILABLE;
-                    mMySync.notify();
-                }
             }
         }
     };
@@ -92,7 +83,7 @@
         mWifiLock.acquire();
         if (!mWifiManager.isWifiEnabled())
             setWifiEnabled(true);
-        Thread.sleep(ENABLE_WAIT_MSEC);
+        Thread.sleep(DURATION);
         assertTrue(mWifiManager.isWifiEnabled());
         mMySync.expectedState = STATE_NULL;
     }
@@ -108,7 +99,7 @@
         mContext.unregisterReceiver(mReceiver);
         if (!mWifiManager.isWifiEnabled())
             setWifiEnabled(true);
-        Thread.sleep(ENABLE_WAIT_MSEC);
+        Thread.sleep(DURATION);
         super.tearDown();
     }
 
@@ -116,15 +107,11 @@
         synchronized (mMySync) {
             mMySync.expectedState = STATE_WIFI_CHANGING;
             assertTrue(mWifiManager.setWifiEnabled(enable));
-            waitForBroadcast(TIMEOUT_MSEC, STATE_WIFI_CHANGED);
-       }
-    }
-
-    private void waitForBroadcast(long timeout, int expectedState) throws Exception {
-        long waitTime = System.currentTimeMillis() + timeout;
-        while (System.currentTimeMillis() < waitTime
-                && mMySync.expectedState != expectedState)
-            mMySync.wait(WAIT_MSEC);
+            long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
+            while (System.currentTimeMillis() < timeout
+                    && mMySync.expectedState == STATE_WIFI_CHANGING)
+                mMySync.wait(WAIT_MSEC);
+        }
     }
 
     public void testScanResultProperties() {
@@ -140,49 +127,4 @@
         }
     }
 
-    private void scanAndWait() throws Exception {
-        synchronized (mMySync) {
-            mMySync.expectedState = STATE_START_SCAN;
-            mWifiManager.startScan();
-            waitForBroadcast(SCAN_WAIT_MSEC, STATE_SCAN_RESULTS_AVAILABLE);
-        }
-   }
-
-    public void testScanResultTimeStamp() throws Exception {
-        if (!WifiFeature.isWifiSupported(getContext())) {
-            // skip the test if WiFi is not supported
-            return;
-        }
-
-        long timestamp = 0;
-        String BSSID = null;
-
-        /* Multiple scans to ensure bssid is updated */
-        scanAndWait();
-        scanAndWait();
-        scanAndWait();
-
-        List<ScanResult> scanResults = mWifiManager.getScanResults();
-        for (ScanResult result : scanResults) {
-            BSSID = result.BSSID;
-            timestamp = result.timestamp;
-            assertTrue(timestamp != 0);
-            break;
-        }
-
-        scanAndWait();
-        scanAndWait();
-        scanAndWait();
-
-        scanResults = mWifiManager.getScanResults();
-        for (ScanResult result : scanResults) {
-            if (result.BSSID.equals(BSSID)) {
-                long timeDiff = (result.timestamp - timestamp) / 1000;
-                assertTrue (timeDiff > 0);
-                assertTrue (timeDiff < 6 * SCAN_WAIT_MSEC);
-            }
-        }
-
-    }
-
 }
