Skip to content
Open
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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ desugar-jdk = "com.android.tools:desugar_jdk_libs:2.1.5"
device-names = "com.jaredrummler:android-device-names:2.1.1"
encryptedlogging = "com.automattic:encryptedlogging:1.1.1"
eventhorizon = "com.automattic:eventhorizon:pocket-casts-2026-08-13_07-58-34"
engage = "com.google.android.engage:engage-core:1.5.12"
engage = "com.google.android.engage:engage-core:1.6.0"
flexbox = "com.google.android.flexbox:flexbox:3.0.0"
guava = "com.google.guava:guava:33.6.0-android" # Required to fix conflict between versions in exoplayer and workmanager
jsonassert = "org.skyscreamer:jsonassert:1.5.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package au.com.shiftyjelly.pocketcasts.engage
import android.content.Context
import au.com.shiftyjelly.pocketcasts.repositories.external.ExternalDataManager
import au.com.shiftyjelly.pocketcasts.repositories.sync.SyncManager
import com.google.android.engage.common.datamodel.ClusterType
import com.google.android.engage.service.AppEngagePublishClient
import com.google.android.engage.service.ServiceAvailabilityRequest
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
Expand All @@ -29,7 +31,11 @@ class EngageSdkAccountSync(
syncJob = coroutineScope.launch {
syncManager.isLoggedInObservable.asFlow().collectLatest { isSignedIn ->
try {
if (client.isServiceAvailable.await()) {
val request = ServiceAvailabilityRequest.Builder()
.addIntendedClusterType(ClusterType.TYPE_ENGAGEMENT)
.build()
val isAvailableMap = client.isServiceAvailable(request).await()
if (isAvailableMap[ClusterType.TYPE_ENGAGEMENT] == true) {
val data = dataManager.getEngageData(isSignedIn)
service.updateUserAccount(data).await()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import androidx.work.WorkerParameters
import au.com.shiftyjelly.pocketcasts.engage.EngageSdkBridge.Companion.TAG
import au.com.shiftyjelly.pocketcasts.repositories.external.ExternalDataManager
import au.com.shiftyjelly.pocketcasts.repositories.sync.SyncManager
import com.google.android.engage.common.datamodel.ClusterType
import com.google.android.engage.service.AppEngageErrorCode
import com.google.android.engage.service.AppEngageException
import com.google.android.engage.service.AppEngagePublishClient
import com.google.android.engage.service.ServiceAvailabilityRequest
import com.google.android.gms.tasks.Task
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
Expand Down Expand Up @@ -136,7 +138,7 @@ internal abstract class ClusterSyncWorker(
Result.failure()
}

!client.isServiceAvailable.await() -> {
!isServiceAvailable() -> {
Timber.tag(TAG).d("Engage SDK service is not avaialable. Failing '$type' cluster sync.")
Result.failure()
}
Expand All @@ -145,6 +147,25 @@ internal abstract class ClusterSyncWorker(
}
}

private suspend fun isServiceAvailable(): Boolean {
return try {
val clusterType = when (type) {
"Recommendations" -> ClusterType.TYPE_RECOMMENDATION
"Continuation" -> ClusterType.TYPE_CONTINUATION
"Featured" -> ClusterType.TYPE_FEATURED
else -> ClusterType.TYPE_UNKNOWN
}
val request = ServiceAvailabilityRequest.Builder()
.addIntendedClusterType(clusterType)
.build()
val availabilityMap = client.isServiceAvailable(request).await()
availabilityMap[clusterType] == true
} catch (e: Throwable) {
Timber.tag(TAG).d(e, "Failed to check service availability for '$type' cluster.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this change. I'm having a bit of trouble testing it. It's giving me the following error. Any ideas what I might be doing wrong?

Engage SDK service is not avaialable. Failing 'Recommendations' cluster sync.
Engage SDK service is not avaialable. Failing 'Continuation' cluster sync.
Engage SDK service is not avaialable. Failing 'Featured' cluster sync.

false
}
}

private suspend fun <T> Task<T>.awaitSafe(): WorkerResult {
return try {
await()
Expand Down
Loading