Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SQDSDK-5597 - Get ad id in background thread #463

Merged
merged 4 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -446,16 +444,17 @@ public WeakReference<Activity> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.os.StatFs;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.util.Log;
markvdouw marked this conversation as resolved.
Show resolved Hide resolved
import android.view.Display;
import android.view.WindowManager;

Expand Down
Loading