Merge "Fix CTS failures on fugu" into nyc-dev
diff --git a/apps/CameraITS/pymodules/its/device.py b/apps/CameraITS/pymodules/its/device.py
index 8dfcc27..4777f97 100644
--- a/apps/CameraITS/pymodules/its/device.py
+++ b/apps/CameraITS/pymodules/its/device.py
@@ -449,13 +449,22 @@
             raise its.error.Error('3A failed to converge')
         return ae_sens, ae_exp, awb_gains, awb_transform, af_dist
 
-    def do_capture(self, cap_request, out_surfaces=None, reprocess_format=None):
+    def do_capture(self, cap_request,
+            out_surfaces=None, reprocess_format=None, repeat_request=None):
         """Issue capture request(s), and read back the image(s) and metadata.
 
         The main top-level function for capturing one or more images using the
         device. Captures a single image if cap_request is a single object, and
         captures a burst if it is a list of objects.
 
+        The optional repeat_request field can be used to assign a repeating
+        request list ran in background for 3 seconds to warm up the capturing
+        pipeline before start capturing. The repeat_requests will be ran on a
+        640x480 YUV surface without sending any data back. The caller needs to
+        make sure the stream configuration defined by out_surfaces and
+        repeat_request are valid or do_capture may fail because device does not
+        support such stream configuration.
+
         The out_surfaces field can specify the width(s), height(s), and
         format(s) of the captured image. The formats may be "yuv", "jpeg",
         "dng", "raw", "raw10", "raw12", or "rawStats". The default is a YUV420
@@ -589,6 +598,17 @@
             cmd["reprocessFormat"] = reprocess_format
         else:
             cmd["cmdName"] = "doCapture"
+
+        if repeat_request is not None and reprocess_format is not None:
+            raise its.error.Error('repeating request + reprocessing is not supported')
+
+        if repeat_request is None:
+            cmd["repeatRequests"] = []
+        elif not isinstance(repeat_request, list):
+            cmd["repeatRequests"] = [repeat_request]
+        else:
+            cmd["repeatRequests"] = repeat_request
+
         if not isinstance(cap_request, list):
             cmd["captureRequests"] = [cap_request]
         else:
diff --git a/apps/CameraITS/tests/scene3/test_edge_enhancement.py b/apps/CameraITS/tests/scene3/test_edge_enhancement.py
new file mode 100644
index 0000000..a2dfdbe
--- /dev/null
+++ b/apps/CameraITS/tests/scene3/test_edge_enhancement.py
@@ -0,0 +1,127 @@
+# Copyright 2015 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.
+
+import its.image
+import its.caps
+import its.device
+import its.objects
+import its.target
+import math
+import matplotlib
+import matplotlib.pyplot
+import numpy
+import os.path
+import pylab
+
+
+def test_edge_mode(cam, edge_mode, sensitivity, exp, fd, out_surface):
+    """Return sharpness of the output image and the capture result metadata
+       for a capture request with the given edge mode, sensitivity, exposure
+       time, focus distance, output surface parameter.
+
+    Args:
+        cam: An open device session.
+        edge_mode: Edge mode for the request as defined in android.edge.mode
+        sensitivity: Sensitivity for the request as defined in
+            android.sensor.sensitivity
+        exp: Exposure time for the request as defined in
+            android.sensor.exposureTime.
+        fd: Focus distance for the request as defined in
+            android.lens.focusDistance
+        output_surface: Specifications of the output image format and size.
+
+    Returns:
+        Object containing reported edge mode and the sharpness of the output
+        image, keyed by the following strings:
+            "edge_mode"
+            "sharpness"
+    """
+
+    NAME = os.path.basename(__file__).split(".")[0]
+    NUM_SAMPLES = 4
+
+    req = its.objects.manual_capture_request(sensitivity, exp)
+    req["android.lens.focusDistance"] = fd
+    req["android.edge.mode"] = edge_mode
+
+    sharpness_list = []
+    test_fmt = out_surface["format"]
+    for n in range(NUM_SAMPLES):
+        cap = cam.do_capture(req, out_surface, repeat_request=req)
+        img = its.image.convert_capture_to_rgb_image(cap)
+        if n == 0:
+            its.image.write_image(img, "%s_edge=%d.jpg" % (NAME, edge_mode))
+            res_edge_mode = cap["metadata"]["android.edge.mode"]
+        tile = its.image.get_image_patch(img, 0.45, 0.45, 0.1, 0.1)
+        sharpness_list.append(its.image.compute_image_sharpness(tile))
+
+    ret = {}
+    ret["edge_mode"] = res_edge_mode
+    ret["sharpness"] = numpy.mean(sharpness_list)
+
+    return ret
+
+def main():
+    """Test that the android.edge.mode param is applied correctly.
+
+    Capture non-reprocess images for each edge mode and calculate their
+    sharpness as a baseline.
+    """
+
+    THRESHOLD_RELATIVE_SHARPNESS_DIFF = 0.1
+
+    with its.device.ItsSession() as cam:
+        props = cam.get_camera_properties()
+
+        its.caps.skip_unless(its.caps.read_3a(props) and
+                             its.caps.per_frame_control(props) and
+                             its.caps.edge_mode(props, 0))
+
+        test_fmt = "yuv"
+        size = its.objects.get_available_output_sizes(test_fmt, props)[0]
+        out_surface = {"width":size[0], "height":size[1], "format":test_fmt}
+
+        # Get proper sensitivity, exposure time, and focus distance.
+        s,e,_,_,fd = cam.do_3a(get_results=True)
+
+        # Get the sharpness for each edge mode for regular requests
+        sharpness_regular = []
+        edge_mode_reported_regular = []
+        for edge_mode in range(4):
+            # Skip unavailable modes
+            if not its.caps.edge_mode(props, edge_mode):
+                edge_mode_reported_regular.append(edge_mode)
+                sharpness_regular.append(0)
+                continue
+            ret = test_edge_mode(cam, edge_mode, s, e, fd, out_surface)
+            edge_mode_reported_regular.append(ret["edge_mode"])
+            sharpness_regular.append(ret["sharpness"])
+
+        print "Reported edge modes:", edge_mode_reported_regular
+        print "Sharpness with EE mode [0,1,2,3]:", sharpness_regular
+
+        # Verify HQ(2) is sharper than OFF(0)
+        assert(sharpness_regular[2] > sharpness_regular[0])
+
+        # Verify OFF(0) is not sharper than FAST(1)
+        assert(sharpness_regular[1] >
+               sharpness_regular[0] * (1.0 - THRESHOLD_RELATIVE_SHARPNESS_DIFF))
+
+        # Verify FAST(1) is not sharper than HQ(2)
+        assert(sharpness_regular[2] >
+               sharpness_regular[1] * (1.0 - THRESHOLD_RELATIVE_SHARPNESS_DIFF))
+
+if __name__ == '__main__':
+    main()
+
diff --git a/apps/CameraITS/tests/scene3/test_reprocess_edge_enhancement.py b/apps/CameraITS/tests/scene3/test_reprocess_edge_enhancement.py
index e96a9ee..8ab0c02 100644
--- a/apps/CameraITS/tests/scene3/test_reprocess_edge_enhancement.py
+++ b/apps/CameraITS/tests/scene3/test_reprocess_edge_enhancement.py
@@ -64,7 +64,7 @@
     sharpness_list = []
     for n in range(NUM_SAMPLES):
         cap = cam.do_capture(req, out_surface, reprocess_format)
-        img = its.image.decompress_jpeg_to_rgb_image(cap["data"])
+        img = its.image.convert_capture_to_rgb_image(cap)
         if n == 0:
             its.image.write_image(img, "%s_reprocess_fmt_%s_edge=%d.jpg" %
                 (NAME, reprocess_format, edge_mode))
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index 79e8a36..41f7b48 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -46,7 +46,7 @@
 
 LOCAL_PROGUARD_FLAG_FILES := proguard.flags
 
-LOCAL_SDK_VERSION := current
+LOCAL_SDK_VERSION := test_current
 
 LOCAL_DEX_PREOPT := false
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsSerializer.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsSerializer.java
index 9abfa9a..193c94c 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsSerializer.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsSerializer.java
@@ -711,11 +711,11 @@
 
     @SuppressWarnings("unchecked")
     public static List<CaptureRequest.Builder> deserializeRequestList(
-            CameraDevice device, JSONObject jsonObjTop)
+            CameraDevice device, JSONObject jsonObjTop, String requestKey)
             throws ItsException {
         try {
             List<CaptureRequest.Builder> requests = null;
-            JSONArray jsonReqs = jsonObjTop.getJSONArray("captureRequests");
+            JSONArray jsonReqs = jsonObjTop.getJSONArray(requestKey);
             requests = new LinkedList<CaptureRequest.Builder>();
             for (int i = 0; i < jsonReqs.length(); i++) {
                 CaptureRequest.Builder templateReq = device.createCaptureRequest(
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
index e3ff74b..641ee19 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/its/ItsService.java
@@ -93,20 +93,24 @@
     public static final String TAG = ItsService.class.getSimpleName();
 
     // Timeouts, in seconds.
-    public static final int TIMEOUT_CALLBACK = 3;
-    public static final int TIMEOUT_3A = 10;
+    private static final int TIMEOUT_CALLBACK = 3;
+    private static final int TIMEOUT_3A = 10;
+
+    // Time given for background requests to warm up pipeline
+    private static final long PIPELINE_WARMUP_TIME_MS = 2000;
 
     // State transition timeouts, in ms.
     private static final long TIMEOUT_IDLE_MS = 2000;
     private static final long TIMEOUT_STATE_MS = 500;
+    private static final long TIMEOUT_SESSION_CLOSE = 3000;
 
     // Timeout to wait for a capture result after the capture buffer has arrived, in ms.
     private static final long TIMEOUT_CAP_RES = 2000;
 
     private static final int MAX_CONCURRENT_READER_BUFFERS = 10;
 
-    // Supports at most RAW+YUV+JPEG, one surface each.
-    private static final int MAX_NUM_OUTPUT_SURFACES = 3;
+    // Supports at most RAW+YUV+JPEG, one surface each, plus optional background stream
+    private static final int MAX_NUM_OUTPUT_SURFACES = 4;
 
     public static final int SERVERPORT = 6000;
 
@@ -732,7 +736,7 @@
     }
 
     private ImageReader.OnImageAvailableListener
-            createAvailableListenerDropper(final CaptureCallback listener) {
+            createAvailableListenerDropper() {
         return new ImageReader.OnImageAvailableListener() {
             @Override
             public void onImageAvailable(ImageReader reader) {
@@ -856,7 +860,7 @@
 
             // Add a listener that just recycles buffers; they aren't saved anywhere.
             ImageReader.OnImageAvailableListener readerListener =
-                    createAvailableListenerDropper(mCaptureCallback);
+                    createAvailableListenerDropper();
             mOutputImageReaders[0].setOnImageAvailableListener(readerListener, mSaveHandlers[0]);
 
             // Get the user-specified regions for AE, AWB, AF.
@@ -1047,7 +1051,7 @@
      * size and format.
      */
     private void prepareImageReadersWithOutputSpecs(JSONArray jsonOutputSpecs, Size inputSize,
-            int inputFormat, int maxInputBuffers) throws ItsException {
+            int inputFormat, int maxInputBuffers, boolean backgroundRequest) throws ItsException {
         Size outputSizes[];
         int outputFormats[];
         int numSurfaces = 0;
@@ -1055,6 +1059,9 @@
         if (jsonOutputSpecs != null) {
             try {
                 numSurfaces = jsonOutputSpecs.length();
+                if (backgroundRequest) {
+                    numSurfaces += 1;
+                }
                 if (numSurfaces > MAX_NUM_OUTPUT_SURFACES) {
                     throw new ItsException("Too many output surfaces");
                 }
@@ -1062,6 +1069,12 @@
                 outputSizes = new Size[numSurfaces];
                 outputFormats = new int[numSurfaces];
                 for (int i = 0; i < numSurfaces; i++) {
+                    // Append optional background stream at the end
+                    if (backgroundRequest && i == numSurfaces - 1) {
+                        outputFormats[i] = ImageFormat.YUV_420_888;
+                        outputSizes[i] = new Size(640, 480);
+                        continue;
+                    }
                     // Get the specified surface.
                     JSONObject surfaceObj = jsonOutputSpecs.getJSONObject(i);
                     String sformat = surfaceObj.optString("format");
@@ -1128,12 +1141,16 @@
             // No surface(s) specified at all.
             // Default: a single output surface which is full-res YUV.
             Size sizes[] = ItsUtils.getYuvOutputSizes(mCameraCharacteristics);
-            numSurfaces = 1;
+            numSurfaces = backgroundRequest ? 2 : 1;
 
-            outputSizes = new Size[1];
-            outputFormats = new int[1];
+            outputSizes = new Size[numSurfaces];
+            outputFormats = new int[numSurfaces];
             outputSizes[0] = sizes[0];
             outputFormats[0] = ImageFormat.YUV_420_888;
+            if (backgroundRequest) {
+                outputSizes[1] = new Size(640, 480);
+                outputFormats[1] = ImageFormat.YUV_420_888;
+            }
         }
 
         prepareImageReaders(outputSizes, outputFormats, inputSize, inputFormat, maxInputBuffers);
@@ -1143,9 +1160,16 @@
         try {
             // Parse the JSON to get the list of capture requests.
             List<CaptureRequest.Builder> requests = ItsSerializer.deserializeRequestList(
-                    mCamera, params);
+                    mCamera, params, "captureRequests");
+
+            // optional background preview requests
+            List<CaptureRequest.Builder> backgroundRequests = ItsSerializer.deserializeRequestList(
+                    mCamera, params, "repeatRequests");
+            boolean backgroundRequest = backgroundRequests.size() > 0;
 
             int numSurfaces = 0;
+            int numCaptureSurfaces = 0;
+            BlockingSessionCallback sessionListener = new BlockingSessionCallback();
             try {
                 mCountRawOrDng.set(0);
                 mCountJpg.set(0);
@@ -1160,20 +1184,24 @@
                 JSONArray jsonOutputSpecs = ItsUtils.getOutputSpecs(params);
 
                 prepareImageReadersWithOutputSpecs(jsonOutputSpecs, /*inputSize*/null,
-                        /*inputFormat*/0, /*maxInputBuffers*/0);
+                        /*inputFormat*/0, /*maxInputBuffers*/0, backgroundRequest);
                 numSurfaces = mOutputImageReaders.length;
+                numCaptureSurfaces = numSurfaces - (backgroundRequest ? 1 : 0);
 
                 List<Surface> outputSurfaces = new ArrayList<Surface>(numSurfaces);
                 for (int i = 0; i < numSurfaces; i++) {
                     outputSurfaces.add(mOutputImageReaders[i].getSurface());
                 }
-                BlockingSessionCallback sessionListener = new BlockingSessionCallback();
                 mCamera.createCaptureSession(outputSurfaces, sessionListener, mCameraHandler);
                 mSession = sessionListener.waitAndGetSession(TIMEOUT_IDLE_MS);
 
                 for (int i = 0; i < numSurfaces; i++) {
-                    ImageReader.OnImageAvailableListener readerListener =
-                            createAvailableListener(mCaptureCallback);
+                    ImageReader.OnImageAvailableListener readerListener;
+                    if (backgroundRequest && i == numSurfaces - 1) {
+                        readerListener = createAvailableListenerDropper();
+                    } else {
+                        readerListener = createAvailableListener(mCaptureCallback);
+                    }
                     mOutputImageReaders[i].setOnImageAvailableListener(readerListener,
                             mSaveHandlers[i]);
                 }
@@ -1182,12 +1210,26 @@
                 // sequence of capture requests. There is one callback per image surface, and one
                 // callback for the CaptureResult, for each capture.
                 int numCaptures = requests.size();
-                mCountCallbacksRemaining.set(numCaptures * (numSurfaces + 1));
+                mCountCallbacksRemaining.set(numCaptures * (numCaptureSurfaces + 1));
 
             } catch (CameraAccessException e) {
                 throw new ItsException("Error configuring outputs", e);
             }
 
+            // Start background requests and let it warm up pipeline
+            if (backgroundRequest) {
+                List<CaptureRequest> bgRequestList =
+                        new ArrayList<CaptureRequest>(backgroundRequests.size());
+                for (int i = 0; i < backgroundRequests.size(); i++) {
+                    CaptureRequest.Builder req = backgroundRequests.get(i);
+                    req.addTarget(mOutputImageReaders[numCaptureSurfaces].getSurface());
+                    bgRequestList.add(req.build());
+                }
+                mSession.setRepeatingBurst(bgRequestList, null, null);
+                // warm up the pipeline
+                Thread.sleep(PIPELINE_WARMUP_TIME_MS);
+            }
+
             // Initiate the captures.
             long maxExpTimeNs = -1;
             for (int i = 0; i < requests.size(); i++) {
@@ -1201,7 +1243,7 @@
                     maxExpTimeNs = expTimeNs;
                 }
 
-                for (int j = 0; j < numSurfaces; j++) {
+                for (int j = 0; j < numCaptureSurfaces; j++) {
                     req.addTarget(mOutputImageReaders[j].getSurface());
                 }
                 mSession.capture(req.build(), mCaptureResultListener, mResultHandler);
@@ -1227,8 +1269,16 @@
                 }
                 currentCount = newCount;
             }
+
+            // Close session and wait until session is fully closed
+            mSession.close();
+            sessionListener.getStateWaiter().waitForState(
+                    BlockingSessionCallback.SESSION_CLOSED, TIMEOUT_SESSION_CLOSE);
+
         } catch (android.hardware.camera2.CameraAccessException e) {
             throw new ItsException("Access error: ", e);
+        } catch (InterruptedException e) {
+            throw new ItsException("Unexpected InterruptedException: ", e);
         }
     }
 
@@ -1273,14 +1323,14 @@
         try {
             // Parse the JSON to get the list of capture requests.
             List<CaptureRequest.Builder> inputRequests =
-                    ItsSerializer.deserializeRequestList(mCamera, params);
+                    ItsSerializer.deserializeRequestList(mCamera, params, "captureRequests");
 
             // Prepare the image readers for reprocess input and reprocess outputs.
             int inputFormat = getReprocessInputFormat(params);
             Size inputSize = ItsUtils.getMaxOutputSize(mCameraCharacteristics, inputFormat);
             JSONArray jsonOutputSpecs = ItsUtils.getOutputSpecs(params);
             prepareImageReadersWithOutputSpecs(jsonOutputSpecs, inputSize, inputFormat,
-                    inputRequests.size());
+                    inputRequests.size(), /*backgroundRequest*/false);
 
             // Prepare a reprocessable session.
             int numOutputSurfaces = mOutputImageReaders.length;
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/SplitTests.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/SplitTests.java
index a2ef1f3..ad00adb 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/SplitTests.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/SplitTests.java
@@ -36,6 +36,10 @@
  * Tests that verify installing of various split APKs from host side.
  */
 public class SplitTests extends DeviceTestCase implements IAbiReceiver, IBuildReceiver {
+    static final String PKG_NO_RESTART = "com.android.cts.norestart";
+    static final String APK_NO_RESTART_BASE = "CtsNoRestartBase.apk";
+    static final String APK_NO_RESTART_FEATURE = "CtsNoRestartFeature.apk";
+
     static final String PKG = "com.android.cts.splitapp";
     static final String CLASS = ".SplitAppTest";
 
@@ -110,6 +114,7 @@
         super.tearDown();
 
         getDevice().uninstallPackage(PKG);
+        getDevice().uninstallPackage(PKG_NO_RESTART);
     }
 
     public void testSingleBase() throws Exception {
@@ -279,6 +284,18 @@
         // TODO: flesh out this test
     }
 
+    public void testFeatureWithoutRestart() throws Exception {
+        new InstallMultiple().addApk(APK).run();
+        new InstallMultiple().addApk(APK_NO_RESTART_BASE).run();
+        runDeviceTests(PKG, CLASS, "testBaseInstalled");
+        new InstallMultiple()
+                .addArg("--dont-kill")
+                .inheritFrom(PKG_NO_RESTART)
+                .addApk(APK_NO_RESTART_FEATURE)
+                .run();
+        runDeviceTests(PKG, CLASS, "testFeatureInstalled");
+    }
+
     /**
      * Verify that installing a new version of app wipes code cache.
      */
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/Android.mk b/hostsidetests/appsecurity/test-apps/NoRestartApp/Android.mk
new file mode 100644
index 0000000..69d3b4a
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/Android.mk
@@ -0,0 +1,39 @@
+#
+# Copyright (C) 2016 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+
+LOCAL_PACKAGE_NAME := CtsNoRestartBase
+
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_DEX_PREOPT := false
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
+
+
+################################################
+# Build the feature split
+
+ifeq (,$(ONE_SHOT_MAKEFILE))
+include $(LOCAL_PATH)/feature/Android.mk
+endif
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/NoRestartApp/AndroidManifest.xml
new file mode 100644
index 0000000..7140333
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/AndroidManifest.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="com.android.cts.norestart"
+    tools:ignore="MissingVersion" >
+
+    <uses-sdk
+        android:minSdkVersion="8"
+        android:targetSdkVersion="23" />
+
+    <application
+        tools:ignore="AllowBackup,MissingApplicationIcon" >
+        <activity
+            android:name=".NoRestartActivity"
+            android:launchMode="singleTop" >
+            <intent-filter>
+                <action android:name="com.android.cts.norestart.START" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+            </activity>
+    </application>
+</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/Android.mk b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/Android.mk
new file mode 100644
index 0000000..204275b
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/Android.mk
@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2016 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+
+LOCAL_PACKAGE_NAME := CtsNoRestartFeature
+
+LOCAL_MODULE_TAGS := tests
+LOCAL_COMPATIBILITY_SUITE := cts
+
+LOCAL_PROGUARD_ENABLED := disabled
+LOCAL_DEX_PREOPT := false
+
+localRStamp := $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),,COMMON)/src/R.stamp
+featureOf := CtsNoRestartBase
+featureOfApk := $(call intermediates-dir-for,APPS,$(featureOf))/package.apk
+$(localRStamp): $(featureOfApk)
+LOCAL_APK_LIBRARIES := $(featureOf)
+LOCAL_AAPT_FLAGS += --feature-of $(featureOfApk)
+
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/AndroidManifest.xml
new file mode 100644
index 0000000..b2fa3e8
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/AndroidManifest.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="com.android.cts.norestart"
+    split="feature"
+    tools:ignore="MissingVersion" >
+
+    <uses-sdk
+        android:minSdkVersion="8"
+        android:targetSdkVersion="23" />
+
+    <application
+        android:allowBackup="false"
+        tools:ignore="MissingApplicationIcon" >
+        <activity
+            android:name=".feature.NoRestartFeatureActivity"  >
+        </activity>
+    </application>
+</manifest>
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/res/layout/no_restart_feature_activity.xml b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/res/layout/no_restart_feature_activity.xml
new file mode 100644
index 0000000..a5f8812
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/res/layout/no_restart_feature_activity.xml
@@ -0,0 +1,32 @@
+<!-- Copyright (C) 2016 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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="16dp"
+    android:paddingLeft="16dp"
+    android:paddingRight="16dp"
+    android:paddingTop="16dp"
+    android:orientation="vertical"
+    tools:context="com.android.cts.norestart.NoRestartFeatureActivity" >
+
+    <TextView
+        android:id="@+id/text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/no_restart_feature_text" />
+
+</LinearLayout>
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/res/values/strings.xml b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/res/values/strings.xml
new file mode 100644
index 0000000..1fb1db3
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/res/values/strings.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+<resources>
+    <string name="no_restart_feature_text">Hello feature!</string>
+</resources>
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/src/com/android/cts/norestart/feature/NoRestartFeatureActivity.java b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/src/com/android/cts/norestart/feature/NoRestartFeatureActivity.java
new file mode 100644
index 0000000..40f8259
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/feature/src/com/android/cts/norestart/feature/NoRestartFeatureActivity.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+package com.android.cts.norestart.feature;
+
+import com.android.cts.norestart.R;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class NoRestartFeatureActivity extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.no_restart_feature_activity);
+    }
+}
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/res/layout/no_restart_activity.xml b/hostsidetests/appsecurity/test-apps/NoRestartApp/res/layout/no_restart_activity.xml
new file mode 100644
index 0000000..60ab817
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/res/layout/no_restart_activity.xml
@@ -0,0 +1,32 @@
+<!-- Copyright (C) 2016 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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="16dp"
+    android:paddingLeft="16dp"
+    android:paddingRight="16dp"
+    android:paddingTop="16dp"
+    android:orientation="vertical"
+    tools:context="com.android.cts.norestart.NoRestartActivity" >
+
+    <TextView
+        android:id="@+id/text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/no_restart_text" />
+
+</LinearLayout>
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/res/values/strings.xml b/hostsidetests/appsecurity/test-apps/NoRestartApp/res/values/strings.xml
new file mode 100644
index 0000000..5240150
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/res/values/strings.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+<resources>
+    <string name="no_restart_text">Hello, world!</string>
+</resources>
diff --git a/hostsidetests/appsecurity/test-apps/NoRestartApp/src/com/android/cts/norestart/NoRestartActivity.java b/hostsidetests/appsecurity/test-apps/NoRestartApp/src/com/android/cts/norestart/NoRestartActivity.java
new file mode 100644
index 0000000..26d5712
--- /dev/null
+++ b/hostsidetests/appsecurity/test-apps/NoRestartApp/src/com/android/cts/norestart/NoRestartActivity.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+package com.android.cts.norestart;
+
+import com.android.cts.norestart.R;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+
+public class NoRestartActivity extends Activity {
+    private int mCreateCount;
+    private int mNewIntentCount;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.no_restart_activity);
+        mCreateCount++;
+        sendBroadcast();
+    }
+
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+        mNewIntentCount++;
+        sendBroadcast();
+    }
+
+    private void sendBroadcast() {
+        final Intent intent = new Intent("com.android.cts.norestart.BROADCAST");
+        intent.putExtra("CREATE_COUNT", mCreateCount);
+        intent.putExtra("NEW_INTENT_COUNT", mNewIntentCount);
+        sendBroadcast(intent);
+    }
+}
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/res/values/values.xml b/hostsidetests/appsecurity/test-apps/SplitApp/res/values/values.xml
index 3118fde..ecb7eae 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/res/values/values.xml
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/res/values/values.xml
@@ -19,6 +19,7 @@
 
     <string name="my_string1">blue</string>
     <string name="my_string2">purple</string>
+    <string name="no_restart_text">Hello world!</string>
 
     <string-array name="my_string_array">
         <item>@string/my_string1</item>
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java b/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java
index c5f0fd0..7a693e8 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java
@@ -19,8 +19,10 @@
 import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
 import static org.xmlpull.v1.XmlPullParser.START_TAG;
 
+import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
@@ -33,6 +35,7 @@
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
 import android.graphics.drawable.Drawable;
+import android.os.ConditionVariable;
 import android.os.Environment;
 import android.os.ParcelFileDescriptor;
 import android.os.StatFs;
@@ -305,6 +308,50 @@
         }
     }
 
+    public void testBaseInstalled() throws Exception {
+        final ConditionVariable cv = new ConditionVariable();
+        final BroadcastReceiver r = new BroadcastReceiver() {
+            @Override
+            public void onReceive(Context context, Intent intent) {
+                assertEquals(1, intent.getIntExtra("CREATE_COUNT", -1));
+                assertEquals(0, intent.getIntExtra("NEW_INTENT_COUNT", -1));
+                cv.open();
+            }
+        };
+        final IntentFilter filter = new IntentFilter("com.android.cts.norestart.BROADCAST");
+        getContext().registerReceiver(r, filter);
+        final Intent i = new Intent("com.android.cts.norestart.START");
+        i.addCategory(Intent.CATEGORY_DEFAULT);
+        getContext().startActivity(i);
+        assertTrue(cv.block(2000L));
+        getContext().unregisterReceiver(r);
+    }
+
+    /**
+     * Tests a running activity remains active while a new feature split is installed.
+     * <p>
+     * Prior to running this test, the activity must be started. That is currently
+     * done in {@link #testBaseInstalled()}.
+     */
+    public void testFeatureInstalled() throws Exception {
+        final ConditionVariable cv = new ConditionVariable();
+        final BroadcastReceiver r = new BroadcastReceiver() {
+            @Override
+            public void onReceive(Context context, Intent intent) {
+                assertEquals(1, intent.getIntExtra("CREATE_COUNT", -1));
+                assertEquals(1, intent.getIntExtra("NEW_INTENT_COUNT", -1));
+                cv.open();
+            }
+        };
+        final IntentFilter filter = new IntentFilter("com.android.cts.norestart.BROADCAST");
+        getContext().registerReceiver(r, filter);
+        final Intent i = new Intent("com.android.cts.norestart.START");
+        i.addCategory(Intent.CATEGORY_DEFAULT);
+        getContext().startActivity(i);
+        assertTrue(cv.block(2000L));
+        getContext().unregisterReceiver(r);
+    }
+
     public void testFeatureApi() throws Exception {
         final Resources r = getContext().getResources();
         final PackageManager pm = getContext().getPackageManager();
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
index 1944444..e1c42b1 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
@@ -47,7 +47,8 @@
         </receiver>
 
         <activity
-            android:name="com.android.cts.deviceowner.KeyManagementActivity" />
+            android:name="com.android.cts.deviceowner.KeyManagementActivity"
+            android:theme="@android:style/Theme.Translucent.NoTitleBar" />
 
         <activity
             android:name="com.android.cts.deviceowner.LockTaskUtilityActivity" />
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementActivity.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementActivity.java
index c108d24..fda124f 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementActivity.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementActivity.java
@@ -17,14 +17,6 @@
 package com.android.cts.deviceowner;
 
 import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
 
 public class KeyManagementActivity extends Activity {
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        finish();
-    }
 }
diff --git a/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java b/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
index 4d9a145..a5aa2ac 100644
--- a/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
@@ -573,7 +573,7 @@
 
             long maxFastYuvRate =
                     config.getOutputMinFrameDuration(ImageFormat.YUV_420_888, maxFastYuvSize);
-            final long MIN_8MP_DURATION_BOUND_NS = 200000000; // 50 ms, 20 fps
+            final long MIN_8MP_DURATION_BOUND_NS = 50000000; // 50 ms, 20 fps
             boolean haveFastYuvRate = maxFastYuvRate <= MIN_8MP_DURATION_BOUND_NS;
 
             final int SIZE_8MP_BOUND = 8000000;
@@ -656,7 +656,7 @@
                 assertTrue(
                         String.format("Camera device %s has all the requirements for BURST" +
                                 " capability but does not report it!", mIds[counter]),
-                        !(haveMaxYuv && haveMaxYuvRate && haveFastAeTargetFps &&
+                        !(haveMaxYuv && haveMaxYuvRate && haveFastYuvRate && haveFastAeTargetFps &&
                                 haveFastSyncLatency && maxYuvMatchSensor &&
                                 haveAeLock && haveAwbLock));
             }
diff --git a/tests/camera/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java b/tests/camera/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
index 9f0c012..e8d5837 100644
--- a/tests/camera/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
+++ b/tests/camera/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
@@ -502,19 +502,11 @@
                 errorPercent)) return false;
 
         if (!expectSimilarValues(
-                formattedMsg, "left pt too right", "left pt too left", actual.left, expected.left,
+                formattedMsg, "too low", "too high", actual.centerY(), expected.centerY(),
                 errorPercent)) return false;
 
         if (!expectSimilarValues(
-                formattedMsg, "right pt too right", "right pt too left",
-                actual.right, expected.right, errorPercent)) return false;
-
-        if (!expectSimilarValues(
-                formattedMsg, "top pt too low", "top pt too high", actual.top, expected.top,
-                errorPercent)) return false;
-
-        if (!expectSimilarValues(
-                formattedMsg, "bottom pt too low", "bottom pt too high", actual.top, expected.top,
+                formattedMsg, "too right", "too left", actual.centerX(), expected.centerX(),
                 errorPercent)) return false;
 
         return true;
diff --git a/tests/tests/net/src/android/net/cts/DnsTest.java b/tests/tests/net/src/android/net/cts/DnsTest.java
index 0377d04..fed0a8d 100644
--- a/tests/tests/net/src/android/net/cts/DnsTest.java
+++ b/tests/tests/net/src/android/net/cts/DnsTest.java
@@ -62,7 +62,8 @@
         try {
             addrs = InetAddress.getAllByName("www.google.com");
         } catch (UnknownHostException e) {}
-        assertTrue(addrs.length != 0);
+        assertTrue("[RERUN] DNS could not resolve www.gooogle.com. Check internet connection",
+            addrs.length != 0);
         boolean foundV4 = false, foundV6 = false;
         for (InetAddress addr : addrs) {
             if (addr instanceof Inet4Address) foundV4 = true;
@@ -96,7 +97,8 @@
             if (DBG) Log.e(TAG, "ipv6.google.com gave " + addr.toString());
         }
 
-        assertTrue(foundV4 == false);
+        assertTrue("[RERUN] ipv6.google.com returned an ipv4 address, check your network's DNS connection.",
+            foundV4 == false);
         assertTrue(foundV6 == true);
 
         assertTrue(testNativeDns());
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java b/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
index 80e3201..913ca82 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
@@ -205,7 +205,8 @@
 
         // Dialing state is unsupported for conference calls. so, the state remains active.
         mConferenceObject.setDialing();
-        assertCallState(conf, Call.STATE_ACTIVE);
+        // just assert call state is not dialing, the state remains as previous one.
+        assertTrue(conf.getState() != Call.STATE_DIALING);
 
         mConferenceObject.setOnHold();
         assertCallState(conf, Call.STATE_HOLDING);
diff --git a/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java b/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
index 9628d60..463d3c9 100644
--- a/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
+++ b/tests/tests/telecom/src/android/telecom/cts/MockConnectionService.java
@@ -94,6 +94,14 @@
                     (MockConnection)connection1, (MockConnection)connection2);
             CtsConnectionService.addConferenceToTelecom(conference);
             conferences.add(conference);
+
+            if (connection1.getState() == Connection.STATE_HOLDING){
+                connection1.setActive();
+            }
+            if(connection2.getState() == Connection.STATE_HOLDING){
+                connection2.setActive();
+            }
+
             lock.release();
         }
     }
diff --git a/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java b/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
index 42c963f..f29e09d 100644
--- a/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
@@ -481,6 +481,13 @@
                             remoteConnection2.getConference() == null) {
                         conferenceRemoteConnections(remoteConnection1, remoteConnection2);
                     }
+
+                    if (connection1.getState() == Connection.STATE_HOLDING){
+                        connection1.setActive();
+                    }
+                    if(connection2.getState() == Connection.STATE_HOLDING){
+                        connection2.setActive();
+                    }
                 }
                 @Override
                 public void onRemoteConferenceAdded(RemoteConference remoteConference) {
@@ -521,6 +528,14 @@
                                 (MockConnection)connection1, (MockConnection)connection2);
                         CtsRemoteConnectionService.addConferenceToTelecom(conference);
                         conferences.add(conference);
+
+                        if (connection1.getState() == Connection.STATE_HOLDING){
+                            connection1.setActive();
+                        }
+                        if(connection2.getState() == Connection.STATE_HOLDING){
+                            connection2.setActive();
+                        }
+
                         lock.release();
                     }
                 }
diff --git a/tests/tests/telephony/src/android/telephony/cts/MmsTest.java b/tests/tests/telephony/src/android/telephony/cts/MmsTest.java
index e15b45f..b5fa45a 100644
--- a/tests/tests/telephony/src/android/telephony/cts/MmsTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/MmsTest.java
@@ -170,8 +170,9 @@
     }
 
     public void testSendMmsMessage() {
-        if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
-            Log.i(TAG, "testSendMmsMessage skipped: no telephony available");
+        if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)
+             || !doesSupportMMS()) {
+            Log.i(TAG, "testSendMmsMessage skipped: no telephony available or MMS not supported");
             return;
         }
 
@@ -316,4 +317,12 @@
                 .getCarrierConfigValues()
                 .getBoolean(SmsManager.MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION, true);
     }
+
+    private static boolean doesSupportMMS() {
+        return SmsManager
+                .getDefault()
+                .getCarrierConfigValues()
+                .getBoolean(SmsManager.MMS_CONFIG_MMS_ENABLED, true);
+    }
+
 }
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 3f4fd92..6d67547 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -203,6 +203,46 @@
     }
 
     @UiThreadTest
+    public void testCreatingWebViewWithDeviceEncrpytionFails() {
+        if (!NullWebViewUtils.isWebViewAvailable()) {
+            return;
+        }
+
+        Context deviceEncryptedContext = getActivity().createDeviceProtectedStorageContext();
+        try {
+            new WebView(deviceEncryptedContext);
+        } catch (IllegalArgumentException e) {
+            return;
+        }
+
+        Assert.fail("WebView should have thrown exception when creating with a device " +
+                "protected storage context");
+    }
+
+    @UiThreadTest
+    public void testCreatingWebViewWithMultipleEncryptionContext() {
+        if (!NullWebViewUtils.isWebViewAvailable()) {
+            return;
+        }
+
+        // Credential encrpytion is the default. Create one here for the sake of clarity.
+        Context credentialEncryptedContext = getActivity().createCredentialProtectedStorageContext();
+        Context deviceEncryptedContext = getActivity().createDeviceProtectedStorageContext();
+
+        // No exception should be thrown with credential encryption context.
+        new WebView(credentialEncryptedContext);
+
+        try {
+            new WebView(deviceEncryptedContext);
+        } catch (IllegalArgumentException e) {
+            return;
+        }
+
+        Assert.fail("WebView should have thrown exception when creating with a device " +
+                "protected storage context");
+    }
+
+    @UiThreadTest
     public void testCreatingWebViewCreatesCookieSyncManager() throws Exception {
         if (!NullWebViewUtils.isWebViewAvailable()) {
             return;