From 470f191175926fae1bb6db9ca60ee2fcdbde8e65 Mon Sep 17 00:00:00 2001 From: Amulya Gaur Date: Fri, 10 Jul 2026 18:35:34 +0530 Subject: [PATCH 01/10] Update EngageWorker.kt --- .../example/snippets/engage/EngageWorker.kt | 224 ++++++++++++++++++ 1 file changed, 224 insertions(+) diff --git a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt index 9d753663e..3c9109623 100644 --- a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt +++ b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt @@ -80,7 +80,231 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine if (getContinuationData().isEmpty()) { val deleteTask = client.deleteContinuationCluster() return publishAndProvideResult(deleteTask) + }/* + * Copyright 2026 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.snippets.engage + +// [START android_engage_worker_implementation] +import android.content.Context +import android.util.Log +import androidx.work.CoroutineWorker +import androidx.work.WorkerParameters +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.AppEngagePublishStatusCode +import com.google.android.engage.service.PublishStatusRequest +import com.google.android.engage.service.ServiceAvailabilityRequest +import com.google.android.gms.tasks.Task +import kotlinx.coroutines.tasks.await + +// [START_EXCLUDE silent] +@SuppressWarnings("unused") +// [END_EXCLUDE] +class EngageWorker(context: Context, workerParams: WorkerParameters) : CoroutineWorker(context, workerParams) { + // Replace {AppEngagePublishClient} with the "client" class found in references/schemas/{VERTICAL}.md. + // Client class can vary based on app's vertical. + // Refer to the references/schemas/{VERTICAL}.md to find the right class. + // This is an example of using AppEngagePublishClient. + private val client = AppEngagePublishClient(context) + private val clusterRequestFactory = ClusterRequestFactory(context) + + override suspend fun doWork(): Result { + if (runAttemptCount > Constants.MAX_PUBLISHING_ATTEMPTS) { + // If we keep failing, report it as a service error before giving up. + updatePublishStatus(AppEngagePublishStatusCode.NOT_PUBLISHED_SERVICE_ERROR) + return Result.failure() + } + + val publishType = inputData.getString(Constants.PUBLISH_TYPE_KEY) + val intendedClusterType = when (publishType) { + Constants.PUBLISH_TYPE_RECOMMENDATIONS -> ClusterType.TYPE_RECOMMENDATION + Constants.PUBLISH_TYPE_FEATURED -> ClusterType.TYPE_FEATURED + Constants.PUBLISH_TYPE_CONTINUATION -> ClusterType.TYPE_CONTINUATION + else -> ClusterType.TYPE_UNKNOWN + } + + if (intendedClusterType != ClusterType.TYPE_UNKNOWN) { + val request = ServiceAvailabilityRequest.Builder() + .addIntendedClusterType(intendedClusterType) + .build() + val availabilityMap = client.isServiceAvailable(request).await() + if (availabilityMap[intendedClusterType] != true) { + Log.e("EngageWorker", "Service not available for cluster type: $intendedClusterType") + return Result.failure() + } + } else { + return Result.failure() + } + + return when (publishType) { + Constants.PUBLISH_TYPE_RECOMMENDATIONS -> publishRecommendations() + // Constants.PUBLISH_TYPE_FEATURED -> publishFeatured() + Constants.PUBLISH_TYPE_CONTINUATION -> publishContinuation() + Constants.PUBLISH_TYPE_USER_ACCOUNT_MANAGEMENT -> publishUserAccountManagement() + else -> Result.failure() + } + } + + // Use similar patterns for other clusters (Featured, Continuation, FoodShoppingList, Reservation etc.) + private suspend fun publishRecommendations(): Result { + val publishTask: Task = + client.publishRecommendationClusters( + clusterRequestFactory.constructRecommendationClustersRequest() + ) + return publishAndProvideResult(publishTask) + } + + private suspend fun publishContinuation(): Result { + // Empty Continuation Guard: If there is no continuation content, + // we must delete the cluster instead of publishing an empty one on the UI. + if (getContinuationData().isEmpty()) { + val deleteTask = client.deleteContinuationCluster() + return publishAndProvideResult(deleteTask) + } + + val publishTask: Task = + client.publishContinuationCluster( + clusterRequestFactory.constructContinuationClusterRequest() + ) + return publishAndProvideResult(publishTask) + } + + private suspend fun publishUserAccountManagement(): Result { + val publishTask: Task + if (isAccountSignedIn()) { + // If signed in, we delete the sign-in card. + publishTask = client.deleteUserManagementCluster() + return publishAndProvideResult(publishTask) + } else { + // If not signed in, we publish the sign-in card. + // Note: Even though we are publishing a card, the status code is NOT_PUBLISHED_REQUIRES_SIGN_IN + // because the actual content (recommendations/continuation) is not published. + publishTask = + client.publishUserAccountManagementRequest( + clusterRequestFactory.constructUserAccountManagementClusterRequest() + ) + return try { + publishTask.await() + updatePublishStatus(AppEngagePublishStatusCode.NOT_PUBLISHED_REQUIRES_SIGN_IN) + Result.success() + } catch (publishException: Exception) { + handlePublishException(publishException) + } + } + } + + private fun isAccountSignedIn(): Boolean { + // Implement your app's sign-in check logic here. + // [START_EXCLUDE] + return true + // [END_EXCLUDE] + } + + private fun getContinuationData(): List { + // Implement your app's data loading logic here. + // [START_EXCLUDE] + return emptyList() + // [END_EXCLUDE] + } + + private suspend fun publishAndProvideResult( + publishTask: Task + ): Result { + return try { + // An AppEngageException may occur while publishing, so we may not be able to await the result. + publishTask.await() + // Update status to PUBLISHED only after successful publication. + updatePublishStatus(AppEngagePublishStatusCode.PUBLISHED) + Result.success() + } catch (publishException: Exception) { + handlePublishException(publishException) + } + } + + private fun handlePublishException(publishException: Exception): Result { + val appEngageException = publishException as? AppEngageException + if (appEngageException != null) { + logPublishing(appEngageException) + + // Map AppEngageException error codes to PublishStatusCodes + val errorStatusCode = when (appEngageException.errorCode) { + AppEngageErrorCode.SERVICE_CALL_INVALID_ARGUMENT -> + AppEngagePublishStatusCode.NOT_PUBLISHED_CLIENT_ERROR + + AppEngageErrorCode.SERVICE_CALL_PERMISSION_DENIED -> + AppEngagePublishStatusCode.NOT_PUBLISHED_CLIENT_ERROR + + else -> + AppEngagePublishStatusCode.NOT_PUBLISHED_SERVICE_ERROR + } + updatePublishStatus(errorStatusCode) + + // Some errors are recoverable, such as a threading issue, some are unrecoverable + // such as a cluster not containing all necessary fields. If an error is recoverable, we + // should attempt to publish again. Setting the result to retry means WorkManager will + // attempt to run the worker again, thus attempting to publish again. + return if (isErrorRecoverable(appEngageException)) Result.retry() else Result.failure() + } + return Result.failure() + } + + private fun updatePublishStatus(statusCode: Int) { + client + .updatePublishStatus(PublishStatusRequest.Builder().setStatusCode(statusCode).build()) + .addOnSuccessListener { + Log.i(TAG, "Successfully updated publish status code to $statusCode") + } + .addOnFailureListener { exception -> + Log.e(TAG, "Failed to update publish status code to $statusCode\n${exception.stackTrace}") + } + } + + private fun logPublishing(publishingException: AppEngageException) { + val message = when (publishingException.errorCode) { + AppEngageErrorCode.SERVICE_NOT_FOUND -> "Service not found" + AppEngageErrorCode.SERVICE_CALL_EXECUTION_FAILURE -> "Execution failure" + AppEngageErrorCode.SERVICE_NOT_AVAILABLE -> "Service not available" + AppEngageErrorCode.SERVICE_CALL_PERMISSION_DENIED -> "Permission denied" + AppEngageErrorCode.SERVICE_CALL_INVALID_ARGUMENT -> "Invalid argument" + AppEngageErrorCode.SERVICE_CALL_INTERNAL -> "Internal error" + AppEngageErrorCode.SERVICE_CALL_RESOURCE_EXHAUSTED -> "Resource exhausted" + else -> "Unknown error" + } + Log.d(TAG, message) + } + + private fun isErrorRecoverable(publishingException: AppEngageException): Boolean { + return when (publishingException.errorCode) { + // Recoverable Error codes + AppEngageErrorCode.SERVICE_CALL_EXECUTION_FAILURE, + AppEngageErrorCode.SERVICE_CALL_INTERNAL, + AppEngageErrorCode.SERVICE_CALL_RESOURCE_EXHAUSTED -> true + // Non recoverable error codes + AppEngageErrorCode.SERVICE_NOT_FOUND, + AppEngageErrorCode.SERVICE_CALL_INVALID_ARGUMENT, + AppEngageErrorCode.SERVICE_CALL_PERMISSION_DENIED, + AppEngageErrorCode.SERVICE_NOT_AVAILABLE -> false + else -> false } + } +} +// [END android_engage_worker_implementation] val publishTask: Task = client.publishContinuationCluster( From 13fd0fb94a6d4ce372cdf775fa2db44ab8ed5bc2 Mon Sep 17 00:00:00 2001 From: Amulya Gaur Date: Fri, 10 Jul 2026 18:43:37 +0530 Subject: [PATCH 02/10] Update EngageWorker.kt --- .../example/snippets/engage/EngageWorker.kt | 210 ------------------ 1 file changed, 210 deletions(-) diff --git a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt index 3c9109623..a83d0bd5c 100644 --- a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt +++ b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt @@ -16,88 +16,6 @@ package com.example.snippets.engage -// [START android_engage_worker_implementation] -import android.content.Context -import android.util.Log -import androidx.work.CoroutineWorker -import androidx.work.WorkerParameters -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.AppEngagePublishStatusCode -import com.google.android.engage.service.PublishStatusRequest -import com.google.android.gms.tasks.Task -import kotlinx.coroutines.tasks.await - -// [START_EXCLUDE silent] -@SuppressWarnings("unused") -// [END_EXCLUDE] -class EngageWorker(context: Context, workerParams: WorkerParameters) : CoroutineWorker(context, workerParams) { - // Replace {AppEngagePublishClient} with the "client" class found in references/schemas/{VERTICAL}.md. - // Client class can vary based on app's vertical. - // Refer to the references/schemas/{VERTICAL}.md to find the right class. - // This is an example of using AppEngagePublishClient. - private val client = AppEngagePublishClient(context) - private val clusterRequestFactory = ClusterRequestFactory(context) - - override suspend fun doWork(): Result { - if (runAttemptCount > Constants.MAX_PUBLISHING_ATTEMPTS) { - // If we keep failing, report it as a service error before giving up. - updatePublishStatus(AppEngagePublishStatusCode.NOT_PUBLISHED_SERVICE_ERROR) - return Result.failure() - } - - // Check if engage service is available before publishing. - val isAvailable = client.isServiceAvailable.await() - - // If the service is not available, do not attempt to publish and indicate failure. - if (!isAvailable) { - return Result.failure() - } - - val publishType = inputData.getString(Constants.PUBLISH_TYPE_KEY) - return when (publishType) { - Constants.PUBLISH_TYPE_RECOMMENDATIONS -> publishRecommendations() - // Constants.PUBLISH_TYPE_FEATURED -> publishFeatured() - Constants.PUBLISH_TYPE_CONTINUATION -> publishContinuation() - Constants.PUBLISH_TYPE_USER_ACCOUNT_MANAGEMENT -> publishUserAccountManagement() - else -> Result.failure() - } - } - - // Use similar patterns for other clusters (Featured, Continuation, FoodShoppingList, Reservation etc.) - private suspend fun publishRecommendations(): Result { - val publishTask: Task = - client.publishRecommendationClusters( - clusterRequestFactory.constructRecommendationClustersRequest() - ) - return publishAndProvideResult(publishTask) - } - - private suspend fun publishContinuation(): Result { - // Empty Continuation Guard: If there is no continuation content, - // we must delete the cluster instead of publishing an empty one on the UI. - if (getContinuationData().isEmpty()) { - val deleteTask = client.deleteContinuationCluster() - return publishAndProvideResult(deleteTask) - }/* - * Copyright 2026 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.snippets.engage - // [START android_engage_worker_implementation] import android.content.Context import android.util.Log @@ -304,132 +222,4 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine } } } -// [END android_engage_worker_implementation] - - val publishTask: Task = - client.publishContinuationCluster( - clusterRequestFactory.constructContinuationClusterRequest() - ) - return publishAndProvideResult(publishTask) - } - - private suspend fun publishUserAccountManagement(): Result { - val publishTask: Task - if (isAccountSignedIn()) { - // If signed in, we delete the sign-in card. - publishTask = client.deleteUserManagementCluster() - return publishAndProvideResult(publishTask) - } else { - // If not signed in, we publish the sign-in card. - // Note: Even though we are publishing a card, the status code is NOT_PUBLISHED_REQUIRES_SIGN_IN - // because the actual content (recommendations/continuation) is not published. - publishTask = - client.publishUserAccountManagementRequest( - clusterRequestFactory.constructUserAccountManagementClusterRequest() - ) - return try { - publishTask.await() - updatePublishStatus(AppEngagePublishStatusCode.NOT_PUBLISHED_REQUIRES_SIGN_IN) - Result.success() - } catch (publishException: Exception) { - handlePublishException(publishException) - } - } - } - - private fun isAccountSignedIn(): Boolean { - // Implement your app's sign-in check logic here. - // [START_EXCLUDE] - return true - // [END_EXCLUDE] - } - - private fun getContinuationData(): List { - // Implement your app's data loading logic here. - // [START_EXCLUDE] - return emptyList() - // [END_EXCLUDE] - } - - private suspend fun publishAndProvideResult( - publishTask: Task - ): Result { - return try { - // An AppEngageException may occur while publishing, so we may not be able to await the result. - publishTask.await() - // Update status to PUBLISHED only after successful publication. - updatePublishStatus(AppEngagePublishStatusCode.PUBLISHED) - Result.success() - } catch (publishException: Exception) { - handlePublishException(publishException) - } - } - - private fun handlePublishException(publishException: Exception): Result { - val appEngageException = publishException as? AppEngageException - if (appEngageException != null) { - logPublishing(appEngageException) - - // Map AppEngageException error codes to PublishStatusCodes - val errorStatusCode = when (appEngageException.errorCode) { - AppEngageErrorCode.SERVICE_CALL_INVALID_ARGUMENT -> - AppEngagePublishStatusCode.NOT_PUBLISHED_CLIENT_ERROR - - AppEngageErrorCode.SERVICE_CALL_PERMISSION_DENIED -> - AppEngagePublishStatusCode.NOT_PUBLISHED_CLIENT_ERROR - - else -> - AppEngagePublishStatusCode.NOT_PUBLISHED_SERVICE_ERROR - } - updatePublishStatus(errorStatusCode) - - // Some errors are recoverable, such as a threading issue, some are unrecoverable - // such as a cluster not containing all necessary fields. If an error is recoverable, we - // should attempt to publish again. Setting the result to retry means WorkManager will - // attempt to run the worker again, thus attempting to publish again. - return if (isErrorRecoverable(appEngageException)) Result.retry() else Result.failure() - } - return Result.failure() - } - - private fun updatePublishStatus(statusCode: Int) { - client - .updatePublishStatus(PublishStatusRequest.Builder().setStatusCode(statusCode).build()) - .addOnSuccessListener { - Log.i(TAG, "Successfully updated publish status code to $statusCode") - } - .addOnFailureListener { exception -> - Log.e(TAG, "Failed to update publish status code to $statusCode\n${exception.stackTrace}") - } - } - - private fun logPublishing(publishingException: AppEngageException) { - val message = when (publishingException.errorCode) { - AppEngageErrorCode.SERVICE_NOT_FOUND -> "Service not found" - AppEngageErrorCode.SERVICE_CALL_EXECUTION_FAILURE -> "Execution failure" - AppEngageErrorCode.SERVICE_NOT_AVAILABLE -> "Service not available" - AppEngageErrorCode.SERVICE_CALL_PERMISSION_DENIED -> "Permission denied" - AppEngageErrorCode.SERVICE_CALL_INVALID_ARGUMENT -> "Invalid argument" - AppEngageErrorCode.SERVICE_CALL_INTERNAL -> "Internal error" - AppEngageErrorCode.SERVICE_CALL_RESOURCE_EXHAUSTED -> "Resource exhausted" - else -> "Unknown error" - } - Log.d(TAG, message) - } - - private fun isErrorRecoverable(publishingException: AppEngageException): Boolean { - return when (publishingException.errorCode) { - // Recoverable Error codes - AppEngageErrorCode.SERVICE_CALL_EXECUTION_FAILURE, - AppEngageErrorCode.SERVICE_CALL_INTERNAL, - AppEngageErrorCode.SERVICE_CALL_RESOURCE_EXHAUSTED -> true - // Non recoverable error codes - AppEngageErrorCode.SERVICE_NOT_FOUND, - AppEngageErrorCode.SERVICE_CALL_INVALID_ARGUMENT, - AppEngageErrorCode.SERVICE_CALL_PERMISSION_DENIED, - AppEngageErrorCode.SERVICE_NOT_AVAILABLE -> false - else -> false - } - } -} // [END android_engage_worker_implementation] From eb6702ad7c3cccb19a170a4ec907eade1aafc466 Mon Sep 17 00:00:00 2001 From: Amulya Gaur Date: Fri, 10 Jul 2026 19:31:12 +0530 Subject: [PATCH 03/10] Update EngageWorker.ktFix EngageWorker: Remove incorrect else block in availability check --- .../src/main/java/com/example/snippets/engage/EngageWorker.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt index a83d0bd5c..31e164032 100644 --- a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt +++ b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt @@ -66,8 +66,6 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine Log.e("EngageWorker", "Service not available for cluster type: $intendedClusterType") return Result.failure() } - } else { - return Result.failure() } return when (publishType) { @@ -189,7 +187,7 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine Log.i(TAG, "Successfully updated publish status code to $statusCode") } .addOnFailureListener { exception -> - Log.e(TAG, "Failed to update publish status code to $statusCode\n${exception.stackTrace}") + Log.e(TAG, "Failed to update publish status code to $statusCode\\n${exception.stackTrace}") } } From 611f4b9ff451c0433ff95908ed18da99da5631ce Mon Sep 17 00:00:00 2001 From: Amulya Gaur Date: Sat, 11 Jul 2026 18:42:56 +0530 Subject: [PATCH 04/10] Define companion object TAG for EngageWorker loggingUpdate EngageWorker.kt --- .../main/java/com/example/snippets/engage/EngageWorker.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt index 31e164032..210f4cbf4 100644 --- a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt +++ b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt @@ -63,7 +63,7 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine .build() val availabilityMap = client.isServiceAvailable(request).await() if (availabilityMap[intendedClusterType] != true) { - Log.e("EngageWorker", "Service not available for cluster type: $intendedClusterType") + Log.e(TAG, "Service not available for cluster type: $intendedClusterType") return Result.failure() } } @@ -187,7 +187,7 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine Log.i(TAG, "Successfully updated publish status code to $statusCode") } .addOnFailureListener { exception -> - Log.e(TAG, "Failed to update publish status code to $statusCode\\n${exception.stackTrace}") + Log.e(TAG, "Failed to update publish status code to $statusCode\n${exception.stackTrace}") } } @@ -219,5 +219,9 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine else -> false } } + + companion object { + private const val TAG = "EngageWorker" + } } // [END android_engage_worker_implementation] From 5f597af95a07f6a55ed73fe903ffcaf01cb48d22 Mon Sep 17 00:00:00 2001 From: Amulya Gaur Date: Sat, 11 Jul 2026 19:05:45 +0530 Subject: [PATCH 05/10] Update EngageWorker.kt --- misc/src/main/java/com/example/snippets/engage/EngageWorker.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt index 210f4cbf4..1d28fb47d 100644 --- a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt +++ b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt @@ -54,6 +54,7 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine Constants.PUBLISH_TYPE_RECOMMENDATIONS -> ClusterType.TYPE_RECOMMENDATION Constants.PUBLISH_TYPE_FEATURED -> ClusterType.TYPE_FEATURED Constants.PUBLISH_TYPE_CONTINUATION -> ClusterType.TYPE_CONTINUATION + Constants.PUBLISH_TYPE_USER_ACCOUNT_MANAGEMENT -> ClusterType.TYPE_ENGAGEMENT else -> ClusterType.TYPE_UNKNOWN } From a380924eed23c85c6e4b6db28314d9edbf87635b Mon Sep 17 00:00:00 2001 From: Amulya Gaur Date: Sat, 11 Jul 2026 19:51:56 +0530 Subject: [PATCH 06/10] Update EngageWorker.kt --- misc/src/main/java/com/example/snippets/engage/EngageWorker.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt index 1d28fb47d..e872266b5 100644 --- a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt +++ b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt @@ -188,7 +188,8 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine Log.i(TAG, "Successfully updated publish status code to $statusCode") } .addOnFailureListener { exception -> - Log.e(TAG, "Failed to update publish status code to $statusCode\n${exception.stackTrace}") + Log.e(TAG, "Failed to update publish status code to $statusCode +${exception.stackTrace}") } } From 53b7837b447014d4a4d456c571cdd810a730e4f8 Mon Sep 17 00:00:00 2001 From: Amulya Gaur Date: Sat, 11 Jul 2026 19:53:30 +0530 Subject: [PATCH 07/10] Update EngageWorker.ktMap PUBLISH_TYPE_USER_ACCOUNT_MANAGEMENT to ClusterType.TYPE_ENGAGEMENT in intendedClusterType --- misc/src/main/java/com/example/snippets/engage/EngageWorker.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt index e872266b5..1b8b1c527 100644 --- a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt +++ b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt @@ -227,3 +227,4 @@ ${exception.stackTrace}") } } // [END android_engage_worker_implementation] + From 67c0b20fab16e6280d64899e11a5b21afd1afaff Mon Sep 17 00:00:00 2001 From: Amulya Gaur Date: Sat, 11 Jul 2026 20:13:42 +0530 Subject: [PATCH 08/10] Update EngageWorker.kt --- .../main/java/com/example/snippets/engage/EngageWorker.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt index 1b8b1c527..17a20db36 100644 --- a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt +++ b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt @@ -64,7 +64,6 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine .build() val availabilityMap = client.isServiceAvailable(request).await() if (availabilityMap[intendedClusterType] != true) { - Log.e(TAG, "Service not available for cluster type: $intendedClusterType") return Result.failure() } } @@ -185,11 +184,10 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine client .updatePublishStatus(PublishStatusRequest.Builder().setStatusCode(statusCode).build()) .addOnSuccessListener { - Log.i(TAG, "Successfully updated publish status code to $statusCode") + Log.i(TAG, "Successfully updated publish status code to ${statusCode}") } .addOnFailureListener { exception -> - Log.e(TAG, "Failed to update publish status code to $statusCode -${exception.stackTrace}") + Log.e(TAG, "Failed to update publish status code to ${statusCode}\n${exception.stackTrace}") } } @@ -227,4 +225,3 @@ ${exception.stackTrace}") } } // [END android_engage_worker_implementation] - From 5b52da457628e752074eee1816dffdeb3c9c74b7 Mon Sep 17 00:00:00 2001 From: Amulya Gaur Date: Sat, 11 Jul 2026 20:23:18 +0530 Subject: [PATCH 09/10] Update EngageWorker.kt --- .../main/java/com/example/snippets/engage/EngageWorker.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt index 17a20db36..2ac540e35 100644 --- a/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt +++ b/misc/src/main/java/com/example/snippets/engage/EngageWorker.kt @@ -184,10 +184,10 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine client .updatePublishStatus(PublishStatusRequest.Builder().setStatusCode(statusCode).build()) .addOnSuccessListener { - Log.i(TAG, "Successfully updated publish status code to ${statusCode}") + Log.i(TAG, "Successfully updated publish status code to $statusCode") } .addOnFailureListener { exception -> - Log.e(TAG, "Failed to update publish status code to ${statusCode}\n${exception.stackTrace}") + Log.e(TAG, "Failed to update publish status code to $statusCode\n${exception.stackTrace}") } } @@ -219,9 +219,5 @@ class EngageWorker(context: Context, workerParams: WorkerParameters) : Coroutine else -> false } } - - companion object { - private const val TAG = "EngageWorker" - } } // [END android_engage_worker_implementation] From aaf9f8111e207f45bc9c234a7a2089f650158d6c Mon Sep 17 00:00:00 2001 From: Amulya Gaur Date: Sat, 11 Jul 2026 20:26:42 +0530 Subject: [PATCH 10/10] Update libs.versions.tomlBump engageCore dependency to 1.6.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 31152c735..684f322d8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -54,7 +54,7 @@ dataStore = "1.2.1" datastoreCore = "1.2.1" datastorePreferencesRxjava2 = "1.2.1" datastorePreferencesRxjava3 = "1.2.1" -engageCore = "1.5.12" +engageCore = "1.6.0" firebase-ai = "17.13.0" firebase-bom = "34.15.0" firebase-ondevice = "16.0.0-beta03"