Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
5bb9171f
Commit
5bb9171f
authored
May 06, 2020
by
Jan-Erik Rediger
Browse files
Update all sample applications to define an http client
parent
a660d340
Changes
6
Hide whitespace changes
Inline
Side-by-side
components/service/experiments/src/test/java/mozilla/components/service/experiments/debug/ExperimentsDebugActivityTest.kt
View file @
5bb9171f
...
...
@@ -12,12 +12,16 @@ import androidx.test.core.app.ApplicationProvider
import
androidx.test.ext.junit.runners.AndroidJUnit4
import
androidx.work.testing.WorkManagerTestInitHelper
import
kotlinx.coroutines.runBlocking
import
mozilla.components.concept.fetch.Client
import
mozilla.components.lib.fetch.httpurlconnection.HttpURLConnectionClient
import
mozilla.components.service.experiments.Configuration
import
mozilla.components.service.experiments.Experiment
import
mozilla.components.service.experiments.Experiments
import
mozilla.components.service.experiments.ExperimentsSnapshot
import
mozilla.components.service.experiments.ExperimentsUpdater
import
mozilla.components.service.glean.Glean
import
mozilla.components.service.glean.config.Configuration
as
GleanConfiguration
import
mozilla.components.service.glean.net.ConceptFetchHttpUploader
import
org.junit.Assert.assertEquals
import
org.junit.Assert.assertFalse
import
org.junit.Assert.assertNotNull
...
...
@@ -42,7 +46,9 @@ class ExperimentsDebugActivityTest {
fun
setup
()
{
WorkManagerTestInitHelper
.
initializeTestWorkManager
(
context
)
Glean
.
initialize
(
context
,
uploadEnabled
=
true
)
val
httpClient
=
ConceptFetchHttpUploader
(
lazy
{
HttpURLConnectionClient
()
as
Client
})
val
config
=
GleanConfiguration
(
httpClient
=
httpClient
)
Glean
.
initialize
(
context
,
uploadEnabled
=
true
,
configuration
=
config
)
// This makes sure we have a "launch" intent in our package, otherwise
// it will fail looking for it in `GleanDebugActivityTest`.
...
...
samples/browser/src/main/java/org/mozilla/samples/browser/SampleApplication.kt
View file @
5bb9171f
...
...
@@ -6,8 +6,12 @@ package org.mozilla.samples.browser
import
android.app.Application
import
mozilla.components.browser.session.Session
import
mozilla.components.concept.fetch.Client
import
mozilla.components.feature.addons.update.GlobalAddonDependencyProvider
import
mozilla.components.lib.fetch.httpurlconnection.HttpURLConnectionClient
import
mozilla.components.service.glean.Glean
import
mozilla.components.service.glean.config.Configuration
import
mozilla.components.service.glean.net.ConceptFetchHttpUploader
import
mozilla.components.support.base.facts.Facts
import
mozilla.components.support.base.facts.processor.LogFactProcessor
import
mozilla.components.support.base.log.Log
...
...
@@ -31,10 +35,12 @@ class SampleApplication : Application() {
return
}
val
httpClient
=
ConceptFetchHttpUploader
(
lazy
{
HttpURLConnectionClient
()
as
Client
})
val
config
=
Configuration
(
httpClient
=
httpClient
)
// IMPORTANT: the following lines initialize the Glean SDK but disable upload
// of pings. If, for testing purposes, upload is required to be on, change the
// next line to `uploadEnabled = true`.
Glean
.
initialize
(
applicationContext
,
uploadEnabled
=
false
)
Glean
.
initialize
(
applicationContext
,
uploadEnabled
=
false
,
configuration
=
config
)
Facts
.
registerProcessor
(
LogFactProcessor
())
...
...
samples/crash/build.gradle
View file @
5bb9171f
...
...
@@ -30,6 +30,7 @@ android {
dependencies
{
implementation
project
(
':lib-crash'
)
implementation
project
(
':lib-fetch-httpurlconnection'
)
implementation
project
(
':service-glean'
)
implementation
project
(
':support-base'
)
...
...
samples/crash/src/main/java/org/mozilla/samples/crash/CrashApplication.kt
View file @
5bb9171f
...
...
@@ -14,12 +14,16 @@ import kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.launch
import
mozilla.components.support.base.log.Log
import
mozilla.components.support.base.log.sink.AndroidLogSink
import
mozilla.components.concept.fetch.Client
import
mozilla.components.lib.crash.Crash
import
mozilla.components.lib.crash.CrashReporter
import
mozilla.components.lib.crash.service.CrashReporterService
import
mozilla.components.lib.crash.service.GleanCrashReporterService
import
mozilla.components.lib.fetch.httpurlconnection.HttpURLConnectionClient
import
mozilla.components.service.glean.Glean
import
mozilla.components.support.base.crash.Breadcrumb
import
mozilla.components.service.glean.config.Configuration
import
mozilla.components.service.glean.net.ConceptFetchHttpUploader
import
java.util.UUID
class
CrashApplication
:
Application
()
{
...
...
@@ -49,7 +53,9 @@ class CrashApplication : Application() {
).
install
(
this
)
// Initialize Glean for recording by the GleanCrashReporterService
Glean
.
initialize
(
applicationContext
,
uploadEnabled
=
true
)
val
httpClient
=
ConceptFetchHttpUploader
(
lazy
{
HttpURLConnectionClient
()
as
Client
})
val
config
=
Configuration
(
httpClient
=
httpClient
)
Glean
.
initialize
(
applicationContext
,
uploadEnabled
=
true
,
configuration
=
config
)
}
companion
object
{
...
...
samples/glean/build.gradle
View file @
5bb9171f
...
...
@@ -50,6 +50,7 @@ dependencies {
implementation
project
(
':service-glean'
)
implementation
project
(
':service-experiments'
)
implementation
project
(
':support-base'
)
implementation
project
(
':lib-fetch-httpurlconnection'
)
implementation
Dependencies
.
kotlin_stdlib
implementation
Dependencies
.
kotlin_coroutines
...
...
samples/glean/src/main/java/org/mozilla/samples/glean/GleanApplication.kt
View file @
5bb9171f
...
...
@@ -6,7 +6,11 @@ package org.mozilla.samples.glean
import
android.app.Application
import
android.content.Intent
import
mozilla.components.concept.fetch.Client
import
mozilla.components.lib.fetch.httpurlconnection.HttpURLConnectionClient
import
mozilla.components.service.glean.Glean
import
mozilla.components.service.glean.config.Configuration
import
mozilla.components.service.glean.net.ConceptFetchHttpUploader
import
mozilla.components.service.experiments.Experiments
import
mozilla.components.support.base.log.Log
import
mozilla.components.support.base.log.sink.AndroidLogSink
...
...
@@ -28,7 +32,9 @@ class GleanApplication : Application() {
// Initialize the Glean library. Ideally, this is the first thing that
// must be done right after enabling logging.
Glean
.
initialize
(
applicationContext
,
uploadEnabled
=
true
)
val
httpClient
=
ConceptFetchHttpUploader
(
lazy
{
HttpURLConnectionClient
()
as
Client
})
val
config
=
Configuration
(
httpClient
=
httpClient
)
Glean
.
initialize
(
applicationContext
,
uploadEnabled
=
true
,
configuration
=
config
)
// Initialize the Experiments library and pass in the callback that will generate a
// broadcast Intent to signal the application that experiments have been updated. This is
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment