[#917] Min API 24

Co-authored-by: Honza <rychnovsky.honza@gmail.com>
This commit is contained in:
Carter Jernigan 2023-02-09 06:52:10 -05:00 committed by GitHub
parent 3ed4c62f8d
commit 8df7a5d3ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 22 additions and 93 deletions

View File

@ -1,6 +1,10 @@
Change Log
==========
## 1.14.0-beta01
### Changed
- The minimum supported version of Android is now API level 24.
## 1.13.0-beta01
### Changed
- The SDK's internal networking has been refactored to a separate Gradle module `lightwallet-client-lib` (and

View File

@ -58,7 +58,7 @@ pluginManager.withPlugin("com.android.test") {
configureBaseExtension()
defaultConfig {
minSdk = project.property("ANDROID_MIN_BENCHMARK_VERSION").toString().toInt()
minSdk = project.property("ANDROID_MIN_SDK_VERSION").toString().toInt()
targetSdk = project.property("ANDROID_TARGET_SDK_VERSION").toString().toInt()
// The last two are for support of pseudolocales in debug builds.

View File

@ -126,7 +126,7 @@ fladle {
}
devices.addAll(
mapOf("model" to "Nexus5", "version" to minSdkVersion),
mapOf("model" to "Nexus5X", "version" to minSdkVersion),
mapOf("model" to "Pixel2.arm", "version" to targetSdkVersion)
)

View File

@ -12,10 +12,8 @@ android {
defaultConfig {
applicationId = "cash.z.ecc.android.sdk.demoapp"
minSdk = 21
versionCode = 1
versionName = "1.0"
multiDexEnabled = true
vectorDrawables.useSupportLibrary = true
}
@ -176,7 +174,7 @@ fladle {
testTimeout.set("5m")
devices.addAll(
mapOf("model" to "Nexus5", "version" to minSdkVersion),
mapOf("model" to "Nexus5X", "version" to minSdkVersion),
mapOf("model" to "Pixel2.arm", "version" to targetSdkVersion)
)

View File

@ -1,34 +1,27 @@
package cash.z.wallet.sdk.sample.demoapp.test
import android.annotation.TargetApi
import android.app.KeyguardManager
import android.content.Context
import android.os.Build
import android.os.PowerManager
import androidx.test.core.app.ApplicationProvider
import org.junit.Before
/**
* Subclass this in view unit and integration tests. This verifies that
* prerequisites necessary for reliable UI tests are met, and it provides more useful error messages.
*/
open class UiTestPrerequisites {
@Before
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
fun verifyPrerequisites() {
assertScreenIsOn()
assertKeyguardIsUnlocked()
}
companion object {
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
fun assertScreenIsOn() {
if (!isScreenOn()) {
throw AssertionError("Screen must be on for Android UI tests to run") // $NON-NLS
}
}
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
private fun isScreenOn(): Boolean {
val powerService = ApplicationProvider.getApplicationContext<Context>()
.getSystemService(Context.POWER_SERVICE) as PowerManager

View File

@ -156,11 +156,7 @@ private fun copyToClipboard(
scope: CoroutineScope,
snackbarHostState: SnackbarHostState
) {
val clipboardManager = if (AndroidApiVersion.isAtLeastM) {
context.getSystemService(ClipboardManager::class.java)
} else {
context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
}
val clipboardManager = context.getSystemService(ClipboardManager::class.java)
val data = ClipData.newPlainText(
tag,

View File

@ -1,10 +1,10 @@
package cash.z.ecc.android.sdk.demoapp
import android.annotation.SuppressLint
import android.os.Build
import android.os.Handler
import android.os.Looper
import android.os.StrictMode
import cash.z.ecc.android.sdk.demoapp.util.AndroidApiVersion
object StrictModeHelper {
@ -15,7 +15,7 @@ object StrictModeHelper {
// 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 (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) {
if (!AndroidApiVersion.isAtLeastO_MR1) {
Handler(Looper.getMainLooper()).postAtFrontOfQueue { configureStrictMode() }
}
}
@ -32,7 +32,7 @@ object StrictModeHelper {
)
// Don't enable missing network tags, because those are noisy.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (AndroidApiVersion.isAtLeastO) {
StrictMode.setVmPolicy(
StrictMode.VmPolicy.Builder().apply {
detectActivityLeaks()
@ -42,7 +42,7 @@ object StrictModeHelper {
detectLeakedClosableObjects()
detectLeakedRegistrationObjects()
detectLeakedSqlLiteObjects()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (AndroidApiVersion.isAtLeastP) {
// Disable because this is mostly flagging Android X and Play Services
// builder.detectNonSdkApiUsage();
}

View File

@ -15,15 +15,6 @@ object AndroidApiVersion {
return Build.VERSION.SDK_INT >= sdk
}
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.LOLLIPOP)
val isAtLeastL = isAtLeast(Build.VERSION_CODES.LOLLIPOP)
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.M)
val isAtLeastM = isAtLeast(Build.VERSION_CODES.M)
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N)
val isAtLeastN = isAtLeast(Build.VERSION_CODES.N)
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
val isAtLeastO = isAtLeast(Build.VERSION_CODES.O)
@ -46,12 +37,7 @@ object AndroidApiVersion {
val isAtLeastT = isAtLeast(Build.VERSION_CODES.TIRAMISU)
/**
* This property indicates a preview version of the current device Android SDK. It works only on
* Android SDK 23 and later, on the previous SDK versions its value is always false.
* This property indicates a preview version of the current device Android SDK.
*/
val isPreview = if (isAtLeastM) {
0 != Build.VERSION.PREVIEW_SDK_INT
} else {
false
}
val isPreview = 0 != Build.VERSION.PREVIEW_SDK_INT
}

View File

@ -23,7 +23,7 @@ ZCASH_ASCII_GPG_KEY=
# Configures whether release is an unstable snapshot, therefore published to the snapshot repository.
IS_SNAPSHOT=true
LIBRARY_VERSION=1.13.0-beta01
LIBRARY_VERSION=1.14.0-beta01
# Kotlin compiler warnings can be considered errors, failing the build.
ZCASH_IS_TREAT_WARNINGS_AS_ERRORS=true
@ -65,8 +65,7 @@ ZCASH_RELEASE_KEY_ALIAS_PASSWORD=
IS_SIGN_RELEASE_BUILD_WITH_DEBUG_KEY=false
# Versions
ANDROID_MIN_SDK_VERSION=21
ANDROID_MIN_BENCHMARK_VERSION=24
ANDROID_MIN_SDK_VERSION=24
ANDROID_TARGET_SDK_VERSION=33
ANDROID_COMPILE_SDK_VERSION=33

View File

@ -1,8 +1,6 @@
package cash.z.ecc.android.sdk.integration.service
import android.os.Build
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SdkSuppress
import androidx.test.filters.SmallTest
import cash.z.ecc.android.sdk.annotation.MaintainedTest
import cash.z.ecc.android.sdk.annotation.TestPurpose
@ -25,7 +23,6 @@ import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.MockitoAnnotations
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.N)
@MaintainedTest(TestPurpose.REGRESSION)
@RunWith(AndroidJUnit4::class)
@SmallTest

View File

@ -3,14 +3,14 @@ package cash.z.ecc.fixture
import cash.z.ecc.android.sdk.internal.Files
import cash.z.ecc.android.sdk.internal.ext.existsSuspend
import cash.z.ecc.android.sdk.internal.ext.getDatabasePathSuspend
import cash.z.ecc.android.sdk.internal.ext.getNoBackupFilesDirCompat
import cash.z.ecc.android.sdk.internal.ext.getNoBackupFilesDirSuspend
import cash.z.ecc.android.sdk.test.getAppContext
import kotlinx.coroutines.runBlocking
import java.io.File
object DatabasePathFixture {
val NO_BACKUP_DIR_PATH: String = runBlocking {
getAppContext().getNoBackupFilesDirCompat().absolutePath
getAppContext().getNoBackupFilesDirSuspend().absolutePath
}
val DATABASE_DIR_PATH: String = runBlocking {
getAppContext().getDatabasePathSuspend("temporary.db").parentFile.let { parentFile ->

View File

@ -15,15 +15,6 @@ internal object AndroidApiVersion {
return Build.VERSION.SDK_INT >= sdk
}
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.LOLLIPOP)
val isAtLeastL = isAtLeast(Build.VERSION_CODES.LOLLIPOP)
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.M)
val isAtLeastM = isAtLeast(Build.VERSION_CODES.M)
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N)
val isAtLeastN = isAtLeast(Build.VERSION_CODES.N)
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
val isAtLeastO = isAtLeast(Build.VERSION_CODES.O)
@ -46,12 +37,7 @@ internal object AndroidApiVersion {
val isAtLeastT = isAtLeast(Build.VERSION_CODES.TIRAMISU)
/**
* This property indicates a preview version of the current device Android SDK. It works only on
* Android SDK 23 and later, on the previous SDK versions its value is always false.
* This property indicates a preview version of the current device Android SDK.
*/
val isPreview = if (isAtLeastM) {
0 != Build.VERSION.PREVIEW_SDK_INT
} else {
false
}
val isPreview = 0 != Build.VERSION.PREVIEW_SDK_INT
}

View File

@ -3,7 +3,7 @@ package cash.z.ecc.android.sdk.internal
import android.content.Context
import cash.z.ecc.android.sdk.internal.ext.canWriteSuspend
import cash.z.ecc.android.sdk.internal.ext.existsSuspend
import cash.z.ecc.android.sdk.internal.ext.getNoBackupFilesDirCompat
import cash.z.ecc.android.sdk.internal.ext.getNoBackupFilesDirSuspend
import cash.z.ecc.android.sdk.internal.ext.mkdirsSuspend
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
@ -29,7 +29,7 @@ internal object Files {
* to prevent multiple threads to invoke the function at the same time.
*/
suspend fun getZcashNoBackupSubdirectory(context: Context): File {
val dir = File(context.getNoBackupFilesDirCompat(), NO_BACKUP_SUBDIRECTORY)
val dir = File(context.getNoBackupFilesDirSuspend(), NO_BACKUP_SUBDIRECTORY)
accessMutex.withLock {
if (!dir.existsSuspend()) {

View File

@ -1,18 +1,13 @@
package cash.z.ecc.android.sdk.internal.ext
import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import cash.z.ecc.android.sdk.internal.AndroidApiVersion
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.File
internal suspend fun Context.getDatabasePathSuspend(fileName: String) =
withContext(Dispatchers.IO) { getDatabasePath(fileName) }
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
internal suspend fun Context.getNoBackupFilesDirSuspend() =
withContext(Dispatchers.IO) { noBackupFilesDir }
@ -24,28 +19,3 @@ internal suspend fun Context.getFilesDirSuspend() =
internal suspend fun Context.getDataDirCompatSuspend() =
withContext(Dispatchers.IO) { ContextCompat.getDataDir(this@getDataDirCompatSuspend) }
private const val FAKE_NO_BACKUP_FOLDER = "no_backup" // $NON-NLS
/**
* @return Path to the no backup folder, with fallback behavior for API < 21.
*/
internal suspend fun Context.getNoBackupFilesDirCompat(): File {
val dir = if (AndroidApiVersion.isAtLeastL) {
getNoBackupFilesDirSuspend()
} else {
File(getDataDirCompatSuspend(), FAKE_NO_BACKUP_FOLDER)
}
if (!dir.existsSuspend()) {
if (!dir.mkdirsSuspend()) {
error("no_backup directory does not exist and could not be created")
}
}
if (!dir.canWriteSuspend()) {
error("${dir.absolutePath} directory is not writable")
}
return dir
}