Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 7.38-rc-2 into main #934

Merged
merged 15 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
7.39
-----


7.38
-----
* Updates:
Expand All @@ -20,6 +19,12 @@
([#814](https://github.com/Automattic/pocket-casts-android/issues/814)).
* Prevented crash when signing out of Android Automotive and clearing data while playback is in progress
([#919](https://github.com/Automattic/pocket-casts-android/pull/919)).

7.37.1
-----
* Bug Fixes:
* Fixed an issue that could cause users to be repeatedly logged out of the app.
([#930](https://github.com/Automattic/pocket-casts-android/pull/930)).

7.37
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,15 @@ class SyncAccountManager @Inject constructor(
AccountConstants.SIGN_IN_TYPE_KEY to AccountConstants.SignInType.Tokens.value,
AccountConstants.LOGIN_IDENTITY to loginIdentity.value
)
accountManager.addAccountExplicitly(account, refreshToken.value, userData)
val accountAdded = accountManager.addAccountExplicitly(account, refreshToken.value, userData)
accountManager.setAuthToken(account, AccountConstants.TOKEN_TYPE, accessToken.value)

// When the account was already added, set the sign in type to Tokens because the account
// does not seem to get updated with this from the userData in the addAccountExplicitly call
if (!accountAdded) {
LogBuffer.i(LogBuffer.TAG_BACKGROUND_TASKS, "Account already added, setting sign in type to Tokens")
accountManager.setUserData(account, AccountConstants.SIGN_IN_TYPE_KEY, AccountConstants.SignInType.Tokens.value)
}
}

fun signOut() {
Expand All @@ -125,6 +132,7 @@ class SyncAccountManager @Inject constructor(
fun setRefreshToken(refreshToken: RefreshToken) {
val account = getAccount() ?: return
accountManager.setPassword(account, refreshToken.value)
accountManager.setUserData(account, AccountConstants.SIGN_IN_TYPE_KEY, AccountConstants.SignInType.Tokens.value)
}

fun setAccessToken(accessToken: AccessToken) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ class SyncManagerImpl @Inject constructor(
private suspend fun fetchAccessToken(account: Account): AccessToken? {
val refreshToken = syncAccountManager.getRefreshToken(account) ?: return null
return try {
Timber.d("Refreshing the access token")
val signInType = syncAccountManager.getSignInType(account)
LogBuffer.i(LogBuffer.TAG_BACKGROUND_TASKS, "Fetching the access token, SignInType: $signInType")
val tokenResponse = downloadTokens(
email = account.name,
refreshToken = refreshToken,
syncServerManager = syncServerManager,
signInType = syncAccountManager.getSignInType(account),
signInType = signInType,
)

// update the refresh token as the expiry may have been increased
Expand Down Expand Up @@ -486,7 +486,6 @@ class SyncManagerImpl @Inject constructor(
private suspend fun downloadTokens(
email: String,
refreshToken: RefreshToken,
syncServerManager: SyncServerManager,
signInType: AccountConstants.SignInType
): LoginTokenResponse =
when (signInType) {
Expand Down Expand Up @@ -555,7 +554,7 @@ class SyncManagerImpl @Inject constructor(

private suspend fun refreshTokenSuspend(): AccessToken {
syncAccountManager.invalidateAccessToken()
return syncAccountManager.getAccessToken() ?: throw Exception("Failed to get refresh token")
return syncAccountManager.getAccessToken() ?: throw Exception("Failed to get access token")
}

private fun isHttpUnauthorized(throwable: Throwable?): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class UserManagerImpl @Inject constructor(

@OptIn(DelicateCoroutinesApi::class)
override fun signOut(playbackManager: PlaybackManager, wasInitiatedByUser: Boolean) {
val wasSignedIn = syncManager.isLoggedIn()

LogBuffer.i(LogBuffer.TAG_BACKGROUND_TASKS, "Signing out")
subscriptionManager.clearCachedStatus()
syncManager.signOut {
Expand All @@ -102,10 +104,12 @@ class UserManagerImpl @Inject constructor(
settings.setMarketingOptIn(false)
settings.setMarketingOptInNeedsSync(false)
settings.setEndOfYearModalHasBeenShown(false)
analyticsTracker.track(
AnalyticsEvent.USER_SIGNED_OUT,
mapOf(KEY_USER_INITIATED to wasInitiatedByUser)
)
if (wasSignedIn) {
analyticsTracker.track(
AnalyticsEvent.USER_SIGNED_OUT,
mapOf(KEY_USER_INITIATED to wasInitiatedByUser)
)
}
analyticsTracker.flush()
analyticsTracker.clearAllData()
analyticsTracker.refreshMetadata()
Expand Down
4 changes: 2 additions & 2 deletions version.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Version Information for Vanilla / Release builds
versionName=7.38-rc-1
versionCode=9089
versionName=7.38-rc-2
versionCode=9091