diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 61b371939b..b0138296a7 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -62,6 +62,7 @@ object Config { const val HANDLE_CALL_ASSERTED_IDENTITY_EVENTS = false const val LOW_PRIVACY_LOG_ENABLE = false + const val ENABLE_STRICT_MODE_LOGS = false /** * The analytics configuration to use for the Debug build type. diff --git a/vector/build.gradle b/vector/build.gradle index 4b1942069c..5910014a99 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -237,9 +237,6 @@ android { resValue "string", "app_name", "Element dbg" resValue "color", "launcher_background", "#0DBD8B" - // Set to true if you want to enable strict mode in debug - buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false" - signingConfig signingConfigs.debug if (project.hasProperty("coverage")) { @@ -251,9 +248,6 @@ android { resValue "string", "app_name", "Element" resValue "color", "launcher_background", "#0DBD8B" - buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false" - - // When updating this block, please also update the same block in the `nightly` buildType below postprocessing { removeUnusedCode true removeUnusedResources true diff --git a/vector/src/main/java/im/vector/app/VectorApplication.kt b/vector/src/main/java/im/vector/app/VectorApplication.kt index 8044ea96f7..9d362f9dc0 100644 --- a/vector/src/main/java/im/vector/app/VectorApplication.kt +++ b/vector/src/main/java/im/vector/app/VectorApplication.kt @@ -198,7 +198,7 @@ class VectorApplication : } private fun enableStrictModeIfNeeded() { - if (BuildConfig.ENABLE_STRICT_MODE_LOGS) { + if (buildMeta.enableStrictModeLogs) { StrictMode.setThreadPolicy( StrictMode.ThreadPolicy.Builder() .detectAll() diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index 2807fd9c5c..208fbb6d73 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -215,6 +215,12 @@ object VectorStaticModule { sdkInt = Build.VERSION.SDK_INT, applicationId = BuildConfig.APPLICATION_ID, lowPrivacyLoggingEnabled = Config.LOW_PRIVACY_LOG_ENABLE, + enableStrictModeLogs = Config.ENABLE_STRICT_MODE_LOGS, + versionName = BuildConfig.VERSION_NAME, + gitRevision = BuildConfig.GIT_REVISION, + gitRevisionDate = BuildConfig.GIT_REVISION_DATE, + gitBranchName = BuildConfig.GIT_BRANCH_NAME, + buildNumber = BuildConfig.BUILD_NUMBER, ) @Provides diff --git a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt index 8571eae9f2..dac4b8b9ed 100644 --- a/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt +++ b/vector/src/main/java/im/vector/app/core/resources/BuildMeta.kt @@ -21,4 +21,10 @@ data class BuildMeta( val sdkInt: Int, val applicationId: String, val lowPrivacyLoggingEnabled: Boolean, + val enableStrictModeLogs: Boolean, + val versionName: String, + val gitRevision: String, + val gitRevisionDate: String, + val gitBranchName: String, + val buildNumber: String, ) diff --git a/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt b/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt index 1cfabc1554..4e8df32d10 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginSplashFragment.kt @@ -62,9 +62,9 @@ class LoginSplashFragment @Inject constructor( if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") - views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" + - "Branch: ${BuildConfig.GIT_BRANCH_NAME}\n" + - "Build: ${BuildConfig.BUILD_NUMBER}" + views.loginSplashVersion.text = "Version : ${buildMeta.versionName}\n" + + "Branch: ${buildMeta.gitBranchName}\n" + + "Build: ${buildMeta.buildNumber}" views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) } } } diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt index 8bc9bed9e2..e967f981d5 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginSplashSignUpSignInSelectionFragment2.kt @@ -54,9 +54,9 @@ class LoginSplashSignUpSignInSelectionFragment2 @Inject constructor( if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") - views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" + - "Branch: ${BuildConfig.GIT_BRANCH_NAME}\n" + - "Build: ${BuildConfig.BUILD_NUMBER}" + views.loginSplashVersion.text = "Version : ${buildMeta.versionName}\n" + + "Branch: ${buildMeta.gitBranchName}\n" + + "Build: ${buildMeta.buildNumber}" views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) } } } diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt index 2d12a1be7c..fd128ae5be 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashCarouselFragment.kt @@ -81,8 +81,8 @@ class FtueAuthSplashCarouselFragment @Inject constructor( if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") - views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}#${BuildConfig.BUILD_NUMBER}\n" + - "Branch: ${BuildConfig.GIT_BRANCH_NAME}" + views.loginSplashVersion.text = "Version : ${buildMeta.versionName}#${buildMeta.buildNumber}\n" + + "Branch: ${buildMeta.gitBranchName}" views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) } } views.splashCarousel.registerAutomaticUntilInteractionTransitions() diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt index d4e5722896..8dc9bf7cea 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthSplashFragment.kt @@ -64,9 +64,9 @@ class FtueAuthSplashFragment @Inject constructor( if (buildMeta.isDebug || vectorPreferences.developerMode()) { views.loginSplashVersion.isVisible = true @SuppressLint("SetTextI18n") - views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" + - "Branch: ${BuildConfig.GIT_BRANCH_NAME}\n" + - "Build: ${BuildConfig.BUILD_NUMBER}" + views.loginSplashVersion.text = "Version : ${buildMeta.versionName}\n" + + "Branch: ${buildMeta.gitBranchName}\n" + + "Build: ${buildMeta.buildNumber}" views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) } } } diff --git a/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt b/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt index e2e5ee2c6e..a327395fd0 100755 --- a/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt +++ b/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt @@ -30,6 +30,7 @@ import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.extensions.getAllChildFragments import im.vector.app.core.extensions.toOnOff +import im.vector.app.core.resources.BuildMeta import im.vector.app.features.settings.VectorLocale import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.settings.devtools.GossipingEventsSerializer @@ -74,7 +75,8 @@ class BugReporter @Inject constructor( private val vectorPreferences: VectorPreferences, private val vectorFileLogger: VectorFileLogger, private val systemLocaleProvider: SystemLocaleProvider, - private val matrix: Matrix + private val matrix: Matrix, + private val buildMeta: BuildMeta, ) { var inMultiWindowMode = false @@ -278,14 +280,14 @@ class BugReporter @Inject constructor( .addFormDataPart("can_contact", canContact.toString()) .addFormDataPart("device_id", deviceId) .addFormDataPart("version", versionProvider.getVersion(longFormat = true, useBuildNumber = false)) - .addFormDataPart("branch_name", BuildConfig.GIT_BRANCH_NAME) + .addFormDataPart("branch_name", buildMeta.gitBranchName) .addFormDataPart("matrix_sdk_version", Matrix.getSdkVersion()) .addFormDataPart("olm_version", olmVersion) .addFormDataPart("device", Build.MODEL.trim()) .addFormDataPart("verbose_log", vectorPreferences.labAllowedExtendedLogging().toOnOff()) .addFormDataPart("multi_window", inMultiWindowMode.toOnOff()) .addFormDataPart( - "os", Build.VERSION.RELEASE + " (API " + Build.VERSION.SDK_INT + ") " + + "os", Build.VERSION.RELEASE + " (API " + buildMeta.sdkInt + ") " + Build.VERSION.INCREMENTAL + "-" + Build.VERSION.CODENAME ) .addFormDataPart("locale", Locale.getDefault().toString()) @@ -299,7 +301,7 @@ class BugReporter @Inject constructor( } } - val buildNumber = BuildConfig.BUILD_NUMBER + val buildNumber = buildMeta.buildNumber if (buildNumber.isNotEmpty() && buildNumber != "0") { builder.addFormDataPart("build_number", buildNumber) } @@ -339,9 +341,9 @@ class BugReporter @Inject constructor( screenshot = null // add some github labels - builder.addFormDataPart("label", BuildConfig.VERSION_NAME) + builder.addFormDataPart("label", buildMeta.versionName) builder.addFormDataPart("label", BuildConfig.FLAVOR_DESCRIPTION) - builder.addFormDataPart("label", BuildConfig.GIT_BRANCH_NAME) + builder.addFormDataPart("label", buildMeta.gitBranchName) // Special for Element builder.addFormDataPart("label", "[Element]") diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt index 977e2fbeba..f818d02e45 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt @@ -70,7 +70,7 @@ class VectorSettingsHelpAboutFragment @Inject constructor( append(versionProvider.getVersion(longFormat = false, useBuildNumber = true)) if (buildMeta.isDebug) { append(" ") - append(BuildConfig.GIT_BRANCH_NAME) + append(buildMeta.gitBranchName) } } diff --git a/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt b/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt index 96a7d917e5..c3d5532854 100644 --- a/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt +++ b/vector/src/main/java/im/vector/app/features/version/VersionProvider.kt @@ -17,10 +17,14 @@ package im.vector.app.features.version import im.vector.app.BuildConfig +import im.vector.app.core.resources.BuildMeta import im.vector.app.core.resources.VersionCodeProvider import javax.inject.Inject -class VersionProvider @Inject constructor(private val versionCodeProvider: VersionCodeProvider) { +class VersionProvider @Inject constructor( + private val versionCodeProvider: VersionCodeProvider, + private val buildMeta: BuildMeta, +) { fun getVersion(longFormat: Boolean, useBuildNumber: Boolean): String { var result = "${BuildConfig.VERSION_NAME} [${versionCodeProvider.getVersionCode()}]" @@ -31,9 +35,9 @@ class VersionProvider @Inject constructor(private val versionCodeProvider: Versi flavor += "-" } - var gitVersion = BuildConfig.GIT_REVISION - val gitRevisionDate = BuildConfig.GIT_REVISION_DATE - val buildNumber = BuildConfig.BUILD_NUMBER + var gitVersion = buildMeta.gitRevision + val gitRevisionDate = buildMeta.gitRevisionDate + val buildNumber = buildMeta.buildNumber var useLongFormat = longFormat diff --git a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt index 347b49400e..89ef96ecbc 100644 --- a/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt +++ b/vector/src/test/java/im/vector/app/test/fixtures/BuildMetaFixture.kt @@ -24,4 +24,10 @@ fun aBuildMeta() = BuildMeta( sdkInt = Build.VERSION_CODES.O, applicationId = "im.vector", lowPrivacyLoggingEnabled = false, + enableStrictModeLogs = false, + versionName = "app-version-name", + gitRevision = "abcdef", + gitRevisionDate = "01-01-01", + gitBranchName = "a-branch-name", + buildNumber = "100", )