Rename FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT

As API review feedback, rename Build#VERSION#FIRST_SDK_INT to
Build#VERSION#DEVICE_INITIAL_SDK_INT. As well as update all usage
in frameworks and tests.

Bug: 184735771
Test: m
Change-Id: I72660959cb4e638a8e80fcf2f4e96ea172969f44
This commit is contained in:
paulhu
2021-04-09 15:47:36 +08:00
parent bd888709ff
commit 016950a485
10 changed files with 15 additions and 15 deletions

View File

@@ -256,7 +256,7 @@ package android.os {
} }
public static class Build.VERSION { public static class Build.VERSION {
field public static final int FIRST_SDK_INT; field public static final int DEVICE_INITIAL_SDK_INT;
} }
public interface Parcelable { public interface Parcelable {

View File

@@ -1585,7 +1585,7 @@ package android.os {
public static class Build.VERSION { public static class Build.VERSION {
field public static final String[] ACTIVE_CODENAMES; field public static final String[] ACTIVE_CODENAMES;
field public static final int FIRST_SDK_INT; field public static final int DEVICE_INITIAL_SDK_INT;
field public static final int RESOURCES_SDK_INT; field public static final int RESOURCES_SDK_INT;
} }

View File

@@ -354,7 +354,7 @@ public final class IpSecAlgorithm implements Parcelable {
} }
for (Entry<String, Integer> entry : ALGO_TO_REQUIRED_FIRST_SDK.entrySet()) { for (Entry<String, Integer> entry : ALGO_TO_REQUIRED_FIRST_SDK.entrySet()) {
if (Build.VERSION.FIRST_SDK_INT >= entry.getValue()) { if (Build.VERSION.DEVICE_INITIAL_SDK_INT >= entry.getValue()) {
enabledAlgos.add(entry.getKey()); enabledAlgos.add(entry.getKey());
} }
} }

View File

@@ -348,7 +348,7 @@ public class Build {
*/ */
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@TestApi @TestApi
public static final int FIRST_SDK_INT = SystemProperties public static final int DEVICE_INITIAL_SDK_INT = SystemProperties
.getInt("ro.product.first_api_level", 0); .getInt("ro.product.first_api_level", 0);
/** /**

View File

@@ -60,7 +60,7 @@ public abstract class VerityUtils {
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
public static boolean isFsVeritySupported() { public static boolean isFsVeritySupported() {
return Build.VERSION.FIRST_SDK_INT >= Build.VERSION_CODES.R return Build.VERSION.DEVICE_INITIAL_SDK_INT >= Build.VERSION_CODES.R
|| SystemProperties.getInt("ro.apk_verity.mode", 0) == 2; || SystemProperties.getInt("ro.apk_verity.mode", 0) == 2;
} }

View File

@@ -486,7 +486,7 @@ public class SystemConfig {
// Vendors are only allowed to customize these // Vendors are only allowed to customize these
int vendorPermissionFlag = ALLOW_LIBS | ALLOW_FEATURES | ALLOW_PRIVAPP_PERMISSIONS int vendorPermissionFlag = ALLOW_LIBS | ALLOW_FEATURES | ALLOW_PRIVAPP_PERMISSIONS
| ALLOW_ASSOCIATIONS; | ALLOW_ASSOCIATIONS;
if (Build.VERSION.FIRST_SDK_INT <= Build.VERSION_CODES.O_MR1) { if (Build.VERSION.DEVICE_INITIAL_SDK_INT <= Build.VERSION_CODES.O_MR1) {
// For backward compatibility // For backward compatibility
vendorPermissionFlag |= (ALLOW_PERMISSIONS | ALLOW_APP_CONFIGS); vendorPermissionFlag |= (ALLOW_PERMISSIONS | ALLOW_APP_CONFIGS);
} }
@@ -538,9 +538,9 @@ public class SystemConfig {
int productPermissionFlag = ALLOW_FEATURES | ALLOW_LIBS | ALLOW_PERMISSIONS int productPermissionFlag = ALLOW_FEATURES | ALLOW_LIBS | ALLOW_PERMISSIONS
| ALLOW_APP_CONFIGS | ALLOW_PRIVAPP_PERMISSIONS | ALLOW_HIDDENAPI_WHITELISTING | ALLOW_APP_CONFIGS | ALLOW_PRIVAPP_PERMISSIONS | ALLOW_HIDDENAPI_WHITELISTING
| ALLOW_ASSOCIATIONS | ALLOW_OVERRIDE_APP_RESTRICTIONS | ALLOW_IMPLICIT_BROADCASTS; | ALLOW_ASSOCIATIONS | ALLOW_OVERRIDE_APP_RESTRICTIONS | ALLOW_IMPLICIT_BROADCASTS;
if (Build.VERSION.FIRST_SDK_INT <= Build.VERSION_CODES.R) { if (Build.VERSION.DEVICE_INITIAL_SDK_INT <= Build.VERSION_CODES.R) {
// TODO(b/157393157): This must check product interface enforcement instead of // TODO(b/157393157): This must check product interface enforcement instead of
// FIRST_SDK_VERSION for the devices without product interface enforcement. // DEVICE_INITIAL_SDK_INT for the devices without product interface enforcement.
productPermissionFlag = ALLOW_ALL; productPermissionFlag = ALLOW_ALL;
} }
readPermissions(Environment.buildPath( readPermissions(Environment.buildPath(
@@ -1241,7 +1241,7 @@ public class SystemConfig {
addFeature(PackageManager.FEATURE_APP_ENUMERATION, 0); addFeature(PackageManager.FEATURE_APP_ENUMERATION, 0);
} }
if (Build.VERSION.FIRST_SDK_INT >= Build.VERSION_CODES.Q) { if (Build.VERSION.DEVICE_INITIAL_SDK_INT >= Build.VERSION_CODES.Q) {
addFeature(PackageManager.FEATURE_IPSEC_TUNNELS, 0); addFeature(PackageManager.FEATURE_IPSEC_TUNNELS, 0);
} }

View File

@@ -69,7 +69,7 @@ public class FingerprintUpdateActiveUserClient extends HalClientMonitor<IBiometr
return; return;
} }
int firstSdkInt = Build.VERSION.FIRST_SDK_INT; int firstSdkInt = Build.VERSION.DEVICE_INITIAL_SDK_INT;
if (firstSdkInt < Build.VERSION_CODES.BASE) { if (firstSdkInt < Build.VERSION_CODES.BASE) {
Slog.e(TAG, "First SDK version " + firstSdkInt + " is invalid; must be " + Slog.e(TAG, "First SDK version " + firstSdkInt + " is invalid; must be " +
"at least VERSION_CODES.BASE"); "at least VERSION_CODES.BASE");

View File

@@ -133,7 +133,7 @@ public class PermissionMonitor {
* Get device first sdk version. * Get device first sdk version.
*/ */
public int getDeviceFirstSdkInt() { public int getDeviceFirstSdkInt() {
return Build.VERSION.FIRST_SDK_INT; return Build.VERSION.DEVICE_INITIAL_SDK_INT;
} }
} }

View File

@@ -602,7 +602,7 @@ public class PackageManagerServiceUtils {
/** Returns true if standard APK Verity is enabled. */ /** Returns true if standard APK Verity is enabled. */
static boolean isApkVerityEnabled() { static boolean isApkVerityEnabled() {
return Build.VERSION.FIRST_SDK_INT >= Build.VERSION_CODES.R return Build.VERSION.DEVICE_INITIAL_SDK_INT >= Build.VERSION_CODES.R
|| SystemProperties.getInt("ro.apk_verity.mode", FSVERITY_DISABLED) || SystemProperties.getInt("ro.apk_verity.mode", FSVERITY_DISABLED)
== FSVERITY_ENABLED; == FSVERITY_ENABLED;
} }

View File

@@ -121,7 +121,7 @@ public class IpSecAlgorithmTest {
@Test @Test
public void testValidationForAlgosAddedInS() throws Exception { public void testValidationForAlgosAddedInS() throws Exception {
if (Build.VERSION.FIRST_SDK_INT <= Build.VERSION_CODES.R) { if (Build.VERSION.DEVICE_INITIAL_SDK_INT <= Build.VERSION_CODES.R) {
return; return;
} }
@@ -194,13 +194,13 @@ public class IpSecAlgorithmTest {
private static Set<String> getMandatoryAlgos() { private static Set<String> getMandatoryAlgos() {
return CollectionUtils.filter( return CollectionUtils.filter(
ALGO_TO_REQUIRED_FIRST_SDK.keySet(), ALGO_TO_REQUIRED_FIRST_SDK.keySet(),
i -> Build.VERSION.FIRST_SDK_INT >= ALGO_TO_REQUIRED_FIRST_SDK.get(i)); i -> Build.VERSION.DEVICE_INITIAL_SDK_INT >= ALGO_TO_REQUIRED_FIRST_SDK.get(i));
} }
private static Set<String> getOptionalAlgos() { private static Set<String> getOptionalAlgos() {
return CollectionUtils.filter( return CollectionUtils.filter(
ALGO_TO_REQUIRED_FIRST_SDK.keySet(), ALGO_TO_REQUIRED_FIRST_SDK.keySet(),
i -> Build.VERSION.FIRST_SDK_INT < ALGO_TO_REQUIRED_FIRST_SDK.get(i)); i -> Build.VERSION.DEVICE_INITIAL_SDK_INT < ALGO_TO_REQUIRED_FIRST_SDK.get(i));
} }
@Test @Test