Merge "Revert "Revert "CTS for timestamp in ScanResult""" into jb-mr1-dev
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/tech/MifareUltralightTagTester.java b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/tech/MifareUltralightTagTester.java
index 23f4762..038d276 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/tech/MifareUltralightTagTester.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/tech/MifareUltralightTagTester.java
@@ -29,7 +29,7 @@
  */
 public class MifareUltralightTagTester implements TagTester {
 
-    private static final int USER_PAGE_OFFSET = 4;
+    private static final int USER_PAGE_OFFSET = 5;
 
     private static final int NUM_PAGES = 4;
 
@@ -77,4 +77,4 @@
             }
         };
     }
-}
\ No newline at end of file
+}
diff --git a/suite/audio_quality/executable/src/main.cpp b/suite/audio_quality/executable/src/main.cpp
index 98dfabe..cf33a0f 100644
--- a/suite/audio_quality/executable/src/main.cpp
+++ b/suite/audio_quality/executable/src/main.cpp
@@ -61,7 +61,7 @@
         fprintf(stderr, "%s [-l log_level][-s serial] test_xml\n", argv[0]);
         return 1;
     }
-    int logLevel = 3;
+    int logLevel = Log::ELogE;
     char* serial = NULL;
     int opt;
     while ((opt = getopt(argc, argv, "l:s:")) != -1) {
diff --git a/suite/audio_quality/test_description/dut_speaker_calibration.xml b/suite/audio_quality/test_description/dut_speaker_calibration.xml
index f0ddf17..e0a613d 100644
--- a/suite/audio_quality/test_description/dut_speaker_calibration.xml
+++ b/suite/audio_quality/test_description/dut_speaker_calibration.xml
@@ -31,7 +31,7 @@
 			<sequential repeat="8" index="j">
 				<input device="host" id="host_in" gain="100" time="500" sync="complete" />
 				<!-- ------------moving average RMS        min for pass, max for pass                result calculated -->
-				<process method="builtin:rms_mva" input="id:host_in,consti:3000,consti:8000" output="val:rms_$i_$j" />
+				<process method="builtin:rms_mva" input="id:host_in,consti:1000,consti:8000" output="val:rms_$i_$j" />
 				<!-- <message input="val:passfail" output_low="Volume Low" output_ok="Volume OK" output_high="Volume High" /> -->
 			</sequential>
 		</sequential>
diff --git a/tests/core/ctscore.mk b/tests/core/ctscore.mk
index 049a58e..027d7c1 100644
--- a/tests/core/ctscore.mk
+++ b/tests/core/ctscore.mk
@@ -12,60 +12,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# First we build an apk without the core-tests resource
-cts_ORIGINAL_PACKAGE_NAME := $(LOCAL_PACKAGE_NAME)
-
-LOCAL_PACKAGE_NAME := $(LOCAL_PACKAGE_NAME).no-core-tests-res
-# Make sure this apk won't get installed
-LOCAL_UNINSTALLABLE_MODULE := true
-
 LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle
 LOCAL_PROGUARD_ENABLED := disabled
 LOCAL_DEX_PREOPT := false
 
-include $(BUILD_PACKAGE)
-# Vars set by $(BUILD_PACKAGE) and needed by the below module definition.
-cts_no-core-tests-res_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
-cts_no-core-tests-res_private_key := $(private_key)
-cts_no-core-tests-res_certificate := $(certificate)
-
-##################################
-# Now the rules to build the apk with core-tests resource
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := $(cts_ORIGINAL_PACKAGE_NAME)
-LOCAL_MODULE_CLASS := APPS
 # don't include these packages in any target
 LOCAL_MODULE_TAGS := optional
-# and when built explicitly put them in the data partition
+# and when installed explicitly put them in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
-LOCAL_BUILT_MODULE_STEM := package.apk
 
-include $(BUILD_SYSTEM)/base_rules.mk
-
-CORETESTS_INTERMEDIATES := $(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
-
-$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_COMMON := $(intermediates.COMMON)
-$(LOCAL_BUILT_MODULE): PRIVATE_CORETESTS_INTERMEDIATES_COMMON := $(CORETESTS_INTERMEDIATES)
-$(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(cts_no-core-tests-res_private_key)
-$(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(cts_no-core-tests-res_certificate)
-$(LOCAL_BUILT_MODULE): $(cts_no-core-tests-res_BUILT_MODULE) $(CORETESTS_INTERMEDIATES)/javalib.jar
-	@echo "Add resources to package ($@)"
-	$(hide) mkdir -p $(dir $@) $(PRIVATE_INTERMEDIATES_COMMON)
-	$(hide) rm -rf $(PRIVATE_INTERMEDIATES_COMMON)/ctsclasses
-	# javalib.jar should only contain .dex files, but the harmony tests also include
-	# some .class files, so get rid of them
-	$(hide) unzip -qo $(PRIVATE_CORETESTS_INTERMEDIATES_COMMON)/javalib.jar \
-		-d $(PRIVATE_INTERMEDIATES_COMMON)/ctsclasses
-	$(hide) find $(PRIVATE_INTERMEDIATES_COMMON)/ctsclasses -type f -name "*.class" -delete
-	$(hide) rm -f $(PRIVATE_INTERMEDIATES_COMMON)/ctsclasses/classes.dex
-	$(hide) cp $< $@
-	$(hide) jar uf $@ -C $(PRIVATE_INTERMEDIATES_COMMON)/ctsclasses .
-	$(sign-package)
-	$(align-package)
-
-# some global vars set in $(BUILD_PACKAGE), not sure if we really need here
-PACKAGES.$(cts_ORIGINAL_PACKAGE_NAME).PRIVATE_KEY := $(cts_no-core-tests-res_private_key)
-PACKAGES.$(cts_ORIGINAL_PACKAGE_NAME).CERTIFICATE := $(cts_no-core-tests-res_certificate)
-PACKAGES := $(PACKAGES) $(cts_ORIGINAL_PACKAGE_NAME)
+include $(BUILD_PACKAGE)
diff --git a/tests/core/libcore/com/Android.mk b/tests/core/libcore/com/Android.mk
index 91a5da0..02dc3de 100644
--- a/tests/core/libcore/com/Android.mk
+++ b/tests/core/libcore/com/Android.mk
@@ -19,7 +19,6 @@
 endif
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := ../src/Dummy.java
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.com
 LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/dalvik/Android.mk b/tests/core/libcore/dalvik/Android.mk
index 45f6e7e..7b77a75 100644
--- a/tests/core/libcore/dalvik/Android.mk
+++ b/tests/core/libcore/dalvik/Android.mk
@@ -19,7 +19,6 @@
 endif
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := ../src/Dummy.java
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.dalvik
 LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/libcore/Android.mk b/tests/core/libcore/libcore/Android.mk
index 97e32bc..382b386 100644
--- a/tests/core/libcore/libcore/Android.mk
+++ b/tests/core/libcore/libcore/Android.mk
@@ -19,7 +19,6 @@
 endif
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := ../src/Dummy.java
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.libcore
 LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/org/Android.mk b/tests/core/libcore/org/Android.mk
index 8fad8de..d7a96b3 100644
--- a/tests/core/libcore/org/Android.mk
+++ b/tests/core/libcore/org/Android.mk
@@ -19,7 +19,6 @@
 endif
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := ../src/Dummy.java
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.org
 LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/src/Dummy.java b/tests/core/libcore/src/Dummy.java
deleted file mode 100644
index 64b67de..0000000
--- a/tests/core/libcore/src/Dummy.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * We really just want the core-tests classes from the static java
- * library, but the build system currently needs at least one input
- * file, not just because its a sanity check, but because the static
- * class files and resources are included in the output of the local
- * java compilation.
- */
-public final class Dummy {}
diff --git a/tests/core/libcore/sun/Android.mk b/tests/core/libcore/sun/Android.mk
index 5fc0c48..44d3d70 100644
--- a/tests/core/libcore/sun/Android.mk
+++ b/tests/core/libcore/sun/Android.mk
@@ -19,7 +19,6 @@
 endif
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := ../src/Dummy.java
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.sun
 LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/tests/Android.mk b/tests/core/libcore/tests/Android.mk
index bcb6628..bfd235f 100644
--- a/tests/core/libcore/tests/Android.mk
+++ b/tests/core/libcore/tests/Android.mk
@@ -19,7 +19,6 @@
 endif
 
 include $(CLEAR_VARS)
-LOCAL_SRC_FILES := ../src/Dummy.java
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.tests
 LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/runner/Android.mk b/tests/core/runner/Android.mk
index 7658b7a..fb548fc 100644
--- a/tests/core/runner/Android.mk
+++ b/tests/core/runner/Android.mk
@@ -27,4 +27,6 @@
 
 LOCAL_PACKAGE_NAME := android.core.tests.runner
 
+LOCAL_STATIC_JAVA_LIBRARIES := core-tests
+
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java b/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java
index 3f28218..1df5011 100644
--- a/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java
+++ b/tests/tests/media/src/android/media/cts/CamcorderProfileTest.java
@@ -266,6 +266,7 @@
                 return true;
             }
         }
+        Log.e(TAG, "Size (" + width + "x" + height + ") is not supported");
         return false;
     }
 }
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
index 5fc23e7..a64477d 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -21,17 +21,22 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.net.NetworkInfo;
 import android.net.wifi.ScanResult;
 import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiManager;
 import android.net.wifi.WifiConfiguration.Status;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiManager.TxPacketCountListener;
 import android.net.wifi.WifiManager.WifiLock;
 import android.test.AndroidTestCase;
 import android.util.Log;
 
+import java.net.HttpURLConnection;
+import java.net.URL;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
 
 public class WifiManagerTest extends AndroidTestCase {
     private static class MySync {
@@ -42,6 +47,7 @@
     private WifiLock mWifiLock;
     private static MySync mMySync;
     private List<ScanResult> mScanResult = null;
+    private NetworkInfo mNetworkInfo;
 
     // Please refer to WifiManager
     private static final int MIN_RSSI = -100;
@@ -78,6 +84,13 @@
                     mMySync.expectedState = STATE_WIFI_CHANGED;
                     mMySync.notify();
                 }
+            } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
+                synchronized (mMySync) {
+                    mNetworkInfo =
+                            (NetworkInfo) intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
+                    if (mNetworkInfo.getState() == NetworkInfo.State.CONNECTED)
+                        mMySync.notify();
+                }
             }
         }
     };
@@ -148,6 +161,18 @@
         }
     }
 
+    private void connectWifi() throws Exception {
+        synchronized (mMySync) {
+            if (mNetworkInfo.getState() == NetworkInfo.State.CONNECTED) return;
+            assertTrue(mWifiManager.reconnect());
+            long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
+            while (System.currentTimeMillis() < timeout
+                    && mNetworkInfo.getState() != NetworkInfo.State.CONNECTED)
+                mMySync.wait(WAIT_MSEC);
+            assertTrue(mNetworkInfo.getState() == NetworkInfo.State.CONNECTED);
+        }
+    }
+
     private boolean existSSID(String ssid) {
         for (final WifiConfiguration w : mWifiManager.getConfiguredNetworks()) {
             if (w.SSID.equals(ssid))
@@ -339,4 +364,65 @@
         rssiB = 4;
         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 {
+        // Make sure WiFi is enabled
+        if (!mWifiManager.isWifiEnabled()) {
+            setWifiEnabled(true);
+            Thread.sleep(DURATION);
+        }
+        assertTrue(mWifiManager.isWifiEnabled());
+
+        // 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();
+        assertTrue(txcount2 > txcount1);
+    }
 }
diff --git a/tests/tests/text/src/android/text/cts/AutoTextTest.java b/tests/tests/text/src/android/text/cts/AutoTextTest.java
index 1f2d1da..cbea4d9 100644
--- a/tests/tests/text/src/android/text/cts/AutoTextTest.java
+++ b/tests/tests/text/src/android/text/cts/AutoTextTest.java
@@ -20,6 +20,7 @@
 import android.test.AndroidTestCase;
 import android.text.AutoText;
 import android.view.View;
+import android.content.res.Configuration;
 
 public class AutoTextTest extends AndroidTestCase {
 
@@ -30,6 +31,11 @@
 
         // set local as English.
         Locale.setDefault(Locale.ENGLISH);
+        Configuration config = getContext().getResources().getConfiguration();
+        if (!config.locale.equals(Locale.getDefault())) {
+                config.locale = Locale.getDefault();
+                getContext().getResources().updateConfiguration(config, null);
+        }
         // New a View instance.
         View view = new View(getContext());
 
@@ -71,6 +77,11 @@
 
     public void testGetSize() {
         Locale.setDefault(Locale.ENGLISH);
+        Configuration config = getContext().getResources().getConfiguration();
+        if (!config.locale.equals(Locale.getDefault())) {
+                config.locale = Locale.getDefault();
+                getContext().getResources().updateConfiguration(config, null);
+        }
         View view = new View(getContext());
         // Returns the size of the auto text dictionary. Just make sure it is bigger than 0.
         assertTrue(AutoText.getSize(view) > 0);
diff --git a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
index 1907ac7..25e6306 100644
--- a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
+++ b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
@@ -52,9 +52,9 @@
                 DateUtils.getDayOfWeekString(Calendar.SUNDAY, DateUtils.LENGTH_LONG));
         assertEquals("Sun",
                 DateUtils.getDayOfWeekString(Calendar.SUNDAY, DateUtils.LENGTH_MEDIUM));
-        assertEquals("Su",
+        assertEquals("Sun",
                 DateUtils.getDayOfWeekString(Calendar.SUNDAY, DateUtils.LENGTH_SHORT));
-        assertEquals("Su",
+        assertEquals("Sun",
                 DateUtils.getDayOfWeekString(Calendar.SUNDAY, DateUtils.LENGTH_SHORTER));
         assertEquals("S",
                 DateUtils.getDayOfWeekString(Calendar.SUNDAY, DateUtils.LENGTH_SHORTEST));
@@ -83,8 +83,8 @@
         if (!LocaleUtils.isCurrentLocale(mContext, Locale.US)) {
             return;
         }
-        assertEquals("am", DateUtils.getAMPMString(Calendar.AM));
-        assertEquals("pm", DateUtils.getAMPMString(Calendar.PM));
+        assertEquals("AM", DateUtils.getAMPMString(Calendar.AM));
+        assertEquals("PM", DateUtils.getAMPMString(Calendar.PM));
     }
 
 
@@ -169,7 +169,7 @@
                 + HOUR_DURATION, DateUtils.FORMAT_SHOW_WEEKDAY));
         assertEquals("January 19", DateUtils.formatDateRange(mContext, timeWithCurrentYear,
                 timeWithCurrentYear + HOUR_DURATION, DateUtils.FORMAT_SHOW_DATE));
-        assertEquals("3:30am", DateUtils.formatDateRange(mContext, fixedTime, fixedTime,
+        assertEquals("3:30AM", DateUtils.formatDateRange(mContext, fixedTime, fixedTime,
                 DateUtils.FORMAT_SHOW_TIME));
         assertEquals("January 19, 2009", DateUtils.formatDateRange(mContext, fixedTime,
                 fixedTime + HOUR_DURATION, DateUtils.FORMAT_SHOW_YEAR));
@@ -177,7 +177,7 @@
                 timeWithCurrentYear + HOUR_DURATION, DateUtils.FORMAT_NO_YEAR));
         assertEquals("January", DateUtils.formatDateRange(mContext, timeWithCurrentYear,
                 timeWithCurrentYear + HOUR_DURATION, DateUtils.FORMAT_NO_MONTH_DAY));
-        assertEquals("3:30am", DateUtils.formatDateRange(mContext, fixedTime, fixedTime,
+        assertEquals("3:30AM", DateUtils.formatDateRange(mContext, fixedTime, fixedTime,
                 DateUtils.FORMAT_12HOUR | DateUtils.FORMAT_SHOW_TIME));
         assertEquals("03:30", DateUtils.formatDateRange(mContext, fixedTime, fixedTime,
                 DateUtils.FORMAT_24HOUR | DateUtils.FORMAT_SHOW_TIME));
@@ -188,14 +188,14 @@
         assertEquals("Noon", DateUtils.formatDateRange(mContext, fixedTime + noonDuration,
                 fixedTime + noonDuration,
                 DateUtils.FORMAT_12HOUR | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_CAP_NOON));
-        assertEquals("12:00pm", DateUtils.formatDateRange(mContext, fixedTime + noonDuration,
+        assertEquals("12:00PM", DateUtils.formatDateRange(mContext, fixedTime + noonDuration,
                 fixedTime + noonDuration,
                 DateUtils.FORMAT_12HOUR | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_SHOW_TIME));
-        assertEquals("12:00am", DateUtils.formatDateRange(mContext, fixedTime - midnightDuration,
+        assertEquals("12:00AM", DateUtils.formatDateRange(mContext, fixedTime - midnightDuration,
                 fixedTime - midnightDuration,
                 DateUtils.FORMAT_12HOUR | DateUtils.FORMAT_SHOW_TIME
                 | DateUtils.FORMAT_NO_MIDNIGHT));
-        assertEquals("3:30am", DateUtils.formatDateRange(mContext, fixedTime, fixedTime,
+        assertEquals("3:30AM", DateUtils.formatDateRange(mContext, fixedTime, fixedTime,
                 DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_UTC));
         assertEquals("3am", DateUtils.formatDateRange(mContext, fixedTime - integralDuration,
                 fixedTime - integralDuration,
diff --git a/tests/tests/view/src/android/view/cts/ViewTest.java b/tests/tests/view/src/android/view/cts/ViewTest.java
index 4387564..288552d 100644
--- a/tests/tests/view/src/android/view/cts/ViewTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewTest.java
@@ -61,7 +61,7 @@
 import android.view.ViewConfiguration;
 import android.view.ViewGroup;
 import android.view.ViewParent;
-import android.view.WindowManagerImpl;
+import android.view.WindowManager;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.animation.AlphaAnimation;
 import android.view.animation.Animation;
@@ -2730,7 +2730,8 @@
         Rect outRect = new Rect();
         View view = new View(mActivity);
         // mAttachInfo is null
-        Display d = WindowManagerImpl.getDefault().getDefaultDisplay();
+        WindowManager wm = (WindowManager)mActivity.getSystemService(Context.WINDOW_SERVICE);
+        Display d = wm.getDefaultDisplay();
         view.getWindowVisibleDisplayFrame(outRect);
         assertEquals(0, outRect.left);
         assertEquals(0, outRect.top);
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
index 1bc8a4f..054217e 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
@@ -235,9 +235,6 @@
         Thread.sleep(100); // Wait for open to be received on the icon db thread.
         assertEquals(WebSettings.LOAD_DEFAULT, mSettings.getCacheMode());
 
-        mSettings.setCacheMode(WebSettings.LOAD_NORMAL);
-        assertEquals(WebSettings.LOAD_NORMAL, mSettings.getCacheMode());
-
         mSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
         assertEquals(WebSettings.LOAD_CACHE_ELSE_NETWORK, mSettings.getCacheMode());
         final IconListenerClient iconListener = new IconListenerClient();
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
index 78f7412..a79b84e 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
@@ -51,6 +51,7 @@
 import java.lang.System;
 import java.lang.Thread;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -148,6 +149,9 @@
             "Interval between each reboot in min. Meaningful only with reboot-per-package option")
     private int mRebootIntervalMin = 30;
 
+
+    private long mPrevRebootTime; // last reboot time
+
     /** data structure for a {@link IRemoteTest} and its known tests */
     class TestPackage {
         private final IRemoteTest mTestForPackage;
@@ -350,8 +354,8 @@
                 Log.i(LOG_TAG, "Initial reboot for multiple packages");
                 rebootDevice();
             }
-            long prevTime = System.currentTimeMillis();
-            long intervalInMSec = mRebootIntervalMin * 60 * 1000;
+            mPrevRebootTime = System.currentTimeMillis();
+
             while (!mRemainingTestPkgs.isEmpty()) {
                 TestPackage knownTests = mRemainingTestPkgs.get(0);
 
@@ -367,15 +371,7 @@
                 test.run(filter);
                 mRemainingTestPkgs.remove(0);
                 if (mRemainingTestPkgs.size() > 0) {
-                    if (mRebootPerPackage) {
-                        long currentTime = System.currentTimeMillis();
-                        if ((currentTime - prevTime) > intervalInMSec) {
-                            Log.i(LOG_TAG, String.format("Rebooting after running package %s",
-                                    knownTests.getPackageDef().getName()));
-                            rebootDevice();
-                            prevTime = System.currentTimeMillis();
-                        }
-                    }
+                    rebootIfNecessary(knownTests, mRemainingTestPkgs.get(0));
                     // remove artifacts like status bar from the previous test.
                     // But this cannot dismiss dialog popped-up.
                     changeToHomeScreen();
@@ -398,6 +394,33 @@
         }
     }
 
+    private void rebootIfNecessary(TestPackage testFinished, TestPackage testToRun)
+            throws DeviceNotAvailableException {
+        // If there comes spurious failure like INJECT_EVENTS for a package,
+        // reboot it before running it.
+        // Also reboot after package which is know to leave pop-up behind
+        final List<String> rebootAfterList = Arrays.asList("CtsWebkitSecurityTestCases");
+        final List<String> rebootBeforeList = Arrays.asList("CtsAnimationTestCases",
+                "CtsGraphicsTestCases",
+                "CtsViewTestCases",
+                "CtsWebkitSecurityTestCases",
+                "CtsWidgetTestCases" );
+        long intervalInMSec = mRebootIntervalMin * 60 * 1000;
+        if (mRebootPerPackage) {
+            long currentTime = System.currentTimeMillis();
+            if (((currentTime - mPrevRebootTime) > intervalInMSec) ||
+                    rebootAfterList.contains(testFinished.getPackageDef().getName()) ||
+                    rebootBeforeList.contains(testToRun.getPackageDef().getName()) ) {
+                Log.i(LOG_TAG,
+                        String.format("Rebooting after running package %s, before package %s",
+                                testFinished.getPackageDef().getName(),
+                                testToRun.getPackageDef().getName()));
+                rebootDevice();
+                mPrevRebootTime = System.currentTimeMillis();
+            }
+        }
+    }
+
     private void rebootDevice() throws DeviceNotAvailableException {
         final int TIMEOUT_MS = 4 * 60 * 1000;
         TestDeviceOptions options = mDevice.getOptions();
diff --git a/tools/utils/buildCts.py b/tools/utils/buildCts.py
index 60c9084..ada706c 100755
--- a/tools/utils/buildCts.py
+++ b/tools/utils/buildCts.py
@@ -124,6 +124,19 @@
     plan.Include(r'android\.tests\.appsecurity')
     self.__WritePlan(plan, 'AppSecurity')
 
+    # hard-coded white list for PDK plan
+    plan.Exclude('.*')
+    plan.Include('android\.bluetooth')
+    plan.Include('android\.graphics.*')
+    plan.Include('android\.hardware')
+    plan.Include('android\.media.*')
+    plan.Include('android\.net')
+    plan.Include('android\.opengl.*')
+    plan.Include('android\.renderscript')
+    plan.Include('android\.telephony')
+    plan.Include('android\.nativemedia.*')
+    self.__WritePlan(plan, 'PDK')
+
 def LogGenerateDescription(name):
   print 'Generating test description for package %s' % name
 
diff --git a/tools/vm-tests-tf/Android.mk b/tools/vm-tests-tf/Android.mk
index 07a3cf8..1bb79b3 100644
--- a/tools/vm-tests-tf/Android.mk
+++ b/tools/vm-tests-tf/Android.mk
@@ -42,6 +42,7 @@
 
 include $(CLEAR_VARS)
 
+LOCAL_UNINSTALLABLE_MODULE := true
 LOCAL_IS_HOST_MODULE := true
 LOCAL_MODULE_CLASS := EXECUTABLES
 LOCAL_MODULE := vm-tests-tf
@@ -70,7 +71,7 @@
 # generated and compile the host side junit tests
 	$(hide) java -cp $(subst $(space),$(colon),$^):$(HOST_JDK_TOOLS_JAR) util.build.BuildDalvikSuite $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) $<:$(PRIVATE_LIB_FOLDER)/junit.jar:$(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar $(PRIVATE_INTERMEDIATES_MAIN_FILES) $(TF_BUILD_UTIL_INTERMEDIATES_CLASSES) $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES) $$RUN_VM_TESTS_RTO
 	@echo "wrote generated Main_*.java files to $(PRIVATE_INTERMEDIATES_MAIN_FILES)"
-INSTALLED_TESTS := $(dir $(LOCAL_INSTALLED_MODULE))../cts_dalviktests_tf/timestamp
+INSTALLED_TESTS := $(dir $(LOCAL_BUILT_MODULE))../cts_dalviktests_tf/timestamp
 
 $(LOCAL_BUILT_MODULE):  $(INSTALLED_TESTS)