Merge cherrypicks of [9111407, 9111408, 9111409, 9111410, 9111411, 9111332, 9110454] into qt-release

Change-Id: I61af9d07d1d145baca082f8d5718744a2d50f2dc
diff --git a/apps/CameraITS/tests/scene1/test_param_shading_mode.py b/apps/CameraITS/tests/scene1/test_param_shading_mode.py
index a65c630..a5f85ca 100644
--- a/apps/CameraITS/tests/scene1/test_param_shading_mode.py
+++ b/apps/CameraITS/tests/scene1/test_param_shading_mode.py
@@ -58,6 +58,13 @@
         #      switching shading modes.
         cam.do_3a(mono_camera=mono_camera)
 
+        # Use smallest yuv size matching the aspect ratio of largest yuv size to
+        # reduce some USB bandwidth overhead since we are only looking at output
+        # metadata in this test.
+        largest_yuv_fmt = its.objects.get_largest_yuv_format(props)
+        largest_yuv_size = (largest_yuv_fmt['width'], largest_yuv_fmt['height'])
+        cap_fmt = its.objects.get_smallest_yuv_format(props, largest_yuv_size)
+
         # Get the reference lens shading maps for OFF, FAST, and HIGH_QUALITY
         # in different sessions.
         # reference_maps[mode]
@@ -68,7 +75,7 @@
             req = its.objects.auto_capture_request()
             req['android.statistics.lensShadingMapMode'] = 1
             req['android.shading.mode'] = mode
-            cap_res = cam.do_capture([req]*NUM_FRAMES)[NUM_FRAMES-1]['metadata']
+            cap_res = cam.do_capture([req]*NUM_FRAMES, cap_fmt)[NUM_FRAMES-1]['metadata']
             lsc_map = cap_res['android.statistics.lensShadingCorrectionMap']
             assert(lsc_map.has_key('width') and
                    lsc_map.has_key('height') and
@@ -89,7 +96,7 @@
                     req['android.shading.mode'] = mode
                     reqs.append(req)
 
-        caps = cam.do_capture(reqs)
+        caps = cam.do_capture(reqs, cap_fmt)
 
         # shading_maps[mode][loop]
         shading_maps = [[[] for loop in range(NUM_SHADING_MODE_SWITCH_LOOPS)]
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 057ac46..69b9116 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -3639,10 +3639,12 @@
     <string name="device_owner_disallow_remove_user_info">
         Please press \'Create uninitialized user\' to create a user that is not set up. Then press the
         \'Set restriction\' button to set the user restriction.
-        Then press \'Go\' to open \'Multiple users\' setting. \n\n
+        Then press \'Go\' to open \'Multiple users\' setting. \n
+        Click the Settings icon adjacent to the managed user.\n\n
 
         Mark this test as passed if:\n\n
-        - Main switch is disabled and in off position\n
+        - \"Delete User\" is disabled.\n
+        - Tapping \"Delete user\" shows an \"Action not allowed\" dialog.\n
         \n
         Use the Back button to return to this page.
     </string>
@@ -3650,8 +3652,9 @@
         Please press the \'Set restriction\' button to set the user restriction.
         Then press \'Go\' to open \'Multiple users\' setting. \n\n
 
-        Mark this test as passed if one of the following conditions is met:\n\n
-        - Main switch is disabled and in off position\n
+        Mark this test as passed if all of the following conditions are met:\n\n
+        - The \"Delete managed user from this device\" option in the overflow menu is disabled\n
+        - Clicking \"Delete managed user from this device\" in the overflow menu results in an \"Action not allowed\" dialog.\n
         \n
         Use the Back button to return to this page.
     </string>
@@ -3962,7 +3965,7 @@
         7) Verify that at the bottom of Quick Settings, you are told the device is managed by \"Foo, Inc.\".\n
         8) Tap on the information.\n
         9) Verify that a dialog informing you about device monitoring opens.\n
-        10) Tap the \"Learn more\" link.\n
+        10) Tap the \"View Policies\" button.\n
         11) Verify that a screen informing you what your managing organization can do is shown.\n
         \n
         Use the Back button to return to this page. If this device does not have quick settings, please skip this test and mark it passing.
diff --git a/tests/camera/src/android/hardware/camera2/cts/CaptureRequestTest.java b/tests/camera/src/android/hardware/camera2/cts/CaptureRequestTest.java
index c845568..2dbe878 100644
--- a/tests/camera/src/android/hardware/camera2/cts/CaptureRequestTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/CaptureRequestTest.java
@@ -1485,67 +1485,11 @@
         // TODO: jchowdhary@, b/130323585, this line can be removed.
         requestBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF);
         CaptureRequest flashOffRequest = requestBuilder.build();
-        int flashModeOffRequests = captureRequestsSynchronized(flashOffRequest, 2, listener,
-                mHandler);
-        // We check that the Nth frame's capture result has flash state as either PARTIAL / READY
-        // and the N+1th frame has its flash state as READY (to take into account flash off ramp
-        // time). For devices supporting per frame control, N is the 1st frame passed into
-        // captureRequestsSynchronized. No two frames can have their flash state as PARTIAL.
-        CaptureResult firstTorchOffResult = null;
-        CaptureResult secondTorchOffResult = null;
-        String torchOffDebugStr = "Timed out waiting for torch off result";
-        if (mStaticInfo.isPerFrameControlSupported()) {
-            firstTorchOffResult =
-                    listener.getCaptureResultForRequest(flashOffRequest, NUM_RESULTS_WAIT_TIMEOUT);
-            secondTorchOffResult =
-                    listener.getCaptureResultForRequest(flashOffRequest, NUM_RESULTS_WAIT_TIMEOUT);
-
-        } else {
-            CaptureResult maybeFirstNonFiredResult;
-            int i = 0;
-            while (i < flashModeOffRequests - 1) {
-                maybeFirstNonFiredResult = listener.getCaptureResultForRequest(flashOffRequest,
-                        NUM_RESULTS_WAIT_TIMEOUT);
-                i++;
-                Integer flashState = maybeFirstNonFiredResult.get(CaptureResult.FLASH_STATE);
-                torchOffDebugStr = "Flash not turned off in time";
-                if (flashState != CaptureResult.FLASH_STATE_FIRED) {
-                    firstTorchOffResult = maybeFirstNonFiredResult;
-                    secondTorchOffResult = listener.getCaptureResultForRequest(flashOffRequest,
-                            NUM_RESULTS_WAIT_TIMEOUT);
-                    torchOffDebugStr = "Timed out waiting for torch off result";
-                    break;
-                }
-            }
-            // The next results should all have their flash state as READY
-            for(int j = i + 1 ; j < flashModeOffRequests; j++) {
-                CaptureResult expectedReadyResult =
-                        listener.getCaptureResultForRequest(flashOffRequest,
-                                NUM_RESULTS_WAIT_TIMEOUT);
-                mCollector.expectEquals("Flash state must remain READY after torch is turned off",
-                        CaptureResult.FLASH_STATE_READY,
-                        expectedReadyResult.get(CaptureResult.FLASH_STATE));
-            }
-        }
-        mCollector.expectNotEquals("first torch off result: " + torchOffDebugStr, null,
-                firstTorchOffResult);
-        mCollector.expectNotEquals("second torch off result: " + torchOffDebugStr, null,
-                secondTorchOffResult);
-        check2TorchOffStates(firstTorchOffResult, secondTorchOffResult);
-    }
-
-    private void check2TorchOffStates(CaptureResult first, CaptureResult second) {
-        Integer flashState = first.get(CaptureResult.FLASH_STATE);
-        // The first frame must have its flash state as FLASH_STATE_READY or
-        // FLASH_STATE_PARTIAL.
-        int [] validStates = new int[] { CaptureRequest.FLASH_STATE_READY,
-              CaptureRequest.FLASH_STATE_PARTIAL};
-        mCollector.expectContains("Flash state must be either PARTIAL or READY", validStates,
-                flashState);
-        // The next frame must have its flash state as FLASH_STATE_READY
-        flashState = second.get(CaptureResult.FLASH_STATE);
-        mCollector.expectEquals("Flash state result must be READY",
-                CaptureResult.FLASH_STATE_READY, flashState);
+        mSession.setRepeatingRequest(flashOffRequest, listener, mHandler);
+        waitForSettingsApplied(listener, NUM_FRAMES_WAITED_FOR_TORCH);
+        result = listener.getCaptureResultForRequest(flashOffRequest, NUM_RESULTS_WAIT_TIMEOUT);
+        mCollector.expectEquals("Flash state result must be READY", CaptureResult.FLASH_STATE_READY,
+                result.get(CaptureResult.FLASH_STATE));
     }
 
     /**
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/SubscriptionManagerTest.java b/tests/tests/telephony/current/src/android/telephony/cts/SubscriptionManagerTest.java
index 0832528..6803431 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/SubscriptionManagerTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/SubscriptionManagerTest.java
@@ -43,6 +43,8 @@
 import android.telephony.SubscriptionPlan;
 import android.telephony.TelephonyManager;
 
+import androidx.test.InstrumentationRegistry;
+
 import com.android.compatibility.common.util.ShellIdentityUtils;
 import com.android.compatibility.common.util.SystemUtil;
 import com.android.internal.util.ArrayUtils;
@@ -66,8 +68,6 @@
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
-import androidx.test.InstrumentationRegistry;
-
 public class SubscriptionManagerTest {
     private SubscriptionManager mSm;
 
@@ -550,10 +550,11 @@
             }
         };
 
-        int [] subList = mSm.getActiveSubscriptionIdList();
+        List<SubscriptionInfo> subscriptionInfos = mSm.getActiveSubscriptionInfoList();
         boolean changes = false;
 
-        for (int subId : subList) {
+        for (SubscriptionInfo subInfo : subscriptionInfos) {
+            int subId = subInfo.getSubscriptionId();
             if (subId != preferredSubId) {
                 int newPreferredSubId = subId;
                 // Change to a new value.