[#1008] SecureScreen customization

* [#1008] Customizing SecureScreen mechanism

Tested with an unexpected value in checkProperties too.
This commit is contained in:
Honza Rychnovský 2023-10-17 16:01:53 +02:00 committed by GitHub
parent 16bf1afa90
commit 5010c624a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 42 additions and 7 deletions

View File

@ -207,6 +207,7 @@ val googlePlayServiceKeyFilePath = project.property("ZCASH_GOOGLE_PLAY_SERVICE_K
androidComponents {
onVariants { variant ->
for (output in variant.outputs) {
// Configure strict mode in runtime
variant.buildConfigFields.put(
"IS_STRICT_MODE_CRASH_ENABLED",
BuildConfigField(

View File

@ -101,6 +101,7 @@ tasks {
"ZCASH_RELEASE_APP_NAME" to "Zashi",
"ZCASH_RELEASE_PACKAGE_NAME" to "co.electriccoin.zcash",
"ZCASH_SUPPORT_EMAIL_ADDRESS" to "support@electriccoin.co",
"IS_SECURE_SCREEN_PROTECTION_ACTIVE" to "true",
"ZCASH_DEBUG_KEYSTORE_PATH" to "",
"ZCASH_RELEASE_KEYSTORE_PATH" to "",

View File

@ -61,6 +61,10 @@ ZCASH_RELEASE_PACKAGE_NAME=co.electriccoin.zcash
ZCASH_DEBUG_APP_NAME_SUFFIX=" (D)"
ZCASH_SUPPORT_EMAIL_ADDRESS=support@electriccoin.co
# Recommended protection of screens with sensitive data.
# It is enabled by default to protect the developers from revealing their wallet secrets by mistake.
IS_SECURE_SCREEN_PROTECTION_ACTIVE=true
# Set keystore details to enable build signing. Typically these
# are overridden via ~/.gradle/gradle.properties to allow secure injection.
# Debug keystore is useful if using Google Maps or Firebase, which require API keys to be linked

View File

@ -1,3 +1,5 @@
import com.android.build.api.variant.BuildConfigField
plugins {
id("com.android.library")
kotlin("android")
@ -51,6 +53,20 @@ android {
}
}
androidComponents {
onVariants { variant ->
// Configure SecureScreen for protecting screens with sensitive data in runtime
variant.buildConfigFields.put(
"IS_SECURE_SCREEN_ENABLED",
BuildConfigField(
type = "boolean",
value = project.property("IS_SECURE_SCREEN_PROTECTION_ACTIVE").toString(),
comment = null
)
)
}
}
dependencies {
implementation(libs.accompanist.permissions)
implementation(libs.androidx.activity)

View File

@ -16,7 +16,6 @@ class VersionInfoTest {
// We expect some VersionInfo object parameters to be empty during the testing
// isDebuggable is not tested as it's not static during UI testing in CI or locally
assertEquals("null", versionInfo.versionName)
assertEquals(0, versionInfo.versionCode)
assertNotEquals(versionInfo.gitSha, "")

View File

@ -43,6 +43,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import cash.z.ecc.android.sdk.model.PersistableWallet
import cash.z.ecc.sdk.fixture.PersistableWalletFixture
import co.electriccoin.zcash.spackle.model.Index
import co.electriccoin.zcash.ui.BuildConfig
import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.common.SecureScreen
import co.electriccoin.zcash.ui.design.MINIMAL_WEIGHT
@ -202,7 +203,9 @@ private fun EducationRecoveryPhrase() {
@Composable
private fun SeedPhrase(persistableWallet: PersistableWallet) {
SecureScreen()
if (BuildConfig.IS_SECURE_SCREEN_ENABLED) {
SecureScreen()
}
Column(
Modifier
.verticalScroll(rememberScrollState())
@ -225,14 +228,16 @@ private data class TestChoice(val originalIndex: Index, val word: String)
*/
@Composable
@Suppress("LongMethod")
private fun TestInProgress(
splitSeedPhrase: ImmutableList<String>,
selectedTestChoices: TestChoices,
onChoicesChanged: ((choicesCount: Int) -> Unit)?,
backupState: BackupState
) {
SecureScreen()
if (BuildConfig.IS_SECURE_SCREEN_ENABLED) {
SecureScreen()
}
val testChoices = splitSeedPhrase
.mapIndexed { index, word -> TestChoice(Index(index), word) }
.filter { testIndices.contains(it.originalIndex) }

View File

@ -32,6 +32,7 @@ import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
import cash.z.ecc.android.sdk.model.PersistableWallet
import cash.z.ecc.sdk.fixture.PersistableWalletFixture
import co.electriccoin.zcash.ui.BuildConfig
import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.common.SecureScreen
import co.electriccoin.zcash.ui.design.component.Body
@ -111,7 +112,9 @@ private fun ShortNewWalletMainContent(
@Composable
private fun SeedPhrase(persistableWallet: PersistableWallet) {
SecureScreen()
if (BuildConfig.IS_SECURE_SCREEN_ENABLED) {
SecureScreen()
}
Column {
Body(stringResource(R.string.new_wallet_short_body))
ChipGrid(persistableWallet.seedPhrase.split.toPersistentList())

View File

@ -63,6 +63,7 @@ import cash.z.ecc.android.sdk.model.BlockHeight
import cash.z.ecc.android.sdk.model.ZcashNetwork
import cash.z.ecc.sdk.model.SeedPhraseValidation
import co.electriccoin.zcash.spackle.model.Index
import co.electriccoin.zcash.ui.BuildConfig
import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.common.SecureScreen
import co.electriccoin.zcash.ui.design.MINIMAL_WEIGHT
@ -201,7 +202,9 @@ fun RestoreWallet(
when (currentStage) {
RestoreStage.Seed -> {
SecureScreen()
if (BuildConfig.IS_SECURE_SCREEN_ENABLED) {
SecureScreen()
}
RestoreSeedMainContent(
userWordList = userWordList,

View File

@ -22,6 +22,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import cash.z.ecc.android.sdk.model.PersistableWallet
import cash.z.ecc.sdk.fixture.PersistableWalletFixture
import co.electriccoin.zcash.ui.BuildConfig
import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.common.SecureScreen
import co.electriccoin.zcash.ui.design.component.Body
@ -55,7 +56,9 @@ fun Seed(
onBack: () -> Unit,
onCopyToClipboard: () -> Unit
) {
SecureScreen()
if (BuildConfig.IS_SECURE_SCREEN_ENABLED) {
SecureScreen()
}
Scaffold(topBar = {
SeedTopAppBar(onBack = onBack)
}) { paddingValues ->