[#972] Min API 27

This commit is contained in:
Carter Jernigan 2023-04-11 07:42:36 -04:00 committed by Carter Jernigan
parent 9d2da8218e
commit d513ac6559
11 changed files with 42 additions and 98 deletions

View File

@ -1,6 +1,10 @@
Change Log Change Log
========== ==========
## 1.16.0-beta01
### Changed
- The minimum supported version of Android is now API level 27.
## 1.15.0-beta01 ## 1.15.0-beta01
### Changed ### Changed
- A new package `sdk-incubator-lib` is now available as a public API. This package contains experimental APIs that may be promoted to the SDK in the future. The APIs in this package are not guaranteed to be stable, and may change at any time. - A new package `sdk-incubator-lib` is now available as a public API. This package contains experimental APIs that may be promoted to the SDK in the future. The APIs in this package are not guaranteed to be stable, and may change at any time.

View File

@ -104,7 +104,7 @@ fladle {
// Firebase Test Lab has min and max values that might differ from our project's // Firebase Test Lab has min and max values that might differ from our project's
// These are determined by `gcloud firebase test android models list` // These are determined by `gcloud firebase test android models list`
@Suppress("MagicNumber", "PropertyName", "VariableNaming") @Suppress("MagicNumber", "PropertyName", "VariableNaming")
val FIREBASE_TEST_LAB_MIN_API = 19 val FIREBASE_TEST_LAB_MIN_API = 27 // Minimum for Pixel2.arm device
@Suppress("MagicNumber", "PropertyName", "VariableNaming") @Suppress("MagicNumber", "PropertyName", "VariableNaming")
val FIREBASE_TEST_LAB_MAX_API = 33 val FIREBASE_TEST_LAB_MAX_API = 33
@ -128,7 +128,7 @@ fladle {
} }
devices.addAll( devices.addAll(
mapOf("model" to "Nexus5X", "version" to minSdkVersion), mapOf("model" to "Pixel2.arm", "version" to minSdkVersion),
mapOf("model" to "Pixel2.arm", "version" to targetSdkVersion) mapOf("model" to "Pixel2.arm", "version" to targetSdkVersion)
) )

View File

@ -142,7 +142,7 @@ fladle {
// Firebase Test Lab has min and max values that might differ from our project's // Firebase Test Lab has min and max values that might differ from our project's
// These are determined by `gcloud firebase test android models list` // These are determined by `gcloud firebase test android models list`
@Suppress("MagicNumber", "PropertyName", "VariableNaming") @Suppress("MagicNumber", "PropertyName", "VariableNaming")
val FIREBASE_TEST_LAB_MIN_API = 19 val FIREBASE_TEST_LAB_MIN_API = 27 // Minimum for Pixel2.arm device
@Suppress("MagicNumber", "PropertyName", "VariableNaming") @Suppress("MagicNumber", "PropertyName", "VariableNaming")
val FIREBASE_TEST_LAB_MAX_API = 33 val FIREBASE_TEST_LAB_MAX_API = 33
@ -180,7 +180,7 @@ fladle {
testTimeout.set("5m") testTimeout.set("5m")
devices.addAll( devices.addAll(
mapOf("model" to "Nexus5X", "version" to minSdkVersion), mapOf("model" to "Pixel2.arm", "version" to minSdkVersion),
mapOf("model" to "Pixel2.arm", "version" to targetSdkVersion) mapOf("model" to "Pixel2.arm", "version" to targetSdkVersion)
) )

View File

@ -1,8 +1,6 @@
package cash.z.ecc.android.sdk.demoapp package cash.z.ecc.android.sdk.demoapp
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Handler
import android.os.Looper
import android.os.StrictMode import android.os.StrictMode
import cash.z.ecc.android.sdk.demoapp.util.AndroidApiVersion import cash.z.ecc.android.sdk.demoapp.util.AndroidApiVersion
@ -10,14 +8,6 @@ object StrictModeHelper {
fun enableStrictMode() { fun enableStrictMode() {
configureStrictMode() configureStrictMode()
// Workaround for Android bug
// https://issuetracker.google.com/issues/36951662
// Not needed if target O_MR1 and running on O_MR1
// Don't really need to check target, because of Google Play enforcement on targetSdkVersion for app updates
if (!AndroidApiVersion.isAtLeastO_MR1) {
Handler(Looper.getMainLooper()).postAtFrontOfQueue { configureStrictMode() }
}
} }
@SuppressLint("NewApi") @SuppressLint("NewApi")
@ -31,30 +21,20 @@ object StrictModeHelper {
}.build() }.build()
) )
// Don't enable missing network tags, because those are noisy. StrictMode.setVmPolicy(
if (AndroidApiVersion.isAtLeastO) { StrictMode.VmPolicy.Builder().apply {
StrictMode.setVmPolicy( detectActivityLeaks()
StrictMode.VmPolicy.Builder().apply { detectCleartextNetwork()
detectActivityLeaks() detectContentUriWithoutPermission()
detectCleartextNetwork() detectFileUriExposure()
detectContentUriWithoutPermission() detectLeakedClosableObjects()
detectFileUriExposure() detectLeakedRegistrationObjects()
detectLeakedClosableObjects() detectLeakedSqlLiteObjects()
detectLeakedRegistrationObjects() if (AndroidApiVersion.isAtLeastP) {
detectLeakedSqlLiteObjects() // Disable because this is mostly flagging Android X and Play Services
if (AndroidApiVersion.isAtLeastP) { // builder.detectNonSdkApiUsage();
// Disable because this is mostly flagging Android X and Play Services }
// builder.detectNonSdkApiUsage(); }.build()
} )
}.build()
)
} else {
StrictMode.setVmPolicy(
StrictMode.VmPolicy.Builder().apply {
detectAll()
penaltyLog()
}.build()
)
}
} }
} }

View File

@ -15,12 +15,6 @@ internal object AndroidApiVersion {
return Build.VERSION.SDK_INT >= sdk return Build.VERSION.SDK_INT >= sdk
} }
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
val isAtLeastO = isAtLeast(Build.VERSION_CODES.O)
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O_MR1)
val isAtLeastO_MR1 = isAtLeast(Build.VERSION_CODES.O_MR1)
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.P) @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.P)
val isAtLeastP = isAtLeast(Build.VERSION_CODES.P) val isAtLeastP = isAtLeast(Build.VERSION_CODES.P)

View File

@ -23,7 +23,7 @@ ZCASH_ASCII_GPG_KEY=
# Configures whether release is an unstable snapshot, therefore published to the snapshot repository. # Configures whether release is an unstable snapshot, therefore published to the snapshot repository.
IS_SNAPSHOT=true IS_SNAPSHOT=true
LIBRARY_VERSION=1.15.0-beta01 LIBRARY_VERSION=1.16.0-beta01
# Kotlin compiler warnings can be considered errors, failing the build. # Kotlin compiler warnings can be considered errors, failing the build.
ZCASH_IS_TREAT_WARNINGS_AS_ERRORS=true ZCASH_IS_TREAT_WARNINGS_AS_ERRORS=true
@ -71,7 +71,7 @@ IS_SIGN_RELEASE_BUILD_WITH_DEBUG_KEY=false
IS_DEBUGGABLE_WHILE_BENCHMARKING=false IS_DEBUGGABLE_WHILE_BENCHMARKING=false
# Versions # Versions
ANDROID_MIN_SDK_VERSION=24 ANDROID_MIN_SDK_VERSION=27
ANDROID_TARGET_SDK_VERSION=33 ANDROID_TARGET_SDK_VERSION=33
ANDROID_COMPILE_SDK_VERSION=33 ANDROID_COMPILE_SDK_VERSION=33

View File

@ -1,7 +1,6 @@
package cash.z.ecc.android.sdk.db package cash.z.ecc.android.sdk.db
import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest
import cash.z.ecc.android.sdk.internal.AndroidApiVersion
import cash.z.ecc.android.sdk.internal.db.DatabaseCoordinator import cash.z.ecc.android.sdk.internal.db.DatabaseCoordinator
import cash.z.ecc.android.sdk.internal.db.commonDatabaseBuilder import cash.z.ecc.android.sdk.internal.db.commonDatabaseBuilder
import cash.z.ecc.android.sdk.internal.db.pending.PendingTransactionDb import cash.z.ecc.android.sdk.internal.db.pending.PendingTransactionDb
@ -30,12 +29,6 @@ class CommonDatabaseBuilderTest {
assertNotNull(db) assertNotNull(db)
val expectedDbName = if (AndroidApiVersion.isAtLeastO_MR1) { assertEquals(dbFileName, db.openHelper.databaseName)
dbFileName
} else {
dbFile.absolutePath
}
assertEquals(expectedDbName, db.openHelper.databaseName)
} }
} }

View File

@ -1,7 +1,5 @@
package cash.z.ecc.android.sdk.db package cash.z.ecc.android.sdk.db
import android.os.Build
import androidx.test.filters.SdkSuppress
import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest
import cash.z.ecc.android.sdk.internal.NoBackupContextWrapper import cash.z.ecc.android.sdk.internal.NoBackupContextWrapper
import cash.z.ecc.android.sdk.test.getAppContext import cash.z.ecc.android.sdk.test.getAppContext
@ -11,7 +9,6 @@ import org.junit.Assert.assertTrue
import org.junit.Test import org.junit.Test
import java.io.File import java.io.File
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.O_MR1)
class NoBackupContextWrapperTest { class NoBackupContextWrapperTest {
private val databaseParentDir = File(DatabasePathFixture.new()) private val databaseParentDir = File(DatabasePathFixture.new())

View File

@ -15,12 +15,6 @@ internal object AndroidApiVersion {
return Build.VERSION.SDK_INT >= sdk return Build.VERSION.SDK_INT >= sdk
} }
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
val isAtLeastO = isAtLeast(Build.VERSION_CODES.O)
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O_MR1)
val isAtLeastO_MR1 = isAtLeast(Build.VERSION_CODES.O_MR1)
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.P) @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.P)
val isAtLeastP = isAtLeast(Build.VERSION_CODES.P) val isAtLeastP = isAtLeast(Build.VERSION_CODES.P)

View File

@ -6,7 +6,6 @@ import androidx.room.Room
import androidx.room.RoomDatabase import androidx.room.RoomDatabase
import cash.z.ecc.android.sdk.exception.InitializeException import cash.z.ecc.android.sdk.exception.InitializeException
import cash.z.ecc.android.sdk.ext.ZcashSdk import cash.z.ecc.android.sdk.ext.ZcashSdk
import cash.z.ecc.android.sdk.internal.AndroidApiVersion
import cash.z.ecc.android.sdk.internal.Files import cash.z.ecc.android.sdk.internal.Files
import cash.z.ecc.android.sdk.internal.LazyWithArgument import cash.z.ecc.android.sdk.internal.LazyWithArgument
import cash.z.ecc.android.sdk.internal.NoBackupContextWrapper import cash.z.ecc.android.sdk.internal.NoBackupContextWrapper
@ -434,20 +433,12 @@ internal fun <T : RoomDatabase> commonDatabaseBuilder(
klass: Class<T>, klass: Class<T>,
databaseFile: File databaseFile: File
): RoomDatabase.Builder<T> { ): RoomDatabase.Builder<T> {
return if (AndroidApiVersion.isAtLeastO_MR1) { return Room.databaseBuilder(
Room.databaseBuilder( NoBackupContextWrapper(
NoBackupContextWrapper(
context,
databaseFile.parentFile ?: throw InitializeException.DatabasePathException
),
klass,
databaseFile.name
)
} else {
Room.databaseBuilder(
context, context,
klass, databaseFile.parentFile ?: throw InitializeException.DatabasePathException
databaseFile.absolutePath ),
) klass,
} databaseFile.name
)
} }

View File

@ -5,7 +5,6 @@ import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.sqlite.db.SupportSQLiteOpenHelper import androidx.sqlite.db.SupportSQLiteOpenHelper
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import cash.z.ecc.android.sdk.exception.InitializeException import cash.z.ecc.android.sdk.exception.InitializeException
import cash.z.ecc.android.sdk.internal.AndroidApiVersion
import cash.z.ecc.android.sdk.internal.NoBackupContextWrapper import cash.z.ecc.android.sdk.internal.NoBackupContextWrapper
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@ -27,23 +26,15 @@ object ReadOnlySupportSqliteOpenHelper {
databaseVersion: Int databaseVersion: Int
): SupportSQLiteDatabase { ): SupportSQLiteDatabase {
return withContext(Dispatchers.IO) { return withContext(Dispatchers.IO) {
val config = if (AndroidApiVersion.isAtLeastO_MR1) { val contextWrapper = NoBackupContextWrapper(
val contextWrapper = NoBackupContextWrapper( context,
context, file.parentFile ?: throw InitializeException.DatabasePathException
file.parentFile ?: throw InitializeException.DatabasePathException )
) val config = SupportSQLiteOpenHelper.Configuration.builder(contextWrapper)
SupportSQLiteOpenHelper.Configuration.builder(contextWrapper) .apply {
.apply { name(file.name)
name(file.name) callback(ReadOnlyCallback(databaseVersion))
callback(ReadOnlyCallback(databaseVersion)) }.build()
}.build()
} else {
SupportSQLiteOpenHelper.Configuration.builder(context)
.apply {
name(file.absolutePath)
callback(ReadOnlyCallback(databaseVersion))
}.build()
}
FrameworkSQLiteOpenHelperFactory().create(config).readableDatabase FrameworkSQLiteOpenHelperFactory().create(config).readableDatabase
} }