diff options
author | 2024-07-19 16:59:48 +0000 | |
---|---|---|
committer | 2024-08-01 22:30:54 +0000 | |
commit | dad7b306f8020c95f76d3b4446476c44905a9946 (patch) | |
tree | 8e49c8044ca96685f3a29fad500d30bbeba30c2f /wifi/java/src | |
parent | 7a733fd9a78d4f16bb6c7ffde506edb4436c6f60 (diff) |
Add method to check whether the vendor partition
version is > T.
Bug: 353140706
Flag: EXEMPT bugfix
Test: Manual test - check for the expected result
on a device with a T vendor partion, and
another with a V vendor partition.
Change-Id: Ie96855f477dfc388885f97335516c54f16e389a5
Diffstat (limited to 'wifi/java/src')
-rw-r--r-- | wifi/java/src/android/net/wifi/WifiBlobStore.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/wifi/java/src/android/net/wifi/WifiBlobStore.java b/wifi/java/src/android/net/wifi/WifiBlobStore.java index 8737c7e91454..57d997bc2267 100644 --- a/wifi/java/src/android/net/wifi/WifiBlobStore.java +++ b/wifi/java/src/android/net/wifi/WifiBlobStore.java @@ -16,8 +16,11 @@ package android.net.wifi; +import android.os.Build; import android.os.ServiceManager; +import android.os.SystemProperties; import android.security.legacykeystore.ILegacyKeystore; +import android.util.Log; import com.android.internal.net.ConnectivityBlobStore; @@ -26,13 +29,44 @@ import com.android.internal.net.ConnectivityBlobStore; * @hide */ public class WifiBlobStore extends ConnectivityBlobStore { + private static final String TAG = "WifiBlobStore"; private static final String DB_NAME = "WifiBlobStore.db"; private static final String LEGACY_KEYSTORE_SERVICE_NAME = "android.security.legacykeystore"; + private static final boolean sIsVendorApiLevelGreaterThanT = isVendorApiLevelGreaterThanT(); private static WifiBlobStore sInstance; private WifiBlobStore() { super(DB_NAME); } + private static boolean isVendorApiLevelGreaterThanT() { + int androidT = Build.VERSION_CODES.TIRAMISU; // redefine to avoid errorprone build issue + String[] vendorApiLevelProps = { + "ro.board.api_level", "ro.board.first_api_level", "ro.vndk.version"}; + for (String propertyName : vendorApiLevelProps) { + int apiLevel = SystemProperties.getInt(propertyName, -1); + if (apiLevel != -1) { + Log.i(TAG, "Retrieved API level property, value=" + apiLevel); + return apiLevel > androidT; + } + } + // If none of the properties are defined, we are using the current API level (> V) + Log.i(TAG, "No API level properties are defined"); + return true; + } + + /** + * Check whether supplicant can access values stored in WifiBlobstore. + * + * NonStandardCertCallback was added in Android U, allowing supplicant to access the + * WifiKeystore APIs, which access WifiBlobstore. Previously, supplicant used + * WifiKeystoreHalConnector to access values stored in Legacy Keystore. + * + * @hide + */ + public static boolean supplicantCanAccessBlobstore() { + return sIsVendorApiLevelGreaterThanT; + } + /** Returns an instance of WifiBlobStore. */ public static WifiBlobStore getInstance() { if (sInstance == null) { |