diff options
author | 2024-08-02 22:30:45 +0000 | |
---|---|---|
committer | 2024-08-02 22:30:45 +0000 | |
commit | e7e89b79ce06f08f4a7b9e56985df39c989a5b61 (patch) | |
tree | 13d929ea690e572872545c52aee90414f14290e8 /wifi | |
parent | 1573d2095b0c173418e42e0b5b54ba02b7852ecc (diff) | |
parent | dad7b306f8020c95f76d3b4446476c44905a9946 (diff) |
Merge "Add method to check whether the vendor partition version is > T." into main
Diffstat (limited to 'wifi')
-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) { |