Skip to content

Commit 59ea627

Browse files
fix: add missing functionality to the sessions after without merge
1 parent ac2f14f commit 59ea627

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

sdk/src/main/java/ly/count/android/sdk/Countly.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,11 +878,11 @@ public synchronized void halt() {
878878
staticInit();
879879
}
880880

881-
synchronized void notifyDeviceIdChange() {
881+
synchronized void notifyDeviceIdChange(boolean withoutMerge) {
882882
L.d("Notifying modules that device ID changed");
883883

884884
for (ModuleBase module : modules) {
885-
module.deviceIdChanged();
885+
module.deviceIdChanged(withoutMerge);
886886
}
887887
}
888888

sdk/src/main/java/ly/count/android/sdk/ModuleBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void callbackOnActivityStopped(Activity activity) {
8888
//}
8989

9090
//notify the SDK modules that the device ID has changed
91-
void deviceIdChanged() {
91+
void deviceIdChanged(boolean withoutMerge) {
9292
}
9393

9494
//notify the SDK modules that consent was updated

sdk/src/main/java/ly/count/android/sdk/ModuleDeviceId.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ void changeDeviceIdWithoutMergeInternal(@NonNull String deviceId) {
131131
//update remote config_ values after id change if automatic update is enabled
132132
_cly.moduleRemoteConfig.clearAndDownloadAfterIdChange();
133133

134-
_cly.moduleSessions.endSessionInternal();
134+
if (!_cly.moduleSessions.manualSessionControlEnabled) {
135+
//if manual session control is not enabled, end the current session
136+
_cly.moduleSessions.endSessionInternal(); // this will check consent
137+
}
135138

136139
//remove all consent
137140
_cly.moduleConsent.removeConsentAllInternal(ModuleConsent.ConsentChangeSource.DeviceIDChangedNotMerged);
@@ -146,7 +149,7 @@ void changeDeviceIdWithoutMergeInternal(@NonNull String deviceId) {
146149

147150
//clear automated star rating session values because now we have a new user
148151
_cly.moduleRatings.clearAutomaticStarRatingSessionCountInternal();
149-
_cly.notifyDeviceIdChange();
152+
_cly.notifyDeviceIdChange(true);
150153
}
151154

152155
/**
@@ -192,7 +195,7 @@ void changeDeviceIdWithMergeInternal(@NonNull String deviceId) {
192195
_cly.moduleRemoteConfig.clearAndDownloadAfterIdChange();
193196
requestQueueProvider.changeDeviceId(deviceId, deviceIdInstance.getCurrentId());
194197
deviceIdInstance.changeToCustomId(deviceId);
195-
_cly.notifyDeviceIdChange();
198+
_cly.notifyDeviceIdChange(false);
196199
}
197200
}
198201

sdk/src/main/java/ly/count/android/sdk/ModuleRemoteConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ void onConsentChanged(@NonNull final List<String> consentChangeDelta, final bool
433433
}
434434

435435
@Override
436-
void deviceIdChanged() {
436+
void deviceIdChanged(boolean withoutMerge) {
437437
L.v("[RemoteConfig] Device ID changed will update values: [" + updateRemoteConfigAfterIdChange + "]");
438438

439439
if (updateRemoteConfigAfterIdChange) {

sdk/src/main/java/ly/count/android/sdk/ModuleSessions.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ void halt() {
171171
sessionRunning = false;
172172
}
173173

174+
@Override
175+
void deviceIdChanged(boolean withoutMerge) {
176+
if (!manualSessionControlEnabled && withoutMerge) {
177+
L.d("[ModuleSessions] deviceIdChanged, automatic session control enabled and device id changed without merge, starting a new session");
178+
beginSessionInternal();
179+
}
180+
}
181+
174182
public class Sessions {
175183
public void beginSession() {
176184
synchronized (_cly) {

0 commit comments

Comments
 (0)