From 7e74af33a6f9db896a4102a28c88d3ada53dc20a Mon Sep 17 00:00:00 2001 From: Joe Bergeron Date: Mon, 4 Nov 2024 09:25:58 -0500 Subject: [PATCH] refactor: Use mobilestack references in android builds (#6039) ### Description Makes the Android builds more brand agnostic. Replaces the existing keystore android keystore containing the upload key by: * Renaming the private key alias within the keystore from `celo-release-key` to `mobilestack-release-key` * Using the same password for both the store as well as the private key within ### Test plan ### Related issues - Fixes #[issue number here] ### Backwards compatibility ### Network scalability If a new NetworkId and/or Network are added in the future, the changes in this PR will: - [ ] Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added) --- .github/workflows/release-fastlane-android.yml | 10 ++++------ WALLET.md | 5 ++--- android/.project | 4 ++-- android/app/.project | 2 +- android/app/build.gradle | 14 +++++++------- ...e.enc => mobilestack-release-key.keystore.enc} | Bin android/app/proguard-rules.pro | 2 +- android/app/src/androidTest/AndroidManifest.xml | 4 ++-- .../mobile => xyz/mobilestack}/DetoxTest.java | 4 ++-- .../mobilestack}/ReactNativeFlipper.java | 2 +- .../mobilestack}/ReactNativeFlipper.java | 2 +- .../src/debug/res/xml/network_security_config.xml | 4 ++-- android/app/src/main/AndroidManifest.xml | 2 +- .../mobilestack}/FirebaseMessagingService.java | 2 +- .../mobile => xyz/mobilestack}/MainActivity.java | 2 +- .../mobilestack}/MainApplication.java | 2 +- .../mobilestack}/UserAgentClientFactory.java | 2 +- .../mobilestack}/UserAgentInterceptor.java | 2 +- android/app/src/main/res/values/colors.xml | 6 +++--- android/app/src/main/res/values/strings.xml | 2 +- android/app/src/main/res/xml/backup_rules.xml | 6 +++--- .../mobilestack}/ReactNativeFlipper.java | 2 +- android/gradle.properties | 6 ++++-- 23 files changed, 43 insertions(+), 44 deletions(-) rename android/app/{celo-release-key.keystore.enc => mobilestack-release-key.keystore.enc} (100%) rename android/app/src/androidTest/java/{org/celo/mobile => xyz/mobilestack}/DetoxTest.java (89%) rename android/app/src/androidTest/java/{org/celo/mobile => xyz/mobilestack}/ReactNativeFlipper.java (96%) rename android/app/src/debug/java/{org/celo/mobile => xyz/mobilestack}/ReactNativeFlipper.java (99%) rename android/app/src/main/java/{org/celo/mobile => xyz/mobilestack}/FirebaseMessagingService.java (98%) rename android/app/src/main/java/{org/celo/mobile => xyz/mobilestack}/MainActivity.java (99%) rename android/app/src/main/java/{org/celo/mobile => xyz/mobilestack}/MainApplication.java (99%) rename android/app/src/main/java/{org/celo/mobile => xyz/mobilestack}/UserAgentClientFactory.java (95%) rename android/app/src/main/java/{org/celo/mobile => xyz/mobilestack}/UserAgentInterceptor.java (97%) rename android/app/src/release/java/{org/celo/mobile => xyz/mobilestack}/ReactNativeFlipper.java (96%) diff --git a/.github/workflows/release-fastlane-android.yml b/.github/workflows/release-fastlane-android.yml index 0417c35daf5..31fe278b692 100644 --- a/.github/workflows/release-fastlane-android.yml +++ b/.github/workflows/release-fastlane-android.yml @@ -38,9 +38,8 @@ jobs: uses: google-github-actions/get-secretmanager-secrets@v2 with: secrets: |- - ANDROID_RELEASE_KEYSTORE:projects/1027349420744/secrets/ANDROID_RELEASE_KEYSTORE - CELO_RELEASE_KEY_PASSWORD:projects/1027349420744/secrets/CELO_RELEASE_KEY_PASSWORD - CELO_RELEASE_STORE_PASSWORD:projects/1027349420744/secrets/CELO_RELEASE_STORE_PASSWORD + ANDROID_RELEASE_KEYSTORE:projects/1027349420744/secrets/VALORA_RELEASE_KEYSTORE_V2 + RELEASE_STORE_PASSWORD:projects/1027349420744/secrets/VALORA_RELEASE_STORE_PASSWORD SLACK_WEBHOOK_URL:projects/1027349420744/secrets/SLACK_WEBHOOK_URL BOT_SSH_KEY:projects/1027349420744/secrets/BOT_SSH_PRIVATE_KEY GOOGLE_PLAY_SERVICE_ACCOUNT_KEY_JSON:projects/1027349420744/secrets/GOOGLE_PLAY_SERVICE_ACCOUNT_KEY_JSON @@ -95,11 +94,10 @@ jobs: # TODO: use ram disk - name: Write secrets run: | - echo '${{ steps.google-secrets.outputs.ANDROID_RELEASE_KEYSTORE }}' | base64 -d > android/app/celo-release-key.keystore + echo '${{ steps.google-secrets.outputs.ANDROID_RELEASE_KEYSTORE }}' | base64 -d > android/app/release-key.keystore echo '${{ steps.google-secrets.outputs.GOOGLE_PLAY_SERVICE_ACCOUNT_KEY_JSON }}' > fastlane/google-play-service-account.json - env: - CELO_RELEASE_STORE_PASSWORD: ${{ steps.google-secrets.outputs.CELO_RELEASE_STORE_PASSWORD }} - CELO_RELEASE_KEY_PASSWORD: ${{ steps.google-secrets.outputs.CELO_RELEASE_KEY_PASSWORD }} + RELEASE_STORE_PASSWORD: ${{ steps.google-secrets.outputs.RELEASE_STORE_PASSWORD }} EMERGE_API_TOKEN: ${{ steps.google-secrets.outputs.EMERGE_API_TOKEN }} SUPPLY_UPLOAD_MAX_RETRIES: 5 RUBYOPT: '-rostruct' # TODO: Remove when https://github.com/fastlane/fastlane/pull/21950 gets released diff --git a/WALLET.md b/WALLET.md index 37e17b76060..eee02cc260b 100644 --- a/WALLET.md +++ b/WALLET.md @@ -442,9 +442,8 @@ If you have not yet created a keystore, one will be required to generate a relea ```sh cd android/app -keytool -genkey -v -keystore celo-release-key.keystore -alias celo-key-alias -storepass celoFakeReleaseStorePass -keypass celoFakeReleaseKeyPass -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US" -export CELO_RELEASE_STORE_PASSWORD=celoFakeReleaseStorePass -export CELO_RELEASE_KEY_PASSWORD=celoFakeReleaseKeyPass +keytool -genkey -v -keystore mobilestack-release-key.keystore -alias mobilestack-key-alias -storepass fakeReleaseStorePass -keypass fakeReleaseStorePass -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US" +export RELEASE_STORE_PASSWORD=fakeReleaseStorePass ``` ### Building an APK or Bundle diff --git a/android/.project b/android/.project index 3af26a51ee8..69be161d33b 100644 --- a/android/.project +++ b/android/.project @@ -1,7 +1,7 @@ - celo - Project celo created by Buildship. + mobilestack + Project mobilestack created by Buildship. diff --git a/android/app/.project b/android/app/.project index ac485d7c3e6..507ffc2152b 100644 --- a/android/app/.project +++ b/android/app/.project @@ -1,7 +1,7 @@ app - Project app created by Buildship. + Project mobilestack created by Buildship. diff --git a/android/app/build.gradle b/android/app/build.gradle index 162dbe898c3..256bec045b1 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -138,7 +138,7 @@ def secrets = loadProjectSecrets(project.env.get("DEFAULT_TESTNET")) android { compileSdkVersion rootProject.ext.compileSdkVersion - namespace "org.celo.mobile" + namespace "xyz.mobilestack" compileOptions { sourceCompatibility JavaVersion.VERSION_11 @@ -155,8 +155,8 @@ android { testBuildType System.getProperty('testBuildType', 'debug') testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" resValue "string", "app_name", project.env.get("APP_DISPLAY_NAME") - resValue "string", "build_config_package", "org.celo.mobile" resValue "string", "deep_link_url_scheme", project.env.get("DEEP_LINK_URL_SCHEME") + resValue "string", "build_config_package", "xyz.mobilestack" missingDimensionStrategy 'react-native-camera', 'general' vectorDrawables.useSupportLibrary = true resValue "bool", "is_profiling_build", System.getenv("IS_PROFILING_BUILD") ?: "false" @@ -178,11 +178,11 @@ android { storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' - } else if (project.hasProperty('CELO_RELEASE_STORE_FILE')) { - storeFile file(CELO_RELEASE_STORE_FILE) - storePassword System.getenv("CELO_RELEASE_STORE_PASSWORD") - keyAlias CELO_RELEASE_KEY_ALIAS - keyPassword System.getenv("CELO_RELEASE_KEY_PASSWORD") + } else if (project.hasProperty('RELEASE_STORE_FILE')) { + storeFile file(RELEASE_STORE_FILE) + storePassword System.getenv("RELEASE_STORE_PASSWORD") + keyAlias RELEASE_KEY_ALIAS + keyPassword System.getenv("RELEASE_STORE_PASSWORD") } } diff --git a/android/app/celo-release-key.keystore.enc b/android/app/mobilestack-release-key.keystore.enc similarity index 100% rename from android/app/celo-release-key.keystore.enc rename to android/app/mobilestack-release-key.keystore.enc diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index c9e4a45cec6..00f0266d33c 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -20,7 +20,7 @@ -keep class com.segment.analytics.** { *; } -keep class androidx.lifecycle.DefaultLifecycleObserver --keep class org.celo.mobile.BuildConfig { *; } +-keep class xyz.mobilestack.BuildConfig { *; } -keep public class com.horcrux.svg.** {*;} -keep class com.rt2zz.reactnativecontacts.** {*;} -keepclassmembers class com.rt2zz.reactnativecontacts.** {*;} diff --git a/android/app/src/androidTest/AndroidManifest.xml b/android/app/src/androidTest/AndroidManifest.xml index 1a5040c9a0d..66900da2b73 100644 --- a/android/app/src/androidTest/AndroidManifest.xml +++ b/android/app/src/androidTest/AndroidManifest.xml @@ -1,4 +1,4 @@ + xmlns:tools="http://schemas.android.com/tools" package="xyz.mobilestack" android:versionCode="1" android:versionName="1.0"> - \ No newline at end of file + diff --git a/android/app/src/androidTest/java/org/celo/mobile/DetoxTest.java b/android/app/src/androidTest/java/xyz/mobilestack/DetoxTest.java similarity index 89% rename from android/app/src/androidTest/java/org/celo/mobile/DetoxTest.java rename to android/app/src/androidTest/java/xyz/mobilestack/DetoxTest.java index 7fdc2af3941..df3b60948a6 100644 --- a/android/app/src/androidTest/java/org/celo/mobile/DetoxTest.java +++ b/android/app/src/androidTest/java/xyz/mobilestack/DetoxTest.java @@ -1,4 +1,4 @@ -package org.celo.mobile; +package xyz.mobilestack; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; @@ -25,7 +25,7 @@ public void runDetoxTests() { DetoxConfig detoxConfig = new DetoxConfig(); detoxConfig.idlePolicyConfig.masterTimeoutSec = 90; detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60; - detoxConfig.rnContextLoadTimeoutSec = (org.celo.mobile.BuildConfig.DEBUG ? 180 : 60); + detoxConfig.rnContextLoadTimeoutSec = (xyz.mobilestack.BuildConfig.DEBUG ? 180 : 60); Detox.runTests(mActivityRule, detoxConfig); } diff --git a/android/app/src/androidTest/java/org/celo/mobile/ReactNativeFlipper.java b/android/app/src/androidTest/java/xyz/mobilestack/ReactNativeFlipper.java similarity index 96% rename from android/app/src/androidTest/java/org/celo/mobile/ReactNativeFlipper.java rename to android/app/src/androidTest/java/xyz/mobilestack/ReactNativeFlipper.java index 4c95da05ef1..ca6b0a7d1bc 100644 --- a/android/app/src/androidTest/java/org/celo/mobile/ReactNativeFlipper.java +++ b/android/app/src/androidTest/java/xyz/mobilestack/ReactNativeFlipper.java @@ -4,7 +4,7 @@ *

This source code is licensed under the MIT license found in the LICENSE file in the root * directory of this source tree. */ -package org.celo.mobile; +package xyz.mobilestack; import android.content.Context; import com.facebook.react.ReactInstanceManager; diff --git a/android/app/src/debug/java/org/celo/mobile/ReactNativeFlipper.java b/android/app/src/debug/java/xyz/mobilestack/ReactNativeFlipper.java similarity index 99% rename from android/app/src/debug/java/org/celo/mobile/ReactNativeFlipper.java rename to android/app/src/debug/java/xyz/mobilestack/ReactNativeFlipper.java index 0c9e3045a54..e06125ac8e3 100644 --- a/android/app/src/debug/java/org/celo/mobile/ReactNativeFlipper.java +++ b/android/app/src/debug/java/xyz/mobilestack/ReactNativeFlipper.java @@ -4,7 +4,7 @@ *

This source code is licensed under the MIT license found in the LICENSE file in the root * directory of this source tree. */ -package org.celo.mobile; +package xyz.mobilestack; import android.content.Context; import com.facebook.flipper.android.AndroidFlipperClient; diff --git a/android/app/src/debug/res/xml/network_security_config.xml b/android/app/src/debug/res/xml/network_security_config.xml index f942d9e6b96..a7100348a2d 100644 --- a/android/app/src/debug/res/xml/network_security_config.xml +++ b/android/app/src/debug/res/xml/network_security_config.xml @@ -3,7 +3,7 @@ localhost - + sslip.io 10.0.1.1 10.0.2.2 @@ -15,4 +15,4 @@ - \ No newline at end of file + diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 608df541fcc..381db2471a6 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -46,7 +46,7 @@ - + diff --git a/android/app/src/main/java/org/celo/mobile/FirebaseMessagingService.java b/android/app/src/main/java/xyz/mobilestack/FirebaseMessagingService.java similarity index 98% rename from android/app/src/main/java/org/celo/mobile/FirebaseMessagingService.java rename to android/app/src/main/java/xyz/mobilestack/FirebaseMessagingService.java index 38532535f6c..7dc9e445454 100644 --- a/android/app/src/main/java/org/celo/mobile/FirebaseMessagingService.java +++ b/android/app/src/main/java/xyz/mobilestack/FirebaseMessagingService.java @@ -1,4 +1,4 @@ -package org.celo.mobile; +package xyz.mobilestack; import android.os.Bundle; import android.util.Log; diff --git a/android/app/src/main/java/org/celo/mobile/MainActivity.java b/android/app/src/main/java/xyz/mobilestack/MainActivity.java similarity index 99% rename from android/app/src/main/java/org/celo/mobile/MainActivity.java rename to android/app/src/main/java/xyz/mobilestack/MainActivity.java index 54c8d7b2dbc..4de9b4ba3a8 100644 --- a/android/app/src/main/java/org/celo/mobile/MainActivity.java +++ b/android/app/src/main/java/xyz/mobilestack/MainActivity.java @@ -1,4 +1,4 @@ -package org.celo.mobile; +package xyz.mobilestack; import android.content.Intent; import android.graphics.Color; diff --git a/android/app/src/main/java/org/celo/mobile/MainApplication.java b/android/app/src/main/java/xyz/mobilestack/MainApplication.java similarity index 99% rename from android/app/src/main/java/org/celo/mobile/MainApplication.java rename to android/app/src/main/java/xyz/mobilestack/MainApplication.java index b1b32e9e285..630de12118d 100644 --- a/android/app/src/main/java/org/celo/mobile/MainApplication.java +++ b/android/app/src/main/java/xyz/mobilestack/MainApplication.java @@ -1,4 +1,4 @@ -package org.celo.mobile; +package xyz.mobilestack; import android.util.Log; import androidx.multidex.MultiDexApplication; diff --git a/android/app/src/main/java/org/celo/mobile/UserAgentClientFactory.java b/android/app/src/main/java/xyz/mobilestack/UserAgentClientFactory.java similarity index 95% rename from android/app/src/main/java/org/celo/mobile/UserAgentClientFactory.java rename to android/app/src/main/java/xyz/mobilestack/UserAgentClientFactory.java index aa88bf81af3..8747e15b598 100644 --- a/android/app/src/main/java/org/celo/mobile/UserAgentClientFactory.java +++ b/android/app/src/main/java/xyz/mobilestack/UserAgentClientFactory.java @@ -1,4 +1,4 @@ -package org.celo.mobile; +package xyz.mobilestack; import android.content.Context; import com.facebook.react.modules.network.OkHttpClientFactory; diff --git a/android/app/src/main/java/org/celo/mobile/UserAgentInterceptor.java b/android/app/src/main/java/xyz/mobilestack/UserAgentInterceptor.java similarity index 97% rename from android/app/src/main/java/org/celo/mobile/UserAgentInterceptor.java rename to android/app/src/main/java/xyz/mobilestack/UserAgentInterceptor.java index 0b577ea34d8..241059e8058 100644 --- a/android/app/src/main/java/org/celo/mobile/UserAgentInterceptor.java +++ b/android/app/src/main/java/xyz/mobilestack/UserAgentInterceptor.java @@ -1,4 +1,4 @@ -package org.celo.mobile; +package xyz.mobilestack; import android.os.Build; import java.io.IOException; diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml index 51011521436..36d51ee6248 100644 --- a/android/app/src/main/res/values/colors.xml +++ b/android/app/src/main/res/values/colors.xml @@ -1,6 +1,6 @@ - #45CD85 - #42D689 + #45CD85 + #42D689 #000000 - \ No newline at end of file + diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 12c78f6d5c4..c77469e7063 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -1,6 +1,6 @@ - Valora would like to verify your identity + This app would like to verify your identity Please have a government issued ID ready to continue. Begin Verification diff --git a/android/app/src/main/res/xml/backup_rules.xml b/android/app/src/main/res/xml/backup_rules.xml index 6a4e245380c..6dc446aabf9 100644 --- a/android/app/src/main/res/xml/backup_rules.xml +++ b/android/app/src/main/res/xml/backup_rules.xml @@ -1,6 +1,6 @@ - - - \ No newline at end of file + + + diff --git a/android/app/src/release/java/org/celo/mobile/ReactNativeFlipper.java b/android/app/src/release/java/xyz/mobilestack/ReactNativeFlipper.java similarity index 96% rename from android/app/src/release/java/org/celo/mobile/ReactNativeFlipper.java rename to android/app/src/release/java/xyz/mobilestack/ReactNativeFlipper.java index 4c95da05ef1..ca6b0a7d1bc 100644 --- a/android/app/src/release/java/org/celo/mobile/ReactNativeFlipper.java +++ b/android/app/src/release/java/xyz/mobilestack/ReactNativeFlipper.java @@ -4,7 +4,7 @@ *

This source code is licensed under the MIT license found in the LICENSE file in the root * directory of this source tree. */ -package org.celo.mobile; +package xyz.mobilestack; import android.content.Context; import com.facebook.react.ReactInstanceManager; diff --git a/android/gradle.properties b/android/gradle.properties index c97efa9614a..97080ac39f6 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -18,8 +18,10 @@ org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects org.gradle.parallel=true -CELO_RELEASE_STORE_FILE=celo-release-key.keystore -CELO_RELEASE_KEY_ALIAS=celo-key-alias +# Note that the key alias lacks Mobile Stack naming, since updating this would +# require regenerating the keystore. +RELEASE_STORE_FILE=release-key.keystore +RELEASE_KEY_ALIAS=mobilestack-key-alias # Setting this manually based on version number until we have this deploying via Cloud Build # Example: v1.5.1 deployment number 1 = 1005001001 (1 005 001 001)