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

Commit e18ffb2

Browse files
keianhzodaoshengmu
authored andcommitted
Rebase and fixes
1 parent f603662 commit e18ffb2

File tree

10 files changed

+48
-37
lines changed

10 files changed

+48
-37
lines changed

app/src/common/shared/org/mozilla/vrbrowser/browser/Accounts.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class Accounts constructor(val context: Context) {
296296

297297
fun pollForEventsAsync(): CompletableFuture<Boolean?>? {
298298
return CoroutineScope(Dispatchers.Main).future {
299-
services.accountManager.authenticatedAccount()?.deviceConstellation()?.pollForEventsAsync()?.await()
299+
services.accountManager.authenticatedAccount()?.deviceConstellation()?.pollForCommandsAsync()?.await()
300300
}
301301
}
302302

@@ -368,8 +368,8 @@ class Accounts constructor(val context: Context) {
368368
}
369369

370370
targets?.forEach { it ->
371-
constellation.sendEventToDeviceAsync(
372-
it.id, DeviceEventOutgoing.SendTab(title, url)
371+
constellation.sendCommandToDeviceAsync(
372+
it.id, DeviceCommandOutgoing.SendTab(title, url)
373373
).await().also { if (it) GleanMetricsService.FxA.sentTab() }
374374
}
375375
}

app/src/common/shared/org/mozilla/vrbrowser/browser/BookmarksStore.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class BookmarksStore constructor(val context: Context) {
8383
}
8484

8585
// Update the folder strings after a language update
86-
fun onConfigurationChanged(newConfig: Configuration) {
86+
fun onConfigurationChanged() {
8787
titles = rootTitles(context)
8888
}
8989

app/src/common/shared/org/mozilla/vrbrowser/browser/Places.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Places(var context: Context) {
2323
var history = PlacesHistoryStorage(context)
2424

2525
fun clear() {
26-
val files = context.filesDir.listFiles { dir, name ->
26+
val files = context.filesDir.listFiles { _, name ->
2727
name.matches("places\\.sqlite.*".toRegex())
2828
}
2929
for (file in files) {

app/src/common/shared/org/mozilla/vrbrowser/browser/Services.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class Services(val context: Context, places: Places): GeckoSession.NavigationDel
6161
// Make sure we get logs out of our android-components.
6262
Log.addSink(AndroidLogSink())
6363

64-
GlobalSyncableStoreProvider.configureStore(SyncEngine.Bookmarks to places.bookmarks)
65-
GlobalSyncableStoreProvider.configureStore(SyncEngine.History to places.history)
64+
GlobalSyncableStoreProvider.configureStore(SyncEngine.Bookmarks to lazy {places.bookmarks})
65+
GlobalSyncableStoreProvider.configureStore(SyncEngine.History to lazy {places.history})
6666

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

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

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

113113
).also {
114-
it.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), true)
114+
it.registerForAccountEvents(deviceEventObserver, ProcessLifecycleOwner.get(), true)
115115
}
116116

117117
init {

app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public void onConfigurationChanged(Configuration newConfig) {
278278
mRuntime.configurationChanged(newConfig);
279279
}
280280

281-
mBookmarksStore.onConfigurationChanged(newConfig);
281+
mBookmarksStore.onConfigurationChanged();
282282
}
283283

284284
// Session Settings

app/src/common/shared/org/mozilla/vrbrowser/geolocation/GeolocationWrapper.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import kotlinx.coroutines.Dispatchers
66
import kotlinx.coroutines.GlobalScope
77
import kotlinx.coroutines.future.future
88
import kotlinx.coroutines.launch
9+
import mozilla.components.service.location.LocationService
910
import mozilla.components.service.location.MozillaLocationService
1011
import org.mozilla.vrbrowser.browser.engine.EngineProvider
1112
import org.mozilla.vrbrowser.browser.SettingsStore
@@ -22,12 +23,12 @@ object GeolocationWrapper {
2223
CoroutineScope(Dispatchers.IO).launch {
2324
locationService.fetchRegion(true)?.run {
2425
val data: GeolocationData = GeolocationData.create(countryCode, countryName)
25-
SettingsStore.getInstance(context).setGeolocationData(data.toString())
26+
SettingsStore.getInstance(context).geolocationData = data.toString()
2627
}
2728
}
2829
}
2930

30-
fun get(context: Context): CompletableFuture<MozillaLocationService.Region?> =
31+
fun get(context: Context): CompletableFuture<LocationService.Region?> =
3132
GlobalScope.future {
3233
val locationService = MozillaLocationService(
3334
context,

app/src/common/shared/org/mozilla/vrbrowser/telemetry/GleanMetricsService.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public static void stopPageLoadTimeWithURI(String uri) {
8484
}
8585

8686
if (domainMap.add(UrlUtils.stripCommonSubdomains(uriLink.getHost()))) {
87-
Url.INSTANCE.getDomains().add();
87+
Url.INSTANCE.domains().add();
8888
}
89-
Url.INSTANCE.getVisits().add();
89+
Url.INSTANCE.visits().add();
9090

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

9797
public static void sessionStop() {
9898
domainMap.clear();
99-
Pings.INSTANCE.getSessionEnd().send();
99+
Pings.INSTANCE.sessionEnd().send();
100100
}
101101

102102
@UiThread
@@ -153,11 +153,11 @@ private static String getDefaultSearchEngineIdentifierForTelemetry() {
153153
}
154154

155155
public static void newWindowOpenEvent() {
156-
Control.INSTANCE.getOpenNewWindow().add();
156+
Control.INSTANCE.openNewWindow().add();
157157
}
158158

159159
private static void setStartupMetrics() {
160-
Distribution.INSTANCE.getChannelName().set(DeviceType.isOculusBuild() ? "oculusvr" : BuildConfig.FLAVOR_platform);
160+
Distribution.INSTANCE.channelName().set(DeviceType.isOculusBuild() ? "oculusvr" : BuildConfig.FLAVOR_platform);
161161
}
162162

163163
@VisibleForTesting
@@ -168,29 +168,29 @@ public static void testSetStartupMetrics() {
168168
public static class FxA {
169169

170170
public static void signIn() {
171-
FirefoxAccount.INSTANCE.getSignIn().record();
171+
FirefoxAccount.INSTANCE.signIn().record();
172172
}
173173

174174
public static void signInResult(boolean status) {
175175
Map<FirefoxAccount.signInResultKeys, String> map = new HashMap<>();
176176
map.put(FirefoxAccount.signInResultKeys.state, String.valueOf(status));
177-
FirefoxAccount.INSTANCE.getSignInResult().record(map);
177+
FirefoxAccount.INSTANCE.signInResult().record(map);
178178
}
179179

180180
public static void signOut() {
181-
FirefoxAccount.INSTANCE.getSignOut().record();
181+
FirefoxAccount.INSTANCE.signOut().record();
182182
}
183183

184184
public static void bookmarksSyncStatus(boolean status) {
185-
FirefoxAccount.INSTANCE.getBookmarksSyncStatus().set(status);
185+
FirefoxAccount.INSTANCE.bookmarksSyncStatus().set(status);
186186
}
187187

188188
public static void historySyncStatus(boolean status) {
189-
FirefoxAccount.INSTANCE.getHistorySyncStatus().set(status);
189+
FirefoxAccount.INSTANCE.historySyncStatus().set(status);
190190
}
191191

192192
public static void sentTab() {
193-
FirefoxAccount.INSTANCE.getTabSent().add();
193+
FirefoxAccount.INSTANCE.tabSent().add();
194194
}
195195

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

219219
public static void activatedEvent() {
220-
org.mozilla.vrbrowser.GleanMetrics.Tabs.INSTANCE.getActivated().add();
220+
org.mozilla.vrbrowser.GleanMetrics.Tabs.INSTANCE.activated().add();
221221
}
222222
}
223223
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
apply from: 'versions.gradle'
55
addRepos(repositories)
66
dependencies {
7-
classpath 'com.android.tools.build:gradle:3.6.1'
7+
classpath 'com.android.tools.build:gradle:3.6.3'
88
classpath "org.mozilla.components:tooling-glean-gradle:$versions.android_components"
99
classpath "$deps.kotlin.plugin"
1010

docs/metrics.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ The following metrics are added to the ping:
6363
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.
6464

6565

66+
This ping includes the [client id](https://mozilla.github.io/glean/book/user/pings/index.html#the-client_info-section).
67+
68+
**Data reviews for this ping:**
69+
70+
- <https://github.com/MozillaReality/FirefoxReality/pull/2241#issuecomment-557740258>
71+
72+
**Bugs related to this ping:**
73+
74+
- <https://github.com/MozillaReality/FirefoxReality/issues/2230>
75+
6676
The following metrics are added to the ping:
6777

6878
| Name | Type | Description | Data reviews | Extras | Expiration |

versions.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ def versions = [:]
2525
// GeckoView versions can be found here:
2626
// https://maven.mozilla.org/?prefix=maven2/org/mozilla/geckoview/
2727
versions.gecko_view = "78.0.20200507085231"
28-
versions.android_components = "37.0.0"
28+
versions.android_components = "40.0.0"
2929
// Note that android-components also depends on application-services,
3030
// and in fact is our main source of appservices-related functionality.
3131
// The version number below tracks the application-services version
3232
// that we depend on directly for its rustlog package, and it's important
3333
// that it be kept insync with the version used by android-components above.
34-
versions.mozilla_appservices = "0.48.2"
34+
versions.mozilla_appservices = "0.58.2"
3535
versions.mozilla_speech = "1.0.11"
3636
versions.openwnn = "1.3.7"
3737
versions.room = "2.2.0"

0 commit comments

Comments
 (0)