Skip to content

Commit

Permalink
feat: stop views on consent removal
Browse files Browse the repository at this point in the history
  • Loading branch information
arifBurakDemiray committed Oct 14, 2024
1 parent 9c2f184 commit 049d01f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions sdk/src/main/java/ly/count/android/sdk/ModuleViews.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,18 @@ void onActivityStarted(Activity activity, int updatedActivityCount) {
}
}

@Override
void onConsentChanged(@NonNull final List<String> 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
*
Expand Down

0 comments on commit 049d01f

Please sign in to comment.