Loading components/concept/sync/src/main/java/mozilla/components/concept/sync/Devices.kt +0 −9 Original line number Diff line number Diff line Loading @@ -26,15 +26,6 @@ interface DeviceConstellation : Observable<DeviceEventsObserver> { capabilities: Set<DeviceCapability> ): Deferred<Boolean> /** * Destroy current device record. * Use this when device record is no longer relevant, e.g. while logging out. On success, other * devices will no longer see the current device in their device lists. * * @return A [Deferred] that will be resolved with a success flag once operation is complete. */ fun destroyCurrentDeviceAsync(): Deferred<Boolean> /** * Ensure that all passed in [capabilities] are configured. * This may involve backend service registration, or other work involving network/disc access. Loading components/concept/sync/src/main/java/mozilla/components/concept/sync/OAuthAccount.kt +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ interface OAuthAccount : AutoCloseable { fun registerPersistenceCallback(callback: StatePersistenceCallback) fun migrateFromSessionTokenAsync(sessionToken: String, kSync: String, kXCS: String): Deferred<Boolean> fun deviceConstellation(): DeviceConstellation fun disconnectAsync(): Deferred<Boolean> fun toJSONString(): String } Loading components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/FirefoxAccount.kt +19 −0 Original line number Diff line number Diff line Loading @@ -238,6 +238,25 @@ class FirefoxAccount internal constructor( } } /** * Reset internal account state and destroy current device record. * Use this when device record is no longer relevant, e.g. while logging out. On success, other * devices will no longer see the current device in their device lists. * * @return A [Deferred] that will be resolved with a success flag once operation is complete. * Failure indicates that we may have failed to destroy current device record. Nothing to do for * the consumer; device record will be cleaned up eventually via TTL. */ override fun disconnectAsync(): Deferred<Boolean> { return scope.async { // TODO can this ever throw FxaUnauthorizedException? would that even make sense? or is that a bug? handleFxaExceptions(logger, "disconnect", { false }) { inner.disconnect() true } } } override fun deviceConstellation(): DeviceConstellation { return deviceConstellation } Loading components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/FxaDeviceConstellation.kt +0 −20 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ package mozilla.components.service.fxa import androidx.lifecycle.LifecycleOwner import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Deferred import kotlinx.coroutines.Dispatchers Loading Loading @@ -67,25 +66,6 @@ class FxaDeviceConstellation( } } override fun destroyCurrentDeviceAsync(): Deferred<Boolean> { val state = state() state?.currentDevice?.let { return scope.async { handleFxaExceptions(logger, "destroying current device") { account.disconnect() // Not sure if this is right! } } } if (state == null) { logger.warn("Asked to destroy device record, but constellation state is not available") } else { logger.warn("Asked to destroy device record, but current device record is not available") } return CompletableDeferred(false) } override fun ensureCapabilitiesAsync(capabilities: Set<DeviceCapability>): Deferred<Boolean> { return scope.async { handleFxaExceptions(logger, "ensuring capabilities") { Loading components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/manager/FxaAccountManager.kt +6 −2 Original line number Diff line number Diff line Loading @@ -490,8 +490,12 @@ open class FxaAccountManager( AccountState.NotAuthenticated -> { when (via) { Event.Logout -> { // Destroy the current device record. account.deviceConstellation().destroyCurrentDeviceAsync().await() // Clean up internal account state and destroy the current FxA device record. if (account.disconnectAsync().await()) { logger.info("Disconnected FxA account") } else { logger.warn("Failed to fully disconnect the FxA account") } // Clean up resources. profile = null account.close() Loading Loading
components/concept/sync/src/main/java/mozilla/components/concept/sync/Devices.kt +0 −9 Original line number Diff line number Diff line Loading @@ -26,15 +26,6 @@ interface DeviceConstellation : Observable<DeviceEventsObserver> { capabilities: Set<DeviceCapability> ): Deferred<Boolean> /** * Destroy current device record. * Use this when device record is no longer relevant, e.g. while logging out. On success, other * devices will no longer see the current device in their device lists. * * @return A [Deferred] that will be resolved with a success flag once operation is complete. */ fun destroyCurrentDeviceAsync(): Deferred<Boolean> /** * Ensure that all passed in [capabilities] are configured. * This may involve backend service registration, or other work involving network/disc access. Loading
components/concept/sync/src/main/java/mozilla/components/concept/sync/OAuthAccount.kt +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ interface OAuthAccount : AutoCloseable { fun registerPersistenceCallback(callback: StatePersistenceCallback) fun migrateFromSessionTokenAsync(sessionToken: String, kSync: String, kXCS: String): Deferred<Boolean> fun deviceConstellation(): DeviceConstellation fun disconnectAsync(): Deferred<Boolean> fun toJSONString(): String } Loading
components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/FirefoxAccount.kt +19 −0 Original line number Diff line number Diff line Loading @@ -238,6 +238,25 @@ class FirefoxAccount internal constructor( } } /** * Reset internal account state and destroy current device record. * Use this when device record is no longer relevant, e.g. while logging out. On success, other * devices will no longer see the current device in their device lists. * * @return A [Deferred] that will be resolved with a success flag once operation is complete. * Failure indicates that we may have failed to destroy current device record. Nothing to do for * the consumer; device record will be cleaned up eventually via TTL. */ override fun disconnectAsync(): Deferred<Boolean> { return scope.async { // TODO can this ever throw FxaUnauthorizedException? would that even make sense? or is that a bug? handleFxaExceptions(logger, "disconnect", { false }) { inner.disconnect() true } } } override fun deviceConstellation(): DeviceConstellation { return deviceConstellation } Loading
components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/FxaDeviceConstellation.kt +0 −20 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ package mozilla.components.service.fxa import androidx.lifecycle.LifecycleOwner import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Deferred import kotlinx.coroutines.Dispatchers Loading Loading @@ -67,25 +66,6 @@ class FxaDeviceConstellation( } } override fun destroyCurrentDeviceAsync(): Deferred<Boolean> { val state = state() state?.currentDevice?.let { return scope.async { handleFxaExceptions(logger, "destroying current device") { account.disconnect() // Not sure if this is right! } } } if (state == null) { logger.warn("Asked to destroy device record, but constellation state is not available") } else { logger.warn("Asked to destroy device record, but current device record is not available") } return CompletableDeferred(false) } override fun ensureCapabilitiesAsync(capabilities: Set<DeviceCapability>): Deferred<Boolean> { return scope.async { handleFxaExceptions(logger, "ensuring capabilities") { Loading
components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/manager/FxaAccountManager.kt +6 −2 Original line number Diff line number Diff line Loading @@ -490,8 +490,12 @@ open class FxaAccountManager( AccountState.NotAuthenticated -> { when (via) { Event.Logout -> { // Destroy the current device record. account.deviceConstellation().destroyCurrentDeviceAsync().await() // Clean up internal account state and destroy the current FxA device record. if (account.disconnectAsync().await()) { logger.info("Disconnected FxA account") } else { logger.warn("Failed to fully disconnect the FxA account") } // Clean up resources. profile = null account.close() Loading