Merge "cts: Add missing BluetoothLeAudioCodecConfig test"
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/bokeh/CameraBokehActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/bokeh/CameraBokehActivity.java
index 3f27a2d..55791c6 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/bokeh/CameraBokehActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/bokeh/CameraBokehActivity.java
@@ -59,6 +59,7 @@
 import android.view.View;
 import android.view.Surface;
 import android.view.TextureView;
+import android.widget.Adapter;
 import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
@@ -98,6 +99,7 @@
                         1f,    1.772f,        0f, 0f, -226.816f,
                         0f,        0f,        0f, 1f,        0f
                     });
+    private static final String CAMERA_ID_PREFIX = "Camera ";
 
     private TextureView mPreviewView;
     private SurfaceTexture mPreviewTexture;
@@ -262,7 +264,7 @@
         String[] cameraNames = new String[cameraIdSet.size()];
         int i = 0;
         for (String id : cameraIdSet) {
-            cameraNames[i++] = "Camera " + id;
+            cameraNames[i++] = CAMERA_ID_PREFIX + id;
         }
         mCameraSpinner = (Spinner) findViewById(R.id.cameras_selection);
         mCameraSpinner.setAdapter(
@@ -592,11 +594,10 @@
         shutdownCamera();
 
         mCurrentCameraIndex = index;
+        Adapter adapter = mCameraSpinner.getAdapter();
+        String idDisplayed = (String) adapter.getItem(index);
+        mCameraId = idDisplayed.substring(CAMERA_ID_PREFIX.length());
 
-        Set<String> cameraIdSet = mTestCases.keySet();
-        List<String> stringsList = new ArrayList<>(cameraIdSet);
-
-        mCameraId = stringsList.get(index);
         try {
             mCameraCharacteristics = mCameraManager.getCameraCharacteristics(mCameraId);
             mCameraDevice = mBlockingCameraManager.openCamera(mCameraId,
@@ -761,7 +762,8 @@
 
     private void startPreview() {
         try {
-            if (mPreviewSize == null || !mPreviewSize.equals(mNextCombination.mPreviewSize)) {
+            if (mPreviewSize == null || !mPreviewSize.equals(mNextCombination.mPreviewSize) ||
+                    mYuvImageReader == null) {
                 mPreviewSize = mNextCombination.mPreviewSize;
 
                 mYuvImageReader = ImageReader.newInstance(mPreviewSize.getWidth(),
diff --git a/hostsidetests/statsdatom/src/android/cts/statsdatom/memory/ProcessMemoryStatsTests.java b/hostsidetests/statsdatom/src/android/cts/statsdatom/memory/ProcessMemoryStatsTests.java
index 632e280..36938fd 100644
--- a/hostsidetests/statsdatom/src/android/cts/statsdatom/memory/ProcessMemoryStatsTests.java
+++ b/hostsidetests/statsdatom/src/android/cts/statsdatom/memory/ProcessMemoryStatsTests.java
@@ -86,7 +86,7 @@
             assertThat(state.getOomAdjScore()).isAtLeast(0);
             assertThat(state.getPageFault()).isAtLeast(0L);
             assertThat(state.getPageMajorFault()).isAtLeast(0L);
-            assertThat(state.getRssInBytes()).isGreaterThan(0L);
+            assertThat(state.getRssInBytes()).isAtLeast(0L);
             assertThat(state.getCacheInBytes()).isAtLeast(0L);
             assertThat(state.getSwapInBytes()).isAtLeast(0L);
         }
diff --git a/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityManagerTestBase.java b/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityManagerTestBase.java
index 9fc6860..331db92 100644
--- a/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityManagerTestBase.java
+++ b/tests/framework/base/windowmanager/util/src/android/server/wm/ActivityManagerTestBase.java
@@ -2670,7 +2670,7 @@
         final int mDisplayId;
         final boolean mInitialIgnoreOrientationRequest;
 
-        IgnoreOrientationRequestSession(int displayId, boolean enable) {
+        public IgnoreOrientationRequestSession(int displayId, boolean enable) {
             mDisplayId = displayId;
             Matcher matcher = IGNORE_ORIENTATION_REQUEST_PATTERN.matcher(
                     executeShellCommand(WM_GET_IGNORE_ORIENTATION_REQUEST + " -d " + mDisplayId));
diff --git a/tests/media/jni/NativeCodecDecoderTest.cpp b/tests/media/jni/NativeCodecDecoderTest.cpp
index 2894009..4112d17 100644
--- a/tests/media/jni/NativeCodecDecoderTest.cpp
+++ b/tests/media/jni/NativeCodecDecoderTest.cpp
@@ -474,8 +474,10 @@
         AMediaExtractor_seekTo(mExtractor, 0, mode);
         test->reset();
         if (!doWork(23)) return false;
-        CHECK_ERR(!test->isPtsStrictlyIncreasing(mPrevOutputPts), "",
-                  "pts is not strictly increasing", isPass);
+        if (!mIsInterlaced) {
+            CHECK_ERR(!test->isPtsStrictlyIncreasing(mPrevOutputPts), "",
+                          "pts is not strictly increasing", isPass);
+        }
 
         /* test flush in running state */
         if (!flushCodec()) return false;
@@ -562,8 +564,13 @@
         CHECK_ERR(loopCounter != 0 && (!ref->equals(test)), log, "output is flaky", isPass);
         CHECK_ERR(loopCounter == 0 && mIsAudio && (!ref->isPtsStrictlyIncreasing(mPrevOutputPts)),
                   log, "pts is not strictly increasing", isPass);
-        CHECK_ERR(loopCounter == 0 && !mIsAudio && (!ref->isOutPtsListIdenticalToInpPtsList(false)),
-                  log, "input pts list and output pts list are not identical", isPass);
+        // TODO: Timestamps for deinterlaced content are under review. (E.g. can decoders
+        // produce multiple progressive frames?) For now, do not verify timestamps.
+        if (!mIsInterlaced) {
+            CHECK_ERR(loopCounter == 0 && !mIsAudio &&
+                      (!ref->isOutPtsListIdenticalToInpPtsList(false)),
+                      log, "input pts list and output pts list are not identical", isPass);
+        }
         loopCounter++;
     }
     return isPass;
@@ -641,9 +648,13 @@
                 CHECK_ERR(loopCounter == 0 && mIsAudio &&
                           (!ref->isPtsStrictlyIncreasing(mPrevOutputPts)),
                           log, "pts is not strictly increasing", isPass);
-                CHECK_ERR(loopCounter == 0 && !mIsAudio &&
-                                  (!ref->isOutPtsListIdenticalToInpPtsList(false)),
-                          log, "input pts list and output pts list are not identical", isPass);
+                // TODO: Timestamps for deinterlaced content are under review. (E.g. can decoders
+                // produce multiple progressive frames?) For now, do not verify timestamps.
+                if (!mIsInterlaced) {
+                    CHECK_ERR(loopCounter == 0 && !mIsAudio &&
+                                      (!ref->isOutPtsListIdenticalToInpPtsList(false)),
+                              log, "input pts list and output pts list are not identical", isPass);
+                }
                 if (validateFormat) {
                     if (mIsCodecInAsyncMode ? !mAsyncHandle.hasOutputFormatChanged()
                                             : !mSignalledOutFormatChanged) {
diff --git a/tests/media/src/android/mediav2/cts/CodecDecoderTest.java b/tests/media/src/android/mediav2/cts/CodecDecoderTest.java
index e7e0739..7a39cc7 100644
--- a/tests/media/src/android/mediav2/cts/CodecDecoderTest.java
+++ b/tests/media/src/android/mediav2/cts/CodecDecoderTest.java
@@ -352,9 +352,15 @@
                             assertTrue(log + " pts is not strictly increasing",
                                     ref.isPtsStrictlyIncreasing(mPrevOutputPts));
                         } else {
-                            assertTrue(
-                                    log + " input pts list and output pts list are not identical",
-                                    ref.isOutPtsListIdenticalToInpPtsList(false));
+                            // TODO: Timestamps for deinterlaced content are under review.
+                            // (E.g. can decoders produce multiple progressive frames?)
+                            // For now, do not verify timestamps.
+                            if (!mIsInterlaced) {
+                                    assertTrue(
+                                        log +
+                                        " input pts list and output pts list are not identical",
+                                        ref.isOutPtsListIdenticalToInpPtsList(false));
+                            }
                         }
                     }
                     if (validateFormat) {
@@ -411,8 +417,12 @@
                 assertTrue("reference output pts is not strictly increasing",
                         ref.isPtsStrictlyIncreasing(mPrevOutputPts));
             } else {
-                assertTrue("input pts list and output pts list are not identical",
-                        ref.isOutPtsListIdenticalToInpPtsList(false));
+                // TODO: Timestamps for deinterlaced content are under review. (E.g. can decoders
+                // produce multiple progressive frames?) For now, do not verify timestamps.
+                if (!mIsInterlaced) {
+                    assertTrue("input pts list and output pts list are not identical",
+                            ref.isOutPtsListIdenticalToInpPtsList(false));
+                }
             }
             mOutputBuff = test;
             setUpSource(mTestFile);
@@ -445,8 +455,10 @@
                 mExtractor.seekTo(0, mode);
                 test.reset();
                 doWork(23);
-                assertTrue(log + " pts is not strictly increasing",
-                        test.isPtsStrictlyIncreasing(mPrevOutputPts));
+                if (!mIsInterlaced) {
+                    assertTrue(log + " pts is not strictly increasing",
+                                test.isPtsStrictlyIncreasing(mPrevOutputPts));
+                }
 
                 boolean checkMetrics = (mOutputCount != 0);
 
@@ -544,10 +556,14 @@
                 assertTrue("config reference output pts is not strictly increasing",
                         configRef.isPtsStrictlyIncreasing(mPrevOutputPts));
             } else {
-                assertTrue("input pts list and reference pts list are not identical",
-                        ref.isOutPtsListIdenticalToInpPtsList(false));
-                assertTrue("input pts list and reconfig ref output pts list are not identical",
-                        ref.isOutPtsListIdenticalToInpPtsList(false));
+                // TODO: Timestamps for deinterlaced content are under review. (E.g. can decoders
+                // produce multiple progressive frames?) For now, do not verify timestamps.
+                if (!mIsInterlaced) {
+                    assertTrue("input pts list and reference pts list are not identical",
+                            ref.isOutPtsListIdenticalToInpPtsList(false));
+                    assertTrue("input pts list and reconfig ref output pts list are not identical",
+                            ref.isOutPtsListIdenticalToInpPtsList(false));
+                }
             }
             mOutputBuff = test;
             mCodec = MediaCodec.createByCodecName(mCodecName);
@@ -713,9 +729,14 @@
                         assertTrue(log + " pts is not strictly increasing",
                                 ref.isPtsStrictlyIncreasing(mPrevOutputPts));
                     } else {
-                        assertTrue(
-                                log + " input pts list and output pts list are not identical",
-                                ref.isOutPtsListIdenticalToInpPtsList(false));
+                        // TODO: Timestamps for deinterlaced content are under review.
+                        // (E.g. can decoders produce multiple progressive frames?)
+                        // For now, do not verify timestamps.
+                        if (!mIsInterlaced) {
+                            assertTrue(
+                                    log + " input pts list and output pts list are not identical",
+                                    ref.isOutPtsListIdenticalToInpPtsList(false));
+                        }
                     }
                 }
                 loopCounter++;
@@ -807,9 +828,15 @@
                                 assertTrue(log + " pts is not strictly increasing",
                                         ref.isPtsStrictlyIncreasing(mPrevOutputPts));
                             } else {
-                                assertTrue(
-                                        log + " input pts list and output pts list are not identical",
-                                        ref.isOutPtsListIdenticalToInpPtsList(false));
+                                // TODO: Timestamps for deinterlaced content are under review.
+                                // (E.g. can decoders produce multiple progressive frames?)
+                                // For now, do not verify timestamps.
+                                if (!mIsInterlaced) {
+                                    assertTrue(
+                                           log +
+                                           " input pts list and output pts list are not identical",
+                                           ref.isOutPtsListIdenticalToInpPtsList(false));
+                                }
                             }
                         }
                         if (validateFormat) {
@@ -869,8 +896,12 @@
                 assertTrue("reference output pts is not strictly increasing",
                         ref.isPtsStrictlyIncreasing(mPrevOutputPts));
             } else {
-                assertTrue("input pts list and output pts list are not identical",
-                        ref.isOutPtsListIdenticalToInpPtsList(false));
+                // TODO: Timestamps for deinterlaced content are under review. (E.g. can decoders
+                // produce multiple progressive frames?) For now, do not verify timestamps.
+                if (!mIsInterlaced) {
+                    assertTrue("input pts list and output pts list are not identical",
+                            ref.isOutPtsListIdenticalToInpPtsList(false));
+                }
             }
             mSaveToMem = true;
             mOutputBuff = test;
diff --git a/tests/media/src/android/mediav2/cts/CodecEncoderValidationTest.java b/tests/media/src/android/mediav2/cts/CodecEncoderValidationTest.java
index c553f1e..9ce7a8f 100644
--- a/tests/media/src/android/mediav2/cts/CodecEncoderValidationTest.java
+++ b/tests/media/src/android/mediav2/cts/CodecEncoderValidationTest.java
@@ -46,7 +46,6 @@
     private static final String INPUT_VIDEO_FILE_HBD = "cosmat_cif_24fps_yuv420p16le.yuv";
 
     private final boolean mUseHBD;
-    private final SupportClass mSupportRequirements;
     // Key: mediaType, Value: tolerance duration in ms
     private static final Map<String, Integer> toleranceMap = new HashMap<>();
 
@@ -59,11 +58,9 @@
     }
 
     public CodecEncoderValidationTest(String encoder, String mediaType, int[] bitrates,
-            int[] encoderInfo1, int[] encoderInfo2, boolean useHBD,
-            SupportClass supportRequirements) {
+            int[] encoderInfo1, int[] encoderInfo2, boolean useHBD) {
         super(encoder, mediaType, bitrates, encoderInfo1, encoderInfo2);
         mUseHBD = useHBD;
-        mSupportRequirements = supportRequirements;
     }
 
     @Parameterized.Parameters(name = "{index}({0})")
@@ -73,54 +70,51 @@
         final boolean needVideo = true;
         List<Object[]> defArgsList = new ArrayList<>(Arrays.asList(new Object[][]{
                 // Audio tests covering cdd sec 5.1.3
-                // mediaType, arrays of bit-rates, sample rates, channel counts, useHBD,
-                // SupportClass
+                // mediaType, arrays of bit-rates, sample rates, channel counts, useHBD
                 {MediaFormat.MIMETYPE_AUDIO_AAC, new int[]{64000, 128000}, new int[]{8000, 12000,
-                        16000, 22050, 24000, 32000, 44100, 48000}, new int[]{1, 2}, false,
-                        CODEC_ALL},
+                        16000, 22050, 24000, 32000, 44100, 48000}, new int[]{1, 2}, false},
                 {MediaFormat.MIMETYPE_AUDIO_OPUS, new int[]{64000, 128000}, new int[]{8000, 12000
-                        , 16000, 24000, 48000}, new int[]{1, 2}, false, CODEC_ALL},
+                        , 16000, 24000, 48000}, new int[]{1, 2}, false},
                 {MediaFormat.MIMETYPE_AUDIO_AMR_NB, new int[]{4750, 5150, 5900, 6700, 7400, 7950,
-                        10200, 12200}, new int[]{8000}, new int[]{1}, false, CODEC_ALL},
+                        10200, 12200}, new int[]{8000}, new int[]{1}, false},
                 {MediaFormat.MIMETYPE_AUDIO_AMR_WB, new int[]{6600, 8850, 12650, 14250, 15850,
-                        18250, 19850, 23050, 23850}, new int[]{16000}, new int[]{1}, false,
-                        CODEC_ALL},
+                        18250, 19850, 23050, 23850}, new int[]{16000}, new int[]{1}, false},
                 /* TODO(169310292) */
                 {MediaFormat.MIMETYPE_AUDIO_FLAC, new int[]{/* 0, 1, 2, */ 3, 4, 5, 6, 7, 8},
                         new int[]{8000, 16000, 32000, 48000, 96000, 192000}, new int[]{1, 2},
-                        false, CODEC_ALL},
+                        false},
                 {MediaFormat.MIMETYPE_AUDIO_FLAC, new int[]{/* 0, 1, 2, */ 3, 4, 5, 6, 7, 8},
                         new int[]{8000, 16000, 32000, 48000, 96000, 192000}, new int[]{1, 2},
-                        true, CODEC_ALL},
+                        true},
 
-                // mediaType, arrays of bit-rates, width, height, useHBD, SupportClass
+                // mediaType, arrays of bit-rates, width, height, useHBD
                 {MediaFormat.MIMETYPE_VIDEO_H263, new int[]{32000, 64000}, new int[]{176},
-                        new int[]{144}, false, CODEC_ALL},
+                        new int[]{144}, false},
                 {MediaFormat.MIMETYPE_VIDEO_MPEG4, new int[]{32000, 64000}, new int[]{176},
-                        new int[]{144}, false, CODEC_ALL},
+                        new int[]{144}, false},
                 {MediaFormat.MIMETYPE_VIDEO_AVC, new int[]{256000}, new int[]{352, 480},
-                        new int[]{240, 360}, false, CODEC_ALL},
+                        new int[]{240, 360}, false},
                 {MediaFormat.MIMETYPE_VIDEO_HEVC, new int[]{256000}, new int[]{352, 480},
-                        new int[]{240, 360}, false, CODEC_ALL},
+                        new int[]{240, 360}, false},
                 {MediaFormat.MIMETYPE_VIDEO_VP8, new int[]{256000}, new int[]{352, 480},
-                        new int[]{240, 360}, false, CODEC_ALL},
+                        new int[]{240, 360}, false},
                 {MediaFormat.MIMETYPE_VIDEO_VP9, new int[]{256000}, new int[]{352, 480},
-                        new int[]{240, 360}, false, CODEC_ALL},
+                        new int[]{240, 360}, false},
                 {MediaFormat.MIMETYPE_VIDEO_AV1, new int[]{256000}, new int[]{352, 480},
-                        new int[]{240, 360}, false, CODEC_ALL},
+                        new int[]{240, 360}, false},
         }));
         // P010 support was added in Android T, hence limit the following tests to Android T and
         // above
         if (IS_AT_LEAST_T) {
             defArgsList.addAll(Arrays.asList(new Object[][]{
                     {MediaFormat.MIMETYPE_VIDEO_AVC, new int[]{256000}, new int[]{352, 480},
-                            new int[]{240, 360}, true, CODEC_OPTIONAL},
+                            new int[]{240, 360}, true},
                     {MediaFormat.MIMETYPE_VIDEO_HEVC, new int[]{256000}, new int[]{352, 480},
-                            new int[]{240, 360}, true, CODEC_OPTIONAL},
+                            new int[]{240, 360}, true},
                     {MediaFormat.MIMETYPE_VIDEO_VP9, new int[]{256000}, new int[]{352, 480},
-                            new int[]{240, 360}, true, CODEC_OPTIONAL},
+                            new int[]{240, 360}, true},
                     {MediaFormat.MIMETYPE_VIDEO_AV1, new int[]{256000}, new int[]{352, 480},
-                            new int[]{240, 360}, true, CODEC_OPTIONAL},
+                            new int[]{240, 360}, true},
             }));
         }
         return prepareParamList(defArgsList, isEncoder, needAudio, needVideo, false);
@@ -131,7 +125,7 @@
             int colorFormat = mFormats.get(0).getInteger(MediaFormat.KEY_COLOR_FORMAT);
             Assume.assumeTrue(hasSupportForColorFormat(mCodecName, mMime, colorFormat));
         }
-        checkFormatSupport(mCodecName, mMime, true, mFormats, null, mSupportRequirements);
+        checkFormatSupport(mCodecName, mMime, true, mFormats, null, CODEC_OPTIONAL);
         setUpSource(inputFile);
         mOutputBuff = new OutputManager();
         {
diff --git a/tests/media/src/android/mediav2/cts/CodecInfoTest.java b/tests/media/src/android/mediav2/cts/CodecInfoTest.java
index 45f0e12..dc7a70f 100644
--- a/tests/media/src/android/mediav2/cts/CodecInfoTest.java
+++ b/tests/media/src/android/mediav2/cts/CodecInfoTest.java
@@ -160,6 +160,8 @@
     @Test
     public void testDecoderAvailability() {
         Assume.assumeTrue("Test is applicable only for encoders", mCodecInfo.isEncoder());
+        Assume.assumeTrue("Test is applicable for video/audio codecs",
+                mMediaType.startsWith("video/") || mMediaType.startsWith("audio/"));
         if (selectCodecs(mMediaType, null, null, true).size() > 0) {
             assertTrue("Device advertises support for encoding " + mMediaType +
                             ", but not decoding it",
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
index 15039fa..ec46c51 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothA2dpTest.java
@@ -151,7 +151,7 @@
 
         BluetoothDevice testDevice = mAdapter.getRemoteDevice("00:11:22:AA:BB:CC");
 
-        assertNull(mBluetoothA2dp.getCodecStatus(testDevice));
+        assertThrows(SecurityException.class, () -> mBluetoothA2dp.getCodecStatus(testDevice));
         assertThrows(IllegalArgumentException.class, () -> {
             mBluetoothA2dp.getCodecStatus(null);
         });
@@ -163,14 +163,6 @@
         assertTrue(waitForProfileConnect());
         assertNotNull(mBluetoothA2dp);
 
-        BluetoothDevice testDevice = mAdapter.getRemoteDevice("00:11:22:AA:BB:CC");
-
-        BluetoothCodecConfig codecConfig = new BluetoothCodecConfig.Builder()
-                .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC)
-                .setCodecPriority(0)
-                .build();
-        mBluetoothA2dp.setCodecConfigPreference(testDevice, codecConfig);
-        assertNull(mBluetoothA2dp.getCodecStatus(testDevice));
         assertThrows(IllegalArgumentException.class, () -> {
             mBluetoothA2dp.setCodecConfigPreference(null, null);
         });
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothAdapterTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothAdapterTest.java
index cf7e759..6962184a 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothAdapterTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothAdapterTest.java
@@ -22,6 +22,7 @@
 
 import android.annotation.NonNull;
 import android.app.UiAutomation;
+import android.bluetooth.BluetoothActivityEnergyInfo;
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothManager;
@@ -501,9 +502,21 @@
     public void test_requestControllerActivityEnergyInfo() {
         if (!mHasBluetooth) return;
 
+        BluetoothAdapter.OnBluetoothActivityEnergyInfoCallback callback =
+                new BluetoothAdapter.OnBluetoothActivityEnergyInfoCallback() {
+                    @Override
+                    public void onBluetoothActivityEnergyInfoAvailable(
+                            BluetoothActivityEnergyInfo info) {
+                        assertNotNull(info);
+                    }
+
+                    @Override
+                    public void onBluetoothActivityEnergyInfoError(int errorCode) {}
+                };
+
         // Verify parameter
         assertThrows(NullPointerException.class,
-                () -> mAdapter.requestControllerActivityEnergyInfo(null));
+                () -> mAdapter.requestControllerActivityEnergyInfo(null, callback));
     }
 
     public void test_clearBluetooth() {
diff --git a/tests/tests/content/src/android/content/cts/IntentTest.java b/tests/tests/content/src/android/content/cts/IntentTest.java
index 29d207e..dcd2fe6 100644
--- a/tests/tests/content/src/android/content/cts/IntentTest.java
+++ b/tests/tests/content/src/android/content/cts/IntentTest.java
@@ -16,6 +16,8 @@
 
 package android.content.cts;
 
+import static org.junit.Assert.assertArrayEquals;
+
 import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -29,6 +31,7 @@
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.Parcel;
+import android.os.Parcelable;
 import android.os.ServiceManager;
 import android.platform.test.annotations.AppModeFull;
 import android.provider.Contacts.People;
@@ -154,6 +157,34 @@
         assertEquals(expected, target);
     }
 
+    public void testGetParcelableArrayListExtraTypeSafe_withMismatchingType_returnsNull() {
+        final ArrayList<TestParcelable> original = new ArrayList<>();
+        original.add(new TestParcelable(0));
+        mIntent.putParcelableArrayListExtra(TEST_EXTRA_NAME, original);
+        roundtrip();
+        assertNull(mIntent.getParcelableArrayListExtra(TEST_EXTRA_NAME, Intent.class));
+    }
+
+    public void testGetParcelableArrayListExtraTypeSafe_withMatchingType_returnsObject() {
+        final ArrayList<TestParcelable> original = new ArrayList<>();
+        original.add(new TestParcelable(0));
+        original.add(new TestParcelable(1));
+        mIntent.putParcelableArrayListExtra(TEST_EXTRA_NAME, original);
+        roundtrip();
+        assertEquals(original,
+                mIntent.getParcelableArrayListExtra(TEST_EXTRA_NAME, TestParcelable.class));
+    }
+
+    public void testGetParcelableArrayListExtraTypeSafe_withBaseType_returnsObject() {
+        final ArrayList<TestParcelable> original = new ArrayList<>();
+        original.add(new TestParcelable(0));
+        original.add(new TestParcelable(1));
+        mIntent.putParcelableArrayListExtra(TEST_EXTRA_NAME, original);
+        roundtrip();
+        assertEquals(original,
+                mIntent.getParcelableArrayListExtra(TEST_EXTRA_NAME, Parcelable.class));
+    }
+
     public void testFilterHashCode() {
         mIntent.filterHashCode();
     }
@@ -609,6 +640,23 @@
         assertEquals(expected, mIntent.getParcelableExtra(TEST_EXTRA_NAME));
     }
 
+    public void testGetParcelableExtraTypeSafe_withMismatchingType_returnsNull() {
+        mIntent.putExtra(TEST_EXTRA_NAME, new TestParcelable(42));
+        assertNull(mIntent.getParcelableExtra(TEST_EXTRA_NAME, Intent.class));
+    }
+
+    public void testGetParcelableExtraTypeSafe_withMatchingType_returnsObject() {
+        final TestParcelable original = new TestParcelable(42);
+        mIntent.putExtra(TEST_EXTRA_NAME, original);
+        assertEquals(original, mIntent.getParcelableExtra(TEST_EXTRA_NAME, TestParcelable.class));
+    }
+
+    public void testGetParcelableExtraTypeSafe_withBaseType_returnsObject() {
+        final TestParcelable original = new TestParcelable(42);
+        mIntent.putExtra(TEST_EXTRA_NAME, original);
+        assertEquals(original, mIntent.getParcelableExtra(TEST_EXTRA_NAME, Parcelable.class));
+    }
+
     public void testAccessAction() {
         mIntent.setAction(TEST_ACTION);
         assertEquals(TEST_ACTION, mIntent.getAction());
@@ -736,7 +784,29 @@
     public void testGetParcelableArrayExtra() {
         final Intent[] expected = { new Intent(TEST_ACTION), new Intent(mContext, MockActivity.class) };
         mIntent.putExtra(TEST_EXTRA_NAME, expected);
-        assertEquals(expected, mIntent.getParcelableArrayExtra(TEST_EXTRA_NAME));
+        assertArrayEquals(expected, mIntent.getParcelableArrayExtra(TEST_EXTRA_NAME));
+    }
+
+    public void testGetParcelableArrayExtraTypeSafe_withMismatchingType_returnsNull() {
+        mIntent.putExtra(TEST_EXTRA_NAME, new TestParcelable[] {new TestParcelable(42)});
+        roundtrip();
+        assertNull(mIntent.getParcelableArrayExtra(TEST_EXTRA_NAME, Intent.class));
+    }
+
+    public void testGetParcelableArrayExtraTypeSafe_withMatchingType_returnsObject() {
+        final TestParcelable[] original = { new TestParcelable(1), new TestParcelable(2) };
+        mIntent.putExtra(TEST_EXTRA_NAME, original);
+        roundtrip();
+        assertArrayEquals(original,
+                mIntent.getParcelableArrayExtra(TEST_EXTRA_NAME, TestParcelable.class));
+    }
+
+    public void testGetParcelableArrayExtraTypeSafe_withBaseType_returnsObject() {
+        final TestParcelable[] original = { new TestParcelable(1), new TestParcelable(2) };
+        mIntent.putExtra(TEST_EXTRA_NAME, original);
+        roundtrip();
+        assertArrayEquals(original,
+                mIntent.getParcelableArrayExtra(TEST_EXTRA_NAME, Parcelable.class));
     }
 
     public void testResolveActivityEmpty() {
@@ -1811,6 +1881,26 @@
         assertEquals(expected.Name, target.Name);
     }
 
+    public void testGetSerializableExtraTypeSafe_withMismatchingType_returnsNull() {
+        mIntent.putExtra(TEST_EXTRA_NAME, new TestSerializable());
+        roundtrip();
+        assertNull(mIntent.getSerializableExtra(TEST_EXTRA_NAME, Long.class));
+    }
+
+    public void testGetSerializableExtraTypeSafe_withMatchingType_returnsObject() {
+        String original = "Hello, World!";
+        mIntent.putExtra(TEST_EXTRA_NAME, original);
+        roundtrip();
+        assertEquals(original, mIntent.getSerializableExtra(TEST_EXTRA_NAME, String.class));
+    }
+
+    public void testGetSerializableExtraTypeSafe_withBaseType_returnsObject() {
+        String original = "Hello, World!";
+        mIntent.putExtra(TEST_EXTRA_NAME, original);
+        roundtrip();
+        assertEquals(original, mIntent.getSerializableExtra(TEST_EXTRA_NAME, Serializable.class));
+    }
+
     public void testReplaceExtras() {
         Bundle extras = new Bundle();
         String bundleKey = "testKey";
@@ -1840,8 +1930,66 @@
         assertEquals("foo/bar", Intent.normalizeMimeType("   foo/bar    "));
     }
 
+    private void roundtrip() {
+        Parcel p = Parcel.obtain();
+        p.writeParcelable(mIntent, 0);
+        p.setDataPosition(0);
+        mIntent = p.readParcelable(getClass().getClassLoader(), Intent.class);
+        mIntent.setExtrasClassLoader(getClass().getClassLoader());
+    }
+
     private static class TestSerializable implements Serializable {
         static final long serialVersionUID = 1l;
         public String Name;
     }
+
+    private static class TestParcelable implements Parcelable {
+        public final int value;
+
+        TestParcelable(int value) {
+            this.value = value;
+        }
+
+        protected TestParcelable(Parcel in) {
+            value = in.readInt();
+        }
+
+        @Override
+        public int describeContents() {
+            return 0;
+        }
+
+        @Override
+        public void writeToParcel(Parcel out, int flags) {
+            out.writeInt(value);
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (this == other) {
+                return true;
+            }
+            if (!(other instanceof TestParcelable)) {
+                return false;
+            }
+            TestParcelable that = (TestParcelable) other;
+            return value == that.value;
+        }
+
+        @Override
+        public int hashCode() {
+            return value;
+        }
+
+        public static final Creator<TestParcelable> CREATOR = new Creator<TestParcelable>() {
+            @Override
+            public TestParcelable createFromParcel(Parcel in) {
+                return new TestParcelable(in);
+            }
+            @Override
+            public TestParcelable[] newArray(int size) {
+                return new TestParcelable[size];
+            }
+        };
+    }
 }
diff --git a/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java b/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java
index d05e231..291afc9 100644
--- a/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java
+++ b/tests/tests/dpi/src/android/dpi/cts/ConfigurationScreenLayoutTest.java
@@ -16,6 +16,10 @@
 
 package android.dpi.cts;
 
+import static android.view.Display.DEFAULT_DISPLAY;
+
+import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
@@ -27,7 +31,11 @@
 import android.view.Display;
 import android.view.WindowManager;
 
-import androidx.test.InstrumentationRegistry;
+import com.android.compatibility.common.util.SystemUtil;
+
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 public class ConfigurationScreenLayoutTest
         extends ActivityInstrumentationTestCase2<OrientationActivity> {
@@ -43,6 +51,48 @@
         super(OrientationActivity.class);
     }
 
+    private static String executeShellCommand(String command) {
+        try {
+            return SystemUtil.runShellCommand(
+                    androidx.test.platform.app.InstrumentationRegistry.getInstrumentation(),
+                    command);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    // Mirrored from ActivityManagerTestBase.java
+    public static class IgnoreOrientationRequestSession implements AutoCloseable {
+        private static final String WM_SET_IGNORE_ORIENTATION_REQUEST =
+                "wm set-ignore-orientation-request ";
+        private static final String WM_GET_IGNORE_ORIENTATION_REQUEST =
+                "wm get-ignore-orientation-request";
+        private static final Pattern IGNORE_ORIENTATION_REQUEST_PATTERN =
+                Pattern.compile("ignoreOrientationRequest (true|false) for displayId=\\d+");
+
+        final int mDisplayId;
+        final boolean mInitialIgnoreOrientationRequest;
+
+        IgnoreOrientationRequestSession(int displayId, boolean enable) {
+            mDisplayId = displayId;
+            Matcher matcher = IGNORE_ORIENTATION_REQUEST_PATTERN.matcher(
+                    executeShellCommand(WM_GET_IGNORE_ORIENTATION_REQUEST + " -d " + mDisplayId));
+            assertTrue("get-ignore-orientation-request should match pattern",
+                    matcher.find());
+            mInitialIgnoreOrientationRequest = Boolean.parseBoolean(matcher.group(1));
+
+            executeShellCommand("wm set-ignore-orientation-request " + (enable ? "true" : "false")
+                    + " -d " + mDisplayId);
+        }
+
+        @Override
+        public void close() {
+            executeShellCommand(
+                    WM_SET_IGNORE_ORIENTATION_REQUEST + mInitialIgnoreOrientationRequest + " -d "
+                            + mDisplayId);
+        }
+    }
+
     public void testScreenLayout() throws Exception {
         if (!supportsRotation()) {
             // test has no effect if device does not support rotation
@@ -57,26 +107,35 @@
             tearDown();
             return;
         }
-        int expectedScreenLayout = computeScreenLayout();
-        int expectedSize = expectedScreenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
-        int expectedLong = expectedScreenLayout & Configuration.SCREENLAYOUT_LONG_MASK;
+        // Disable IgnoreOrientationRequest feature because when it's enabled, the device would only
+        // follow physical rotations.
+        try (IgnoreOrientationRequestSession session =
+                     new IgnoreOrientationRequestSession(DEFAULT_DISPLAY, false)) {
+            int expectedScreenLayout = computeScreenLayout();
+            int expectedSize = expectedScreenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
+            int expectedLong = expectedScreenLayout & Configuration.SCREENLAYOUT_LONG_MASK;
 
-        // Check that all four orientations report the same configuration value.
-        for (int i = 0; i < ORIENTATIONS.length; i++) {
-            Activity activity = startOrientationActivity(ORIENTATIONS[i]);
-            if (activity.isInMultiWindowMode()) {
-                // activity.setRequestedOrientation has no effect in multiwindow mode.
+            // Check that all four orientations report the same configuration value.
+            for (int i = 0; i < ORIENTATIONS.length; i++) {
+                Activity activity = startOrientationActivity(ORIENTATIONS[i]);
+                if (activity.isInMultiWindowMode()) {
+                    // activity.setRequestedOrientation has no effect in multiwindow mode.
+                    tearDown();
+                    return;
+                }
+                Configuration mConfig = activity.getResources().getConfiguration();
+                int actualSize = mConfig.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
+                int actualLong = mConfig.screenLayout & Configuration.SCREENLAYOUT_LONG_MASK;
+
+                assertEquals("Expected screen size value of " + expectedSize + " but got "
+                        + actualSize + " for orientation "
+                        + ORIENTATIONS[i], expectedSize, actualSize);
+                assertEquals("Expected screen long value of " + expectedLong + " but got "
+                        + actualLong + " for orientation "
+                        + ORIENTATIONS[i], expectedLong, actualLong);
                 tearDown();
-                return;
             }
-            Configuration mConfig = activity.getResources().getConfiguration();
-            int actualSize = mConfig.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
-            int actualLong = mConfig.screenLayout & Configuration.SCREENLAYOUT_LONG_MASK;
-
-            assertEquals("Expected screen size value of " + expectedSize + " but got " + actualSize
-                    + " for orientation " + ORIENTATIONS[i], expectedSize, actualSize);
-            assertEquals("Expected screen long value of " + expectedLong + " but got " + actualLong
-                    + " for orientation " + ORIENTATIONS[i], expectedLong, actualLong);
+        } finally {
             tearDown();
         }
     }
@@ -102,7 +161,7 @@
     }
 
     private boolean hasDeviceFeature(final String requiredFeature) {
-        return InstrumentationRegistry.getContext()
+        return getInstrumentation().getContext()
                 .getPackageManager()
                 .hasSystemFeature(requiredFeature);
     }
diff --git a/tests/tests/nativehardware/jni/AHardwareBufferTest.cpp b/tests/tests/nativehardware/jni/AHardwareBufferTest.cpp
index 08eba99..61b27a0 100644
--- a/tests/tests/nativehardware/jni/AHardwareBufferTest.cpp
+++ b/tests/tests/nativehardware/jni/AHardwareBufferTest.cpp
@@ -42,6 +42,8 @@
 
 using testing::AnyOf;
 using testing::Eq;
+using testing::Ge;
+using testing::NotNull;
 
 #define FORMAT_CASE(x) case AHARDWAREBUFFER_FORMAT_ ## x: os << #x ; break
 
@@ -439,6 +441,57 @@
     AHardwareBuffer_release(buffer);
 }
 
+TEST(AHardwareBufferTest, PlanarLockAndUnlockYuvP010Succeed) {
+    AHardwareBuffer* buffer = NULL;
+    AHardwareBuffer_Desc desc = {};
+
+    desc.width = 32;
+    desc.height = 32;
+    desc.layers = 1;
+    desc.usage = AHARDWAREBUFFER_USAGE_CPU_READ_RARELY;
+    desc.format = AHARDWAREBUFFER_FORMAT_YCbCr_P010;
+
+    if (!AHardwareBuffer_isSupported(&desc)) {
+        ALOGI("Test skipped: AHARDWAREBUFFER_FORMAT_YCbCr_P010 not supported.");
+        return;
+    }
+
+    // Allocate the buffer.
+    int err = AHardwareBuffer_allocate(&desc, &buffer);
+    EXPECT_EQ(NO_ERROR, err);
+
+    // Lock its planes
+    AHardwareBuffer_Planes planes;
+    err = AHardwareBuffer_lockPlanes(buffer, AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, -1, NULL,
+        &planes);
+
+    // Make sure everything looks right
+    EXPECT_EQ(NO_ERROR, err);
+    EXPECT_EQ(3U, planes.planeCount);
+
+    const uint32_t yPlaneWidth = desc.width;
+    const uint32_t cPlaneWidth = desc.width / 2;
+    const uint32_t bytesPerPixel = 2;
+
+    EXPECT_THAT(planes.planes[0].data, NotNull());
+    EXPECT_THAT(planes.planes[0].pixelStride, Eq(bytesPerPixel));
+    EXPECT_THAT(planes.planes[0].rowStride, Ge(yPlaneWidth * bytesPerPixel));
+
+    EXPECT_THAT(planes.planes[1].data, NotNull());
+    EXPECT_THAT(planes.planes[1].pixelStride, Eq(bytesPerPixel * /*interleaved=*/2));
+    EXPECT_THAT(planes.planes[1].rowStride, Ge(cPlaneWidth * bytesPerPixel));
+
+    EXPECT_THAT(planes.planes[2].data, NotNull());
+    EXPECT_THAT(planes.planes[2].pixelStride, Eq(bytesPerPixel * /*interleaved=*/2));
+    EXPECT_THAT(planes.planes[2].rowStride, Ge(cPlaneWidth * bytesPerPixel));
+
+    // Unlock
+    err = AHardwareBuffer_unlock(buffer, nullptr);
+    EXPECT_EQ(NO_ERROR, err);
+
+    AHardwareBuffer_release(buffer);
+}
+
 TEST(AHardwareBufferTest, PlanarLockAndUnlockRgbaSucceed) {
     AHardwareBuffer* buffer = NULL;
     AHardwareBuffer_Desc desc = {};
diff --git a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsCallingTest.java b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsCallingTest.java
index b563d16..62f0f01 100644
--- a/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsCallingTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/ims/cts/ImsCallingTest.java
@@ -381,7 +381,6 @@
 
         if (sServiceConnector != null && sIsBound) {
             sServiceConnector.disconnectCarrierImsService();
-            sServiceConnector.disconnectServices();
             sIsBound = false;
         }
     }
diff --git a/tests/tests/view/src/android/view/cts/AttachedSurfaceControlTest.java b/tests/tests/view/src/android/view/cts/AttachedSurfaceControlTest.java
index 8ba340a..962d75a 100644
--- a/tests/tests/view/src/android/view/cts/AttachedSurfaceControlTest.java
+++ b/tests/tests/view/src/android/view/cts/AttachedSurfaceControlTest.java
@@ -17,12 +17,14 @@
 
 import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
 import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
+import static android.view.Display.DEFAULT_DISPLAY;
 
 import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
 import android.util.Log;
+import android.server.wm.ActivityManagerTestBase;
 import android.view.AttachedSurfaceControl;
 
 import androidx.lifecycle.Lifecycle;
@@ -34,6 +36,7 @@
 
 import org.junit.Assert;
 import org.junit.Assume;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -48,6 +51,7 @@
 @RequiresDevice
 public class AttachedSurfaceControlTest {
     private static final String TAG = "AttachedSurfaceControlTest";
+    private ActivityManagerTestBase.IgnoreOrientationRequestSession mOrientationSession;
 
     private static class TransformHintListener implements
             AttachedSurfaceControl.OnBufferTransformHintChangedListener {
@@ -77,7 +81,6 @@
         }
     }
 
-
     @Before
     public void setup() {
         PackageManager pm =
@@ -85,6 +88,12 @@
         boolean supportsRotation = pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_PORTRAIT)
                 && pm.hasSystemFeature(PackageManager.FEATURE_SCREEN_LANDSCAPE);
         Assume.assumeTrue(supportsRotation);
+        mOrientationSession = new ActivityManagerTestBase.IgnoreOrientationRequestSession(DEFAULT_DISPLAY, false);
+    }
+
+    @After
+    public void teardown() {
+        mOrientationSession.close();
     }
 
     @Test
@@ -175,10 +184,9 @@
             // If the device is already in landscape, do nothing.
             if (firstCallback[0] != null) {
                 Assert.assertTrue(firstCallback[0].await(3, TimeUnit.SECONDS));
-            }
-            // Check the callback value matches the call to get the transform hint.
-            scenario.onActivity(activity -> Assert.assertEquals(transformHintResult[0],
+                scenario.onActivity(activity -> Assert.assertEquals(transformHintResult[0],
                     activity.getWindow().getRootSurfaceControl().getBufferTransformHint()));
+            }
 
             scenario.onActivity(activity -> {
                 TransformHintListener listener = new TransformHintListener(activity,