-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Move pixel API to its own gradle lib module #1103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| @Database( | ||
| entities = [PixelEntity::class], | ||
| version = 1 | ||
| ) | ||
| @TypeConverters( | ||
| QueryParamsTypeConverter::class | ||
| ) | ||
| abstract class TestDatabase : RoomDatabase() { | ||
| abstract fun pixelDao(): PendingPixelDao | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created the TestDatabase to break the circular dependency with the main app module. Also, we don't need the full DB, just the DAO to perform the test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed, we can get rid of this
| interface AtbInitializerListener { | ||
|
|
||
| /** | ||
| * This method will be called before initializing the ATB | ||
| */ | ||
| suspend fun beforeAtbInit() | ||
|
|
||
| /** | ||
| * @return the timeout in milliseconds after which [beforeAtbInit] | ||
| * will be stopped | ||
| */ | ||
| fun beforeAtbInitTimeoutMillis(): Long | ||
| } | ||
|
|
||
| class AtbInitializer( | ||
| private val statisticsDataStore: StatisticsDataStore, | ||
| private val statisticsUpdater: StatisticsUpdater, | ||
| private val appReferrerStateListener: AppInstallationReferrerStateListener | ||
| private val listeners: Set<AtbInitializerListener> | ||
| ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creater AtbInitializerListener to break circular dependency with the main app module.
Also, the fact that the AtbInitializer depended on the AppInstallationReferrerStateListener was leaking the referrer logic into the AtbInitializer, which preferably should not happen.
The AtbInitializer now provides a listener that can be implemented by any other class in the app that is interested in executing some code before the AtbInitializer is initialized.
This way, the AtbInitializer does not need to know anything about these classes
| override val appVersion by lazy { | ||
| val info = context.packageManager.getPackageInfo(context.packageName, 0) | ||
| info.versionName.orEmpty() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BuildConfig.VERSION_NAME cannot be access from a lib gradle module. So we get the version name programatically
| val version: String, | ||
| val timestamp: Long = System.currentTimeMillis() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BuildConfig.VERSION_NAME cannot be access from a lib gradle module, so I made version required so that the caller side can provide the proper version
| val exceptionEntity = UncaughtExceptionEntity( | ||
| message = rootCause.extractExceptionCause(), | ||
| exceptionSource = exceptionSource, | ||
| version = deviceInfo.appVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version is now required param, so get it from the DeviceInfo
| version.google.dagger=2.27 | ||
| version.io.reactivex.rxjava2..rxandroid=2.0.2 | ||
| version.io.reactivex.rxjava2..rxjava=2.1.10 | ||
| version.io.reactivex.rxjava2..rxjava=2.2.9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumped this dependency bc I realised that it was overriden by the AndroidX.work.rxJava2, which was bringing version 2.2.9 along, so we effectively had two rxjava versions in the APK, but we were using 2.2.9
66a853e to
a80752d
Compare
70451b8 to
26709d0
Compare
malmstein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple of changes on sdk versions and removing the unnecessary TestDatabase
| statisticsDataStore: StatisticsDataStore, | ||
| statisticsUpdater: StatisticsUpdater, | ||
| appReferrerStateListener: AppInstallationReferrerStateListener | ||
| listeners: Set<@JvmSuppressWildcards AtbInitializerListener> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| @Database( | ||
| entities = [PixelEntity::class], | ||
| version = 1 | ||
| ) | ||
| @TypeConverters( | ||
| QueryParamsTypeConverter::class | ||
| ) | ||
| abstract class TestDatabase : RoomDatabase() { | ||
| abstract fun pixelDao(): PendingPixelDao | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed, we can get rid of this
common/build.gradle
Outdated
|
|
||
| defaultConfig { | ||
| minSdkVersion 21 | ||
| targetSdkVersion 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
project's targetSdkVersion is 29, probably we should export it for everyone's to use.
common/build.gradle
Outdated
| } | ||
|
|
||
| android { | ||
| compileSdkVersion 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, this is 29
common/build.gradle
Outdated
| testImplementation AndroidX.room.testing | ||
| androidTestImplementation AndroidX.room.testing | ||
|
|
||
| testImplementation 'junit:junit:4.+' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you call ./gradleW refreshVersions so this is extracted?
| import org.junit.Assert.assertTrue | ||
| import org.junit.Test | ||
|
|
||
| class DummyTestForCI { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💥
statistics/build.gradle
Outdated
| } | ||
|
|
||
| android { | ||
| compileSdkVersion 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here regarding version 29
statistics/build.gradle
Outdated
|
|
||
| defaultConfig { | ||
| minSdkVersion 21 | ||
| targetSdkVersion 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
statistics/build.gradle
Outdated
| // Play Store referrer library | ||
| implementation("com.android.installreferrer:installreferrer:_") | ||
|
|
||
| testImplementation 'junit:junit:4.+' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here for refreshVersions
…statistics and extracted common lib gradle config
malmstein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes @aitorvs , this looks great!
| applicationId "com.duckduckgo.mobile.android" | ||
| minSdkVersion 21 | ||
| targetSdkVersion 29 | ||
| minSdkVersion min_sdk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Task/Issue URL: https://app.asana.com/0/414730916066338/1199931182139284/f
Tech Design URL:
CC:
Description:
This PR moves the
statisticspackage, that contains the ATB and Pixel APIs to its own gradle lib module. The PR:I have left the corresponding test in the
appgradle module for now to be sure the are executed in CI (I was not sured whether CI was prepared to execute tests in other gradle lib modules).Once that's done, we can move the tests as well
Steps to test this PR:
Internal references:
Software Engineering Expectations
Technical Design Template