Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into AC_3439
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketsroger authored Aug 13, 2019
2 parents 6eebb4b + eda2ba6 commit c766015
Show file tree
Hide file tree
Showing 497 changed files with 8,740 additions and 2,295 deletions.
2 changes: 1 addition & 1 deletion .buildconfig.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
componentsVersion: 8.0.0
componentsVersion: 9.0.0
projects:
concept-awesomebar:
path: components/concept/awesomebar
Expand Down
4 changes: 3 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

---
<!-- Text above this line will be added to the commit once "bors" merges this PR -->

### Pull Request checklist
<!-- Before submitting the PR, please address each item -->
Expand All @@ -9,4 +11,4 @@

### After merge
- [ ] **Milestone**: Make sure issues closed by this pull request are added to the [milestone](https://github.com/mozilla-mobile/android-components/milestones) of the version currently in development.
- [ ] **Breaking Changes**: If this is a breaking change, please push a draft PR on [Reference Browser](https://github.com/mozilla-mobile/reference-browser) to address the breaking issues.
- [ ] **Breaking Changes**: If this is a breaking change, please push a draft PR on [Reference Browser](https://github.com/mozilla-mobile/reference-browser) to address the breaking issues.
8 changes: 6 additions & 2 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ tasks:
$let:
decision_task_id: {$eval: as_slugid("decision_task")}
expires_in: {$fromNow: '1 year'}
user: ${event.sender.login}
user:
# GitHub adds "[bot]" to bot usernames and that doesn't validate as email.
$if: 'event.sender.login == "bors[bot]"'
then: bors
else: ${event.sender.login}

# We define the following variable at the very top, because they are used in the
# default definition
Expand Down Expand Up @@ -153,7 +157,7 @@ tasks:
metadata:
name: 'Android Components - Decision task (Pull Request #${pull_request_number})'
description: 'Building and testing Android components - triggered by [#${pull_request_number}](${pull_request_url})'
- $if: 'tasks_for == "github-push" && head_branch[:10] != "refs/tags/"'
- $if: 'tasks_for == "github-push" && head_branch[:10] != "refs/tags/" && head_branch != "staging.tmp" && head_branch != "trying.tmp"'
then:
$mergeDeep:
- {$eval: 'default_task_definition'}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Task Status](https://github.taskcluster.net/v1/repository/mozilla-mobile/android-components/master/badge.svg)](https://github.taskcluster.net/v1/repository/mozilla-mobile/android-components/master/latest)
[![codecov](https://codecov.io/gh/mozilla-mobile/android-components/branch/master/graph/badge.svg)](https://codecov.io/gh/mozilla-mobile/android-components)
[![Bors enabled](https://bors.tech/images/badge_small.svg)](https://app.bors.tech/repositories/19637)

_A collection of Android libraries to build browsers or browser-like applications._

Expand Down
13 changes: 13 additions & 0 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
status = [
"Taskcluster (push)"
]
block_labels = [
"blocked",
"work in progress"
]
[committer]
name = "MickeyMoz"
email = "[email protected]"
required_approvals = 1
delete_merged_branches = true
cut_body_after = "---"
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/Gecko.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ internal object GeckoVersions {
/**
* GeckoView Nightly Version.
*/
const val nightly_version = "70.0.20190807095705"
const val nightly_version = "70.0.20190809095611"

/**
* GeckoView Beta Version.
*/
const val beta_version = "69.0.20190808090046"
const val beta_version = "69.0.20190812090043"

/**
* GeckoView Release Version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ internal class GeckoMedia(
) : Media() {
override val controller: Controller = GeckoMediaController(mediaElement)

override var metadata: Metadata = Metadata()
internal set

init {
mediaElement.delegate = MediaDelegate(this)
}
Expand All @@ -44,7 +47,7 @@ internal class GeckoMedia(
}

private class MediaDelegate(
private val media: Media
private val media: GeckoMedia
) : MediaElement.Delegate {

override fun onPlaybackStateChange(mediaElement: MediaElement, mediaState: Int) {
Expand All @@ -63,8 +66,11 @@ private class MediaDelegate(
}
}

override fun onMetadataChange(mediaElement: MediaElement, metaData: MediaElement.Metadata) {
media.metadata = Media.Metadata(metaData.duration)
}

override fun onReadyStateChange(mediaElement: MediaElement, readyState: Int) = Unit
override fun onMetadataChange(mediaElement: MediaElement, metaData: MediaElement.Metadata) = Unit
override fun onLoadProgress(mediaElement: MediaElement, progressInfo: MediaElement.LoadProgressInfo) = Unit
override fun onVolumeChange(mediaElement: MediaElement, volume: Double, muted: Boolean) = Unit
override fun onTimeChange(mediaElement: MediaElement, time: Double) = Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package mozilla.components.browser.engine.gecko.media
import mozilla.components.concept.engine.media.Media
import mozilla.components.support.test.argumentCaptor
import mozilla.components.support.test.mock
import mozilla.components.test.ReflectionUtils
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
Expand Down Expand Up @@ -84,4 +85,38 @@ class GeckoMediaTest {
delegate.onPlaybackStateChange(mediaElement, MediaElement.MEDIA_STATE_PLAYING)
verify(observer).onPlaybackStateChanged(media, Media.PlaybackState.PLAYING)
}

@Test
fun `GeckoMedia exposes Metadata`() {
val mediaElement: MediaElement = mock()

val media = GeckoMedia(mediaElement)

val captor = argumentCaptor<MediaElement.Delegate>()
verify(mediaElement).delegate = captor.capture()

assertEquals(-1.0, media.metadata.duration, 0.0001)

val delegate = captor.value

delegate.onMetadataChange(mediaElement, MockedGeckoMetadata(duration = 5.0))
assertEquals(5.0, media.metadata.duration, 0.0001)

delegate.onMetadataChange(mediaElement, MockedGeckoMetadata(duration = 572.0))
assertEquals(572.0, media.metadata.duration, 0.0001)

delegate.onMetadataChange(mediaElement, MockedGeckoMetadata(duration = 0.0))
assertEquals(0.0, media.metadata.duration, 0.0001)

delegate.onMetadataChange(mediaElement, MockedGeckoMetadata(duration = -1.0))
assertEquals(-1.0, media.metadata.duration, 0.0001)
}
}

private class MockedGeckoMetadata(
duration: Double
) : MediaElement.Metadata() {
init {
ReflectionUtils.setField(this, "duration", duration)
}
}
19 changes: 19 additions & 0 deletions components/browser/engine-gecko-nightly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ Use Gradle to download the library from [maven.mozilla.org](https://maven.mozill
implementation "org.mozilla.components:browser-engine-gecko-nightly:{latest-version}"
```

### Integration with the Glean SDK

The [Glean SDK](../../../components/service/glean/README.md) can be used to collect [Gecko Telemetry](https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/index.html).
Applications using both this component and the Glean SDK should setup the Gecko Telemetry delegate
as shown below:

```Kotlin
val builder = GeckoRuntimeSettings.Builder()
val runtimeSettings = builder
.telemetryDelegate(GeckoGleanAdapter()) // Sets up the delegate!
.build()
// Create the Gecko runtime.
GeckoRuntime.create(context, runtimeSettings)
```

#### Adding new metrics

New Gecko metrics can be added as described [in the Firefox Telemetry docs](https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/start/adding-a-new-probe.html).

## License

This Source Code Form is subject to the terms of the Mozilla Public
Expand Down
29 changes: 29 additions & 0 deletions components/browser/engine-gecko-nightly/metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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/.

# IMPORTANT NOTE: this file is here only as a safety measure, to make
# sure the correct code is generated even though the GeckoView AAR file
# reports an empty metrics.yaml file. The metric in this file is currently
# disabled and not supposed to collect any data.

$schema: moz://mozilla.org/schemas/glean/metrics/1-0-0

test.glean.geckoview:
streaming:
type: timing_distribution
gecko_datapoint: TELEMETRY_TEST_STREAMING
disabled: true
description: |
A test-only, disabled metric. This is required to guarantee
that a `GleanGeckoHistogramMapping` is always generated, even
though the GeckoView AAR exports no metric. Please note that
the data-review field below contains no review, since this
metric is disabled and not allowed to collect any data.
bugs:
- 1566374
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1566374
notification_emails:
- [email protected]
expires: never
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* 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 mozilla.components.browser.engine.gecko.glean

import mozilla.components.browser.engine.gecko.GleanMetrics.GleanGeckoHistogramMapping
import org.mozilla.geckoview.RuntimeTelemetry

/**
* This implements a [RuntimeTelemetry.Delegate] that dispatches Gecko runtime
* telemetry to the Glean SDK.
*
* Metrics defined in the `metrics.yaml` file in Gecko's mozilla-central repository
* will be automatically dispatched to the Glean SDK and sent through the requested
* pings.
*
* This can be used, in products collecting data through the Glean SDK, by
* providing an instance to `GeckoRuntimeSettings.Builder().telemetryDelegate`.
*/
class GeckoAdapter : RuntimeTelemetry.Delegate {
override fun onTelemetryReceived(metric: RuntimeTelemetry.Metric) {
// Note that the `GleanGeckoHistogramMapping` is automatically generated at
// build time by the Glean SDK parsers.
GleanGeckoHistogramMapping[metric.name]?.accumulateSamples(metric.values)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ internal class GeckoMedia(
) : Media() {
override val controller: Controller = GeckoMediaController(mediaElement)

override var metadata: Metadata = Metadata()
internal set

init {
mediaElement.delegate = MediaDelegate(this)
}
Expand All @@ -44,7 +47,7 @@ internal class GeckoMedia(
}

private class MediaDelegate(
private val media: Media
private val media: GeckoMedia
) : MediaElement.Delegate {

override fun onPlaybackStateChange(mediaElement: MediaElement, mediaState: Int) {
Expand All @@ -63,8 +66,11 @@ private class MediaDelegate(
}
}

override fun onMetadataChange(mediaElement: MediaElement, metaData: MediaElement.Metadata) {
media.metadata = Media.Metadata(metaData.duration)
}

override fun onReadyStateChange(mediaElement: MediaElement, readyState: Int) = Unit
override fun onMetadataChange(mediaElement: MediaElement, metaData: MediaElement.Metadata) = Unit
override fun onLoadProgress(mediaElement: MediaElement, progressInfo: MediaElement.LoadProgressInfo) = Unit
override fun onVolumeChange(mediaElement: MediaElement, volume: Double, muted: Boolean) = Unit
override fun onTimeChange(mediaElement: MediaElement, time: Double) = Unit
Expand Down
Loading

0 comments on commit c766015

Please sign in to comment.