From d9cbeba04114d9504ab5aa3e81abca893a6ffda3 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Wed, 10 Mar 2021 14:36:33 -0500 Subject: [PATCH] PackageManager: Add FEATURE_HARDWARE_KEYSTORE, modify FEATURE_STRONGBOX_KEYSTORE. These feature flags will hold the KeyMint version for the default and StrongBox HALs. They can be used by apps to convey that they'll only work on devices which have a recent enough version of KeyMint. For example, if an application requires ECDH to be implemented in Secure Hardware it can convey this requirement by indicated that it needs FEATURE_HARDWARE_KEYSTORE >= 100. Or if it needs this in the StrongBox it can use FEATURE_STRONGBOX_KEYSTORE >= 100. As with other feature flags, this can be used to only show the app on devices which satisfy such requirements. Test: Compiles Bug: 160616951 Change-Id: I582e50fba92de0d598d7e86fcc3b1b2b4a91b103 --- core/api/current.txt | 1 + .../android/content/pm/PackageManager.java | 53 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 15dfc51ec61c6..0da6489cab4ce 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -12139,6 +12139,7 @@ package android.content.pm { field public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint"; field public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT = "android.software.freeform_window_management"; field public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; + field public static final String FEATURE_HARDWARE_KEYSTORE = "android.hardware.hardware_keystore"; field public static final String FEATURE_HIFI_SENSORS = "android.hardware.sensor.hifi_sensors"; field public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; field public static final String FEATURE_IDENTITY_CREDENTIAL_HARDWARE = "android.hardware.identity_credential"; diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 7e17256f0229c..23f5e3ab6c1f1 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -3167,8 +3167,57 @@ public abstract class PackageManager { public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking"; /** - * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: - * The device has a StrongBox hardware-backed Keystore. + * Feature for {@link #getSystemAvailableFeatures} and + * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements + * the Android Keystore backed by an isolated execution environment. The version indicates + * which features are implemented in the isolated execution environment: + * + * This feature version is guaranteed to be set for all devices launching with Android 12 and + * may be set on devices launching with an earlier version. If the feature version is set, it + * will at least have the value 40. If it's not set the device may have a version of + * hardware-backed keystore but it may not support all features listed above. + */ + @SdkConstant(SdkConstantType.FEATURE) + public static final String FEATURE_HARDWARE_KEYSTORE = "android.hardware.hardware_keystore"; + + /** + * Feature for {@link #getSystemAvailableFeatures}, {@link #hasSystemFeature(String)}, and + * {@link #hasSystemFeature(String, int)}: If this feature is supported, the device implements + * the Android Keystore backed by a dedicated secure processor referred to as + * + * StrongBox. If this feature has a version, the version number indicates which features are + * implemented in StrongBox: + * + * If a device has StrongBox, this feature version number is guaranteed to be set for all + * devices launching with Android 12 and may be set on devices launching with an earlier + * version. If the feature version is set, it will at least have the value 40. If it's not + * set the device may have StrongBox but it may not support all features listed above. */ @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_STRONGBOX_KEYSTORE =