diff --git a/android-core/src/androidTest/kotlin/com.mparticle/internal/UpdateAdIdIdentityTest.kt b/android-core/src/androidTest/kotlin/com.mparticle/internal/UpdateAdIdIdentityTest.kt index f2a5ed578..2f97af378 100644 --- a/android-core/src/androidTest/kotlin/com.mparticle/internal/UpdateAdIdIdentityTest.kt +++ b/android-core/src/androidTest/kotlin/com.mparticle/internal/UpdateAdIdIdentityTest.kt @@ -25,7 +25,8 @@ class UpdateAdIdIdentityTest : BaseCleanInstallEachTest() { ) // execute CheckAdIdRunnable without a current user - AppStateManager.CheckAdIdRunnable("newAdId", "oldAdId").run() + MParticle.getInstance()!!.Internal().configManager + AppStateManager.CheckAdIdRunnable(MParticle.getInstance()!!.Internal().configManager).run() assertNull(MParticle.getInstance()!!.Identity().currentUser) // set a current user @@ -44,8 +45,7 @@ class UpdateAdIdIdentityTest : BaseCleanInstallEachTest() { request.asIdentityRequest().body.identity_changes.let { it.size == 1 && it[0].let { identityChange -> - identityChange["new_value"] == "newAdId" && - identityChange["old_value"] == "oldAdId" + identityChange["new_value"] == "someId" } } }.let { diff --git a/android-core/src/main/java/com/mparticle/internal/AppStateManager.java b/android-core/src/main/java/com/mparticle/internal/AppStateManager.java index 9d76d16a8..6a483b4e7 100644 --- a/android-core/src/main/java/com/mparticle/internal/AppStateManager.java +++ b/android-core/src/main/java/com/mparticle/internal/AppStateManager.java @@ -173,9 +173,7 @@ public void onActivityResumed(Activity activity) { initialize(mCurrentActivityName, previousSessionUri, previousSessionParameters, previousSessionPackage); } else if (isBackgrounded() && mLastStoppedTime.get() > 0) { isBackToForeground = true; - MPUtility.AdIdInfo adIdInfo = MPUtility.getAdIdInfo(mContext); - String currentGoogleAdId = (adIdInfo == null ? null : (adIdInfo.isLimitAdTrackingEnabled ? null : adIdInfo.id)); - mMessageManager.postToMessageThread(new CheckAdIdRunnable(currentGoogleAdId, mConfigManager.getPreviousAdId())); + mMessageManager.postToMessageThread(new CheckAdIdRunnable(mConfigManager)); logStateTransition(Constants.StateTransitionType.STATE_TRANS_FORE, mCurrentActivityName, mLastStoppedTime.get() - mLastForegroundTime, @@ -446,16 +444,17 @@ public WeakReference getCurrentActivity() { } static class CheckAdIdRunnable implements Runnable { - String currentAdId; - String previousAdId; + ConfigManager configManager; - CheckAdIdRunnable(@Nullable String currentAdId, @Nullable String previousAdId) { - this.currentAdId = currentAdId; - this.previousAdId = previousAdId; + CheckAdIdRunnable(@Nullable ConfigManager configManager) { + this.configManager = configManager; } @Override public void run() { + MPUtility.AdIdInfo adIdInfo = MPUtility.getAdIdInfo(MParticle.getInstance().Internal().getAppStateManager().mContext); + String currentAdId = (adIdInfo == null ? null : (adIdInfo.isLimitAdTrackingEnabled ? null : adIdInfo.id)); + String previousAdId = configManager.getPreviousAdId(); if (currentAdId != null && !currentAdId.equals(previousAdId)) { MParticle instance = MParticle.getInstance(); if (instance != null) {