GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Bug 40115: Update components for switch to Fenix 82

Update application-services
parent 015ff456
From 1641b74b17dad85a3ee65802a0a6320d2184c6c3 Mon Sep 17 00:00:00 2001
From: Georg Koppen <gk@torproject.org>
Date: Fri, 21 Aug 2020 19:26:37 +0000
Subject: [PATCH] 1651660
diff --git a/build.gradle b/build.gradle
index 6b16a91d..58a4ddae 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,16 +4,16 @@ buildscript {
ext.kotlin_version = '1.3.71'
ext.jna_version = '5.2.0'
ext.android_gradle_plugin_version = '3.6.0'
-
- // N.B. try to keep these two in sync
- ext.android_components_version = '24.0.0'
- ext.glean_version = '21.3.0'
+ ext.android_components_version = '47.0.0'
ext.build = [
ndkVersion: "21.3.6528147", // Keep it in sync in TC Dockerfile.
compileSdkVersion: 29,
targetSdkVersion: 28,
minSdkVersion: 21, // So that we can publish for aarch64.
+ // This is required to support new AndroidX support libraries.
+ // See mozilla-mobile/android-components#842
+ jvmTargetCompatibility: "1.8",
]
repositories {
@@ -44,6 +44,11 @@ buildscript {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12'
+ // Since the Glean version depends on the Android components version,
+ // it is very important to use a modern version of Glean and, ideally,
+ // let this come from the embedding product itself.
+ classpath "org.mozilla.components:tooling-glean-gradle:$android_components_version"
+
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
diff --git a/components/fxa-client/android/build.gradle b/components/fxa-client/android/build.gradle
index 9981facd..e0cac485 100644
--- a/components/fxa-client/android/build.gradle
+++ b/components/fxa-client/android/build.gradle
@@ -36,6 +36,19 @@ android {
}
}
}
+
+ // This is required to support new AndroidX support libraries.
+ // See mozilla-mobile/android-components#842
+ compileOptions {
+ sourceCompatibility rootProject.ext.build.jvmTargetCompatibility
+ targetCompatibility rootProject.ext.build.jvmTargetCompatibility
+ }
+
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
+ kotlinOptions {
+ jvmTarget = rootProject.ext.build.jvmTargetCompatibility
+ }
+ }
}
configurations {
diff --git a/components/logins/android/build.gradle b/components/logins/android/build.gradle
index be777e5b..166b81fe 100644
--- a/components/logins/android/build.gradle
+++ b/components/logins/android/build.gradle
@@ -46,6 +46,19 @@ android {
includeAndroidResources = true
}
}
+
+ // This is required to support new AndroidX support libraries.
+ // See mozilla-mobile/android-components#842
+ compileOptions {
+ sourceCompatibility rootProject.ext.build.jvmTargetCompatibility
+ targetCompatibility rootProject.ext.build.jvmTargetCompatibility
+ }
+
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
+ kotlinOptions {
+ jvmTarget = rootProject.ext.build.jvmTargetCompatibility
+ }
+ }
}
configurations {
@@ -80,6 +93,12 @@ protobuf {
}
}
+// Needs to happen before `dependencies` in order for the variables
+// exposed by the plugin to be available for this project.
+ext.gleanGenerateMarkdownDocs = true
+ext.gleanDocsDirectory = "$rootDir/docs/metrics/logins"
+apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"
+
dependencies {
// Part of the public API.
api project(':sync15')
@@ -108,7 +127,7 @@ dependencies {
testImplementation 'org.mockito:mockito-core:2.21.0'
testImplementation 'androidx.test:core-ktx:1.2.0'
testImplementation 'androidx.work:work-testing:2.2.0'
- testImplementation "org.mozilla.telemetry:glean-forUnitTests:$glean_version"
+ testImplementation "org.mozilla.telemetry:glean-forUnitTests:$project.ext.glean_version"
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
@@ -132,8 +151,3 @@ afterEvaluate {
apply from: "$rootDir/publish.gradle"
ext.configurePublish()
-
-ext.gleanGenerateMarkdownDocs = true
-ext.gleanDocsDirectory = "$rootDir/docs/metrics/logins"
-apply from: "https://github.com/mozilla-mobile/android-components/raw/v${android_components_version}/components/service/glean/scripts/sdk_generator.gradle"
-
diff --git a/components/logins/android/metrics.yaml b/components/logins/android/metrics.yaml
index e7ddec62..c81d6e43 100644
--- a/components/logins/android/metrics.yaml
+++ b/components/logins/android/metrics.yaml
@@ -2,31 +2,36 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-# This file defines the metrics that will be gathered for the "logins" storage component.
-# These are emitted for all users of the component. Additional metrics specific to the
-# *syncing* of logins are defined in a separate "sync_ping" package.
+# This file defines the metrics that will be gathered for the "logins"
+# storage component.
+# These are emitted for all users of the component. Additional metrics
+# specific to the *syncing* of logins are defined in a separate "sync_ping"
+# package.
#
-# Changes to these metrics require data review, which should take into consideration
-# the following known consumers of the logins component Android bindings:
+# Changes to these metrics require data review, which should take into
+# consideration the following known consumers of the logins component
+# Android bindings:
#
# * Firefox Preview
# * Firefox Lockwise for Android
+---
$schema: moz://mozilla.org/schemas/glean/metrics/1-0-0
logins_store:
- # These help us understand how much the logins store is being used, and whether it's succeeding
- # in the duties asked of it. We'll use them to graph e.g. the error rate of applications trying
- # to use the logins store, and identify application or platform features that lead to unusually
+ # These help us understand how much the logins store is being used, and
+ # whether it's succeeding in the duties asked of it. We'll use them to
+ # graph e.g. the error rate of applications trying to use the logins store,
+ # and identify application or platform features that lead to unusually
# high error rates.
unlock_count:
type: counter
description: >
The number of times the login store was unlocked.
- It is intended to be used together with `unlock_error_count` to measure the overall
- error rate of unlocking the logins store.
+ It is intended to be used together with `unlock_error_count` to measure
+ the overall error rate of unlocking the logins store.
bugs:
- https://github.com/mozilla/application-services/issues/2225
data_reviews:
@@ -39,9 +44,10 @@ logins_store:
unlock_error_count:
type: labeled_counter
description: >
- The number of errors encountered when unlocking the logins store, labeled by type.
- It is intended to be used together with `unlock_count` to measure the overall error
- rate of unlocking the logins store.
+ The number of errors encountered when unlocking the logins store, labeled
+ by type.
+ It is intended to be used together with `unlock_count` to measure the
+ overall error rate of unlocking the logins store.
labels:
- invalid_key
- mismatched_lock
@@ -59,9 +65,10 @@ logins_store:
type: counter
description: >
The total number of read operations performed on the logins store.
- The count only includes operations triggered by the application, not e.g. incidental reads performed
- as part of a sync. It is intended to be used together with `read_query_error_count` to measure the
- overall error rate of read operations on the logins store.
+ The count only includes operations triggered by the application, not
+ e.g. incidental reads performed as part of a sync. It is intended to be
+ used together with `read_query_error_count` to measure the overall error
+ rate of read operations on the logins store.
bugs:
- https://github.com/mozilla/application-services/issues/2225
data_reviews:
@@ -74,9 +81,10 @@ logins_store:
read_query_error_count:
type: labeled_counter
description: >
- The total number of errors encountered during read operations on the logins store, labeled by type.
- It is intended to be used together with `read_query_count` to measure the overall error rate
- of read operations on the logins store.
+ The total number of errors encountered during read operations on the
+ logins store, labeled by type.
+ It is intended to be used together with `read_query_count` to measure
+ the overall error rate of read operations on the logins store.
labels:
- interrupted
- storage_error
@@ -93,9 +101,10 @@ logins_store:
type: counter
description: >
The total number of write operations performed on the logins store.
- The count only includes operations triggered by the application, not e.g. incidental writes performed
- as part of a sync. It is intended to be used together with `write_query_error_count` to measure the
- overall error rate of write operations on the logins store.
+ The count only includes operations triggered by the application, not
+ e.g. incidental writes performed as part of a sync. It is intended to
+ be used together with `write_query_error_count` to measure the overall
+ error rate of write operations on the logins store.
bugs:
- https://github.com/mozilla/application-services/issues/2225
data_reviews:
@@ -108,9 +117,10 @@ logins_store:
write_query_error_count:
type: labeled_counter
description: >
- The total number of errors encountered during write operations on the logins store, labeled by type.
- It is intended to be used together with `write_query_count` to measure the overall error rate
- of write operations on the logins store.
+ The total number of errors encountered during write operations on the
+ logins store, labeled by type.
+ It is intended to be used together with `write_query_count` to measure
+ the overall error rate of write operations on the logins store.
labels:
- no_such_record
- id_collision
@@ -127,14 +137,16 @@ logins_store:
expires: "2021-03-01"
# These help us understand the performance of the logins store in the wild.
- # We'll use them to identify any application or platform features that are leading to unacceptably
- # slow performance of the store, and eventually for comparison with other logins store implementations
- # (such as the one in Desktop).
+ # We'll use them to identify any application or platform features that are
+ # leading to unacceptably slow performance of the store, and eventually for
+ # comparison with other logins store implementations (such as the one in
+ # Desktop).
unlock_time:
type: timing_distribution
description: >
- The time taken to open the logins store on startup, or after locking it due to user inactivity.
+ The time taken to open the logins store on startup, or after locking it
+ due to user inactivity.
bugs:
- https://github.com/mozilla/application-services/issues/2225
data_reviews:
@@ -147,8 +159,8 @@ logins_store:
read_query_time:
type: timing_distribution
description: >
- The time taken to execute a read query on the logins store (such as listing all logins, or finding a
- specific login by id).
+ The time taken to execute a read query on the logins store (such as
+ listing all logins, or finding a specific login by id).
bugs:
- https://github.com/mozilla/application-services/issues/2225
data_reviews:
@@ -161,8 +173,8 @@ logins_store:
write_query_time:
type: timing_distribution
description: >
- The time taken to execute a write query on the logins store (such as adding, updating, or deleting
- a login record).
+ The time taken to execute a write query on the logins store (such as
+ adding, updating, or deleting a login record).
bugs:
- https://github.com/mozilla/application-services/issues/2225
data_reviews:
diff --git a/components/logins/android/src/main/java/mozilla/appservices/logins/DatabaseLoginsStorage.kt b/components/logins/android/src/main/java/mozilla/appservices/logins/DatabaseLoginsStorage.kt
index ae2ba8b1..8eb2ee7a 100644
--- a/components/logins/android/src/main/java/mozilla/appservices/logins/DatabaseLoginsStorage.kt
+++ b/components/logins/android/src/main/java/mozilla/appservices/logins/DatabaseLoginsStorage.kt
@@ -23,7 +23,6 @@ import org.mozilla.appservices.logins.GleanMetrics.LoginsStore as LoginsStoreMet
* on version updates.
*/
import mozilla.components.service.glean.private.CounterMetricType
-import mozilla.components.service.glean.private.TimingDistributionMetricType
import mozilla.components.service.glean.private.LabeledMetricType
/**
@@ -419,22 +418,6 @@ internal fun Pointer.getRustString(): String {
return this.getString(0, "utf8")
}
-/**
- * A helper extension method for conveniently measuring execution time of a closure.
- *
- * N.B. since we're measuring calls to Rust code here, the provided callback may be doing
- * unsafe things. It's very imporant that we always call the function exactly once here
- * and don't try to do anything tricky like stashing it for later or calling it multiple times.
- */
-inline fun <U> TimingDistributionMetricType.measure(funcToMeasure: () -> U): U {
- val timerId = this.start()
- try {
- return funcToMeasure()
- } finally {
- this.stopAndAccumulate(timerId)
- }
-}
-
/**
* A helper class for gathering basic count metrics on different kinds of LoginsStore operation.
*
diff --git a/components/places/android/build.gradle b/components/places/android/build.gradle
index 4debb737..5655326c 100644
--- a/components/places/android/build.gradle
+++ b/components/places/android/build.gradle
@@ -44,6 +44,19 @@ android {
includeAndroidResources = true
}
}
+
+ // This is required to support new AndroidX support libraries.
+ // See mozilla-mobile/android-components#842
+ compileOptions {
+ sourceCompatibility rootProject.ext.build.jvmTargetCompatibility
+ targetCompatibility rootProject.ext.build.jvmTargetCompatibility
+ }
+
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
+ kotlinOptions {
+ jvmTarget = rootProject.ext.build.jvmTargetCompatibility
+ }
+ }
}
configurations {
@@ -77,6 +90,11 @@ protobuf {
}
}
+// Generate markdown docs for the collected metrics.
+ext.gleanGenerateMarkdownDocs = true
+ext.gleanDocsDirectory = "$rootDir/docs/metrics/places"
+apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"
+
dependencies {
// Part of the public API.
api project(':sync15')
@@ -105,7 +123,7 @@ dependencies {
testImplementation 'org.mockito:mockito-core:2.21.0'
testImplementation 'androidx.test:core-ktx:1.2.0'
testImplementation 'androidx.work:work-testing:2.2.0'
- testImplementation "org.mozilla.telemetry:glean-forUnitTests:$glean_version"
+ testImplementation "org.mozilla.telemetry:glean-forUnitTests:$project.ext.glean_version"
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
@@ -130,8 +148,3 @@ afterEvaluate {
apply from: "$rootDir/publish.gradle"
ext.configurePublish()
-
-// Generate markdown docs for the collected metrics.
-ext.gleanGenerateMarkdownDocs = true
-ext.gleanDocsDirectory = "$rootDir/docs/metrics/places"
-apply from: "https://github.com/mozilla-mobile/android-components/raw/v${android_components_version}/components/service/glean/scripts/sdk_generator.gradle"
diff --git a/components/places/android/metrics.yaml b/components/places/android/metrics.yaml
index 2c4b7891..dcfd1318 100644
--- a/components/places/android/metrics.yaml
+++ b/components/places/android/metrics.yaml
@@ -2,15 +2,19 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-# This file defines the metrics that will be gathered for the "places" storage component.
-# These are emitted for all users of the component. Additional metrics specific to the
-# *syncing* of places are defined in a separate "sync_ping" package.
+# This file defines the metrics that will be gathered for the "places"
+# storage component.
+# These are emitted for all users of the component. Additional metrics
+# specific to the *syncing* of places are defined in a separate "sync_ping"
+# package.
#
-# Changes to these metrics require data review, which should take into consideration
+# Changes to these metrics require data review, which should take into
+# consideration
# the following known consumers of the places component Android bindings:
#
# * Fenix for Andriod
+---
$schema: moz://mozilla.org/schemas/glean/metrics/1-0-0
places_manager:
@@ -19,9 +23,10 @@ places_manager:
type: counter
description: >
The total number of read operations performed on the places store.
- The count only includes operations triggered by the application, not e.g. incidental reads performed
- as part of a sync. It is intended to be used together with `read_query_error_count` to measure the
- overall error rate of read operations on the places store.
+ The count only includes operations triggered by the application, not
+ e.g. incidental reads performed as part of a sync. It is intended to
+ be used together with `read_query_error_count` to measure the overall
+ error rate of read operations on the places store.
bugs:
- https://github.com/mozilla/application-services/issues/2300
- https://github.com/mozilla/application-services/issues/2299
@@ -35,9 +40,10 @@ places_manager:
read_query_error_count:
type: labeled_counter
description: >
- The total number of errors encountered during read operations on the places store, labeled by type.
- It is intended to be used together with `read_query_count` to measure the overall error rate
- of read operations on the places store.
+ The total number of errors encountered during read operations on the
+ places store, labeled by type.
+ It is intended to be used together with `read_query_count` to measure
+ the overall error rate of read operations on the places store.
labels:
- url_parse_failed
- operation_interrupted
@@ -55,9 +61,10 @@ places_manager:
type: counter
description: >
The total number of write operations performed on the places store.
- The count only includes operations triggered by the application, not e.g. incidental writes performed
- as part of a sync. It is intended to be used together with `write_query_error_count` to measure the
- overall error rate of write operations on the places store.
+ The count only includes operations triggered by the application, not
+ e.g. incidental writes performed as part of a sync. It is intended to
+ be used together with `write_query_error_count` to measure the overall
+ error rate of write operations on the places store.
bugs:
- https://github.com/mozilla/application-services/issues/2300
- https://github.com/mozilla/application-services/issues/2299
@@ -71,9 +78,10 @@ places_manager:
write_query_error_count:
type: labeled_counter
description: >
- The total number of errors encountered during write operations on the places store, labeled by type.
- It is intended to be used together with `write_query_count` to measure the overall error rate
- of write operations on the places store.
+ The total number of errors encountered during write operations on the
+ places store, labeled by type.
+ It is intended to be used together with `write_query_count` to measure
+ the overall error rate of write operations on the places store.
labels:
- url_parse_failed
- invalid_bookmark_update
@@ -108,8 +116,9 @@ places_manager:
scan_query_time:
type: timing_distribution
description: >
- The time taken to execute a scan query on the places store. This metric is for queries that we
- expect to be costly e.g. getBookmarksTree(guid, recursive=True).
+ The time taken to execute a scan query on the places store. This metric
+ is for queries that we expect to be costly
+ e.g. getBookmarksTree(guid, recursive=True).
bugs:
- https://github.com/mozilla/application-services/issues/2300
- https://github.com/mozilla/application-services/issues/2299
diff --git a/components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt b/components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt
index 518bf77a..df2110c4 100644
--- a/components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt
+++ b/components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt
@@ -27,7 +27,6 @@ import org.mozilla.appservices.places.GleanMetrics.PlacesManager as PlacesManage
* on version updates.
*/
import mozilla.components.service.glean.private.CounterMetricType
-import mozilla.components.service.glean.private.TimingDistributionMetricType
import mozilla.components.service.glean.private.LabeledMetricType
/**
@@ -1273,22 +1272,6 @@ data class VisitInfosWithBound(
}
}
-/**
- * A helper extension method for conveniently measuring execution time of a closure.
- *
- * N.B. since we're measuring calls to Rust code here, the provided callback may be doing
- * unsafe things. It's very imporant that we always call the function exactly once here
- * and don't try to do anything tricky like stashing it for later or calling it multiple times.
- */
-inline fun <U> TimingDistributionMetricType.measure(funcToMeasure: () -> U): U {
- val timerId = this.start()
- try {
- return funcToMeasure()
- } finally {
- this.stopAndAccumulate(timerId)
- }
-}
-
/**
* A helper class for gathering basic count metrics on different kinds of PlacesManager operations.
*
diff --git a/components/push/android/build.gradle b/components/push/android/build.gradle
index c68815f1..9dcc0678 100644
--- a/components/push/android/build.gradle
+++ b/components/push/android/build.gradle
@@ -36,6 +36,19 @@ android {
}
}
}
+
+ // This is required to support new AndroidX support libraries.
+ // See mozilla-mobile/android-components#842
+ compileOptions {
+ sourceCompatibility rootProject.ext.build.jvmTargetCompatibility
+ targetCompatibility rootProject.ext.build.jvmTargetCompatibility
+ }
+
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
+ kotlinOptions {
+ jvmTarget = rootProject.ext.build.jvmTargetCompatibility
+ }
+ }
}
configurations {
diff --git a/components/rc_log/android/build.gradle b/components/rc_log/android/build.gradle
index 07f6b238..ad813fca 100644
--- a/components/rc_log/android/build.gradle
+++ b/components/rc_log/android/build.gradle
@@ -29,6 +29,19 @@ android {
// has their own build dir)
test.resources.srcDirs += "${project(':full-megazord').buildDir}/rustJniLibs/desktop"
}
+
+ // This is required to support new AndroidX support libraries.
+ // See mozilla-mobile/android-components#842
+ compileOptions {
+ sourceCompatibility rootProject.ext.build.jvmTargetCompatibility
+ targetCompatibility rootProject.ext.build.jvmTargetCompatibility
+ }
+
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
+ kotlinOptions {
+ jvmTarget = rootProject.ext.build.jvmTargetCompatibility
+ }
+ }
}
configurations {
diff --git a/components/support/android/build.gradle b/components/support/android/build.gradle
index 6555c057..0454acb2 100644
--- a/components/support/android/build.gradle
+++ b/components/support/android/build.gradle
@@ -25,6 +25,18 @@ android {
}
}
+ // This is required to support new AndroidX support libraries.
+ // See mozilla-mobile/android-components#842
+ compileOptions {
+ sourceCompatibility rootProject.ext.build.jvmTargetCompatibility
+ targetCompatibility rootProject.ext.build.jvmTargetCompatibility
+ }
+
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
+ kotlinOptions {
+ jvmTarget = rootProject.ext.build.jvmTargetCompatibility
+ }
+ }
}
dependencies {
diff --git a/components/sync15/android/build.gradle b/components/sync15/android/build.gradle
index cd9f7c63..48520a94 100644
--- a/components/sync15/android/build.gradle
+++ b/components/sync15/android/build.gradle
@@ -25,6 +25,18 @@ android {
}
}
+ // This is required to support new AndroidX support libraries.
+ // See mozilla-mobile/android-components#842
+ compileOptions {
+ sourceCompatibility rootProject.ext.build.jvmTargetCompatibility
+ targetCompatibility rootProject.ext.build.jvmTargetCompatibility
+ }
+
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
+ kotlinOptions {
+ jvmTarget = rootProject.ext.build.jvmTargetCompatibility
+ }
+ }
}
dependencies {
diff --git a/components/sync_manager/android/build.gradle b/components/sync_manager/android/build.gradle
index 7593e09c..2f1bc7fb 100644
--- a/components/sync_manager/android/build.gradle
+++ b/components/sync_manager/android/build.gradle
@@ -33,6 +33,19 @@ android {
}
}
}
+
+ // This is required to support new AndroidX support libraries.
+ // See mozilla-mobile/android-components#842
+ compileOptions {
+ sourceCompatibility rootProject.ext.build.jvmTargetCompatibility
+ targetCompatibility rootProject.ext.build.jvmTargetCompatibility
+ }
+
+ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
+ kotlinOptions {
+ jvmTarget = rootProject.ext.build.jvmTargetCompatibility
+ }
+ }
}
configurations {
diff --git a/components/tabs/android/build.gradle b/components/tabs/android/build.gradle
index 7593e09c..2f1bc7fb 100644
--- a/components/tabs/android/build.gradle
+++ b/components/tabs/android/build.gradle
@@ -33,6 +33,19 @@ android {
}
}
}