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

Add logging to all accounts callbacks #2166

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/src/common/shared/org/mozilla/vrbrowser/browser/Accounts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package org.mozilla.vrbrowser.browser
import android.content.Context
import android.os.Handler
import android.os.Looper
import android.util.Log
import androidx.lifecycle.ProcessLifecycleOwner
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -56,6 +57,8 @@ class Accounts constructor(val context: Context) {

private val syncStatusObserver = object : SyncStatusObserver {
override fun onStarted() {
Log.d(LOGTAG, "Account syncing has started")

isSyncing = true
syncListeners.toMutableList().forEach {
Handler(Looper.getMainLooper()).post {
Expand All @@ -65,6 +68,8 @@ class Accounts constructor(val context: Context) {
}

override fun onIdle() {
Log.d(LOGTAG, "Account syncing has finished")

isSyncing = false
syncListeners.toMutableList().forEach {
Handler(Looper.getMainLooper()).post {
Expand All @@ -74,6 +79,8 @@ class Accounts constructor(val context: Context) {
}

override fun onError(error: Exception?) {
Log.d(LOGTAG, "There was an error while syncing the account: " + error?.localizedMessage)

isSyncing = false
syncListeners.toMutableList().forEach {
Handler(Looper.getMainLooper()).post {
Expand All @@ -85,6 +92,8 @@ class Accounts constructor(val context: Context) {

private val deviceConstellationObserver = object : DeviceConstellationObserver {
override fun onDevicesUpdate(constellation: ConstellationState) {
Log.d(LOGTAG, "Device constellation has been updated: " + constellation.otherDevices.toString())

otherDevices = constellation.otherDevices
deviceConstellationListeners.toMutableList().forEach {
Handler(Looper.getMainLooper()).post {
Expand All @@ -96,6 +105,8 @@ class Accounts constructor(val context: Context) {

private val accountObserver = object : AccountObserver {
override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
Log.d(LOGTAG, "The user has been successfully logged in")

accountStatus = AccountStatus.SIGNED_IN

// Enable syncing after signing in
Expand All @@ -119,6 +130,8 @@ class Accounts constructor(val context: Context) {
}

override fun onAuthenticationProblems() {
Log.d(LOGTAG, "There was a problem authenticating the user")

accountStatus = AccountStatus.NEEDS_RECONNECT
accountListeners.toMutableList().forEach {
Handler(Looper.getMainLooper()).post {
Expand All @@ -128,6 +141,8 @@ class Accounts constructor(val context: Context) {
}

override fun onLoggedOut() {
Log.d(LOGTAG, "The user has been logged out")

accountStatus = AccountStatus.SIGNED_OUT
accountListeners.toMutableList().forEach {
Handler(Looper.getMainLooper()).post {
Expand All @@ -137,6 +152,8 @@ class Accounts constructor(val context: Context) {
}

override fun onProfileUpdated(profile: Profile) {
Log.d(LOGTAG, "The user profile has been updated")

accountListeners.toMutableList().forEach {
Handler(Looper.getMainLooper()).post {
it.onProfileUpdated(profile)
Expand Down