From 36b3aece2c818b820b3b493c1b00cb62bebf5b35 Mon Sep 17 00:00:00 2001 From: Ryan Morales Date: Tue, 24 Sep 2024 09:40:35 -0700 Subject: [PATCH 1/7] update presentation error to match iOS updates - rename DelegateGateNotMet` to `SuppressedByAppDeveloper`. - update conflict and suppressed by app developer error reasons to match the ones in-use in the iOS core --- .../com/adobe/marketing/mobile/services/ui/Presentation.kt | 6 +++--- .../adobe/marketing/mobile/services/ui/PresentationError.kt | 6 +++--- .../marketing/mobile/services/ui/common/AEPPresentable.kt | 5 +++-- .../mobile/services/ui/common/AEPPresentableTest.kt | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/Presentation.kt b/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/Presentation.kt index 2ed176017..c46f87127 100644 --- a/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/Presentation.kt +++ b/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/Presentation.kt @@ -37,7 +37,7 @@ sealed class Presentation>(val listener: PresentationEventLi /** * Represents an InAppMessage presentation. * @param settings the settings for the InAppMessage - * @param eventListener the listener for the getting notified about InAppMessage lifecycle events + * @param eventListener the listener for getting notifications about InAppMessage lifecycle events * @param eventHandler the event handler performing operations on the InAppMessage */ class InAppMessage( @@ -54,7 +54,7 @@ class InAppMessage( /** * Represents a FloatingButton presentation. - * @param eventListener the listener for the getting notified about FloatingButton lifecycle events + * @param eventListener the listener for getting notifications about FloatingButton lifecycle events * @param settings the settings for the FloatingButton */ class FloatingButton( @@ -72,7 +72,7 @@ class FloatingButton( /** * Represents an Alert presentation. * @param settings the settings for the Alert - * @param eventListener the listener for the getting notified about Alert lifecycle events + * @param eventListener the listener for getting notifications about Alert lifecycle events */ class Alert( val settings: AlertSettings, diff --git a/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/PresentationError.kt b/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/PresentationError.kt index a1c9caf0f..9c8416044 100644 --- a/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/PresentationError.kt +++ b/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/PresentationError.kt @@ -27,7 +27,7 @@ sealed class DismissFailed(val reason: String) : PresentationError /** * Represents a failure to show a Presentable because a conflicting presentation is already shown. */ -object ConflictingPresentation : ShowFailed("Conflicting presentation is visible.") +object ConflictingPresentation : ShowFailed("Conflict") /** * Represents a failure to show a Presentable because there is no activity to show it on. @@ -35,9 +35,9 @@ object ConflictingPresentation : ShowFailed("Conflicting presentation is visible object NoAttachableActivity : ShowFailed("No attachable activity available.") /** - * Represents a failure to show a Presentable because the delegate gate was not met. + * Represents a failure to show a Presentable because the app developer has suppressed [Presentable]s. */ -object DelegateGateNotMet : ShowFailed("PresentationDelegate suppressed the presentation from being shown.") +object SuppressedByAppDeveloper : ShowFailed("SuppressedByAppDeveloper") /** * Represents a failure to show a Presentable because it is already shown. diff --git a/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/common/AEPPresentable.kt b/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/common/AEPPresentable.kt index 8de958236..034c146b6 100644 --- a/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/common/AEPPresentable.kt +++ b/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/common/AEPPresentable.kt @@ -25,13 +25,13 @@ import com.adobe.marketing.mobile.services.ui.AlreadyDismissed import com.adobe.marketing.mobile.services.ui.AlreadyHidden import com.adobe.marketing.mobile.services.ui.AlreadyShown import com.adobe.marketing.mobile.services.ui.ConflictingPresentation -import com.adobe.marketing.mobile.services.ui.DelegateGateNotMet import com.adobe.marketing.mobile.services.ui.NoActivityToDetachFrom import com.adobe.marketing.mobile.services.ui.NoAttachableActivity import com.adobe.marketing.mobile.services.ui.Presentable import com.adobe.marketing.mobile.services.ui.Presentation import com.adobe.marketing.mobile.services.ui.PresentationDelegate import com.adobe.marketing.mobile.services.ui.PresentationUtilityProvider +import com.adobe.marketing.mobile.services.ui.SuppressedByAppDeveloper import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import java.lang.ref.WeakReference @@ -158,7 +158,8 @@ internal abstract class AEPPresentable> : if (gateDisplay()) { val canShow = (presentationDelegate?.canShow(this@AEPPresentable) ?: true) if (!canShow) { - presentation.listener.onError(this@AEPPresentable, DelegateGateNotMet) + Log.debug(ServiceConstants.LOG_TAG, LOG_SOURCE, "Presentable couldn't be displayed, PresentationDelegate#canShow states the presentable should not be displayed.") + presentation.listener.onError(this@AEPPresentable, SuppressedByAppDeveloper) return@launch } } diff --git a/code/core/src/test/java/com/adobe/marketing/mobile/services/ui/common/AEPPresentableTest.kt b/code/core/src/test/java/com/adobe/marketing/mobile/services/ui/common/AEPPresentableTest.kt index 70fb71d2c..3210f9fa6 100644 --- a/code/core/src/test/java/com/adobe/marketing/mobile/services/ui/common/AEPPresentableTest.kt +++ b/code/core/src/test/java/com/adobe/marketing/mobile/services/ui/common/AEPPresentableTest.kt @@ -21,7 +21,6 @@ import com.adobe.marketing.mobile.services.ui.Alert import com.adobe.marketing.mobile.services.ui.AlreadyDismissed import com.adobe.marketing.mobile.services.ui.AlreadyHidden import com.adobe.marketing.mobile.services.ui.AlreadyShown -import com.adobe.marketing.mobile.services.ui.DelegateGateNotMet import com.adobe.marketing.mobile.services.ui.FloatingButton import com.adobe.marketing.mobile.services.ui.InAppMessage import com.adobe.marketing.mobile.services.ui.NoActivityToDetachFrom @@ -29,6 +28,7 @@ import com.adobe.marketing.mobile.services.ui.Presentable import com.adobe.marketing.mobile.services.ui.Presentation import com.adobe.marketing.mobile.services.ui.PresentationDelegate import com.adobe.marketing.mobile.services.ui.PresentationUtilityProvider +import com.adobe.marketing.mobile.services.ui.SuppressedByAppDeveloper import com.adobe.marketing.mobile.services.ui.message.InAppMessageEventListener import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -175,7 +175,7 @@ internal class AEPPresentableTest { verify(mockPresentationDelegate).canShow(aepPresentableWithGatedDisplay) // verify that the listener is notified of the error - verify(mockPresentationListener).onError(aepPresentableWithGatedDisplay, DelegateGateNotMet) + verify(mockPresentationListener).onError(aepPresentableWithGatedDisplay, SuppressedByAppDeveloper) // verify that the lifecycle provider is called to register the listener verify(mockAppLifecycleProvider, never()).registerListener( From 62fb38a90a24d164976206e98e4b5fa1a644297d Mon Sep 17 00:00:00 2001 From: Ryan Morales Date: Tue, 24 Sep 2024 10:03:14 -0700 Subject: [PATCH 2/7] Update core.api --- code/core/api/core.api | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/core/api/core.api b/code/core/api/core.api index b26f1cf47..495550716 100644 --- a/code/core/api/core.api +++ b/code/core/api/core.api @@ -778,11 +778,6 @@ public final class com/adobe/marketing/mobile/services/ui/ConflictingPresentatio public static final field INSTANCE Lcom/adobe/marketing/mobile/services/ui/ConflictingPresentation; } -public final class com/adobe/marketing/mobile/services/ui/DelegateGateNotMet : com/adobe/marketing/mobile/services/ui/ShowFailed { - public static final field $stable I - public static final field INSTANCE Lcom/adobe/marketing/mobile/services/ui/DelegateGateNotMet; -} - public abstract class com/adobe/marketing/mobile/services/ui/DismissFailed : com/adobe/marketing/mobile/services/ui/PresentationError { public static final field $stable I public synthetic fun (Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -891,6 +886,11 @@ public abstract class com/adobe/marketing/mobile/services/ui/ShowFailed : com/ad public final fun getReason ()Ljava/lang/String; } +public final class com/adobe/marketing/mobile/services/ui/SuppressedByAppDeveloper : com/adobe/marketing/mobile/services/ui/ShowFailed { + public static final field $stable I + public static final field INSTANCE Lcom/adobe/marketing/mobile/services/ui/SuppressedByAppDeveloper; +} + public abstract interface class com/adobe/marketing/mobile/services/ui/UIService { public abstract fun create (Lcom/adobe/marketing/mobile/services/ui/Presentation;Lcom/adobe/marketing/mobile/services/ui/PresentationUtilityProvider;)Lcom/adobe/marketing/mobile/services/ui/Presentable; public abstract fun setPresentationDelegate (Lcom/adobe/marketing/mobile/services/ui/PresentationDelegate;)V From c2253a18dad2e144e9c573cdefa4888eaa8e7899 Mon Sep 17 00:00:00 2001 From: Ryan Morales Date: Tue, 24 Sep 2024 11:07:03 -0700 Subject: [PATCH 3/7] re-add DelegateGateNotMet error, deprecate it --- code/core/api/core.api | 5 +++++ .../adobe/marketing/mobile/services/ui/PresentationError.kt | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/code/core/api/core.api b/code/core/api/core.api index 495550716..4e30f5dfb 100644 --- a/code/core/api/core.api +++ b/code/core/api/core.api @@ -778,6 +778,11 @@ public final class com/adobe/marketing/mobile/services/ui/ConflictingPresentatio public static final field INSTANCE Lcom/adobe/marketing/mobile/services/ui/ConflictingPresentation; } +public final class com/adobe/marketing/mobile/services/ui/DelegateGateNotMet : com/adobe/marketing/mobile/services/ui/ShowFailed { + public static final field $stable I + public static final field INSTANCE Lcom/adobe/marketing/mobile/services/ui/DelegateGateNotMet; +} + public abstract class com/adobe/marketing/mobile/services/ui/DismissFailed : com/adobe/marketing/mobile/services/ui/PresentationError { public static final field $stable I public synthetic fun (Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V diff --git a/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/PresentationError.kt b/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/PresentationError.kt index 9c8416044..03964a498 100644 --- a/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/PresentationError.kt +++ b/code/core/src/main/java/com/adobe/marketing/mobile/services/ui/PresentationError.kt @@ -34,6 +34,12 @@ object ConflictingPresentation : ShowFailed("Conflict") */ object NoAttachableActivity : ShowFailed("No attachable activity available.") +/** + * Represents a failure to show a Presentable because the delegate gate was not met. + */ +@Deprecated("Use SuppressedByAppDeveloper instead", ReplaceWith("SuppressedByAppDeveloper")) +object DelegateGateNotMet : ShowFailed("PresentationDelegate suppressed the presentation from being shown.") + /** * Represents a failure to show a Presentable because the app developer has suppressed [Presentable]s. */ From 6a742ccf527a9bec538fa2e7f226403ed51bf808 Mon Sep 17 00:00:00 2001 From: Ishita Gambhir Date: Wed, 25 Sep 2024 11:49:27 +0530 Subject: [PATCH 4/7] add new error codes for AdobeError --- code/core/api/core.api | 4 ++++ .../java/com/adobe/marketing/mobile/AdobeError.java | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/code/core/api/core.api b/code/core/api/core.api index 4e30f5dfb..bc90e80ca 100644 --- a/code/core/api/core.api +++ b/code/core/api/core.api @@ -10,6 +10,10 @@ public class com/adobe/marketing/mobile/AdobeError : java/io/Serializable { public static final field CALLBACK_NULL Lcom/adobe/marketing/mobile/AdobeError; public static final field CALLBACK_TIMEOUT Lcom/adobe/marketing/mobile/AdobeError; public static final field EXTENSION_NOT_INITIALIZED Lcom/adobe/marketing/mobile/AdobeError; + public static final field INVALID_REQUEST Lcom/adobe/marketing/mobile/AdobeError; + public static final field INVALID_RESPONSE Lcom/adobe/marketing/mobile/AdobeError; + public static final field NETWORK_ERROR Lcom/adobe/marketing/mobile/AdobeError; + public static final field SERVER_ERROR Lcom/adobe/marketing/mobile/AdobeError; public static final field UNEXPECTED_ERROR Lcom/adobe/marketing/mobile/AdobeError; protected fun (Ljava/lang/String;I)V public fun getErrorCode ()I diff --git a/code/core/src/main/java/com/adobe/marketing/mobile/AdobeError.java b/code/core/src/main/java/com/adobe/marketing/mobile/AdobeError.java index dbb4e9402..bd44940b6 100644 --- a/code/core/src/main/java/com/adobe/marketing/mobile/AdobeError.java +++ b/code/core/src/main/java/com/adobe/marketing/mobile/AdobeError.java @@ -27,6 +27,18 @@ public class AdobeError implements Serializable { /** when a callback is null. */ public static final AdobeError CALLBACK_NULL = new AdobeError("general.callback.null", 2); + /** when a server error happens. */ + public static final AdobeError SERVER_ERROR = new AdobeError("general.server.error", 4); + + /** when a network error happens. */ + public static final AdobeError NETWORK_ERROR = new AdobeError("general.network.error", 5); + + /** when an invalid request is made. */ + public static final AdobeError INVALID_REQUEST = new AdobeError("general.request.invalid", 6); + + /** when an invalid response is received. */ + public static final AdobeError INVALID_RESPONSE = new AdobeError("general.response.invalid", 7); + /** when a extension is not initialized. */ public static final AdobeError EXTENSION_NOT_INITIALIZED = new AdobeError("general.extension.not.initialized", 11); From 416002ecc88fd0bf9803b4861375023e810fee92 Mon Sep 17 00:00:00 2001 From: praveek Date: Wed, 25 Sep 2024 18:05:57 +0000 Subject: [PATCH 5/7] Update versions [Core-3.2.0] --- .../java/com/adobe/marketing/mobile/internal/CoreConstants.kt | 2 +- code/gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt b/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt index fedd11f15..680ef9534 100644 --- a/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt +++ b/code/core/src/main/java/com/adobe/marketing/mobile/internal/CoreConstants.kt @@ -13,7 +13,7 @@ package com.adobe.marketing.mobile.internal internal object CoreConstants { const val LOG_TAG = "MobileCore" - const val VERSION = "3.1.2" + const val VERSION = "3.2.0" object EventDataKeys { /** diff --git a/code/gradle.properties b/code/gradle.properties index f742c47d5..f6e4d6d5a 100644 --- a/code/gradle.properties +++ b/code/gradle.properties @@ -5,7 +5,7 @@ android.useAndroidX=true #Maven artifacts #Core extension -coreExtensionVersion=3.1.2 +coreExtensionVersion=3.2.0 coreExtensionName=core coreMavenRepoName=AdobeMobileCoreSdk coreMavenRepoDescription=Android Core Extension for Adobe Mobile Marketing From dfa565dc044942303970d34aef15ef65ca18d93b Mon Sep 17 00:00:00 2001 From: Ryan Morales Date: Thu, 26 Sep 2024 15:14:19 -0700 Subject: [PATCH 6/7] remove cancellation of coroutine children the coroutine children cancellation was causing all other coroutines other than the first to be cancelled early. this led to some race condition like behavior when determining if a presentable conflict had occurred. removing the children cancellation should have no effect on the event handling done in the `DefaultInAppMessageEventHandler`. --- .../services/ui/message/DefaultInAppMessageEventHandler.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/DefaultInAppMessageEventHandler.kt b/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/DefaultInAppMessageEventHandler.kt index 44c051a99..6aa883504 100644 --- a/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/DefaultInAppMessageEventHandler.kt +++ b/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/DefaultInAppMessageEventHandler.kt @@ -119,7 +119,6 @@ internal class DefaultInAppMessageEventHandler internal constructor( @MainThread internal fun onNewWebView(webView: WebView?) { Log.debug(ServiceConstants.LOG_TAG, LOG_SOURCE, "Internal web view was reset.") - mainScope.coroutineContext.cancelChildren() webView?.let { this@DefaultInAppMessageEventHandler.webView = WeakReference(it) From 2f148fc8db02728f9bb8474dd7cd65d11d1cc53a Mon Sep 17 00:00:00 2001 From: Ryan Morales Date: Thu, 26 Sep 2024 17:56:09 -0700 Subject: [PATCH 7/7] remove unused import --- .../services/ui/message/DefaultInAppMessageEventHandler.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/DefaultInAppMessageEventHandler.kt b/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/DefaultInAppMessageEventHandler.kt index 6aa883504..b25c123d2 100644 --- a/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/DefaultInAppMessageEventHandler.kt +++ b/code/core/src/phone/java/com/adobe/marketing/mobile/services/ui/message/DefaultInAppMessageEventHandler.kt @@ -19,7 +19,6 @@ import com.adobe.marketing.mobile.AdobeCallback import com.adobe.marketing.mobile.services.Log import com.adobe.marketing.mobile.services.ServiceConstants import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.cancelChildren import kotlinx.coroutines.launch import java.io.UnsupportedEncodingException import java.lang.ref.WeakReference