Skip to content

Commit

Permalink
SDKS-3597 Update Ping SDK Minimum Supported Version to API Level 28
Browse files Browse the repository at this point in the history
  • Loading branch information
witrisna committed Nov 21, 2024
1 parent 3ee6dc2 commit e55b2f8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package com.pingidentity.storage.encrypt

import android.content.Context
import android.content.pm.PackageManager
import android.os.Build
import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyProperties
import android.security.keystore.StrongBoxUnavailableException
Expand Down Expand Up @@ -276,29 +275,25 @@ class SecretKeyEncryptor(block: SecretKeyEncryptorConfig.() -> Unit = {}) : Encr
keyGenParameterSpec.setInvalidatedByBiometricEnrollment(config.invalidatedByBiometricEnrollment)

//Allow access the data during screen lock
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
keyGenParameterSpec.setUnlockedDeviceRequired(false)
if (config.context.packageManager.hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE)) {
keyGenParameterSpec.setIsStrongBoxBacked(true)
}
//Add in Level 28
keyGenParameterSpec.setUnlockedDeviceRequired(false)
if (config.context.packageManager.hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE)) {
keyGenParameterSpec.setIsStrongBoxBacked(true)
}

val keyPairGenerator = KeyPairGenerator.getInstance(
KeyProperties.KEY_ALGORITHM_RSA, ANDROID_KEYSTORE
)

keyPairGenerator.initialize(keyGenParameterSpec.build())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
try {
keyPairGenerator.generateKeyPair()
} catch (e: StrongBoxUnavailableException) {
//In case failed to use Strong Box, disable it.
logger.w("Strong Box unavailable, recover without strong box", e)
keyGenParameterSpec.setIsStrongBoxBacked(false)
keyPairGenerator.initialize(keyGenParameterSpec.build())
keyPairGenerator.generateKeyPair()
}
} else {
//Add in Level 28
try {
keyPairGenerator.generateKeyPair()
} catch (e: StrongBoxUnavailableException) {
//In case failed to use Strong Box, disable it.
logger.w("Strong Box unavailable, recover without strong box", e)
keyGenParameterSpec.setIsStrongBoxBacked(false)
keyPairGenerator.initialize(keyGenParameterSpec.build())
keyPairGenerator.generateKeyPair()
}
}
Expand Down Expand Up @@ -368,25 +363,21 @@ class SecretKeyEncryptor(block: SecretKeyEncryptorConfig.() -> Unit = {}) : Encr
specBuilder.setInvalidatedByBiometricEnrollment(config.invalidatedByBiometricEnrollment)

//Allow access the data during screen lock
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
specBuilder.setUnlockedDeviceRequired(false)
if (config.context.packageManager.hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE)) {
specBuilder.setIsStrongBoxBacked(true)
}
//Add in Level 28
specBuilder.setUnlockedDeviceRequired(false)
if (config.context.packageManager.hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE)) {
specBuilder.setIsStrongBoxBacked(true)
}

keyGenerator.init(specBuilder.build())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
try {
return keyGenerator.generateKey()
} catch (e: StrongBoxUnavailableException) {
//In case failed to use Strong Box, disable it.
logger.w("Strong Box unavailable, recover without strong box", e)
specBuilder.setIsStrongBoxBacked(false)
keyGenerator.init(specBuilder.build())
return keyGenerator.generateKey()
}
} else {
//Add in Level 28
try {
return keyGenerator.generateKey()
} catch (e: StrongBoxUnavailableException) {
//In case failed to use Strong Box, disable it.
logger.w("Strong Box unavailable, recover without strong box", e)
specBuilder.setIsStrongBoxBacked(false)
keyGenerator.init(specBuilder.build())
return keyGenerator.generateKey()
}
}
Expand Down
18 changes: 9 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[versions]
compileSdk = "35"
targetSdk = "35"
minSdk = "24"
minSdk = "29"
jvmTarget = "17"

activityCompose = "1.9.3"
agp = "8.7.1"
agp = "8.7.2"
coreSplashscreen = "1.0.1"
datastore = "1.0.0" # DataStorageTest failed when using 1.1.1 https://issuetracker.google.com/issues/337870543
kotlin = "2.0.0"
compose = "1.7.4"
compose-material3 = "1.3.0"
coreKtx = "1.13.1"
compose = "1.7.5"
compose-material3 = "1.3.1"
coreKtx = "1.15.0"
junit = "4.13.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
Expand All @@ -21,8 +21,8 @@ jetbrainsKotlinJvm = "2.0.0"

ktor = "2.3.11" #There is a defect in 3.0.0-beta-1 which related to AcceptAllCookiesStorage, Using Int instead of Long when calculating the cookie exipration
coroutines = "1.7.3"
materialIconsExtended = "1.7.4"
navVersion = "2.8.3"
materialIconsExtended = "1.7.5"
navVersion = "2.8.4"
securityCrypto = "1.1.0-alpha06"
serialization = "1.6.2"
pluginSserialization = "2.0.0"
Expand All @@ -32,7 +32,7 @@ androidx-test-runner = "1.6.2"
androidx-credentials = "1.3.0" #May need to use 1.2.2, seem to have issues with 1.3.0-alpha04
robolectric = "4.12.2"
appauth = "0.11.1"
composeBom = "2024.10.00"
composeBom = "2024.11.00"
activity = "1.9.3"
mockk = "1.13.10"
testLogger = "4.0.0"
Expand All @@ -46,7 +46,7 @@ nexus = "1.3.0"
dokka = "1.9.20"
googleid = "1.1.1"
facebook-login = "17.0.2"
credentials = "1.3.0-beta01"
credentials = "1.3.0"

[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
Expand Down
2 changes: 1 addition & 1 deletion samples/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android {

defaultConfig {
applicationId = "com.pingidentity.samples.app"
minSdk = 24
minSdk = 29
targetSdk = 35
versionCode = 1
versionName = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion samples/journeyapp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {

defaultConfig {
applicationId = "com.pingidentity.samples.journeyapp"
minSdk = 24
minSdk = 29
targetSdk = 35
versionCode = 1
versionName = "1.0"
Expand Down

0 comments on commit e55b2f8

Please sign in to comment.