From 049d01f0900a0fd88d41bd89a89d5d2c2c8da73d Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray Date: Mon, 14 Oct 2024 10:27:57 +0300 Subject: [PATCH] feat: stop views on consent removal --- .../ly/count/android/sdk/scSE_SessionsTests.java | 2 +- .../main/java/ly/count/android/sdk/ModuleViews.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sdk/src/androidTest/java/ly/count/android/sdk/scSE_SessionsTests.java b/sdk/src/androidTest/java/ly/count/android/sdk/scSE_SessionsTests.java index df4e1cf04..e24eb24b6 100644 --- a/sdk/src/androidTest/java/ly/count/android/sdk/scSE_SessionsTests.java +++ b/sdk/src/androidTest/java/ly/count/android/sdk/scSE_SessionsTests.java @@ -312,7 +312,7 @@ public void SE_206_CR_CNG_A_id_change() throws InterruptedException { flowAutomaticSessions(countly, new TestLifecycleObserver()); - Assert.assertEquals(5, TestUtils.getCurrentRQ().length); + Assert.assertEquals(6, TestUtils.getCurrentRQ().length); validateSessionConsentRequest(0, false, TestUtils.commonDeviceId); validateRequest(TestUtils.map("location", ""), 1); TestUtils.validateRequest("newID", TestUtils.map("old_device_id", TestUtils.commonDeviceId), 2); diff --git a/sdk/src/main/java/ly/count/android/sdk/ModuleViews.java b/sdk/src/main/java/ly/count/android/sdk/ModuleViews.java index 176edeaf5..467b360be 100644 --- a/sdk/src/main/java/ly/count/android/sdk/ModuleViews.java +++ b/sdk/src/main/java/ly/count/android/sdk/ModuleViews.java @@ -558,6 +558,18 @@ void onActivityStarted(Activity activity, int updatedActivityCount) { } } + @Override + void onConsentChanged(@NonNull final List consentChangeDelta, final boolean newConsent, @NonNull final ModuleConsent.ConsentChangeSource changeSource) { + L.d("[ModuleViews] onConsentChanged, consentChangeDelta:[" + consentChangeDelta + "], newConsent:[" + newConsent + "], changeSource:[" + changeSource + "]"); + if (consentChangeDelta.contains(Countly.CountlyFeatureNames.views)) { + if (!newConsent) { + L.d("[ModuleViews] onConsentChanged, stopping all views because consent was removed"); + + stopAllViewsInternal(null); + } + } + } + /** * Needed for mocking test result *