ipsec - use ro.vendor.api_level instead of ro.product.first_api_level
Bug: 254143771 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I9f91fc250e0fa40c9dc9ee3e7a2f7bc3cf2ebc75
This commit is contained in:
@@ -21,6 +21,7 @@ import android.content.res.Resources;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.os.SystemProperties;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
|
|
||||||
@@ -351,8 +352,11 @@ public final class IpSecAlgorithm implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// T introduced calculated property 'ro.vendor.api_level',
|
||||||
|
// which is the API level of the VSR that the device must conform to.
|
||||||
|
int vendorApiLevel = SystemProperties.getInt("ro.vendor.api_level", 10000);
|
||||||
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.DEVICE_INITIAL_SDK_INT >= entry.getValue()) {
|
if (vendorApiLevel >= entry.getValue()) {
|
||||||
enabledAlgos.add(entry.getKey());
|
enabledAlgos.add(entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.mock;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
import android.os.SystemProperties;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
@@ -123,9 +124,7 @@ public class IpSecAlgorithmTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidationForAlgosAddedInS() throws Exception {
|
public void testValidationForAlgosAddedInS() throws Exception {
|
||||||
if (Build.VERSION.DEVICE_INITIAL_SDK_INT <= Build.VERSION_CODES.R) {
|
if (SystemProperties.getInt("ro.vendor.api_level", 10000) <= Build.VERSION_CODES.R) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int len : new int[] {160, 224, 288}) {
|
for (int len : new int[] {160, 224, 288}) {
|
||||||
checkCryptKeyLenValidation(IpSecAlgorithm.CRYPT_AES_CTR, len);
|
checkCryptKeyLenValidation(IpSecAlgorithm.CRYPT_AES_CTR, len);
|
||||||
@@ -194,15 +193,17 @@ public class IpSecAlgorithmTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Set<String> getMandatoryAlgos() {
|
private static Set<String> getMandatoryAlgos() {
|
||||||
|
int vendorApiLevel = SystemProperties.getInt("ro.vendor.api_level", 10000);
|
||||||
return CollectionUtils.filter(
|
return CollectionUtils.filter(
|
||||||
ALGO_TO_REQUIRED_FIRST_SDK.keySet(),
|
ALGO_TO_REQUIRED_FIRST_SDK.keySet(),
|
||||||
i -> Build.VERSION.DEVICE_INITIAL_SDK_INT >= ALGO_TO_REQUIRED_FIRST_SDK.get(i));
|
i -> vendorApiLevel >= ALGO_TO_REQUIRED_FIRST_SDK.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<String> getOptionalAlgos() {
|
private static Set<String> getOptionalAlgos() {
|
||||||
|
int vendorApiLevel = SystemProperties.getInt("ro.vendor.api_level", 10000);
|
||||||
return CollectionUtils.filter(
|
return CollectionUtils.filter(
|
||||||
ALGO_TO_REQUIRED_FIRST_SDK.keySet(),
|
ALGO_TO_REQUIRED_FIRST_SDK.keySet(),
|
||||||
i -> Build.VERSION.DEVICE_INITIAL_SDK_INT < ALGO_TO_REQUIRED_FIRST_SDK.get(i));
|
i -> vendorApiLevel < ALGO_TO_REQUIRED_FIRST_SDK.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user