From d6f91aaae1b303be065f1202e8f8fabc91b00e81 Mon Sep 17 00:00:00 2001 From: Giorgos Papadopoulos Date: Fri, 24 Sep 2021 11:44:28 +0300 Subject: [PATCH 1/4] fix crash --- .../ctr/verifier/ui/scanner/ScanResultValidFragment.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/verifier/src/main/java/nl/rijksoverheid/ctr/verifier/ui/scanner/ScanResultValidFragment.kt b/verifier/src/main/java/nl/rijksoverheid/ctr/verifier/ui/scanner/ScanResultValidFragment.kt index a05ecc1db..0e4213819 100644 --- a/verifier/src/main/java/nl/rijksoverheid/ctr/verifier/ui/scanner/ScanResultValidFragment.kt +++ b/verifier/src/main/java/nl/rijksoverheid/ctr/verifier/ui/scanner/ScanResultValidFragment.kt @@ -50,7 +50,7 @@ class ScanResultValidFragment : Fragment(R.layout.fragment_scan_result_valid) { _binding = FragmentScanResultValidBinding.bind(view) binding.toolbar.setNavigationOnClickListener { - findNavController().navigate(ScanResultValidFragmentDirections.actionNavMain()) + navigateSafety(ScanResultValidFragmentDirections.actionNavMain()) } when (args.validData) { @@ -75,7 +75,7 @@ class ScanResultValidFragment : Fragment(R.layout.fragment_scan_result_valid) { } binding.personalDetails.buttonIncorrectData.setOnClickListener { - findNavController().navigate(ScanResultValidFragmentDirections.actionShowValidExplanation()) + navigateSafety(ScanResultValidFragmentDirections.actionShowValidExplanation()) } binding.personalDetails.bottom.setButtonClick { From e320be3e43dd70cb94521a2ff17112c01cdee0e2 Mon Sep 17 00:00:00 2001 From: Giorgos Papadopoulos Date: Mon, 27 Sep 2021 12:03:29 +0300 Subject: [PATCH 2/4] fix cameraselector crash --- .../rijksoverheid/ctr/qrscanner/QrCodeScannerFragment.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qrscanner/src/main/java/nl/rijksoverheid/ctr/qrscanner/QrCodeScannerFragment.kt b/qrscanner/src/main/java/nl/rijksoverheid/ctr/qrscanner/QrCodeScannerFragment.kt index 1957ba56e..c8c6e6a78 100644 --- a/qrscanner/src/main/java/nl/rijksoverheid/ctr/qrscanner/QrCodeScannerFragment.kt +++ b/qrscanner/src/main/java/nl/rijksoverheid/ctr/qrscanner/QrCodeScannerFragment.kt @@ -140,7 +140,7 @@ abstract class QrCodeScannerFragment : Fragment(R.layout.fragment_scanner) { } } - private fun setupCamera() { + private fun setupCamera(lensFacing: Int = CameraSelector.LENS_FACING_BACK) { // make sure it's still added when coming back from a dialog if (!isAdded) { return @@ -155,7 +155,7 @@ abstract class QrCodeScannerFragment : Fragment(R.layout.fragment_scanner) { // Select camera to use, back facing camera by default val cameraSelector = - CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build() + CameraSelector.Builder().requireLensFacing(lensFacing).build() // Request access to CameraX service. Will return a CameraProvider bound to the lifecycle of // our activity if one is available @@ -251,7 +251,7 @@ abstract class QrCodeScannerFragment : Fragment(R.layout.fragment_scanner) { throw illegalStateException } catch (illegalArgumentException: IllegalArgumentException) { Timber.e("Illegal argument, probably too many use cases linked to camera lifecycle, max is three: ${illegalArgumentException.message}") - throw illegalArgumentException + setupCamera(CameraSelector.LENS_FACING_FRONT) } } @@ -302,7 +302,7 @@ abstract class QrCodeScannerFragment : Fragment(R.layout.fragment_scanner) { throw illegalStateException } catch (illegalArgumentException: IllegalArgumentException) { Timber.e("Illegal argument, probably too many use cases linked to camera lifecycle, max is three: ${illegalArgumentException.message}") - throw illegalArgumentException + setupCamera(CameraSelector.LENS_FACING_FRONT) } } From f84e89abd71370833d5090939e62ffc5dff76f3e Mon Sep 17 00:00:00 2001 From: Giorgos Papadopoulos Date: Tue, 28 Sep 2021 14:52:45 +0300 Subject: [PATCH 3/4] update cdn urls and bump version --- .../ctr/appconfig/AppConfigModule.kt | 8 ++++--- verifier/build.gradle | 23 +++++++++++++++---- .../ctr/verifier/VerifierApplication.kt | 2 +- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/appconfig/src/main/java/nl/rijksoverheid/ctr/appconfig/AppConfigModule.kt b/appconfig/src/main/java/nl/rijksoverheid/ctr/appconfig/AppConfigModule.kt index eba7def4c..1a731b254 100644 --- a/appconfig/src/main/java/nl/rijksoverheid/ctr/appconfig/AppConfigModule.kt +++ b/appconfig/src/main/java/nl/rijksoverheid/ctr/appconfig/AppConfigModule.kt @@ -14,6 +14,8 @@ import nl.rijksoverheid.ctr.appconfig.persistence.* import nl.rijksoverheid.ctr.appconfig.repositories.ConfigRepository import nl.rijksoverheid.ctr.appconfig.repositories.ConfigRepositoryImpl import nl.rijksoverheid.ctr.appconfig.usecases.* +import okhttp3.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.OkHttpClient import org.koin.android.ext.koin.androidContext import org.koin.androidx.viewmodel.dsl.viewModel @@ -26,7 +28,7 @@ import retrofit2.Retrofit * @param path Path for the config api, for example "holder" to fetch the config from /holder/config * @param versionCode version code */ -fun appConfigModule(path: String, versionCode: Int) = module { +fun appConfigModule(cdnUrl: String, path: String, versionCode: Int) = module { factory { ConfigRepositoryImpl(get()) } factory { AppConfigUseCaseImpl(get(), get(), get(), get()) } factory { @@ -62,7 +64,7 @@ fun appConfigModule(path: String, versionCode: Int) = module { single { val okHttpClient = get(OkHttpClient::class).newBuilder().build() val retrofit = get(Retrofit::class) - val baseUrl = retrofit.baseUrl().newBuilder().addPathSegments("$path/").build() + val baseUrl = cdnUrl.toHttpUrl().newBuilder().addPathSegments("$path/").build() retrofit.newBuilder().baseUrl(baseUrl).client(okHttpClient).build() .create(AppConfigApi::class.java) } @@ -82,4 +84,4 @@ fun appConfigModule(path: String, versionCode: Int) = module { } fun isVerifierApp(applicationContext: Context): Boolean = - applicationContext.packageName.contains("verifier") + applicationContext.packageName.contains("verifier") \ No newline at end of file diff --git a/verifier/build.gradle b/verifier/build.gradle index 140a6ec80..1dc96984b 100644 --- a/verifier/build.gradle +++ b/verifier/build.gradle @@ -7,7 +7,7 @@ plugins { } def appVersionCode = System.getenv("GITHUB_RUN_NUMBER") != null ? System.getenv("GITHUB_RUN_NUMBER").toInteger() : 1000000 -version = "2.3.1" +version = "2.3.2" archivesBaseName = "verifier-v${version}-${appVersionCode}" android { @@ -32,7 +32,12 @@ android { buildConfigField "String", "SIGNATURE_CERTIFICATE_CN_MATCH", '".coronatester.nl"' buildConfigField "boolean", "FEATURE_CORONA_CHECK_API_CHECKS", "true" buildConfigField "boolean", "FEATURE_TEST_PROVIDER_API_CHECKS", "true" - buildConfigField "String", "BASE_API_URL", "\"https://verifier-api.coronacheck.nl/v4/\"" + buildConfigField "String", "BASE_API_URL", "\"https://verifier-api.coronacheck.nl/v5/\"" + buildConfigField "String[]", "CERTIFICATE_PINS", + "{" + + "\"sha256/lR7gRvqDMW5nhsCMRPE7TKLq0tJkTWMxQ5HAzHCIfQ0=\"" + + "}" + buildConfigField "String", "CDN_API_URL", "\"https://verifier-api-cdn.coronacheck.nl/v5/\"" } signingConfigs { @@ -59,9 +64,13 @@ android { versionNameSuffix "-test" applicationIdSuffix ".test" manifestPlaceholders = [appLabel: "@string/app_name_test"] - buildConfigField "String", "BASE_API_URL", "\"https://api-ct.bananenhalen.nl/v4/\"" + buildConfigField "String", "BASE_API_URL", "\"https://api-ct.bananenhalen.nl/v5/\"" buildConfigField "boolean", "FEATURE_CORONA_CHECK_API_CHECKS", "false" buildConfigField "boolean", "FEATURE_TEST_PROVIDER_API_CHECKS", "false" + buildConfigField "String[]", "CERTIFICATE_PINS", + "{" + + "\"sha256/C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M=\"" + + "}" apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' } @@ -70,7 +79,12 @@ android { versionNameSuffix "-acc" applicationIdSuffix ".acc" manifestPlaceholders = [appLabel: "@string/app_name_acc"] - buildConfigField "String", "BASE_API_URL", "\"https://verifier-api.acc.coronacheck.nl/v4/\"" + buildConfigField "String", "BASE_API_URL", "\"https://verifier-api.acc.coronacheck.nl/v5/\"" + buildConfigField "String[]", "CERTIFICATE_PINS", + "{" + + "\"sha256/lR7gRvqDMW5nhsCMRPE7TKLq0tJkTWMxQ5HAzHCIfQ0=\"" + + "}" + buildConfigField "String", "CDN_API_URL", "\"https://verifier-api-cdn.acc.coronacheck.nl/v5/\"" apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' } @@ -126,4 +140,3 @@ dependencies { debugImplementation "androidx.fragment:fragment-testing:$fragment_version" } - diff --git a/verifier/src/main/java/nl/rijksoverheid/ctr/verifier/VerifierApplication.kt b/verifier/src/main/java/nl/rijksoverheid/ctr/verifier/VerifierApplication.kt index 0f6024dc4..15a8e880c 100644 --- a/verifier/src/main/java/nl/rijksoverheid/ctr/verifier/VerifierApplication.kt +++ b/verifier/src/main/java/nl/rijksoverheid/ctr/verifier/VerifierApplication.kt @@ -42,7 +42,7 @@ open class VerifierApplication : SharedApplication() { verifierModule("verifier"), verifierIntroductionModule, sharedModule, - appConfigModule("verifier", BuildConfig.VERSION_CODE), + appConfigModule(BuildConfig.CDN_API_URL, "verifier", BuildConfig.VERSION_CODE), introductionModule, *getAdditionalModules().toTypedArray(), designModule, From c86d66b81de0152b0969a74429944f1a7fd264ec Mon Sep 17 00:00:00 2001 From: Giorgos Papadopoulos Date: Tue, 28 Sep 2021 15:28:04 +0300 Subject: [PATCH 4/4] fix conflicts --- holder/build.gradle | 2 ++ .../ctr/holder/HolderApplication.kt | 2 +- .../ctr/holder/CertificatePinTest.kt | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/holder/build.gradle b/holder/build.gradle index 2067b7a5c..e65b66ff5 100644 --- a/holder/build.gradle +++ b/holder/build.gradle @@ -40,6 +40,7 @@ android { "{" + "\"sha256/lR7gRvqDMW5nhsCMRPE7TKLq0tJkTWMxQ5HAzHCIfQ0=\"" + "}" + buildConfigField "String", "CDN_API_URL", "\"https://holder-api-cdn.coronacheck.nl/v5/\"" manifestPlaceholders = [appLabel: "@string/app_name", deepLinkHost: "coronacheck.nl", digidSchema: "coronacheck"] javaCompileOptions { @@ -96,6 +97,7 @@ android { "{" + "\"sha256/lR7gRvqDMW5nhsCMRPE7TKLq0tJkTWMxQ5HAzHCIfQ0=\"" + "}" + buildConfigField "String", "CDN_API_URL", "\"https://holder-api-cdn.acc.coronacheck.nl/v5/\"" dimension "environment" versionNameSuffix "-acc" applicationIdSuffix ".acc" diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/HolderApplication.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/HolderApplication.kt index d57e04cac..86409a503 100644 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/HolderApplication.kt +++ b/holder/src/main/java/nl/rijksoverheid/ctr/holder/HolderApplication.kt @@ -77,7 +77,7 @@ open class HolderApplication : SharedApplication(), Configuration.Provider { BuildConfig.CERTIFICATE_PINS, ), sharedModule, - appConfigModule("holder", BuildConfig.VERSION_CODE), + appConfigModule(BuildConfig.CDN_API_URL,"holder", BuildConfig.VERSION_CODE), introductionModule, *getAdditionalModules().toTypedArray(), designModule diff --git a/holder/src/test/java/nl/rijksoverheid/ctr/holder/CertificatePinTest.kt b/holder/src/test/java/nl/rijksoverheid/ctr/holder/CertificatePinTest.kt index f1bede9d7..a5f3388ac 100644 --- a/holder/src/test/java/nl/rijksoverheid/ctr/holder/CertificatePinTest.kt +++ b/holder/src/test/java/nl/rijksoverheid/ctr/holder/CertificatePinTest.kt @@ -3,10 +3,19 @@ package nl.rijksoverheid.ctr.holder import com.squareup.moshi.Moshi import kotlinx.coroutines.runBlocking import nl.rijksoverheid.ctr.api.json.JsonObjectJsonAdapter +import nl.rijksoverheid.ctr.appconfig.AppConfigViewModel +import nl.rijksoverheid.ctr.appconfig.AppConfigViewModelImpl import nl.rijksoverheid.ctr.appconfig.api.AppConfigApi +import nl.rijksoverheid.ctr.appconfig.appConfigModule +import nl.rijksoverheid.ctr.appconfig.isVerifierApp +import nl.rijksoverheid.ctr.appconfig.persistence.* +import nl.rijksoverheid.ctr.appconfig.repositories.ConfigRepository +import nl.rijksoverheid.ctr.appconfig.repositories.ConfigRepositoryImpl +import nl.rijksoverheid.ctr.appconfig.usecases.* import okhttp3.CertificatePinner import okhttp3.CertificatePinner.Companion.sha256Hash import okhttp3.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.OkHttpClient import okhttp3.mockwebserver.MockResponse import okhttp3.mockwebserver.MockWebServer @@ -15,7 +24,10 @@ import okhttp3.tls.HeldCertificate import org.junit.Assert.assertThrows import org.junit.Test import org.junit.runner.RunWith +import org.koin.android.ext.koin.androidContext +import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.core.context.loadKoinModules +import org.koin.core.context.unloadKoinModules import org.koin.dsl.module import org.koin.test.AutoCloseKoinTest import org.koin.test.get @@ -57,7 +69,8 @@ class CertificatePinTest: AutoCloseKoinTest() { setBody("{}") }) - loadKoinModules(apiModule(server.url("/"))) + unloadKoinModules(appConfigModule(BuildConfig.CDN_API_URL, "holder", BuildConfig.VERSION_CODE)) + loadKoinModules(listOf(apiModule(server.url("/")), appConfigModule(server.url("/").toString(), "holder", BuildConfig.VERSION_CODE))) val configApi: AppConfigApi = get() @@ -128,4 +141,4 @@ class CertificatePinTest: AutoCloseKoinTest() { .add(JsonObjectJsonAdapter()) } } -} \ No newline at end of file +}