From bc1499441fa960b35407aa7e4983b45bf12241dc Mon Sep 17 00:00:00 2001 From: kkmurerwa Date: Fri, 5 May 2023 12:43:37 +0300 Subject: [PATCH 1/9] feat: Add deprecation platform parameters and their dagger injection providers for both the app and testing --- .../PlatformParameterAlphaKenyaModule.kt | 57 ++++++++++++++- .../PlatformParameterModule.kt | 57 ++++++++++++++- .../TestPlatformParameterModule.kt | 58 ++++++++++++++- .../PlatformParameterConstants.kt | 71 +++++++++++++++++++ 4 files changed, 240 insertions(+), 3 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt index 87ef4a4f809..5d2ac1cd882 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt @@ -5,6 +5,7 @@ import dagger.Provides import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE import org.oppia.android.util.platformparameter.CacheLatexRendering +import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE @@ -14,6 +15,7 @@ import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEF import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation import org.oppia.android.util.platformparameter.EnableContinueButtonAnimation import org.oppia.android.util.platformparameter.EnableDownloadsSupport import org.oppia.android.util.platformparameter.EnableEditAccountsOptionsUi @@ -23,7 +25,16 @@ import org.oppia.android.util.platformparameter.EnableLanguageSelectionUi import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi +import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS +import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL +import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.LowestSupportedApiLevel +import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES @@ -189,4 +200,48 @@ class PlatformParameterAlphaKenyaModule { ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE ) } -} + + @Provides + @EnableAppAndOsDeprecation + fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { + return PlatformParameterValue.createDefaultParameter( + ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE + ) + } + + @Provides + @OptionalAppUpdateVersionCode + fun provideOptionalAppUpdateVersionCode( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getIntegerPlatformParameter( + OPTIONAL_APP_UPDATE_VERSION_CODE + ) ?: PlatformParameterValue.createDefaultParameter( + OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + ) + } + + @Provides + @ForcedAppUpdateVersionCode + fun provideForcedAppUpdateVersionCode( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getIntegerPlatformParameter( + FORCED_APP_UPDATE_VERSION_CODE + ) ?: PlatformParameterValue.createDefaultParameter( + FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + ) + } + + @Provides + @LowestSupportedApiLevel + fun provideLowestSupportedApiLevel( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getIntegerPlatformParameter( + LOWEST_SUPPORTED_API_LEVEL + ) ?: PlatformParameterValue.createDefaultParameter( + LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE + ) + } +} \ No newline at end of file diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index 161c27f8df9..1a40090483d 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -5,6 +5,7 @@ import dagger.Provides import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE import org.oppia.android.util.platformparameter.CacheLatexRendering +import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE @@ -14,6 +15,7 @@ import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEF import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_SPOTLIGHT_UI_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation import org.oppia.android.util.platformparameter.EnableContinueButtonAnimation import org.oppia.android.util.platformparameter.EnableDownloadsSupport import org.oppia.android.util.platformparameter.EnableEditAccountsOptionsUi @@ -23,8 +25,17 @@ import org.oppia.android.util.platformparameter.EnableLanguageSelectionUi import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi +import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL +import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.LowestSupportedApiLevel +import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES @@ -185,4 +196,48 @@ class PlatformParameterModule { ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE ) } -} + + @Provides + @EnableAppAndOsDeprecation + fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { + return PlatformParameterValue.createDefaultParameter( + ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE + ) + } + + @Provides + @OptionalAppUpdateVersionCode + fun provideOptionalAppUpdateVersionCode( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getIntegerPlatformParameter( + OPTIONAL_APP_UPDATE_VERSION_CODE + ) ?: PlatformParameterValue.createDefaultParameter( + OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + ) + } + + @Provides + @ForcedAppUpdateVersionCode + fun provideForcedAppUpdateVersionCode( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getIntegerPlatformParameter( + FORCED_APP_UPDATE_VERSION_CODE + ) ?: PlatformParameterValue.createDefaultParameter( + FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + ) + } + + @Provides + @LowestSupportedApiLevel + fun provideLowestSupportedApiLevel( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getIntegerPlatformParameter( + LOWEST_SUPPORTED_API_LEVEL + ) ?: PlatformParameterValue.createDefaultParameter( + LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE + ) + } +} \ No newline at end of file diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index 3909d19c7dd..2f6881c5c7e 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -41,6 +41,17 @@ import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HO import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours import javax.inject.Singleton +import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation +import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode +import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL +import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.LowestSupportedApiLevel +import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode /* Fake Platform Parameter Module that provides individual Platform Parameters for testing. */ @Module @@ -193,6 +204,50 @@ class TestPlatformParameterModule { ) } + @Provides + @EnableAppAndOsDeprecation + fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { + return PlatformParameterValue.createDefaultParameter( + enableAppAndOsDeprecation + ) + } + + @Provides + @OptionalAppUpdateVersionCode + fun provideOptionalAppUpdateVersionCode( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getIntegerPlatformParameter( + OPTIONAL_APP_UPDATE_VERSION_CODE + ) ?: PlatformParameterValue.createDefaultParameter( + OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + ) + } + + @Provides + @ForcedAppUpdateVersionCode + fun provideForcedAppUpdateVersionCode( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getIntegerPlatformParameter( + FORCED_APP_UPDATE_VERSION_CODE + ) ?: PlatformParameterValue.createDefaultParameter( + FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + ) + } + + @Provides + @LowestSupportedApiLevel + fun provideLowestSupportedApiLevel( + platformParameterSingleton: PlatformParameterSingleton + ): PlatformParameterValue { + return platformParameterSingleton.getIntegerPlatformParameter( + LOWEST_SUPPORTED_API_LEVEL + ) ?: PlatformParameterValue.createDefaultParameter( + LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE + ) + } + companion object { private var enableDownloadsSupport = ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE private var enableLanguageSelectionUi = ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE @@ -204,6 +259,7 @@ class TestPlatformParameterModule { private var enablePerformanceMetricsCollection = ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE private var enableSpotlightUi = true + private var enableAppAndOsDeprecation = ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE /** Enables forcing [EnableLanguageSelectionUi] platform parameter flag from tests. */ @VisibleForTesting(otherwise = VisibleForTesting.NONE) @@ -272,4 +328,4 @@ class TestPlatformParameterModule { enablePerformanceMetricsCollection = ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE } } -} +} \ No newline at end of file diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt index 1d04df9960e..ab2764330d4 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt @@ -231,3 +231,74 @@ annotation class EnableInteractionConfigChangeStateRetention * Default value for feature flag corresponding to [EnableInteractionConfigChangeStateRetention]. */ const val ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE = false + +/** + * Qualifier for the [EnableAppAndOsDeprecation] platform parameter that controls whether to enable + * app and OS deprecation or not. + */ +@Qualifier +annotation class EnableAppAndOsDeprecation + +/** + * Default value for the feature flag corresponding to [EnableAppAndOsDeprecation]. + */ +const val ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE = false + +/** + * Qualifier for the [OptionalAppUpdateVersionCode] platform parameter that contains the version + * code for the latest optional app update. + */ +@Qualifier +annotation class OptionalAppUpdateVersionCode + +/** + * Name of the platform parameter that tracks an integer from the gating console that indicates + * the version code of the latest optional app update. + */ +const val OPTIONAL_APP_UPDATE_VERSION_CODE = "optional_app_update_version_code" + +/** + * Default value for the feature flag corresponding to [OptionalAppUpdateVersionCode]. + */ +const val OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE = 1 + +/** + * Qualifier for the [ForcedAppUpdateVersionCode] platform parameter that contains the version + * code for the latest forced app update. + */ +@Qualifier +annotation class ForcedAppUpdateVersionCode + +/** + * Name of the platform parameter that tracks an integer from the gating console that indicates + * the version code of the latest forced app update. + */ +const val FORCED_APP_UPDATE_VERSION_CODE = "forced_app_update_version_code" + +/** + * Default value for the feature flag corresponding to [ForcedAppUpdateVersionCode]. The default + * value is intentionally set as 0 which is lower than the default value for the + * [OptionalAppUpdateVersionCode] that is 1. This is so that the app will not be forced to update + * unless the value is explicitly set in the gating console. + */ +const val FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE = 0 + +/** + * Qualifier for the [LowestSupportedApiLevel] platform parameter that contains an integer that + * represents the lowest supported API Level. + */ +@Qualifier +annotation class LowestSupportedApiLevel + +/** + * Name of the platform parameter that tracks an integer from the gating console that indicates + * the lowest supported API Level. + */ +const val LOWEST_SUPPORTED_API_LEVEL = "lowest_supported_api_level" + +/** + * Default value for the feature flag corresponding to [LowestSupportedApiLevel]. Currently, + * according to the app-level build.gradle file, the lowest supported API Level is 19. This is set + * as the default value for this feature flag. + */ +const val LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE = 19 \ No newline at end of file From f98ade90ced730a887f9531c82b103bd961aa2b8 Mon Sep 17 00:00:00 2001 From: kkmurerwa Date: Fri, 5 May 2023 12:45:08 +0300 Subject: [PATCH 2/9] feat: Add deprecation platform parameters and their dagger injection providers for both app and testing --- .../platformparameter/PlatformParameterAlphaKenyaModule.kt | 2 +- .../android/domain/platformparameter/PlatformParameterModule.kt | 2 +- .../testing/platformparameter/TestPlatformParameterModule.kt | 2 +- .../util/platformparameter/PlatformParameterConstants.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt index 5d2ac1cd882..5fbd934cbd1 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt @@ -244,4 +244,4 @@ class PlatformParameterAlphaKenyaModule { LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE ) } -} \ No newline at end of file +} diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index 1a40090483d..4005dfacf0d 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -240,4 +240,4 @@ class PlatformParameterModule { LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE ) } -} \ No newline at end of file +} diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index 2f6881c5c7e..f9518e3d993 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -328,4 +328,4 @@ class TestPlatformParameterModule { enablePerformanceMetricsCollection = ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE } } -} \ No newline at end of file +} diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt index ab2764330d4..c75c5010110 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt @@ -301,4 +301,4 @@ const val LOWEST_SUPPORTED_API_LEVEL = "lowest_supported_api_level" * according to the app-level build.gradle file, the lowest supported API Level is 19. This is set * as the default value for this feature flag. */ -const val LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE = 19 \ No newline at end of file +const val LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE = 19 From 1375a1aec89bc3a012e9266b89bfcf891f6a293b Mon Sep 17 00:00:00 2001 From: kkmurerwa Date: Fri, 5 May 2023 12:48:36 +0300 Subject: [PATCH 3/9] fix: Fix linting issues --- .../TestPlatformParameterModule.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index f9518e3d993..7d766068165 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -6,6 +6,7 @@ import dagger.Provides import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE import org.oppia.android.util.platformparameter.CacheLatexRendering +import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_CONTINUE_BUTTON_ANIMATION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_DOWNLOADS_SUPPORT_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_EDIT_ACCOUNTS_OPTIONS_UI_DEFAULT_VALUE @@ -13,6 +14,7 @@ import org.oppia.android.util.platformparameter.ENABLE_EXTRA_TOPIC_TABS_UI_DEFAU import org.oppia.android.util.platformparameter.ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_LANGUAGE_SELECTION_UI_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation import org.oppia.android.util.platformparameter.EnableContinueButtonAnimation import org.oppia.android.util.platformparameter.EnableDownloadsSupport import org.oppia.android.util.platformparameter.EnableEditAccountsOptionsUi @@ -22,7 +24,16 @@ import org.oppia.android.util.platformparameter.EnableLanguageSelectionUi import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi +import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL +import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.LowestSupportedApiLevel +import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE +import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE +import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_LOW_FREQUENCY_TIME_INTERVAL_IN_MINUTES @@ -41,17 +52,6 @@ import org.oppia.android.util.platformparameter.SYNC_UP_WORKER_TIME_PERIOD_IN_HO import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg import org.oppia.android.util.platformparameter.SyncUpWorkerTimePeriodHours import javax.inject.Singleton -import org.oppia.android.util.platformparameter.ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation -import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode -import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL -import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.LowestSupportedApiLevel -import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE -import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode /* Fake Platform Parameter Module that provides individual Platform Parameters for testing. */ @Module From 162560df441d7a6c04e7afc5d602022b97f396eb Mon Sep 17 00:00:00 2001 From: kkmurerwa Date: Tue, 9 May 2023 17:45:39 +0300 Subject: [PATCH 4/9] chore: Update the comments on the new platform parameters and feature flag to improve readability --- .../TestPlatformParameterModule.kt | 1 + .../PlatformParameterConstants.kt | 34 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index 7d766068165..307aa8b3d06 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -326,6 +326,7 @@ class TestPlatformParameterModule { enableInteractionConfigChangeStateRetention = ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE enablePerformanceMetricsCollection = ENABLE_PERFORMANCE_METRICS_COLLECTION_DEFAULT_VALUE + enableAppAndOsDeprecation = ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE } } } diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt index c75c5010110..b721fd3ef73 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt @@ -233,7 +233,7 @@ annotation class EnableInteractionConfigChangeStateRetention const val ENABLE_INTERACTION_CONFIG_CHANGE_STATE_RETENTION_DEFAULT_VALUE = false /** - * Qualifier for the [EnableAppAndOsDeprecation] platform parameter that controls whether to enable + * Qualifier for the [EnableAppAndOsDeprecation] feature flag that controls whether to enable * app and OS deprecation or not. */ @Qualifier @@ -245,59 +245,61 @@ annotation class EnableAppAndOsDeprecation const val ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE = false /** - * Qualifier for the [OptionalAppUpdateVersionCode] platform parameter that contains the version - * code for the latest optional app update. + * Qualifier for the platform parameter that contains the version code of the latest available + * optional app update, which is used to notify the app that a soft update is available. */ @Qualifier annotation class OptionalAppUpdateVersionCode /** - * Name of the platform parameter that tracks an integer from the gating console that indicates - * the version code of the latest optional app update. + * Name of the platform parameter that contains the integer version code of the latest available + * optional app update. */ const val OPTIONAL_APP_UPDATE_VERSION_CODE = "optional_app_update_version_code" /** - * Default value for the feature flag corresponding to [OptionalAppUpdateVersionCode]. + * Default value for the platform parameter corresponding to [OptionalAppUpdateVersionCode]. The + * default value is set as 1 which is the version code for the current app version. This will + * prevent an optional update being presented incorrectly. */ const val OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE = 1 /** - * Qualifier for the [ForcedAppUpdateVersionCode] platform parameter that contains the version - * code for the latest forced app update. + * Qualifier for the platform parameter that contains the version code of the latest available + * forced app update, which is used to notify the app that a mandatory update is available. */ @Qualifier annotation class ForcedAppUpdateVersionCode /** - * Name of the platform parameter that tracks an integer from the gating console that indicates - * the version code of the latest forced app update. + * Name of the platform parameter that contains the integer version code of the latest available + * forced app update. */ const val FORCED_APP_UPDATE_VERSION_CODE = "forced_app_update_version_code" /** - * Default value for the feature flag corresponding to [ForcedAppUpdateVersionCode]. The default - * value is intentionally set as 0 which is lower than the default value for the + * Default value for the platform parameter corresponding to [ForcedAppUpdateVersionCode]. The + * default value is intentionally set to 0 which is lower than the default value for the * [OptionalAppUpdateVersionCode] that is 1. This is so that the app will not be forced to update * unless the value is explicitly set in the gating console. */ const val FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE = 0 /** - * Qualifier for the [LowestSupportedApiLevel] platform parameter that contains an integer that - * represents the lowest supported API Level. + * Qualifier for the platform parameter that contains an integer from the gating console that + * indicates the lowest supported API Level. */ @Qualifier annotation class LowestSupportedApiLevel /** - * Name of the platform parameter that tracks an integer from the gating console that indicates + * Name of the platform parameter that contains an integer from the gating console that indicates * the lowest supported API Level. */ const val LOWEST_SUPPORTED_API_LEVEL = "lowest_supported_api_level" /** - * Default value for the feature flag corresponding to [LowestSupportedApiLevel]. Currently, + * Default value for the platform parameter corresponding to [LowestSupportedApiLevel]. Currently, * according to the app-level build.gradle file, the lowest supported API Level is 19. This is set * as the default value for this feature flag. */ From c536da73acdb430e6e458887aebd1d49ba357def Mon Sep 17 00:00:00 2001 From: kkmurerwa Date: Wed, 10 May 2023 12:11:38 +0300 Subject: [PATCH 5/9] chore: Improve comments on platform parameters to make them more readable and easier to understand --- .../PlatformParameterConstants.kt | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt index b721fd3ef73..90d5d4773a3 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt @@ -258,9 +258,8 @@ annotation class OptionalAppUpdateVersionCode const val OPTIONAL_APP_UPDATE_VERSION_CODE = "optional_app_update_version_code" /** - * Default value for the platform parameter corresponding to [OptionalAppUpdateVersionCode]. The - * default value is set as 1 which is the version code for the current app version. This will - * prevent an optional update being presented incorrectly. + * Default value for the platform parameter that contains the integer version code of the latest + * available optional app update. */ const val OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE = 1 @@ -278,29 +277,28 @@ annotation class ForcedAppUpdateVersionCode const val FORCED_APP_UPDATE_VERSION_CODE = "forced_app_update_version_code" /** - * Default value for the platform parameter corresponding to [ForcedAppUpdateVersionCode]. The - * default value is intentionally set to 0 which is lower than the default value for the - * [OptionalAppUpdateVersionCode] that is 1. This is so that the app will not be forced to update - * unless the value is explicitly set in the gating console. + * Default value for the platform parameter that contains the integer version code of the latest + * available forced app update. */ const val FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE = 0 /** - * Qualifier for the platform parameter that contains an integer from the gating console that - * indicates the lowest supported API Level. + * Qualifier for the platform parameter that contains an integer indicating the lowest supported + * Android API Level. */ @Qualifier annotation class LowestSupportedApiLevel /** - * Name of the platform parameter that contains an integer from the gating console that indicates - * the lowest supported API Level. + * Name of the platform parameter that contains an integer indicating the lowest supported Android + * API Level. */ const val LOWEST_SUPPORTED_API_LEVEL = "lowest_supported_api_level" /** - * Default value for the platform parameter corresponding to [LowestSupportedApiLevel]. Currently, - * according to the app-level build.gradle file, the lowest supported API Level is 19. This is set - * as the default value for this feature flag. + * Default value for the platform parameter that contains an integer indicating the lowest + * supported Android API Level. + * + * Th current minimum supported API level is 19 (KitKat). */ const val LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE = 19 From 4a46645d2b1508f32cad010bc22e1833f822610c Mon Sep 17 00:00:00 2001 From: kkmurerwa Date: Wed, 10 May 2023 14:07:49 +0300 Subject: [PATCH 6/9] fix: Fix typo on the LowestSupportedApiLevel platform parameter --- .../util/platformparameter/PlatformParameterConstants.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt index 90d5d4773a3..d8b4affb4ce 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt @@ -299,6 +299,6 @@ const val LOWEST_SUPPORTED_API_LEVEL = "lowest_supported_api_level" * Default value for the platform parameter that contains an integer indicating the lowest * supported Android API Level. * - * Th current minimum supported API level is 19 (KitKat). + * The current minimum supported API level is 19 (KitKat). */ const val LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE = 19 From 02a350898bf0f536991f0e693336497b8d26c9aa Mon Sep 17 00:00:00 2001 From: kkmurerwa Date: Fri, 12 May 2023 15:10:12 +0300 Subject: [PATCH 7/9] This commit will; - Fix comments made on the PR - Add tests for the changed approach on the PlatformParameterModule --- .../PlatformParameterAlphaKenyaModule.kt | 14 ++++---- .../PlatformParameterModule.kt | 14 ++++---- .../PlatformParameterModuleTest.kt | 33 +++++++++++++++++++ .../testing/platformparameter/BUILD.bazel | 2 ++ .../TestOptionalAppUpdateVersionCode.kt | 24 ++++++++++++++ .../TestPlatformParameterModule.kt | 33 ++++++++++++++----- .../PlatformParameterConstants.kt | 12 ------- 7 files changed, 99 insertions(+), 33 deletions(-) create mode 100644 testing/src/main/java/org/oppia/android/testing/platformparameter/TestOptionalAppUpdateVersionCode.kt diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt index 5fbd934cbd1..42ffafbc2e3 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterAlphaKenyaModule.kt @@ -1,7 +1,9 @@ package org.oppia.android.domain.platformparameter +import android.content.Context import dagger.Module import dagger.Provides +import org.oppia.android.app.utility.getVersionCode import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE import org.oppia.android.util.platformparameter.CacheLatexRendering @@ -26,14 +28,12 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE import org.oppia.android.util.platformparameter.LowestSupportedApiLevel import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL @@ -212,24 +212,26 @@ class PlatformParameterAlphaKenyaModule { @Provides @OptionalAppUpdateVersionCode fun provideOptionalAppUpdateVersionCode( - platformParameterSingleton: PlatformParameterSingleton + platformParameterSingleton: PlatformParameterSingleton, + context: Context ): PlatformParameterValue { return platformParameterSingleton.getIntegerPlatformParameter( OPTIONAL_APP_UPDATE_VERSION_CODE ) ?: PlatformParameterValue.createDefaultParameter( - OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + context.getVersionCode() ) } @Provides @ForcedAppUpdateVersionCode fun provideForcedAppUpdateVersionCode( - platformParameterSingleton: PlatformParameterSingleton + platformParameterSingleton: PlatformParameterSingleton, + context: Context ): PlatformParameterValue { return platformParameterSingleton.getIntegerPlatformParameter( FORCED_APP_UPDATE_VERSION_CODE ) ?: PlatformParameterValue.createDefaultParameter( - FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + context.getVersionCode() ) } diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt index 4005dfacf0d..4ce52320f39 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt @@ -1,7 +1,9 @@ package org.oppia.android.domain.platformparameter +import android.content.Context import dagger.Module import dagger.Provides +import org.oppia.android.app.utility.getVersionCode import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE import org.oppia.android.util.platformparameter.CacheLatexRendering @@ -26,7 +28,6 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE @@ -34,7 +35,6 @@ import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE import org.oppia.android.util.platformparameter.LowestSupportedApiLevel import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL @@ -208,24 +208,26 @@ class PlatformParameterModule { @Provides @OptionalAppUpdateVersionCode fun provideOptionalAppUpdateVersionCode( - platformParameterSingleton: PlatformParameterSingleton + platformParameterSingleton: PlatformParameterSingleton, + context: Context ): PlatformParameterValue { return platformParameterSingleton.getIntegerPlatformParameter( OPTIONAL_APP_UPDATE_VERSION_CODE ) ?: PlatformParameterValue.createDefaultParameter( - OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + context.getVersionCode() ) } @Provides @ForcedAppUpdateVersionCode fun provideForcedAppUpdateVersionCode( - platformParameterSingleton: PlatformParameterSingleton + platformParameterSingleton: PlatformParameterSingleton, + context: Context ): PlatformParameterValue { return platformParameterSingleton.getIntegerPlatformParameter( FORCED_APP_UPDATE_VERSION_CODE ) ?: PlatformParameterValue.createDefaultParameter( - FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + context.getVersionCode() ) } diff --git a/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt index f309b956197..ea9336ee83f 100644 --- a/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt @@ -1,6 +1,7 @@ package org.oppia.android.domain.platformparameter import android.app.Application +import android.content.Context import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat @@ -11,6 +12,7 @@ import dagger.Provides import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.PlatformParameter +import org.oppia.android.app.utility.getVersionCode import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_DEFAULT_VALUE import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_NAME import org.oppia.android.testing.platformparameter.TEST_BOOLEAN_PARAM_SERVER_VALUE @@ -24,6 +26,8 @@ import org.oppia.android.testing.platformparameter.TestBooleanParam import org.oppia.android.testing.platformparameter.TestIntegerParam import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.platformparameter.TestStringParam +import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode +import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode import org.oppia.android.util.platformparameter.PlatformParameterSingleton import org.oppia.android.util.platformparameter.PlatformParameterValue import org.robolectric.annotation.Config @@ -44,6 +48,9 @@ class PlatformParameterModuleTest { @Inject lateinit var platformParameterSingleton: PlatformParameterSingleton + @Inject + lateinit var context: Context + @field:[Inject TestStringParam] lateinit var stringPlatformParameterProvider: Provider> @@ -53,6 +60,12 @@ class PlatformParameterModuleTest { @field:[Inject TestBooleanParam] lateinit var booleanPlatformParameterProvider: Provider> + @field:[Inject OptionalAppUpdateVersionCode] + lateinit var optionalAppUpdateVersionCodeProvider: Provider> + + @field:[Inject ForcedAppUpdateVersionCode] + lateinit var forcedAppUpdateVersionCodeProvider: Provider> + private val platformParameterMapWithValues by lazy { val mockStringPlatformParameter = PlatformParameter.newBuilder() .setString(TEST_STRING_PARAM_SERVER_VALUE).build() @@ -137,6 +150,20 @@ class PlatformParameterModuleTest { .isEqualTo(TEST_BOOLEAN_PARAM_SERVER_VALUE) } + @Test + fun testModule_retrieveOptionalAppUpdateVersionCode_returnsParamValue() { + setUpTestApplicationComponent(platformParameterMapWithValues) + assertThat(optionalAppUpdateVersionCodeProvider.get().value) + .isEqualTo(context.getVersionCode()) + } + + @Test + fun testModule_retrieveForcedAppUpdateVersionCode_returnsParamValue() { + setUpTestApplicationComponent(platformParameterMapWithValues) + assertThat(forcedAppUpdateVersionCodeProvider.get().value) + .isEqualTo(context.getVersionCode()) + } + private fun setUpTestApplicationComponent(platformParameterMap: Map) { ApplicationProvider.getApplicationContext().inject(this) platformParameterSingleton.setPlatformParameterMap(platformParameterMap) @@ -149,6 +176,12 @@ class PlatformParameterModuleTest { fun providePlatformParameterSingleton( platformParameterSingletonImpl: PlatformParameterSingletonImpl ): PlatformParameterSingleton = platformParameterSingletonImpl + + @Provides + @Singleton + fun provideContext(application: Application): Context { + return application + } } // TODO(#89): Move this to a common test application component. diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel b/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel index 1b6b8298bf5..0f647b5bf1c 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel @@ -13,6 +13,7 @@ kt_android_library( "TestBooleanPlatformParameter.kt", "TestIntegerPlatformParameter.kt", "TestStringPlatformParameter.kt", + "TestOptionalAppUpdateVersionCode.kt", ], visibility = [ "//:oppia_testing_visibility", @@ -35,6 +36,7 @@ kt_android_library( ":dagger", ":test_constants", "//utility", + "//utility/src/main/java/org/oppia/android/util/extensions:context_extensions", ], ) diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestOptionalAppUpdateVersionCode.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestOptionalAppUpdateVersionCode.kt new file mode 100644 index 00000000000..f27a8750df7 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestOptionalAppUpdateVersionCode.kt @@ -0,0 +1,24 @@ +package org.oppia.android.testing.platformparameter + +import javax.inject.Qualifier + +/** + * Qualifier for test optional app update version code. Only used in tests related to platform parameter. + */ +@Qualifier +annotation class TestOptionalAppUpdateVersionCode + +/** + * Name for the test optional app update version code. Only used in tests related to platform parameter. + */ +const val TEST_OPTIONAL_APP_UPDATE_VERSION_CODE_NAME = "test_optional_app_update_version_code_name" + +/** + * Default value for the test optional app update version code. Only used in tests related to platform parameter. + */ +const val TEST_OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE = 0 + +/** + * Server value for the test optional app update version code. Only used in tests related to platform parameter. + */ +const val TEST_OPTIONAL_APP_UPDATE_VERSION_CODE_SERVER_VALUE = 1 diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index 307aa8b3d06..f8b8a2fe18e 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -1,8 +1,10 @@ package org.oppia.android.testing.platformparameter +import android.content.Context import androidx.annotation.VisibleForTesting import dagger.Module import dagger.Provides +import org.oppia.android.app.utility.getVersionCode import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING import org.oppia.android.util.platformparameter.CACHE_LATEX_RENDERING_DEFAULT_VALUE import org.oppia.android.util.platformparameter.CacheLatexRendering @@ -25,14 +27,12 @@ import org.oppia.android.util.platformparameter.EnableLearnerStudyAnalytics import org.oppia.android.util.platformparameter.EnablePerformanceMetricsCollection import org.oppia.android.util.platformparameter.EnableSpotlightUi import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode import org.oppia.android.util.platformparameter.LEARNER_STUDY_ANALYTICS_DEFAULT_VALUE import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL import org.oppia.android.util.platformparameter.LOWEST_SUPPORTED_API_LEVEL_DEFAULT_VALUE import org.oppia.android.util.platformparameter.LowestSupportedApiLevel import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE -import org.oppia.android.util.platformparameter.OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES import org.oppia.android.util.platformparameter.PERFORMANCE_METRICS_COLLECTION_HIGH_FREQUENCY_TIME_INTERVAL_IN_MINUTES_DEFAULT_VAL @@ -207,32 +207,47 @@ class TestPlatformParameterModule { @Provides @EnableAppAndOsDeprecation fun provideEnableAppAndOsDeprecation(): PlatformParameterValue { - return PlatformParameterValue.createDefaultParameter( - enableAppAndOsDeprecation - ) + return PlatformParameterValue.createDefaultParameter(enableAppAndOsDeprecation) } @Provides + @Singleton @OptionalAppUpdateVersionCode fun provideOptionalAppUpdateVersionCode( - platformParameterSingleton: PlatformParameterSingleton + platformParameterSingleton: PlatformParameterSingleton, + context: Context ): PlatformParameterValue { return platformParameterSingleton.getIntegerPlatformParameter( OPTIONAL_APP_UPDATE_VERSION_CODE ) ?: PlatformParameterValue.createDefaultParameter( - OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + context.getVersionCode() ) } @Provides @ForcedAppUpdateVersionCode fun provideForcedAppUpdateVersionCode( - platformParameterSingleton: PlatformParameterSingleton + platformParameterSingleton: PlatformParameterSingleton, + context: Context ): PlatformParameterValue { return platformParameterSingleton.getIntegerPlatformParameter( FORCED_APP_UPDATE_VERSION_CODE ) ?: PlatformParameterValue.createDefaultParameter( - FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE + context.getVersionCode() + ) + } + + @TestOptionalAppUpdateVersionCode + @Provides + @Singleton + fun provideTestForcedAppUpdateVersionCode( + platformParameterSingleton: PlatformParameterSingleton, + context: Context + ): PlatformParameterValue { + return platformParameterSingleton.getIntegerPlatformParameter( + TEST_OPTIONAL_APP_UPDATE_VERSION_CODE_NAME + ) ?: PlatformParameterValue.createDefaultParameter( + context.getVersionCode() ) } diff --git a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt index d8b4affb4ce..04b6f2b8ea6 100644 --- a/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt +++ b/utility/src/main/java/org/oppia/android/util/platformparameter/PlatformParameterConstants.kt @@ -257,12 +257,6 @@ annotation class OptionalAppUpdateVersionCode */ const val OPTIONAL_APP_UPDATE_VERSION_CODE = "optional_app_update_version_code" -/** - * Default value for the platform parameter that contains the integer version code of the latest - * available optional app update. - */ -const val OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE = 1 - /** * Qualifier for the platform parameter that contains the version code of the latest available * forced app update, which is used to notify the app that a mandatory update is available. @@ -276,12 +270,6 @@ annotation class ForcedAppUpdateVersionCode */ const val FORCED_APP_UPDATE_VERSION_CODE = "forced_app_update_version_code" -/** - * Default value for the platform parameter that contains the integer version code of the latest - * available forced app update. - */ -const val FORCED_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE = 0 - /** * Qualifier for the platform parameter that contains an integer indicating the lowest supported * Android API Level. From 31b5332df52a42c8df24d00b91cddac6317055c2 Mon Sep 17 00:00:00 2001 From: kkmurerwa Date: Fri, 12 May 2023 19:28:02 +0300 Subject: [PATCH 8/9] fix: Fix failing buildifier check --- .../testing/platformparameter/BUILD.bazel | 1 - .../TestOptionalAppUpdateVersionCode.kt | 24 ------------------- .../TestPlatformParameterModule.kt | 14 ----------- 3 files changed, 39 deletions(-) delete mode 100644 testing/src/main/java/org/oppia/android/testing/platformparameter/TestOptionalAppUpdateVersionCode.kt diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel b/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel index 0f647b5bf1c..a724de2135e 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/BUILD.bazel @@ -13,7 +13,6 @@ kt_android_library( "TestBooleanPlatformParameter.kt", "TestIntegerPlatformParameter.kt", "TestStringPlatformParameter.kt", - "TestOptionalAppUpdateVersionCode.kt", ], visibility = [ "//:oppia_testing_visibility", diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestOptionalAppUpdateVersionCode.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestOptionalAppUpdateVersionCode.kt deleted file mode 100644 index f27a8750df7..00000000000 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestOptionalAppUpdateVersionCode.kt +++ /dev/null @@ -1,24 +0,0 @@ -package org.oppia.android.testing.platformparameter - -import javax.inject.Qualifier - -/** - * Qualifier for test optional app update version code. Only used in tests related to platform parameter. - */ -@Qualifier -annotation class TestOptionalAppUpdateVersionCode - -/** - * Name for the test optional app update version code. Only used in tests related to platform parameter. - */ -const val TEST_OPTIONAL_APP_UPDATE_VERSION_CODE_NAME = "test_optional_app_update_version_code_name" - -/** - * Default value for the test optional app update version code. Only used in tests related to platform parameter. - */ -const val TEST_OPTIONAL_APP_UPDATE_VERSION_CODE_DEFAULT_VALUE = 0 - -/** - * Server value for the test optional app update version code. Only used in tests related to platform parameter. - */ -const val TEST_OPTIONAL_APP_UPDATE_VERSION_CODE_SERVER_VALUE = 1 diff --git a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt index f8b8a2fe18e..6dd32e0d855 100644 --- a/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/platformparameter/TestPlatformParameterModule.kt @@ -237,20 +237,6 @@ class TestPlatformParameterModule { ) } - @TestOptionalAppUpdateVersionCode - @Provides - @Singleton - fun provideTestForcedAppUpdateVersionCode( - platformParameterSingleton: PlatformParameterSingleton, - context: Context - ): PlatformParameterValue { - return platformParameterSingleton.getIntegerPlatformParameter( - TEST_OPTIONAL_APP_UPDATE_VERSION_CODE_NAME - ) ?: PlatformParameterValue.createDefaultParameter( - context.getVersionCode() - ) - } - @Provides @LowestSupportedApiLevel fun provideLowestSupportedApiLevel( From 1af1f9dadb7b6faa80eed1a9b2cc4d71e773cb41 Mon Sep 17 00:00:00 2001 From: kkmurerwa Date: Tue, 16 May 2023 14:39:56 +0300 Subject: [PATCH 9/9] test: Add tests for the app/os deprecation feature flag and improved existing tests --- .../PlatformParameterModuleTest.kt | 59 +++++++++++++++++-- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt b/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt index ea9336ee83f..1601eafc8c4 100644 --- a/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/platformparameter/PlatformParameterModuleTest.kt @@ -3,6 +3,8 @@ package org.oppia.android.domain.platformparameter import android.app.Application import android.content.Context import androidx.test.core.app.ApplicationProvider +import androidx.test.core.content.pm.ApplicationInfoBuilder +import androidx.test.core.content.pm.PackageInfoBuilder import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat import dagger.BindsInstance @@ -26,10 +28,13 @@ import org.oppia.android.testing.platformparameter.TestBooleanParam import org.oppia.android.testing.platformparameter.TestIntegerParam import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.platformparameter.TestStringParam +import org.oppia.android.util.platformparameter.EnableAppAndOsDeprecation import org.oppia.android.util.platformparameter.ForcedAppUpdateVersionCode +import org.oppia.android.util.platformparameter.LowestSupportedApiLevel import org.oppia.android.util.platformparameter.OptionalAppUpdateVersionCode import org.oppia.android.util.platformparameter.PlatformParameterSingleton import org.oppia.android.util.platformparameter.PlatformParameterValue +import org.robolectric.Shadows import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode import javax.inject.Inject @@ -60,12 +65,18 @@ class PlatformParameterModuleTest { @field:[Inject TestBooleanParam] lateinit var booleanPlatformParameterProvider: Provider> + @field:[Inject EnableAppAndOsDeprecation] + lateinit var enableAppAndOsDeprecationProvider: Provider> + @field:[Inject OptionalAppUpdateVersionCode] lateinit var optionalAppUpdateVersionCodeProvider: Provider> @field:[Inject ForcedAppUpdateVersionCode] lateinit var forcedAppUpdateVersionCodeProvider: Provider> + @field:[Inject LowestSupportedApiLevel] + lateinit var lowestSupportedApiLevelProvider: Provider> + private val platformParameterMapWithValues by lazy { val mockStringPlatformParameter = PlatformParameter.newBuilder() .setString(TEST_STRING_PARAM_SERVER_VALUE).build() @@ -151,34 +162,67 @@ class PlatformParameterModuleTest { } @Test - fun testModule_retrieveOptionalAppUpdateVersionCode_returnsParamValue() { + fun testModule_injectEnableAppAndOsDeprecation_hasCorrectDefaultValue() { + setUpTestApplicationComponent(platformParameterMapWithValues) + assertThat(enableAppAndOsDeprecationProvider.get().value) + .isEqualTo(TEST_ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE) + } + + @Test + fun testModule_injectOptionalAppUpdateVersionCode_hasCorrectAppVersionCode() { setUpTestApplicationComponent(platformParameterMapWithValues) assertThat(optionalAppUpdateVersionCodeProvider.get().value) .isEqualTo(context.getVersionCode()) + assertThat(optionalAppUpdateVersionCodeProvider.get().value) + .isEqualTo(TEST_APP_VERSION_CODE) } @Test - fun testModule_retrieveForcedAppUpdateVersionCode_returnsParamValue() { + fun testModule_injectForcedAppUpdateVersionCode_hasCorrectAppVersionCode() { setUpTestApplicationComponent(platformParameterMapWithValues) assertThat(forcedAppUpdateVersionCodeProvider.get().value) .isEqualTo(context.getVersionCode()) + assertThat(forcedAppUpdateVersionCodeProvider.get().value) + .isEqualTo(TEST_APP_VERSION_CODE) + } + + @Test + fun testModule_injectLowestSupportedApiLevel_hasCorrectMinimumApiLevel() { + setUpTestApplicationComponent(platformParameterMapWithValues) + assertThat(lowestSupportedApiLevelProvider.get().value) + .isEqualTo(TEST_LOWEST_SUPPORTED_API_LEVEL) + } + + private fun registerTestApplication() { + val packageManager = Shadows.shadowOf(context.packageManager) + val applicationInfo = + ApplicationInfoBuilder.newBuilder() + .setPackageName(context.packageName) + .build() + val packageInfo = + PackageInfoBuilder.newBuilder() + .setPackageName(context.packageName) + .setApplicationInfo(applicationInfo) + .build() + packageInfo.versionName = TEST_APP_VERSION_NAME + packageInfo.longVersionCode = TEST_APP_VERSION_CODE + packageManager.installPackage(packageInfo) } private fun setUpTestApplicationComponent(platformParameterMap: Map) { ApplicationProvider.getApplicationContext().inject(this) platformParameterSingleton.setPlatformParameterMap(platformParameterMap) + registerTestApplication() } @Module class TestModule { @Provides - @Singleton fun providePlatformParameterSingleton( platformParameterSingletonImpl: PlatformParameterSingletonImpl ): PlatformParameterSingleton = platformParameterSingletonImpl @Provides - @Singleton fun provideContext(application: Application): Context { return application } @@ -213,4 +257,11 @@ class PlatformParameterModuleTest { component.inject(platformParameterModuleTest) } } + + private companion object { + private const val TEST_APP_VERSION_NAME = "oppia-android-test-0123456789" + private const val TEST_APP_VERSION_CODE = 125L + private const val TEST_LOWEST_SUPPORTED_API_LEVEL = 19 + private const val TEST_ENABLE_APP_AND_OS_DEPRECATION_DEFAULT_VALUE = false + } }