Merge changes from topics "nfc_aosp_main_merge", "nfc_aosp_main_merge_stage2" into main
* changes:
Create a HostTestsActivity to support general host-side tests.
(1) Add Nfc test instruction into the dialog. (2) Add the non-NFC supported case information to dialog. (3) Remove the check for CTS Verifier installation.
Change the multi-device tile to NFC tests
[Support Multi-device in CTS-V] Enable the pipeline to add and trigger multidevice tests and return results to CTS-V.
[Support Multi-device in CTS-V] Add CtsNfcHceMultiDeviceTestCases into CTS-V.
Remove discovery tech multidevice tests
Have XWalletRoleHolderService point to the correct aid list.
Assume that observe mode is supported
Skip testSendVendorCmd on VSR Android U and below
Test multple services receiving polling loops for auto-disabling
Test that we autotransact if the service receiving polling loop notifications hasn't come to the foreground or disabled observe mode after 3s.
Ignore multi-device tests if NFC not supported.
Test that observe mode is enabled after NFC is turned on if the preferred service sets shouldDefaultToObserveMode
Lengthen timeout to re-enable observe mode after an autotransaction
Add test for multiple custom frames being filtered by different services
Test sending two full loops with a custom loop that matches a filter.
Update SDK version check to 35
Add observe mode supported assumption for setShouldDefaultToObserveMode
Remove CTS-V manual tests for NFC HCE tests as they are covered by new multidevice tests (live here now: https://source.corp.google.com/h/googleplex-android/platform/superproject/main/+/main:cts/hostsidetests/multidevices/nfc/cts_nfc_hce_multi_device_test.py).
Migrate NFC test config to 2.0 to set up CI tests with ATP.
Wait for 2 full loops before sending polling loops to the preferred service
Test for setDefaultDiscoveryTechnology
Calling setShouldDefaultToObserveModeForService should set observe mode for service.
[cts(nfc)] cts tests for nfc OEM extension
nfc(cts): Add trunk stable flag check for sendVendorCmd test
Revert "CTSVerifier test for Observe Mode"
Test that observe mode doesn't change if the preferred service doesn't change
Add test for polling loop with no OFFs
Ensure preferred service set in CTS tests before proceeding.
nfc(multi-device-cts): Test to verify routing is set after NFC toggle
Refactoring common multidevice test code to packages/apps/Nfc.
Sets foreground preference for PrefixAccessService due to AID conflict.
Update CardEmulationTest to check for enabled nfc when setting nfc observe mode.
[Nfc] Add cts tests for enable/disable nfc by DO/PO.
Assert that role holder removal succeeds.
nfc(cts-multidevice): Log test start/end in logcat
Increase timeout of ensureUnlocked() to 30s and Assume that the user is a Main user
nfc(multi-device-cts): Add CDD requirement annotations for test
cts(multi-device-cts): Add test for setDiscoveryTech tech mismatch scenario
cts(multi-device-cts): Add test for setDiscoveryTech
cts(multi-device-cts): Take bugreport on failure
cts(multi-device-cts): Add parameterized poll & listen tech RPCs
nfc(multi-device-cts): Turn reader screen on before every test
nfc(cts-verifier): Add observe mode reader tests under feature check
Re-enable `testAidResolutionWithRoleHolder_holderDoesNotSupportAid_overLappingAids`
Poll observe mode value assertions in autotransact tests
Test that only the currently preferred service can enable and disable observe mode
Test that Offhost NFC services shouldn't be able to register non-autotransact polling loop filters
autoTransact tests unnecessarily require wallet role disabled
WalletRoleTestUtils should not use assumeTrue for method success
CTS MultiDevice Test for Screen-On Only OffHost Service.
CTS Multidevice Tests for Conflicting Non-Payment AIDs test, and Conflicting Non-Payment Prefix AIDs test. Also includes refactoring to make resource configuration work (needed to fetch string resources for this test to pass properly.)
Multidevice CTS NFC tests for: Other Prefix AIDs, Dual Non-Payment, Foreground Non-Payment, Throughput, Tap 50 Times, Large Num AIDs, Screen Off Payment, and Protocol Params test.
Reduce the use of mocks in NfcAdapterTest
Add offhost NFC multidevice tests
Multidevice CTS NFC tests for: Dual Payment, Foreground override payment services, Dynamic Payment AIDs, Payment Prefix AIDs, Payment Prefix AIDs 2 Test result: https://fusion2.corp.google.com/invocations/8b93adad-fbb3-49ef-9120-c5443d155c3e;mt=CtsNfcHceMultiDeviceTestCases;mc=default/targets/CtsNfcHceMultiDeviceTestCases;config=default/tests?q=target:CtsNfcHceMultiDeviceTestCases 11/1100 failures (1%) - being tracked at b/333102067
Get polling frames after a single loop instead of two
notifyPollingLoop test method should exercise NativeNfcManager
Single Payment Service NFC tests. Includes changes to support selecting default wallet role Test result: https://fusion2.corp.google.com/invocations/99508856-385a-4a26-90fb-dab5b4e52ac3/targets/CtsNfcHceMultiDeviceTestCases;config=default/timing
Fix Wearable overlayconfig test. Some overlay configs(ie gmscore) is not role eligible for certain builds such as wearable.
Test that timestamps are a value outside the range of a signed Integer
Add test for filter removal
[nfc] Add package name as argument when enable/disable nfc.
nfc(cts): Add INTERACT_ACROSS_USERS permission
Add API for polling loop pattern filters based on developer feedback.
WalletRoleTests should only run on nfc devices.
Provide information on whether a polling frame is auto-transact
Add tests to test wallet role migration.
Fixing CTS-V Polling Loop tests
Rename getGain() to getVendorSpecificGain()
diff --git a/apps/CameraITS/tools/run_all_tests.py b/apps/CameraITS/tools/run_all_tests.py
index ed09268..dcaa9bf 100755
--- a/apps/CameraITS/tools/run_all_tests.py
+++ b/apps/CameraITS/tools/run_all_tests.py
@@ -355,7 +355,7 @@
logging.info('Capturing an image to check the test scene')
cap = cam.do_capture(req, fmt)
img = image_processing_utils.convert_capture_to_rgb_image(cap)
- img_name = os.path.join(out_path, f'test_{scene}.jpg')
+ img_name = os.path.join(out_path, f'test_{scene.replace("/", "_")}.jpg')
logging.info('Please check scene setup in %s', img_name)
image_processing_utils.write_image(img, img_name)
choice = input(f'Is the image okay for ITS {scene}? (Y/N)').lower()
diff --git a/apps/CtsVerifier/res/layout-small/positive_device_owner.xml b/apps/CtsVerifier/res/layout-small/positive_device_owner.xml
index 6a9274c..719f58a 100644
--- a/apps/CtsVerifier/res/layout-small/positive_device_owner.xml
+++ b/apps/CtsVerifier/res/layout-small/positive_device_owner.xml
@@ -43,7 +43,7 @@
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
- android:layout_height="1200dp"/>
+ android:layout_height="1400dp"/>
</LinearLayout>
</ScrollView>
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/KeyManagementTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/KeyManagementTest.java
index 30ce15f..bdcb590 100755
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/KeyManagementTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/KeyManagementTest.java
@@ -20,6 +20,8 @@
import static android.app.admin.DevicePolicyManager.ID_TYPE_INDIVIDUAL_ATTESTATION;
import static android.app.admin.DevicePolicyManager.ID_TYPE_MEID;
import static android.app.admin.DevicePolicyManager.ID_TYPE_SERIAL;
+import static android.content.pm.PackageManager.FEATURE_TELEPHONY_CDMA;
+import static android.content.pm.PackageManager.FEATURE_TELEPHONY_GSM;
import static android.keystore.cts.CertificateUtils.createCertificate;
import static com.google.common.truth.Truth.assertThat;
@@ -461,15 +463,19 @@
assertWithMessage("Need to be able to read device identifiers")
.that(telephonyService)
.isNotNull();
- imei = telephonyService.getImei(0);
- meid = telephonyService.getMeid(0);
- // If the device has a valid IMEI it must support attestation for it.
- if (imei != null) {
- modesToTest.add(ID_TYPE_IMEI);
+ if (mContext.getPackageManager().hasSystemFeature(FEATURE_TELEPHONY_GSM)) {
+ imei = telephonyService.getImei(0);
+ // If the device has a valid IMEI it must support attestation for it.
+ if (imei != null) {
+ modesToTest.add(ID_TYPE_IMEI);
+ }
}
- // Same for MEID
- if (meid != null) {
- modesToTest.add(ID_TYPE_MEID);
+ if (mContext.getPackageManager().hasSystemFeature(FEATURE_TELEPHONY_CDMA)) {
+ meid = telephonyService.getMeid(0);
+ // Same for MEID
+ if (meid != null) {
+ modesToTest.add(ID_TYPE_MEID);
+ }
}
}
int numCombinations = 1 << modesToTest.size();
diff --git a/hostsidetests/os/OWNERS b/hostsidetests/os/OWNERS
index 867f59d..cda6a22 100644
--- a/hostsidetests/os/OWNERS
+++ b/hostsidetests/os/OWNERS
@@ -4,3 +4,4 @@
per-file InattentiveSleepTests.java=qingxun@google.com
per-file QuiescentBootTests.java=qingxun@google.com
per-file StaticSharedLibsHostTests.java=patb@google.com
+per-file MemcgV2HostTests.java=tjmercier@google.com
diff --git a/hostsidetests/os/src/android/os/cts/MemcgV2HostTests.java b/hostsidetests/os/src/android/os/cts/MemcgV2HostTests.java
new file mode 100644
index 0000000..81bf31e
--- /dev/null
+++ b/hostsidetests/os/src/android/os/cts/MemcgV2HostTests.java
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) 2024 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 android.os.cts;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
+
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
+import com.android.tradefed.util.CommandResult;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+
+/*
+ * These tests exercise kernel UAPIs for memory control groups (memcg) version 2, which Android may
+ * use if configured to do so.
+ *
+ * No Android interfaces are tested here.
+ *
+ * If the device does not have memcg v2 enabled the tests will be skipped, but they will fail if
+ * we cannot determine whether memcg v2 is enabled or not.
+ */
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class MemcgV2HostTests extends BaseHostJUnit4Test {
+
+ // For the remote possibility that it has been mounted somewhere other than the default
+ private String getCgroupV2MountPoint() {
+ try {
+ CommandResult commandResult = getDevice().executeShellV2Command("mount | grep cgroup2");
+ if (commandResult.getExitCode() == 0) {
+ String[] tokens = commandResult.getStdout().split("\\s+");
+ return tokens[2];
+ }
+ } catch (Exception ignore) { }
+
+ // Hope the default is correct
+ return "/sys/fs/cgroup";
+ }
+
+ private Boolean isMemcgV2Enabled() {
+ try {
+ CommandResult commandResult = getDevice().executeShellV2Command(
+ "grep memory /proc/cgroups");
+
+ if (commandResult.getExitCode() == 0) {
+ String[] tokens = commandResult.getStdout().split("\\s+");
+ boolean memcg_enabled = tokens[3].equals("1");
+ if (!memcg_enabled) return false;
+ return tokens[1].equals("0"); // 0 == default hierarchy == v2
+ } else if (commandResult.getExitCode() == 1) { // "memory" not found by grep
+ // We know for sure it's not enabled, either because it is mounted as v1
+ // (cgroups.json override), or because it was intentionally disabled via kernel
+ // command line (cgroup_disable=memory), or because it's not built in to the
+ // kernel (CONFIG_MEMCG is not set).
+ return false;
+ } else { // Problems accessing /proc/cgroups
+ CLog.w("Could not read /proc/cgroups: " + commandResult.getStderr());
+ // We don't really know if it's enabled or not. Try checking the root
+ // cgroup.controllers file directly.
+ String cg_controllers_path = mCgroupV2Root + "/cgroup.controllers";
+
+ commandResult = getDevice().executeShellV2Command(
+ "grep memory " + cg_controllers_path);
+ if (commandResult.getExitCode() == 0) return true;
+ if (commandResult.getExitCode() == 1) return false;
+
+ CLog.e("Could not determine if memcg v2 is enabled: " + commandResult.getStderr());
+ }
+ } catch (Exception e) {
+ CLog.e(e.toString());
+ }
+ return null;
+ }
+
+ // Record the original subtree state for memcg so we can restore it after the test if necessary
+ private Boolean checkRootSubtreeState() {
+ try {
+ CommandResult commandResult = getDevice().executeShellV2Command(
+ "grep memory " + mCgroupV2Root + "/cgroup.subtree_control");
+ if (commandResult.getExitCode() == 0) return true;
+ if (commandResult.getExitCode() == 1) return false;
+
+ CLog.e("Could not determine if root memcg subtree control is enabled: "
+ + commandResult.getStderr());
+ } catch (Exception e) {
+ CLog.e(e.toString());
+ }
+ return null;
+ }
+
+ private String mCgroupV2Root;
+ private Boolean mMemcgV2Enabled;
+ private Boolean mRootSubtreeStateWasEnabled;
+ private String mChildCgroup;
+
+ @Before
+ public void initialize() {
+ mCgroupV2Root = getCgroupV2MountPoint();
+ mMemcgV2Enabled = isMemcgV2Enabled();
+ mRootSubtreeStateWasEnabled = checkRootSubtreeState();
+
+ assertNotNull(mMemcgV2Enabled);
+ assertNotNull(mRootSubtreeStateWasEnabled);
+ }
+
+ @After
+ public void cleanup() {
+ try {
+ if (mChildCgroup != null) getDevice().executeShellV2Command("rmdir " + mChildCgroup);
+
+ if (mRootSubtreeStateWasEnabled != null && !mRootSubtreeStateWasEnabled) {
+ getDevice().executeShellV2Command(
+ "echo -memory > " + mCgroupV2Root + "/cgroup.subtree_control");
+ }
+ } catch (Exception ignore) { }
+ }
+
+ @Test
+ public void testCanActivateMemcgV2Cgroup() throws Exception {
+ assumeTrue(mMemcgV2Enabled);
+
+ // The root has to have memcg in the subtree control to activate it in children
+ if (!mRootSubtreeStateWasEnabled) {
+ CommandResult commandResult = getDevice().executeShellV2Command(
+ "echo +memory > " + mCgroupV2Root + "/cgroup.subtree_control");
+ assertTrue("Could not activate memcg under root", commandResult.getExitCode() == 0);
+ }
+
+ // Make a new, temporary, randomly-named v2 cgroup in which we will attempt to activate
+ // memcg
+ CommandResult commandResult = getDevice().executeShellV2Command(
+ "mktemp -d -p " + mCgroupV2Root + " " + this.getClass().getSimpleName()
+ + ".XXXXXXXXXX");
+ assertTrue("Could not make child cgroup", commandResult.getExitCode() == 0);
+
+ mChildCgroup = commandResult.getStdout();
+
+
+ commandResult = getDevice().executeShellV2Command(
+ "grep memory " + mChildCgroup + "/cgroup.controllers");
+ assertTrue("Memcg was not activated in child cgroup", commandResult.getExitCode() == 0);
+
+
+ commandResult = getDevice().executeShellV2Command(
+ "echo +memory > " + mChildCgroup + "/cgroup.subtree_control");
+ assertTrue("Could not activate memcg for child cgroup subtree",
+ commandResult.getExitCode() == 0);
+ }
+
+
+ // Test for fix: mm: memcg: use larger batches for proactive reclaim
+ // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=287d5fedb377ddc232b216b882723305b27ae31a
+ @Test(timeout = 20000)
+ public void testProactiveReclaimDoesntTakeForever() throws Exception {
+ // Not all kernels have memory.reclaim
+ CommandResult commandResult = getDevice().executeShellV2Command(
+ "test -f " + mCgroupV2Root + "/memory.reclaim");
+ assumeTrue(commandResult.getExitCode() == 0);
+
+ getDevice().executeShellV2Command(
+ "echo \"\" > " + mCgroupV2Root + "/memory.reclaim");
+ // This is a test for completion within the timeout. The command is likely to "fail" with
+ // exit code 1 since we are asking to reclaim more memory than probably exists.
+ }
+
+}
diff --git a/tests/media/src/android/mediav2/cts/CodecDecoderDetachedSurfaceTest.java b/tests/media/src/android/mediav2/cts/CodecDecoderDetachedSurfaceTest.java
index 3dd7f9e..0fef676 100644
--- a/tests/media/src/android/mediav2/cts/CodecDecoderDetachedSurfaceTest.java
+++ b/tests/media/src/android/mediav2/cts/CodecDecoderDetachedSurfaceTest.java
@@ -19,8 +19,8 @@
import static android.media.codec.Flags.FLAG_NULL_OUTPUT_SURFACE;
import static android.media.MediaCodecInfo.CodecCapabilities.COLOR_FormatYUVP010;
-import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import android.graphics.ImageFormat;
@@ -78,6 +78,8 @@
public class CodecDecoderDetachedSurfaceTest extends CodecDecoderTestBase {
private static final String LOG_TAG = CodecDecoderDetachedSurfaceTest.class.getSimpleName();
private static final String MEDIA_DIR = WorkDir.getMediaDirString();
+ // 1 - 2 frames can be dropped during surface change
+ private static final int FRAMES_DROPPED_PER_SWITCH = 2;
private static final int MAX_ACTIVE_SURFACES = 4;
private static final int IMAGE_SURFACE_QUEUE_SIZE = 3;
private static final long WAIT_FOR_IMAGE_TIMEOUT_MS = 5;
@@ -92,6 +94,7 @@
private final int[] mFramesRendered = new int[MAX_ACTIVE_SURFACES];
// total frames rendered on to output surface
private final int[] mFramesRenderedExpected = new int[MAX_ACTIVE_SURFACES];
+ private int mTotalSurfaceSwitch;
// exp number of frames to be rendered on output surface
private boolean mSurfaceAttached = true;
private int mAttachedSurfaceId;
@@ -183,6 +186,7 @@
protected void resetContext(boolean isAsync, boolean signalEOSWithLastFrame) {
super.resetContext(isAsync, signalEOSWithLastFrame);
mOutputCountInBursts = 0;
+ mTotalSurfaceSwitch = 0;
Arrays.fill(mFramesRendered, 0);
Arrays.fill(mFramesRenderedExpected, 0);
}
@@ -282,6 +286,26 @@
}
}
+ private void validateTestRun() {
+ int totalFramesRenderedExpected = 0;
+ int totalFramesRendered = 0;
+ for (int i = 0; i < mFramesRendered.length; i++) {
+ assertTrue(String.format(Locale.getDefault(),
+ "Number of frames rendered to output surface is exceeding the total "
+ + "frames released to the surface. Exp / got : %d / %d \n",
+ mFramesRenderedExpected[i], mFramesRendered[i]) + mTestConfig
+ + mTestEnv, mFramesRendered[i] <= mFramesRenderedExpected[i]);
+ totalFramesRenderedExpected += mFramesRenderedExpected[i];
+ totalFramesRendered += mFramesRendered[i];
+ }
+ Assume.assumeTrue(String.format(Locale.getDefault(),
+ "Number of frames rendered to output surface is much lesser than the "
+ + "total frames released to the surface. Exp / got : %d / %d \n",
+ totalFramesRenderedExpected, totalFramesRendered) + mTestConfig + mTestEnv,
+ totalFramesRenderedExpected - totalFramesRendered
+ <= FRAMES_DROPPED_PER_SWITCH * mTotalSurfaceSwitch);
+ }
+
/**
* At the start of the test #MAX_ACTIVE_SURFACES number of surfaces are instantiated. The
* first surface is used for codec configuration. After decoding/rendering 'n' frames,
@@ -311,6 +335,7 @@
while (!mSawInputEOS) {
mOutputCountInBursts = 0;
mCodec.setOutputSurface(mSurfaces.get(surfaceId)); // switch surface periodically
+ mTotalSurfaceSwitch++;
mImageSurface = mImageSurfaces.get(surfaceId);
mSurface = mSurfaces.get(surfaceId);
mAttachedSurfaceId = surfaceId;
@@ -323,11 +348,7 @@
waitForAllOutputs();
endCodecSession(mCodec);
getAllImagesInRenderQueue();
- assertArrayEquals(String.format(Locale.getDefault(),
- "Number of frames rendered to output surface are not as expected."
- + " Exp / got : %s / %s \n",
- Arrays.toString(mFramesRenderedExpected), Arrays.toString(mFramesRendered))
- + mTestConfig + mTestEnv, mFramesRenderedExpected, mFramesRendered);
+ validateTestRun();
}
mCodec.release();
mExtractor.release();
@@ -373,6 +394,7 @@
mOutputCountInBursts = 0;
if (attachSurface) {
mCodec.setOutputSurface(mSurfaces.get(surfaceId));
+ mTotalSurfaceSwitch++;
mImageSurface = mImageSurfaces.get(surfaceId);
mSurface = mSurfaces.get(surfaceId);
mSurfaceAttached = true;
@@ -391,11 +413,7 @@
waitForAllOutputs();
endCodecSession(mCodec);
getAllImagesInRenderQueue();
- assertArrayEquals(String.format(Locale.getDefault(),
- "Number of frames rendered to output surface are not as expected."
- + " Exp / got : %s / %s \n",
- Arrays.toString(mFramesRenderedExpected), Arrays.toString(mFramesRendered))
- + mTestConfig + mTestEnv, mFramesRenderedExpected, mFramesRendered);
+ validateTestRun();
}
mCodec.release();
mExtractor.release();
@@ -444,6 +462,7 @@
int surfaceId = 0;
mOutputCountInBursts = 0;
mCodec.setOutputSurface(mSurfaces.get(surfaceId));
+ mTotalSurfaceSwitch++;
mImageSurface = mImageSurfaces.get(surfaceId);
mSurface = mSurfaces.get(surfaceId);
mSurfaceAttached = true;
@@ -451,7 +470,7 @@
doWork(mBurstLength); // decode
getAllImagesInRenderQueue();
- // detach surface and release it
+ // detach surface
try {
mCodec.detachOutputSurface();
} catch (IllegalStateException e) {
@@ -459,9 +478,6 @@
+ " detachOutputSurface() fails with " + e + "\n" + mTestConfig
+ mTestEnv);
}
- mImageSurfaces.get(surfaceId).release();
- mImageSurfaces.remove(surfaceId);
- mSurfaces.remove(surfaceId);
// decode few frames without attaching surface
mOutputCountInBursts = 0;
@@ -469,9 +485,15 @@
doWork(mBurstLength);
getAllImagesInRenderQueue();
+ // release surface
+ mImageSurfaces.get(surfaceId).release();
+ mImageSurfaces.remove(surfaceId);
+ mSurfaces.remove(surfaceId);
+
// attach new surface and decode few frames
mOutputCountInBursts = 0;
mCodec.setOutputSurface(mSurfaces.get(surfaceId));
+ mTotalSurfaceSwitch++;
mImageSurface = mImageSurfaces.get(surfaceId);
mSurface = mSurfaces.get(surfaceId);
mSurfaceAttached = true;
@@ -507,11 +529,7 @@
waitForAllOutputs();
endCodecSession(mCodec);
getAllImagesInRenderQueue();
- assertArrayEquals(String.format(Locale.getDefault(),
- "Number of frames rendered to output surface are not as expected."
- + " Exp / got : %s / %s \n",
- Arrays.toString(mFramesRenderedExpected), Arrays.toString(mFramesRendered))
- + mTestConfig + mTestEnv, mFramesRenderedExpected, mFramesRendered);
+ validateTestRun();
}
mCodec.release();
mExtractor.release();
diff --git a/tests/mediapc/common/src/android/mediapc/cts/common/Requirements.java.tmpl b/tests/mediapc/common/src/android/mediapc/cts/common/Requirements.java.tmpl
index 9d393e8..f6f5139 100644
--- a/tests/mediapc/common/src/android/mediapc/cts/common/Requirements.java.tmpl
+++ b/tests/mediapc/common/src/android/mediapc/cts/common/Requirements.java.tmpl
@@ -137,11 +137,13 @@
{{- SafeTestConfigID $t_id | UpperCamelCase}}());
}
{{- range $v_id, $v := $r.GetVariants }}
+ {{- if HasConfigVariant $r $t_id $v_id }}
public Config{{ SafeTestConfigID $t_id | UpperCamelCase}}AndVariant
{{- UpperCamelCase $v_id}} withVariant{{- UpperCamelCase $v_id}}() {
return new Config{{SafeTestConfigID $t_id | UpperCamelCase}}AndVariant
{{- UpperCamelCase $v_id}}();
}
+ {{- end }}{{/* if HasConfigVariant */}}
{{- end }}{{/* range $v_id, $v */}}
}
{{- end }}
@@ -151,6 +153,7 @@
public static final class Variant{{UpperCamelCase $v_id}} {
private Variant{{UpperCamelCase $v_id}}() {}
{{- range $t_id, $t := $r.GetTestConfigs }}
+ {{- if HasConfigVariant $r $t_id $v_id }}
{{- if eq $t_id "" }}
public {{UpperCamelCase $r.GetName}}Requirement to(PerformanceClassEvaluator pce) {
return pce.addRequirement({{UpperCamelCase $r.GetName}}Requirement.create
@@ -164,6 +167,7 @@
{{- UpperCamelCase $v_id}}();
}
{{- end }}
+ {{- end }}{{/* if HasConfigVariant */}}
{{- end }}{{/* range $t_id, $t */}}
}
{{- end }}{{/* range $v_id, $v */}}
@@ -171,6 +175,7 @@
{{- range $t_id, $t := $r.GetTestConfigs }}
{{- if ne $t_id "" }}
{{- range $v_id, $v := $r.GetVariants }}
+ {{- if HasConfigVariant $r $t_id $v_id }}
public static final class Config{{SafeTestConfigID $t_id | UpperCamelCase}}AndVariant
{{- UpperCamelCase $v_id}} {
private Config{{ SafeTestConfigID $t_id | UpperCamelCase}}AndVariant
@@ -181,6 +186,7 @@
{{- UpperCamelCase $v_id}}());
}
}
+ {{- end }}{{/* if HasConfigVariant */}}
{{- end }}{{/* range $v_id, $v */}}
{{- end }}
{{- end }}{{/* range $t_id, $t */}}
@@ -261,6 +267,7 @@
{{- range $t_id, $t := $r.GetTestConfigs }}
{{- range $v_id, $v := $r.GetVariants }}
+ {{- if HasConfigVariant $r $t_id $v_id }}
/**
* {{ $r.GetId }} {{$r.GetName}}{{- with $v.GetDescription}} {{.}}{{end}}
@@ -313,6 +320,7 @@
{{- end }}
return req;
}
+ {{- end }}{{/* if HasConfigVariant */}}
{{- end }}{{/* range $v_id, $v */}}
{{- end }}{{/* range $t_id, $t */}}
diff --git a/tests/mediapc/requirements/requirements.txtpb b/tests/mediapc/requirements/requirements.txtpb
index 986f759..91bc9f6 100644
--- a/tests/mediapc/requirements/requirements.txtpb
+++ b/tests/mediapc/requirements/requirements.txtpb
@@ -3078,7 +3078,7 @@
requirements {
id: "7.6.1/H-1-1"
name: "Android 11 Memory"
- description: "Minimum memory available to the kernel as reported by android.app.ActivityManager.MemoryInfo."
+ description: "Minimum memory available to the kernel as reported by ActivityManager.MemoryInfo.totalMemory"
test_configs: {
key: ""
value: {
@@ -3088,7 +3088,7 @@
measurements: {
key: "physical_memory_mb"
value: {
- description: "Physical memory in MiB as reported by android.app.ActivityManager.MemeryInfo.totalMemory."
+ description: "Physical memory in MiB as reported by ActivityManager.MemeryInfo.totalMemory."
comparison: COMPARISON_GREATER_THAN_OR_EQUAL
measurement_type: MEASUREMENT_TYPE_LONG
}
@@ -3110,7 +3110,7 @@
requirements {
id: "7.6.1/H-2-1"
name: "Memory"
- description: "Minimum memory available to the kernel as reported by android.app.ActivityManager.MemoryInfo."
+ description: "Minimum memory available to the kernel as reported by ActivityManager.MemoryInfo.totalMemory"
test_configs: {
key: ""
value: {
@@ -3120,7 +3120,7 @@
measurements: {
key: "physical_memory_mb"
value: {
- description: "Physical memory in MiB as reported by android.app.ActivityManager.MemeryInfo.totalMemory."
+ description: "Physical memory in MiB as reported by ActivityManager.MemoryInfo.totalMemory."
comparison: COMPARISON_GREATER_THAN_OR_EQUAL
measurement_type: MEASUREMENT_TYPE_LONG
}
diff --git a/tests/tests/keystore/src/android/keystore/cts/ImportWrappedKeyTest.java b/tests/tests/keystore/src/android/keystore/cts/ImportWrappedKeyTest.java
index f947797..9eec567 100644
--- a/tests/tests/keystore/src/android/keystore/cts/ImportWrappedKeyTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/ImportWrappedKeyTest.java
@@ -69,8 +69,8 @@
import androidx.test.runner.AndroidJUnit4;
import org.bouncycastle.asn1.ASN1Encoding;
-import org.bouncycastle.asn1.DEREncodableVector;
-import org.bouncycastle.asn1.DERInteger;
+import org.bouncycastle.asn1.ASN1EncodableVector;
+import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.DERNull;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERSequence;
@@ -473,8 +473,8 @@
int keyFormat, DERSequence authorizationList, boolean correctWrappingRequired)
throws Exception {
// Build description
- DEREncodableVector descriptionItems = new DEREncodableVector();
- descriptionItems.add(new DERInteger(keyFormat));
+ ASN1EncodableVector descriptionItems = new ASN1EncodableVector();
+ descriptionItems.add(new ASN1Integer(keyFormat));
descriptionItems.add(authorizationList);
DERSequence wrappedKeyDescription = new DERSequence(descriptionItems);
@@ -515,9 +515,9 @@
// Remove GCM tag from end of output
encryptedSecureKey = Arrays.copyOfRange(encryptedSecureKey, 0, len - tagSize);
- // Build ASN.1 DER encoded sequence WrappedKeyWrapper
- DEREncodableVector items = new DEREncodableVector();
- items.add(new DERInteger(WRAPPED_FORMAT_VERSION));
+ // Build ASN.1 encoded sequence WrappedKeyWrapper
+ ASN1EncodableVector items = new ASN1EncodableVector();
+ items.add(new ASN1Integer(WRAPPED_FORMAT_VERSION));
items.add(new DEROctetString(encryptedEphemeralKeys));
items.add(new DEROctetString(iv));
items.add(wrappedKeyDescription);
@@ -527,27 +527,27 @@
}
private DERSequence makeSymKeyAuthList(int size, int algo) {
- DEREncodableVector allPurposes = new DEREncodableVector();
- allPurposes.add(new DERInteger(KM_PURPOSE_ENCRYPT));
- allPurposes.add(new DERInteger(KM_PURPOSE_DECRYPT));
+ ASN1EncodableVector allPurposes = new ASN1EncodableVector();
+ allPurposes.add(new ASN1Integer(KM_PURPOSE_ENCRYPT));
+ allPurposes.add(new ASN1Integer(KM_PURPOSE_DECRYPT));
DERSet purposeSet = new DERSet(allPurposes);
DERTaggedObject purpose =
new DERTaggedObject(true, removeTagType(KM_TAG_PURPOSE), purposeSet);
DERTaggedObject algorithm =
- new DERTaggedObject(true, removeTagType(KM_TAG_ALGORITHM), new DERInteger(algo));
+ new DERTaggedObject(true, removeTagType(KM_TAG_ALGORITHM), new ASN1Integer(algo));
DERTaggedObject keySize =
- new DERTaggedObject(true, removeTagType(KM_TAG_KEY_SIZE), new DERInteger(size));
+ new DERTaggedObject(true, removeTagType(KM_TAG_KEY_SIZE), new ASN1Integer(size));
- DEREncodableVector allBlockModes = new DEREncodableVector();
- allBlockModes.add(new DERInteger(KM_MODE_ECB));
- allBlockModes.add(new DERInteger(KM_MODE_CBC));
+ ASN1EncodableVector allBlockModes = new ASN1EncodableVector();
+ allBlockModes.add(new ASN1Integer(KM_MODE_ECB));
+ allBlockModes.add(new ASN1Integer(KM_MODE_CBC));
DERSet blockModeSet = new DERSet(allBlockModes);
DERTaggedObject blockMode =
new DERTaggedObject(true, removeTagType(KM_TAG_BLOCK_MODE), blockModeSet);
- DEREncodableVector allPaddings = new DEREncodableVector();
- allPaddings.add(new DERInteger(KM_PAD_PKCS7));
- allPaddings.add(new DERInteger(KM_PAD_NONE));
+ ASN1EncodableVector allPaddings = new ASN1EncodableVector();
+ allPaddings.add(new ASN1Integer(KM_PAD_PKCS7));
+ allPaddings.add(new ASN1Integer(KM_PAD_NONE));
DERSet paddingSet = new DERSet(allPaddings);
DERTaggedObject padding =
new DERTaggedObject(true, removeTagType(KM_TAG_PADDING), paddingSet);
@@ -556,7 +556,7 @@
new DERTaggedObject(true, removeTagType(KM_TAG_NO_AUTH_REQUIRED), DERNull.INSTANCE);
// Build sequence
- DEREncodableVector allItems = new DEREncodableVector();
+ ASN1EncodableVector allItems = new ASN1EncodableVector();
allItems.add(purpose);
allItems.add(algorithm);
allItems.add(keySize);
@@ -576,40 +576,40 @@
}
private DERSequence makeRsaAuthList(int size) {
- DEREncodableVector allPurposes = new DEREncodableVector();
- allPurposes.add(new DERInteger(KM_PURPOSE_ENCRYPT));
- allPurposes.add(new DERInteger(KM_PURPOSE_DECRYPT));
- allPurposes.add(new DERInteger(KM_PURPOSE_SIGN));
- allPurposes.add(new DERInteger(KM_PURPOSE_VERIFY));
+ ASN1EncodableVector allPurposes = new ASN1EncodableVector();
+ allPurposes.add(new ASN1Integer(KM_PURPOSE_ENCRYPT));
+ allPurposes.add(new ASN1Integer(KM_PURPOSE_DECRYPT));
+ allPurposes.add(new ASN1Integer(KM_PURPOSE_SIGN));
+ allPurposes.add(new ASN1Integer(KM_PURPOSE_VERIFY));
DERSet purposeSet = new DERSet(allPurposes);
DERTaggedObject purpose =
new DERTaggedObject(true, removeTagType(KM_TAG_PURPOSE), purposeSet);
DERTaggedObject algorithm =
new DERTaggedObject(true, removeTagType(KM_TAG_ALGORITHM),
- new DERInteger(KM_ALGORITHM_RSA));
+ new ASN1Integer(KM_ALGORITHM_RSA));
DERTaggedObject keySize =
- new DERTaggedObject(true, removeTagType(KM_TAG_KEY_SIZE), new DERInteger(size));
+ new DERTaggedObject(true, removeTagType(KM_TAG_KEY_SIZE), new ASN1Integer(size));
- DEREncodableVector allDigests = new DEREncodableVector();
- allDigests.add(new DERInteger(KM_DIGEST_NONE));
- allDigests.add(new DERInteger(KM_DIGEST_MD5));
- allDigests.add(new DERInteger(KM_DIGEST_SHA1));
- allDigests.add(new DERInteger(KM_DIGEST_SHA_2_224));
- allDigests.add(new DERInteger(KM_DIGEST_SHA_2_256));
- allDigests.add(new DERInteger(KM_DIGEST_SHA_2_384));
- allDigests.add(new DERInteger(KM_DIGEST_SHA_2_512));
+ ASN1EncodableVector allDigests = new ASN1EncodableVector();
+ allDigests.add(new ASN1Integer(KM_DIGEST_NONE));
+ allDigests.add(new ASN1Integer(KM_DIGEST_MD5));
+ allDigests.add(new ASN1Integer(KM_DIGEST_SHA1));
+ allDigests.add(new ASN1Integer(KM_DIGEST_SHA_2_224));
+ allDigests.add(new ASN1Integer(KM_DIGEST_SHA_2_256));
+ allDigests.add(new ASN1Integer(KM_DIGEST_SHA_2_384));
+ allDigests.add(new ASN1Integer(KM_DIGEST_SHA_2_512));
DERSet digestSet = new DERSet(allDigests);
DERTaggedObject digest =
new DERTaggedObject(true, removeTagType(KM_TAG_DIGEST), digestSet);
- DEREncodableVector allPaddings = new DEREncodableVector();
- allPaddings.add(new DERInteger(KM_PAD_PKCS7));
- allPaddings.add(new DERInteger(KM_PAD_NONE));
- allPaddings.add(new DERInteger(KM_PAD_RSA_OAEP));
- allPaddings.add(new DERInteger(KM_PAD_RSA_PSS));
- allPaddings.add(new DERInteger(KM_PAD_RSA_PKCS1_1_5_ENCRYPT));
- allPaddings.add(new DERInteger(KM_PAD_RSA_PKCS1_1_5_SIGN));
+ ASN1EncodableVector allPaddings = new ASN1EncodableVector();
+ allPaddings.add(new ASN1Integer(KM_PAD_PKCS7));
+ allPaddings.add(new ASN1Integer(KM_PAD_NONE));
+ allPaddings.add(new ASN1Integer(KM_PAD_RSA_OAEP));
+ allPaddings.add(new ASN1Integer(KM_PAD_RSA_PSS));
+ allPaddings.add(new ASN1Integer(KM_PAD_RSA_PKCS1_1_5_ENCRYPT));
+ allPaddings.add(new ASN1Integer(KM_PAD_RSA_PKCS1_1_5_SIGN));
DERSet paddingSet = new DERSet(allPaddings);
DERTaggedObject padding =
new DERTaggedObject(true, removeTagType(KM_TAG_PADDING), paddingSet);
@@ -618,7 +618,7 @@
new DERTaggedObject(true, removeTagType(KM_TAG_NO_AUTH_REQUIRED), DERNull.INSTANCE);
// Build sequence
- DEREncodableVector allItems = new DEREncodableVector();
+ ASN1EncodableVector allItems = new ASN1EncodableVector();
allItems.add(purpose);
allItems.add(algorithm);
allItems.add(keySize);
@@ -630,24 +630,24 @@
}
private DERSequence makeEcAuthList(int size) {
- DEREncodableVector allPurposes = new DEREncodableVector();
- allPurposes.add(new DERInteger(KM_PURPOSE_SIGN));
- allPurposes.add(new DERInteger(KM_PURPOSE_VERIFY));
+ ASN1EncodableVector allPurposes = new ASN1EncodableVector();
+ allPurposes.add(new ASN1Integer(KM_PURPOSE_SIGN));
+ allPurposes.add(new ASN1Integer(KM_PURPOSE_VERIFY));
DERSet purposeSet = new DERSet(allPurposes);
DERTaggedObject purpose =
new DERTaggedObject(true, removeTagType(KM_TAG_PURPOSE), purposeSet);
DERTaggedObject algorithm =
new DERTaggedObject(true, removeTagType(KM_TAG_ALGORITHM),
- new DERInteger(KM_ALGORITHM_EC));
+ new ASN1Integer(KM_ALGORITHM_EC));
DERTaggedObject keySize =
- new DERTaggedObject(true, removeTagType(KM_TAG_KEY_SIZE), new DERInteger(size));
+ new DERTaggedObject(true, removeTagType(KM_TAG_KEY_SIZE), new ASN1Integer(size));
- DEREncodableVector allDigests = new DEREncodableVector();
- allDigests.add(new DERInteger(KM_DIGEST_SHA_2_224));
- allDigests.add(new DERInteger(KM_DIGEST_SHA_2_256));
- allDigests.add(new DERInteger(KM_DIGEST_SHA_2_384));
- allDigests.add(new DERInteger(KM_DIGEST_SHA_2_512));
+ ASN1EncodableVector allDigests = new ASN1EncodableVector();
+ allDigests.add(new ASN1Integer(KM_DIGEST_SHA_2_224));
+ allDigests.add(new ASN1Integer(KM_DIGEST_SHA_2_256));
+ allDigests.add(new ASN1Integer(KM_DIGEST_SHA_2_384));
+ allDigests.add(new ASN1Integer(KM_DIGEST_SHA_2_512));
DERSet digestSet = new DERSet(allDigests);
DERTaggedObject digest =
new DERTaggedObject(true, removeTagType(KM_TAG_DIGEST), digestSet);
@@ -656,7 +656,7 @@
new DERTaggedObject(true, removeTagType(KM_TAG_NO_AUTH_REQUIRED), DERNull.INSTANCE);
// Build sequence
- DEREncodableVector allItems = new DEREncodableVector();
+ ASN1EncodableVector allItems = new ASN1EncodableVector();
allItems.add(purpose);
allItems.add(algorithm);
allItems.add(keySize);
diff --git a/tests/tests/media/audio/src/android/media/audio/cts/DirectAudioProfilesForAttributesTest.kt b/tests/tests/media/audio/src/android/media/audio/cts/DirectAudioProfilesForAttributesTest.kt
index 50ecc03..d223318 100644
--- a/tests/tests/media/audio/src/android/media/audio/cts/DirectAudioProfilesForAttributesTest.kt
+++ b/tests/tests/media/audio/src/android/media/audio/cts/DirectAudioProfilesForAttributesTest.kt
@@ -112,7 +112,9 @@
// Utils
private fun AudioProfile.getAllAudioFormats() =
- sampleRates.map { sampleRate ->
+ sampleRates.filter {
+ it <= AudioFormat.SAMPLE_RATE_HZ_MAX
+ }.map { sampleRate ->
channelMasks.map { channelMask ->
AudioFormat.Builder()
.setEncoding(format)
diff --git a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerCodecActivity.java b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerCodecActivity.java
index 7077122..9e1e9f3 100644
--- a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerCodecActivity.java
+++ b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerCodecActivity.java
@@ -17,6 +17,7 @@
package android.media.misc.cts;
import android.app.Activity;
+import android.content.Context;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecInfo.CodecCapabilities;
@@ -31,7 +32,6 @@
public class ResourceManagerCodecActivity extends Activity {
private static final String TAG = "ResourceManagerCodecActivity";
- private static final int MAX_INSTANCES = 32;
private static final int FRAME_RATE = 30;
private static final int IFRAME_INTERVAL = 10;
private boolean mHighResolution = false;
@@ -57,7 +57,10 @@
mMime = extras.getString("mime", mMime);
}
- if (allocateCodecs(MAX_INSTANCES) == MAX_INSTANCES) {
+ Context context = getApplicationContext();
+ int maxInstances = ResourceManagerStubActivity.getMaxCodecInstances(context);
+
+ if (allocateCodecs(maxInstances) == maxInstances) {
// As we haven't reached the limit with MAX_INSTANCES,
// no need to wait for reclaim exception.
Log.d(TAG, "We may not get reclaim event");
diff --git a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerStubActivity.java b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerStubActivity.java
index d16a48d..7dd6922 100644
--- a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerStubActivity.java
+++ b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerStubActivity.java
@@ -18,6 +18,7 @@
import static org.junit.Assume.assumeTrue;
import android.app.Activity;
+import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@@ -34,6 +35,12 @@
// Test case was skipped as the device doesn't have any camera available for recording.
public static final int RESULT_CODE_NO_CAMERA = Activity.RESULT_FIRST_USER + 3;
+ // The max concurrent codec instances.
+ private static final int MAX_INSTANCES = 32;
+ // Reduce the max concurrent codec instances on Low Ram Devices
+ // to 8 to avoid getting into low memory issues.
+ private static final int LOW_RAM_DEVICE_MAX_INSTANCES = 8;
+
private static final String TAG = "ResourceManagerStubActivity";
private final Object mFinishEvent = new Object();
private int[] mRequestCodes = {0, 1};
@@ -310,4 +317,19 @@
mResults[1] = RESULT_OK;
processActivityResults();
}
+
+ /**
+ * The max concurrent codec instances allowed to created
+ * by the test activities.
+ * Though we set this to 32 (or 8 on low ram devices), it could be
+ * lesser than that, based on how many concurrent codec instances can be supported
+ * by the oem implementation.
+ */
+ public static int getMaxCodecInstances(Context context) {
+ boolean isLowRamDevice = context.getSystemService(ActivityManager.class).isLowRamDevice();
+ if (isLowRamDevice) {
+ return LOW_RAM_DEVICE_MAX_INSTANCES;
+ }
+ return MAX_INSTANCES;
+ }
}
diff --git a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTest.java b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTest.java
index ec281e9..32b6135 100644
--- a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTest.java
+++ b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTest.java
@@ -39,6 +39,36 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+/**
+ * Verification of ResourceManagerService functionality.
+ *
+ * This tests codec reclaim by launching 2 activities:
+ * - Activity1: A background activity (that runs in its own process) that creates,
+ * configures and starts an allowable number of codecs.
+ * - Activity2: A foreground activity (that runs in its own process) that creates,
+ * configures and starts codecs, which would reclaim codecs from the Activity1.
+ *
+ * The Activity2 is started 5 seconds after Activity1 to give enough time for
+ * Activity1 to use all the codecs available.
+ *
+ * Once started, Activity1 waits for (at most) 15 seconds for a possible exception.
+ * If the expected exception (MediaCodec.CodecException#ERROR_RECLAIMED) was caught,
+ * it will finish/complete the Activity with SUCCESS or FAILED otherwise.
+ *
+ * Once started, Activity2 is expected to successfully create, configure and start the
+ * codecs (possibly by reclaiming a codec from Activity1). This activity ends with SUCCESS
+ * upon successful codec operation or FAILED otherwise.
+ *
+ * The test waits on both the Activities to complete with SUCCESS for the test to PASS.
+ *
+ * Since Activity1 starts vendor supported maximum concurrent codecs, on some devices
+ * this may cause the device to run out of memory before codec reclaimation is signaled.
+ * When the device runs out of memory, lmkd kills the applications (including the test Activities).
+ * Upon lmkd killing test Activities, the test FAILs.
+ * To avoid that, the test reduces the maximum (concurrent) codec instances on low ram devices
+ * to 8 (from 32).
+ * This may result in test not verifying reclaimation.
+ */
@RequiresDevice
@AppModeFull(reason = "TODO: evaluate and port to instant")
@FrameworkSpecificTest
diff --git a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivity1.java b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivity1.java
index 921bd81..60a36459 100644
--- a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivity1.java
+++ b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivity1.java
@@ -16,6 +16,7 @@
package android.media.misc.cts;
+import android.content.Context;
import android.os.Bundle;
import android.util.Log;
@@ -33,7 +34,10 @@
mWaitForReclaim = extras.getBoolean("wait-for-reclaim", mWaitForReclaim);
}
- if (allocateCodecs(MAX_INSTANCES) == MAX_INSTANCES) {
+ Context context = getApplicationContext();
+ int maxCodecInstances = ResourceManagerStubActivity.getMaxCodecInstances(context);
+
+ if (allocateCodecs(maxCodecInstances) == maxCodecInstances) {
// haven't reached the limit with MAX_INSTANCES, no need to wait for reclaim exception.
mWaitForReclaim = false;
}
diff --git a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivity2.java b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivity2.java
index 4498a26..a731389 100644
--- a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivity2.java
+++ b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivity2.java
@@ -16,6 +16,7 @@
package android.media.misc.cts;
+import android.content.Context;
import android.util.Log;
public class ResourceManagerTestActivity2 extends ResourceManagerTestActivityBase {
@@ -29,7 +30,9 @@
// Try to create as many as MAX_INSTANCES codecs from this foreground activity
// so that we run into Resource conflict (INSUFFICIENT_RESOURCE) situation
// and eventually reclaim a codec from the background activity.
- int codecCount = allocateCodecs(MAX_INSTANCES);
+ Context context = getApplicationContext();
+ int maxCodecInstances = ResourceManagerStubActivity.getMaxCodecInstances(context);
+ int codecCount = allocateCodecs(maxCodecInstances);
int result = RESULT_OK;
// See if we have failed to create at least one codec.
if (codecCount == 0) {
@@ -38,7 +41,7 @@
// If we have set codec-importance, then we expect reclaim error, provided,
// the activity has already created MAX_INSTANCES of codecs.
// So wait for the codecs to be used and reclaim error to be thrown.
- if (mChangingCodecImportance && result == RESULT_OK && codecCount < MAX_INSTANCES) {
+ if (mChangingCodecImportance && result == RESULT_OK && codecCount < maxCodecInstances) {
useCodecs();
} else {
finishWithResult(result);
diff --git a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivityBase.java b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivityBase.java
index 02ff2eb..90a9a4f 100644
--- a/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivityBase.java
+++ b/tests/tests/media/misc/src/android/media/misc/cts/ResourceManagerTestActivityBase.java
@@ -36,7 +36,6 @@
private static final int FRAME_RATE = 10;
// 10 seconds between I-frames
private static final int IFRAME_INTERVAL = 10;
- protected static final int MAX_INSTANCES = 32;
// Less important codec of value 100.
private static final int CODEC_IMPORTANCE_100 = 100;
private static final MediaCodecList sMCL = new MediaCodecList(MediaCodecList.REGULAR_CODECS);