2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/17869 - Start the Android Keystore experiment

Only on API 23+ (minimum Android version needed for SecureAbove22Preferences)
and only if enabled by a Nimbus experiment.

The Nimbus experiment will have the key `fenix-android-keystore` and use the
default branches - "control" and "treatment".
This commit is contained in:
Mugurell 2021-03-04 21:28:35 +02:00 committed by Grisha Kruglov
parent 1c8387fdb9
commit 3812cffed0
3 changed files with 39 additions and 0 deletions

View File

@ -48,6 +48,7 @@ import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.GleanMetrics.PerfStartup
import org.mozilla.fenix.components.Components
import org.mozilla.fenix.components.metrics.MetricServiceType
import org.mozilla.fenix.components.metrics.SecurePrefsTelemetry
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.perf.ProfilerMarkerFactProcessor
import org.mozilla.fenix.perf.StartupTimeline
@ -218,6 +219,8 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
components.core.bookmarksStorage.warmUp()
components.core.passwordsStorage.warmUp()
}
SecurePrefsTelemetry(this@FenixApplication, components.analytics.experiments).startTests()
}
// Account manager initialization needs to happen on the main thread.
GlobalScope.launch(Dispatchers.Main) {

View File

@ -0,0 +1,35 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
package org.mozilla.fenix.components.metrics
import android.content.Context
import android.os.Build
import mozilla.components.lib.dataprotect.SecurePrefsReliabilityExperiment
import mozilla.components.service.nimbus.NimbusApi
import org.mozilla.fenix.experiments.ExperimentBranch
import org.mozilla.fenix.experiments.Experiments
import org.mozilla.fenix.ext.withExperiment
/**
* Allows starting a quick test of ACs SecureAbove22Preferences that will emit Facts
* for the basic operations and allow us to log them for later evaluation of APIs stability.
*/
class SecurePrefsTelemetry(
private val appContext: Context,
private val experiments: NimbusApi
) {
suspend fun startTests() {
// The Android Keystore is used to secure the shared prefs only on API 23+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// These tests should run only if the experiment is live
experiments.withExperiment(Experiments.ANDROID_KEYSTORE) { experimentBranch ->
// .. and this device is not in the control group.
if (experimentBranch == ExperimentBranch.TREATMENT) {
SecurePrefsReliabilityExperiment(appContext)()
}
}
}
}
}

View File

@ -8,6 +8,7 @@ class Experiments {
companion object {
const val A_A_NIMBUS_VALIDATION = "fenix-nimbus-validation-v3"
const val BOOKMARK_ICON = "fenix-bookmark-list-icon"
const val ANDROID_KEYSTORE = "fenix-android-keystore"
}
}