Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Update app services, android components, and megazord configuration #864

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 9 additions & 32 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ dependencies {
implementation "org.mozilla.components:lib-dataprotect:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:lib-fetch-httpurlconnection:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:lib-publicsuffixlist:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:support-rusthttp:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:support-rustlog:${rootProject.ext.android_components_version}"
implementation "org.mozilla.components:concept-sync:${rootProject.ext.android_components_version}"

Expand Down Expand Up @@ -151,6 +152,14 @@ dependencies {
androidTestImplementation 'br.com.concretesolutions:kappuccino:1.2.1'
ktlint "com.github.shyiko:ktlint:0.28.0"
androidTestImplementation "tools.fastlane:screengrab:1.2.0"
modules {
module('org.mozilla.appservices:full-megazord') {
replacedBy('org.mozilla.appservices:lockbox-megazord', 'prefer the lockbox megazord, to reduce final application size')
}
module('org.mozilla.appservices:lockbox-megazord') {
replacedBy('org.mozilla.appservices:lockbox-megazord-forUnitTests', 'prefer the forUnitTests variant if present')
}
}
}

sentry {
Expand Down Expand Up @@ -254,35 +263,3 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {

// Internal, but stable and convenient.
import org.gradle.api.internal.artifacts.DefaultModuleIdentifier

// This is the equivalent of what the `org.mozilla.appservices` Gradle plugin
// achieved, minus asserting that the versions of all the megazord components
// agree. That assertion could be added if required.
afterEvaluate {
// The definitions of the megazords themselves evolve: this set was determined from
// https://github.com/mozilla/application-services/blob/v0.27.0/megazords/lockbox/android/build.gradle#L79-L82,
// where the version in the URL is the tag corresponding to `mozilla_appservices_version`. This
// will need to be bumped when `android_components_version` (and thus
// `mozilla_appservices_version`) is rolled forward.
def megazord = DefaultModuleIdentifier.newId('org.mozilla.appservices', 'lockbox-megazord')
def megazordComponents = [
DefaultModuleIdentifier.newId('org.mozilla.appservices', 'fxaclient'),
DefaultModuleIdentifier.newId('org.mozilla.appservices', 'logins'),
DefaultModuleIdentifier.newId('org.mozilla.appservices', 'rustlog'),
]

configurations.each { configuration ->
configuration.resolutionStrategy.dependencySubstitution.all { dependency ->
if (dependency.requested instanceof ModuleComponentSelector) {
def moduleIdentifier = ((ModuleComponentSelector) dependency.requested).moduleIdentifier
if (megazordComponents.contains(moduleIdentifier)) {
def megazordVersion = rootProject.ext.mozilla_appservices_version
def substitution = "${megazord.group}:${megazord.name}:${megazordVersion}"
logger.lifecycle("In ${configuration}: substituting megazord module '$substitution' for component module" +
" '${moduleIdentifier.group}:${moduleIdentifier.name}:${dependency.requested.version}'")
dependency.useTarget(substitution)
}
}
}
}
}
6 changes: 4 additions & 2 deletions app/src/main/java/mozilla/lockbox/LockboxApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import com.adjust.sdk.Adjust
import com.adjust.sdk.AdjustConfig
import com.squareup.leakcanary.LeakCanary
import kotlinx.coroutines.ExperimentalCoroutinesApi
import mozilla.appservices.LockboxMegazord
import mozilla.appservices.Megazord
import mozilla.components.support.rusthttp.RustHttpConfig
import mozilla.components.lib.fetch.httpurlconnection.HttpURLConnectionClient
import mozilla.components.support.base.log.Log
import mozilla.components.support.base.log.logger.Logger
Expand Down Expand Up @@ -77,7 +78,8 @@ open class LockboxApplication : Application() {
}

private fun setupDataStoreSupport() {
LockboxMegazord.init(lazy { HttpURLConnectionClient() })
Megazord.init()
RustHttpConfig.setClient(lazy { HttpURLConnectionClient() })
RustLog.enable()

FxASyncDataStoreSupport.shared.injectContext(this)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/mozilla/lockbox/store/AccountStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.rx2.asMaybe
import kotlinx.coroutines.rx2.asSingle
import mozilla.appservices.fxaclient.Config
import mozilla.appservices.fxaclient.FxaException
import mozilla.components.concept.sync.AccessTokenInfo
import mozilla.components.concept.sync.Avatar
import mozilla.components.concept.sync.Profile
import mozilla.components.service.fxa.ServerConfig
import mozilla.components.service.fxa.FirefoxAccount
import mozilla.lockbox.action.AccountAction
import mozilla.lockbox.action.DataStoreAction
Expand Down Expand Up @@ -189,7 +189,7 @@ open class AccountStore(

private fun generateNewFirefoxAccount() {
try {
val config = Config.release(Constant.FxA.clientID, Constant.FxA.redirectUri)
val config = ServerConfig.release(Constant.FxA.clientID, Constant.FxA.redirectUri)
fxa = FirefoxAccount(config)
generateLoginURL()
} catch (e: FxaException) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/mozilla/lockbox/store/DataStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ open class DataStore(

backend.sync(support.syncConfig!!)
.asSingle(coroutineContext)
.map { log.debug("### ping: $it") }
.timeout(Constant.App.syncTimeout, TimeUnit.SECONDS)
.doOnEvent { _, err ->
(err as? TimeoutException).let {
Expand Down
10 changes: 9 additions & 1 deletion app/src/test/java/mozilla/lockbox/mocks/MockLoginsStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package mozilla.lockbox.mocks
import mozilla.appservices.logins.LoginsStorage
import mozilla.appservices.logins.ServerPassword
import mozilla.appservices.logins.SyncUnlockInfo
import mozilla.appservices.sync15.SyncTelemetryPing
import mozilla.components.service.sync.logins.AsyncLoginsStorage
import mozilla.components.service.sync.logins.AsyncLoginsStorageAdapter
import mozilla.lockbox.support.DataStoreSupport
Expand Down Expand Up @@ -60,7 +61,14 @@ open class MockLoginsStorage : LoginsStorage {

override fun close() {}

override fun sync(syncInfo: SyncUnlockInfo) {}
override fun sync(syncInfo: SyncUnlockInfo): SyncTelemetryPing {
return SyncTelemetryPing(
version = 1,
uid = "uid",
events = emptyList(),
syncs = emptyList()
)
}

override fun reset() {}

Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
buildscript {
ext.android_support_version = '28.0.0'
ext.kotlin_version = '1.3.0'
ext.android_components_version = '4.0.0'
// XXX: might not want to use the prerelease version?
ext.android_components_version = '7.0.0-SNAPSHOT'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably not release with a snapshot version of Android Components.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7.0.0 is released now, we might like to update to that.

// Determined from
// https://github.com/mozilla-mobile/android-components/blob/v0.51.0/buildSrc/src/main/java/Dependencies.kt,
// where the version in the URL is the tag corresponding to `android_components_version`.
ext.mozilla_appservices_version = '0.32.0'
ext.mozilla_appservices_version = '0.36.0'
ext.lifecycle_version = '1.1.1'
ext.navigation_version = '1.0.0'
ext.rxbinding_version = '2.2.0'
Expand Down
24 changes: 24 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,27 @@
*/

include ':app', ':thirdparty'

// Allow substituting the local application-services path, avoiding the need to
// do a local publish for most cases.
Properties localProperties = null;
String settingAppServicesPath = "substitutions.application-services.dir";

if (file('local.properties').canRead()) {
localProperties = new Properties()
localProperties.load(file('local.properties').newDataInputStream())
logger.lifecycle('Local configuration: loaded local.properties')
} else {
logger.lifecycle('Local configuration: absent local.properties; proceeding as normal.')
}

if (localProperties != null) {
String appServicesLocalPath = localProperties.getProperty(settingAppServicesPath);

if (appServicesLocalPath != null) {
logger.lifecycle("Local configuration: substituting application-services modules from path: $appServicesLocalPath")
includeBuild(appServicesLocalPath)
} else {
logger.lifecycle("Local configuration: application-services substitution path missing. Specify it via '$settingAppServicesPath' setting.")
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.