Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Rebase and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and daoshengmu committed May 15, 2020
1 parent f603662 commit e18ffb2
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class Accounts constructor(val context: Context) {

fun pollForEventsAsync(): CompletableFuture<Boolean?>? {
return CoroutineScope(Dispatchers.Main).future {
services.accountManager.authenticatedAccount()?.deviceConstellation()?.pollForEventsAsync()?.await()
services.accountManager.authenticatedAccount()?.deviceConstellation()?.pollForCommandsAsync()?.await()
}
}

Expand Down Expand Up @@ -368,8 +368,8 @@ class Accounts constructor(val context: Context) {
}

targets?.forEach { it ->
constellation.sendEventToDeviceAsync(
it.id, DeviceEventOutgoing.SendTab(title, url)
constellation.sendCommandToDeviceAsync(
it.id, DeviceCommandOutgoing.SendTab(title, url)
).await().also { if (it) GleanMetricsService.FxA.sentTab() }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class BookmarksStore constructor(val context: Context) {
}

// Update the folder strings after a language update
fun onConfigurationChanged(newConfig: Configuration) {
fun onConfigurationChanged() {
titles = rootTitles(context)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Places(var context: Context) {
var history = PlacesHistoryStorage(context)

fun clear() {
val files = context.filesDir.listFiles { dir, name ->
val files = context.filesDir.listFiles { _, name ->
name.matches("places\\.sqlite.*".toRegex())
}
for (file in files) {
Expand Down
28 changes: 14 additions & 14 deletions app/src/common/shared/org/mozilla/vrbrowser/browser/Services.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class Services(val context: Context, places: Places): GeckoSession.NavigationDel
// Make sure we get logs out of our android-components.
Log.addSink(AndroidLogSink())

GlobalSyncableStoreProvider.configureStore(SyncEngine.Bookmarks to places.bookmarks)
GlobalSyncableStoreProvider.configureStore(SyncEngine.History to places.history)
GlobalSyncableStoreProvider.configureStore(SyncEngine.Bookmarks to lazy {places.bookmarks})
GlobalSyncableStoreProvider.configureStore(SyncEngine.History to lazy {places.history})

// TODO this really shouldn't be necessary, since WorkManager auto-initializes itself, unless
// auto-initialization is disabled in the manifest file. We don't disable the initialization,
Expand All @@ -81,26 +81,26 @@ class Services(val context: Context, places: Places): GeckoSession.NavigationDel

// Process received device events, only handling received tabs for now.
// They'll come from other FxA devices (e.g. Firefox Desktop).
private val deviceEventObserver = object : DeviceEventsObserver {
private val deviceEventObserver = object : AccountEventsObserver {
private val logTag = "DeviceEventsObserver"

override fun onEvents(events: List<DeviceEvent>) {
override fun onEvents(events: List<AccountEvent>) {
CoroutineScope(Dispatchers.Main).launch {
Logger(logTag).info("Received ${events.size} device event(s)")
val filteredEvents = events.filterIsInstance(DeviceEvent.TabReceived::class.java)
if (filteredEvents.isNotEmpty()) {
filteredEvents.map { event -> event.from?.deviceType?.let { GleanMetricsService.FxA.receivedTab(it) } }
val tabs = filteredEvents.map {
event -> event.entries
}.flatten()
tabReceivedDelegate?.onTabsReceived(tabs)
}
events
.filterIsInstance<AccountEvent.DeviceCommandIncoming>()
.map { it.command }
.filterIsInstance<DeviceCommandIncoming.TabReceived>()
.forEach { command ->
command.from?.deviceType?.let { GleanMetricsService.FxA.receivedTab(it) }
tabReceivedDelegate?.onTabsReceived(command.entries)
}
}
}
}
val accountManager = FxaAccountManager(
context = context,
serverConfig = ServerConfig.release(CLIENT_ID, REDIRECT_URL),
serverConfig = ServerConfig(Server.RELEASE, CLIENT_ID, REDIRECT_URL),
deviceConfig = DeviceConfig(
// This is a default name, and can be changed once user is logged in.
// E.g. accountManager.authenticatedAccount()?.deviceConstellation()?.setDeviceNameAsync("new name")
Expand All @@ -111,7 +111,7 @@ class Services(val context: Context, places: Places): GeckoSession.NavigationDel
syncConfig = SyncConfig(setOf(SyncEngine.History, SyncEngine.Bookmarks), syncPeriodInMinutes = 1440L)

).also {
it.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), true)
it.registerForAccountEvents(deviceEventObserver, ProcessLifecycleOwner.get(), true)
}

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public void onConfigurationChanged(Configuration newConfig) {
mRuntime.configurationChanged(newConfig);
}

mBookmarksStore.onConfigurationChanged(newConfig);
mBookmarksStore.onConfigurationChanged();
}

// Session Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.future.future
import kotlinx.coroutines.launch
import mozilla.components.service.location.LocationService
import mozilla.components.service.location.MozillaLocationService
import org.mozilla.vrbrowser.browser.engine.EngineProvider
import org.mozilla.vrbrowser.browser.SettingsStore
Expand All @@ -22,12 +23,12 @@ object GeolocationWrapper {
CoroutineScope(Dispatchers.IO).launch {
locationService.fetchRegion(true)?.run {
val data: GeolocationData = GeolocationData.create(countryCode, countryName)
SettingsStore.getInstance(context).setGeolocationData(data.toString())
SettingsStore.getInstance(context).geolocationData = data.toString()
}
}
}

fun get(context: Context): CompletableFuture<MozillaLocationService.Region?> =
fun get(context: Context): CompletableFuture<LocationService.Region?> =
GlobalScope.future {
val locationService = MozillaLocationService(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public static void stopPageLoadTimeWithURI(String uri) {
}

if (domainMap.add(UrlUtils.stripCommonSubdomains(uriLink.getHost()))) {
Url.INSTANCE.getDomains().add();
Url.INSTANCE.domains().add();
}
Url.INSTANCE.getVisits().add();
Url.INSTANCE.visits().add();

} catch (IllegalArgumentException e) {
Log.e(LOGTAG, "Invalid URL", e);
Expand All @@ -96,7 +96,7 @@ public static void stopPageLoadTimeWithURI(String uri) {

public static void sessionStop() {
domainMap.clear();
Pings.INSTANCE.getSessionEnd().send();
Pings.INSTANCE.sessionEnd().send();
}

@UiThread
Expand Down Expand Up @@ -153,11 +153,11 @@ private static String getDefaultSearchEngineIdentifierForTelemetry() {
}

public static void newWindowOpenEvent() {
Control.INSTANCE.getOpenNewWindow().add();
Control.INSTANCE.openNewWindow().add();
}

private static void setStartupMetrics() {
Distribution.INSTANCE.getChannelName().set(DeviceType.isOculusBuild() ? "oculusvr" : BuildConfig.FLAVOR_platform);
Distribution.INSTANCE.channelName().set(DeviceType.isOculusBuild() ? "oculusvr" : BuildConfig.FLAVOR_platform);
}

@VisibleForTesting
Expand All @@ -168,29 +168,29 @@ public static void testSetStartupMetrics() {
public static class FxA {

public static void signIn() {
FirefoxAccount.INSTANCE.getSignIn().record();
FirefoxAccount.INSTANCE.signIn().record();
}

public static void signInResult(boolean status) {
Map<FirefoxAccount.signInResultKeys, String> map = new HashMap<>();
map.put(FirefoxAccount.signInResultKeys.state, String.valueOf(status));
FirefoxAccount.INSTANCE.getSignInResult().record(map);
FirefoxAccount.INSTANCE.signInResult().record(map);
}

public static void signOut() {
FirefoxAccount.INSTANCE.getSignOut().record();
FirefoxAccount.INSTANCE.signOut().record();
}

public static void bookmarksSyncStatus(boolean status) {
FirefoxAccount.INSTANCE.getBookmarksSyncStatus().set(status);
FirefoxAccount.INSTANCE.bookmarksSyncStatus().set(status);
}

public static void historySyncStatus(boolean status) {
FirefoxAccount.INSTANCE.getHistorySyncStatus().set(status);
FirefoxAccount.INSTANCE.historySyncStatus().set(status);
}

public static void sentTab() {
FirefoxAccount.INSTANCE.getTabSent().add();
FirefoxAccount.INSTANCE.tabSent().add();
}

public static void receivedTab(@NonNull mozilla.components.concept.sync.DeviceType source) {
Expand All @@ -217,7 +217,7 @@ public static void openedCounter(@NonNull TabSource source) {
}

public static void activatedEvent() {
org.mozilla.vrbrowser.GleanMetrics.Tabs.INSTANCE.getActivated().add();
org.mozilla.vrbrowser.GleanMetrics.Tabs.INSTANCE.activated().add();
}
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
apply from: 'versions.gradle'
addRepos(repositories)
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.mozilla.components:tooling-glean-gradle:$versions.android_components"
classpath "$deps.kotlin.plugin"

Expand Down
10 changes: 10 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ The following metrics are added to the ping:
This ping is sent at the end of a session (when Firefox Reality switches to the background). We usually send search and UI control metrics at the end of a session.


This ping includes the [client id](https://mozilla.github.io/glean/book/user/pings/index.html#the-client_info-section).

**Data reviews for this ping:**

- <https://github.com/MozillaReality/FirefoxReality/pull/2241#issuecomment-557740258>

**Bugs related to this ping:**

- <https://github.com/MozillaReality/FirefoxReality/issues/2230>

The following metrics are added to the ping:

| Name | Type | Description | Data reviews | Extras | Expiration |
Expand Down
4 changes: 2 additions & 2 deletions versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def versions = [:]
// GeckoView versions can be found here:
// https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/
versions.gecko_view = "78.0.20200507085231"
versions.android_components = "37.0.0"
versions.android_components = "40.0.0"
// Note that android-components also depends on application-services,
// and in fact is our main source of appservices-related functionality.
// The version number below tracks the application-services version
// that we depend on directly for its rustlog package, and it's important
// that it be kept insync with the version used by android-components above.
versions.mozilla_appservices = "0.48.2"
versions.mozilla_appservices = "0.58.2"
versions.mozilla_speech = "1.0.11"
versions.openwnn = "1.3.7"
versions.room = "2.2.0"
Expand Down

0 comments on commit e18ffb2

Please sign in to comment.