diff options
author | David Zeuthen <zeuthen@google.com> | 2022-01-31 16:51:26 -0500 |
---|---|---|
committer | David Zeuthen <zeuthen@google.com> | 2022-02-01 13:04:37 -0500 |
commit | 9699aa5aad8253be94366f144645da337aeaded2 (patch) | |
tree | 6b08d1122db37958771b7cea192b408b3fb219e3 /identity | |
parent | 411e98d20276dcf1bd1432094487a24cf323611b (diff) |
identity: Add VTS test to check that Identity Credential is implemented.
Chipsets launching with Android 13 must support Identity Credential at
feature version 202201 or later. Verify this.
Bug: 217197568
Test: atest IdentityCredentialImplementedTest
Change-Id: Icddb2c63571a4a69213bd9796ba78f5b384f7d5d
Diffstat (limited to 'identity')
3 files changed, 99 insertions, 0 deletions
diff --git a/identity/aidl/vts/Android.bp b/identity/aidl/vts/Android.bp index c5b84a16c5..20faeeefaa 100644 --- a/identity/aidl/vts/Android.bp +++ b/identity/aidl/vts/Android.bp @@ -58,3 +58,16 @@ cc_test { "vts", ], } + +java_test_host { + name: "IdentityCredentialImplementedTest", + libs: [ + "tradefed", + "vts-core-tradefed-harness", + ], + srcs: ["src/**/*.java"], + test_suites: [ + "vts", + ], + test_config: "IdentityCredentialImplementedTest.xml", +} diff --git a/identity/aidl/vts/IdentityCredentialImplementedTest.xml b/identity/aidl/vts/IdentityCredentialImplementedTest.xml new file mode 100644 index 0000000000..1d76a74db4 --- /dev/null +++ b/identity/aidl/vts/IdentityCredentialImplementedTest.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2022 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. +--> +<configuration description="Runs IdentityCredentialImplementedTest"> + <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" /> + + <test class="com.android.tradefed.testtype.HostTest" > + <option name="jar" value="IdentityCredentialImplementedTest.jar" /> + </test> +</configuration> diff --git a/identity/aidl/vts/src/com/android/tests/security/identity/IdentityCredentialImplementedTest.java b/identity/aidl/vts/src/com/android/tests/security/identity/IdentityCredentialImplementedTest.java new file mode 100644 index 0000000000..541a38aa9e --- /dev/null +++ b/identity/aidl/vts/src/com/android/tests/security/identity/IdentityCredentialImplementedTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.tests.security.identity; + +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import android.platform.test.annotations.RequiresDevice; +import com.android.tradefed.device.DeviceNotAvailableException; +import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; +import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(DeviceJUnit4ClassRunner.class) +public class IdentityCredentialImplementedTest extends BaseHostJUnit4Test { + // Returns the ro.vendor.api_level or 0 if not set. + // + // Throws NumberFormatException if ill-formatted. + // + // Throws DeviceNotAvailableException if device is not available. + // + private int getVendorApiLevel() throws NumberFormatException, DeviceNotAvailableException { + String vendorApiLevelString = + getDevice().executeShellCommand("getprop ro.vendor.api_level").trim(); + if (vendorApiLevelString.isEmpty()) { + return 0; + } + return Integer.parseInt(vendorApiLevelString); + } + + // As of Android 13 (API level 31), Identity Credential is required at feature version 202201 + // or newer. + // + @RequiresDevice + @Test + public void testIdentityCredentialIsImplemented() throws Exception { + int vendorApiLevel = getVendorApiLevel(); + assumeTrue(vendorApiLevel >= 31); + + final String minimumFeatureVersionNeeded = "202201"; + + String result = getDevice().executeShellCommand( + "pm has-feature android.hardware.identity_credential " + + minimumFeatureVersionNeeded); + if (!result.trim().equals("true")) { + fail("Identity Credential feature version " + minimumFeatureVersionNeeded + + " required but not found"); + } + } +} |