GoooBet v1.0版本的 MD5 值为:ff9748f16167bfd7735b669c0a9931c5

以下内容为反编译后的 PersonalInfoManager.java 源代码,内容仅作参考


package com.mopub.common.privacy;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.text.TextUtils;
import com.mopub.common.ClientMetadata;
import com.mopub.common.Constants;
import com.mopub.common.MoPub;
import com.mopub.common.Preconditions;
import com.mopub.common.SdkInitializationListener;
import com.mopub.common.logging.MoPubLog;
import com.mopub.common.privacy.MoPubIdentifier;
import com.mopub.common.privacy.SyncRequest;
import com.mopub.common.util.ManifestUtils;
import com.mopub.mobileads.MoPubConversionTracker;
import com.mopub.mobileads.MoPubErrorCode;
import com.mopub.network.MoPubNetworkError;
import com.mopub.network.MultiAdResponse;
import com.mopub.network.Networking;
import com.mopub.volley.VolleyError;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class PersonalInfoManager {
    private static final long MINIMUM_SYNC_DELAY = 300000;
    private final Context mAppContext;
    private final ConsentDialogController mConsentDialogController;
    private final Set<ConsentStatusChangeListener> mConsentStatusChangeListeners;
    private final MoPubConversionTracker mConversionTracker;
    private boolean mForceGdprAppliesChanged;
    private boolean mForceGdprAppliesChangedSending;
    private Long mLastSyncRequestTimeUptimeMs;
    private boolean mLegitimateInterestAllowed;
    private final PersonalInfoData mPersonalInfoData;
    private SdkInitializationListener mSdkInitializationListener;
    private MultiAdResponse.ServerOverrideListener mServerOverrideListener;
    private long mSyncDelayMs = 300000;
    private ConsentStatus mSyncRequestConsentStatus;
    private boolean mSyncRequestInFlight;
    private final SyncRequest.Listener mSyncRequestListener;

    public PersonalInfoManager(Context context, String str, SdkInitializationListener sdkInitializationListener) {
        Preconditions.checkNotNull(context);
        Preconditions.checkNotNull(str);
        this.mAppContext = context.getApplicationContext();
        this.mConsentStatusChangeListeners = Collections.synchronizedSet(new HashSet());
        this.mSyncRequestListener = new PersonalInfoSyncRequestListener();
        PersonalInfoServerOverrideListener personalInfoServerOverrideListener = new PersonalInfoServerOverrideListener();
        this.mServerOverrideListener = personalInfoServerOverrideListener;
        MultiAdResponse.setServerOverrideListener(personalInfoServerOverrideListener);
        this.mConsentDialogController = new ConsentDialogController(this.mAppContext);
        this.mPersonalInfoData = new PersonalInfoData(this.mAppContext);
        if (!TextUtils.isEmpty(str) && !str.equals(this.mPersonalInfoData.getCachedLastAdUnitIdUsedForInit())) {
            this.mPersonalInfoData.setAdUnit("");
            this.mPersonalInfoData.setCachedLastAdUnitIdUsedForInit(str);
            this.mPersonalInfoData.writeToDisk();
        }
        this.mConversionTracker = new MoPubConversionTracker(this.mAppContext);
        MoPubIdentifier.AdvertisingIdChangeListener advertisingIdChangeListener = new MoPubIdentifier.AdvertisingIdChangeListener() {
            @Override
            public void onIdChanged(AdvertisingId advertisingId, AdvertisingId advertisingId2) {
                Preconditions.checkNotNull(advertisingId);
                Preconditions.checkNotNull(advertisingId2);
                if (advertisingId.isDoNotTrack() && advertisingId2.isDoNotTrack()) {
                    return;
                }
                if (!advertisingId.isDoNotTrack() && advertisingId2.isDoNotTrack()) {
                    PersonalInfoManager.this.attemptStateTransition(ConsentStatus.DNT, ConsentChangeReason.DENIED_BY_DNT_ON);
                    PersonalInfoManager.this.requestSync(true);
                    return;
                }
                if (advertisingId.isDoNotTrack() && !advertisingId2.isDoNotTrack()) {
                    if (ConsentStatus.EXPLICIT_NO.equals(PersonalInfoManager.this.mPersonalInfoData.getConsentStatusBeforeDnt())) {
                        PersonalInfoManager.this.attemptStateTransition(ConsentStatus.EXPLICIT_NO, ConsentChangeReason.DNT_OFF);
                        return;
                    } else {
                        PersonalInfoManager.this.attemptStateTransition(ConsentStatus.UNKNOWN, ConsentChangeReason.DNT_OFF);
                        return;
                    }
                }
                if (TextUtils.isEmpty(advertisingId2.mAdvertisingId) || advertisingId2.getIfaWithPrefix().equals(PersonalInfoManager.this.mPersonalInfoData.getUdid()) || !ConsentStatus.EXPLICIT_YES.equals(PersonalInfoManager.this.mPersonalInfoData.getConsentStatus())) {
                    return;
                }
                PersonalInfoManager.this.mPersonalInfoData.setLastSuccessfullySyncedConsentStatus(null);
                PersonalInfoManager.this.mPersonalInfoData.setLastChangedMs(null);
                PersonalInfoManager.this.attemptStateTransition(ConsentStatus.UNKNOWN, ConsentChangeReason.IFA_CHANGED);
            }
        };
        this.mSdkInitializationListener = sdkInitializationListener;
        MoPubIdentifier moPubIdentifier = ClientMetadata.getInstance(this.mAppContext).getMoPubIdentifier();
        moPubIdentifier.setIdChangeListener(advertisingIdChangeListener);
        moPubIdentifier.setInitializationListener(createInitializationListener());
    }

    public boolean shouldShowConsentDialog() {
        Boolean gdprApplies = gdprApplies();
        if (gdprApplies == null || !gdprApplies.booleanValue()) {
            return false;
        }
        if (this.mPersonalInfoData.shouldReacquireConsent()) {
            return true;
        }
        return this.mPersonalInfoData.getConsentStatus().equals(ConsentStatus.UNKNOWN);
    }

    public boolean isConsentDialogReady() {
        return this.mConsentDialogController.isReady();
    }

    public void loadConsentDialog(final ConsentDialogListener consentDialogListener) {
        MoPubLog.log(MoPubLog.ConsentLogEvent.LOAD_ATTEMPTED, new Object[0]);
        ManifestUtils.checkGdprActivitiesDeclared(this.mAppContext);
        if (ClientMetadata.getInstance(this.mAppContext).getMoPubIdentifier().getAdvertisingInfo().isDoNotTrack()) {
            if (consentDialogListener != null) {
                new Handler().post(new Runnable() {
                    @Override
                    public void run() {
                        MoPubLog.log(MoPubLog.ConsentLogEvent.LOAD_FAILED, Integer.valueOf(MoPubErrorCode.DO_NOT_TRACK.getIntCode()), MoPubErrorCode.DO_NOT_TRACK);
                        consentDialogListener.onConsentDialogLoadFailed(MoPubErrorCode.DO_NOT_TRACK);
                    }
                });
                return;
            }
            return;
        }
        Boolean gdprApplies = gdprApplies();
        if (gdprApplies == null || gdprApplies.booleanValue()) {
            this.mConsentDialogController.loadConsentDialog(consentDialogListener, gdprApplies, this.mPersonalInfoData);
        } else if (consentDialogListener != null) {
            new Handler().post(new Runnable() {
                @Override
                public void run() {
                    MoPubLog.log(MoPubLog.ConsentLogEvent.LOAD_FAILED, Integer.valueOf(MoPubErrorCode.GDPR_DOES_NOT_APPLY.getIntCode()), MoPubErrorCode.GDPR_DOES_NOT_APPLY);
                    consentDialogListener.onConsentDialogLoadFailed(MoPubErrorCode.GDPR_DOES_NOT_APPLY);
                }
            });
        }
    }

    public boolean showConsentDialog() {
        return this.mConsentDialogController.showConsentDialog();
    }

    public boolean canCollectPersonalInformation() {
        Boolean gdprApplies = gdprApplies();
        if (gdprApplies == null) {
            return false;
        }
        if (gdprApplies.booleanValue()) {
            return getPersonalInfoConsentStatus().equals(ConsentStatus.EXPLICIT_YES) && !ClientMetadata.getInstance(this.mAppContext).getMoPubIdentifier().getAdvertisingInfo().isDoNotTrack();
        }
        return true;
    }

    public void setAllowLegitimateInterest(boolean z) {
        this.mLegitimateInterestAllowed = z;
    }

    public boolean shouldAllowLegitimateInterest() {
        return this.mLegitimateInterestAllowed;
    }

    public Boolean gdprApplies() {
        if (this.mPersonalInfoData.isForceGdprApplies()) {
            return true;
        }
        return this.mPersonalInfoData.getGdprApplies();
    }

    public void forceGdprApplies() {
        if (this.mPersonalInfoData.isForceGdprApplies()) {
            return;
        }
        boolean canCollectPersonalInformation = canCollectPersonalInformation();
        this.mPersonalInfoData.setForceGdprApplies(true);
        this.mForceGdprAppliesChanged = true;
        this.mPersonalInfoData.writeToDisk();
        boolean canCollectPersonalInformation2 = canCollectPersonalInformation();
        if (canCollectPersonalInformation != canCollectPersonalInformation2) {
            fireOnConsentStateChangeListeners(this.mPersonalInfoData.getConsentStatus(), this.mPersonalInfoData.getConsentStatus(), canCollectPersonalInformation2);
        }
        requestSync(true);
    }

    public ConsentStatus getPersonalInfoConsentStatus() {
        return this.mPersonalInfoData.getConsentStatus();
    }

    public void grantConsent() {
        if (ClientMetadata.getInstance(this.mAppContext).getMoPubIdentifier().getAdvertisingInfo().isDoNotTrack()) {
            MoPubLog.log(MoPubLog.ConsentLogEvent.CUSTOM, "Cannot grant consent because Do Not Track is on.");
            return;
        }
        if (this.mPersonalInfoData.isWhitelisted()) {
            attemptStateTransition(ConsentStatus.EXPLICIT_YES, ConsentChangeReason.GRANTED_BY_WHITELISTED_PUB);
        } else {
            MoPubLog.log(MoPubLog.ConsentLogEvent.CUSTOM, "You do not have approval to use the grantConsent API. Please reach out to your account teams or support@mopub.com for more information.");
            attemptStateTransition(ConsentStatus.POTENTIAL_WHITELIST, ConsentChangeReason.GRANTED_BY_NOT_WHITELISTED_PUB);
        }
        requestSync(true);
    }

    public void revokeConsent() {
        if (ClientMetadata.getInstance(this.mAppContext).getMoPubIdentifier().getAdvertisingInfo().isDoNotTrack()) {
            MoPubLog.log(MoPubLog.ConsentLogEvent.CUSTOM, "Cannot revoke consent because Do Not Track is on.");
        } else {
            attemptStateTransition(ConsentStatus.EXPLICIT_NO, ConsentChangeReason.DENIED_BY_PUB);
            requestSync(true);
        }
    }

    public void changeConsentStateFromDialog(ConsentStatus consentStatus) {
        Preconditions.checkNotNull(consentStatus);
        int i = AnonymousClass6.$SwitchMap$com$mopub$common$privacy$ConsentStatus[consentStatus.ordinal()];
        if (i == 1) {
            attemptStateTransition(consentStatus, ConsentChangeReason.GRANTED_BY_USER);
            requestSync(true);
        } else {
            if (i == 2) {
                attemptStateTransition(consentStatus, ConsentChangeReason.DENIED_BY_USER);
                requestSync(true);
                return;
            }
            MoPubLog.log(MoPubLog.ConsentLogEvent.CUSTOM, "Invalid consent status: " + consentStatus + ". This is a bug with the use of changeConsentStateFromDialog.");
        }
    }

    static class AnonymousClass6 {
        static final int[] $SwitchMap$com$mopub$common$privacy$ConsentStatus;

        static {
            int[] iArr = new int[ConsentStatus.values().length];
            $SwitchMap$com$mopub$common$privacy$ConsentStatus = iArr;
            try {
                iArr[ConsentStatus.EXPLICIT_YES.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$com$mopub$common$privacy$ConsentStatus[ConsentStatus.EXPLICIT_NO.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
        }
    }

    public void subscribeConsentStatusChangeListener(ConsentStatusChangeListener consentStatusChangeListener) {
        if (consentStatusChangeListener == null) {
            return;
        }
        this.mConsentStatusChangeListeners.add(consentStatusChangeListener);
    }

    public void unsubscribeConsentStatusChangeListener(ConsentStatusChangeListener consentStatusChangeListener) {
        this.mConsentStatusChangeListeners.remove(consentStatusChangeListener);
    }

    static boolean shouldMakeSyncRequest(boolean z, Boolean bool, boolean z2, Long l, long j, String str, boolean z3) {
        if (z) {
            return false;
        }
        if (bool == null) {
            return true;
        }
        if (!bool.booleanValue()) {
            return false;
        }
        if (z2) {
            return true;
        }
        if (z3 && TextUtils.isEmpty(str)) {
            return false;
        }
        return l == null || SystemClock.uptimeMillis() - l.longValue() > j;
    }

    public void requestSync(boolean z) {
        if (MoPub.isSdkInitialized()) {
            if (shouldMakeSyncRequest(this.mSyncRequestInFlight, gdprApplies(), z, this.mLastSyncRequestTimeUptimeMs, this.mSyncDelayMs, this.mPersonalInfoData.getUdid(), ClientMetadata.getInstance(this.mAppContext).getMoPubIdentifier().getAdvertisingInfo().isDoNotTrack())) {
                requestSync();
            }
        }
    }

    void requestSync() {
        MoPubLog.log(MoPubLog.ConsentLogEvent.SYNC_ATTEMPTED, new Object[0]);
        this.mSyncRequestConsentStatus = this.mPersonalInfoData.getConsentStatus();
        this.mSyncRequestInFlight = true;
        this.mLastSyncRequestTimeUptimeMs = Long.valueOf(SystemClock.uptimeMillis());
        SyncUrlGenerator syncUrlGenerator = new SyncUrlGenerator(this.mAppContext, this.mSyncRequestConsentStatus.getValue());
        syncUrlGenerator.withAdUnitId(this.mPersonalInfoData.chooseAdUnit()).withUdid(this.mPersonalInfoData.getUdid()).withLastChangedMs(this.mPersonalInfoData.getLastChangedMs()).withLastConsentStatus(this.mPersonalInfoData.getLastSuccessfullySyncedConsentStatus()).withConsentChangeReason(this.mPersonalInfoData.getConsentChangeReason()).withConsentedVendorListVersion(this.mPersonalInfoData.getConsentedVendorListVersion()).withConsentedPrivacyPolicyVersion(this.mPersonalInfoData.getConsentedPrivacyPolicyVersion()).withCachedVendorListIabHash(this.mPersonalInfoData.getCurrentVendorListIabHash()).withExtras(this.mPersonalInfoData.getExtras()).withGdprApplies(gdprApplies()).withForceGdprApplies(this.mPersonalInfoData.isForceGdprApplies());
        if (this.mForceGdprAppliesChanged) {
            this.mForceGdprAppliesChangedSending = true;
            syncUrlGenerator.withForceGdprAppliesChanged(true);
        }
        Networking.getRequestQueue(this.mAppContext).add(new SyncRequest(this.mAppContext, syncUrlGenerator.generateUrlString(Constants.HOST), this.mSyncRequestListener));
    }

    public ConsentData getConsentData() {
        return new PersonalInfoData(this.mAppContext);
    }

    public void attemptStateTransition(ConsentStatus consentStatus, ConsentChangeReason consentChangeReason) {
        attemptStateTransition(consentStatus, consentChangeReason.getReason());
    }

    void attemptStateTransition(ConsentStatus consentStatus, String str) {
        Preconditions.checkNotNull(consentStatus);
        Preconditions.checkNotNull(str);
        ConsentStatus consentStatus2 = this.mPersonalInfoData.getConsentStatus();
        if (!this.mPersonalInfoData.shouldReacquireConsent() && consentStatus2.equals(consentStatus)) {
            MoPubLog.log(MoPubLog.ConsentLogEvent.CUSTOM, "Consent status is already " + consentStatus2 + ". Not doing a state transition.");
            return;
        }
        this.mPersonalInfoData.setLastChangedMs("" + Calendar.getInstance().getTimeInMillis());
        this.mPersonalInfoData.setConsentChangeReason(str);
        this.mPersonalInfoData.setConsentStatus(consentStatus);
        if (shouldSetConsentedVersions(consentStatus2, consentStatus)) {
            PersonalInfoData personalInfoData = this.mPersonalInfoData;
            personalInfoData.setConsentedPrivacyPolicyVersion(personalInfoData.getCurrentPrivacyPolicyVersion());
            PersonalInfoData personalInfoData2 = this.mPersonalInfoData;
            personalInfoData2.setConsentedVendorListVersion(personalInfoData2.getCurrentVendorListVersion());
            PersonalInfoData personalInfoData3 = this.mPersonalInfoData;
            personalInfoData3.setConsentedVendorListIabFormat(personalInfoData3.getCurrentVendorListIabFormat());
        }
        if (ConsentStatus.DNT.equals(consentStatus) || ConsentStatus.UNKNOWN.equals(consentStatus)) {
            this.mPersonalInfoData.setConsentedPrivacyPolicyVersion(null);
            this.mPersonalInfoData.setConsentedVendorListVersion(null);
            this.mPersonalInfoData.setConsentedVendorListIabFormat(null);
        }
        if (ConsentStatus.EXPLICIT_YES.equals(consentStatus)) {
            this.mPersonalInfoData.setUdid(ClientMetadata.getInstance(this.mAppContext).getMoPubIdentifier().getAdvertisingInfo().getIfaWithPrefix());
        }
        if (ConsentStatus.DNT.equals(consentStatus)) {
            this.mPersonalInfoData.setConsentStatusBeforeDnt(consentStatus2);
        }
        this.mPersonalInfoData.setShouldReacquireConsent(false);
        this.mPersonalInfoData.writeToDisk();
        boolean canCollectPersonalInformation = canCollectPersonalInformation();
        if (canCollectPersonalInformation) {
            ClientMetadata.getInstance(this.mAppContext).repopulateCountryData();
            if (this.mConversionTracker.shouldTrack()) {
                this.mConversionTracker.reportAppOpen(false);
            }
        }
        MoPubLog.log(MoPubLog.ConsentLogEvent.UPDATED, consentStatus2, consentStatus, Boolean.valueOf(canCollectPersonalInformation()), str);
        fireOnConsentStateChangeListeners(consentStatus2, consentStatus, canCollectPersonalInformation);
    }

    private static boolean shouldSetConsentedVersions(ConsentStatus consentStatus, ConsentStatus consentStatus2) {
        if (ConsentStatus.EXPLICIT_NO.equals(consentStatus2) || ConsentStatus.POTENTIAL_WHITELIST.equals(consentStatus2)) {
            return true;
        }
        return !ConsentStatus.POTENTIAL_WHITELIST.equals(consentStatus) && ConsentStatus.EXPLICIT_YES.equals(consentStatus2);
    }

    public void fireOnConsentStateChangeListeners(final ConsentStatus consentStatus, final ConsentStatus consentStatus2, final boolean z) {
        synchronized (this.mConsentStatusChangeListeners) {
            for (final ConsentStatusChangeListener consentStatusChangeListener : this.mConsentStatusChangeListeners) {
                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {
                        consentStatusChangeListener.onConsentStateChange(consentStatus, consentStatus2, z);
                    }
                });
            }
        }
    }

    private SdkInitializationListener createInitializationListener() {
        return new SdkInitializationListener() {
            @Override
            public void onInitializationFinished() {
                MoPubLog.log(MoPubLog.ConsentLogEvent.CUSTOM, "MoPubIdentifier initialized.");
                if (!PersonalInfoManager.shouldMakeSyncRequest(PersonalInfoManager.this.mSyncRequestInFlight, PersonalInfoManager.this.gdprApplies(), false, PersonalInfoManager.this.mLastSyncRequestTimeUptimeMs, PersonalInfoManager.this.mSyncDelayMs, PersonalInfoManager.this.mPersonalInfoData.getUdid(), ClientMetadata.getInstance(PersonalInfoManager.this.mAppContext).getMoPubIdentifier().getAdvertisingInfo().isDoNotTrack())) {
                    if (PersonalInfoManager.this.mSdkInitializationListener != null) {
                        PersonalInfoManager.this.mSdkInitializationListener.onInitializationFinished();
                        PersonalInfoManager.this.mSdkInitializationListener = null;
                    }
                } else {
                    PersonalInfoManager.this.requestSync();
                }
                new MoPubConversionTracker(PersonalInfoManager.this.mAppContext).reportAppOpen(true);
            }
        };
    }

    private class PersonalInfoSyncRequestListener implements SyncRequest.Listener {
        private PersonalInfoSyncRequestListener() {
        }

        @Override
        public void onSuccess(SyncResponse syncResponse) {
            MoPubLog.log(MoPubLog.ConsentLogEvent.SYNC_COMPLETED, new Object[0]);
            boolean canCollectPersonalInformation = PersonalInfoManager.this.canCollectPersonalInformation();
            if (PersonalInfoManager.this.mPersonalInfoData.getGdprApplies() == null) {
                PersonalInfoManager.this.mPersonalInfoData.setGdprApplies(Boolean.valueOf(syncResponse.isGdprRegion()));
            }
            if (syncResponse.isForceGdprApplies()) {
                PersonalInfoManager.this.mForceGdprAppliesChanged = true;
                PersonalInfoManager.this.mPersonalInfoData.setForceGdprApplies(true);
                boolean canCollectPersonalInformation2 = PersonalInfoManager.this.canCollectPersonalInformation();
                if (canCollectPersonalInformation != canCollectPersonalInformation2) {
                    PersonalInfoManager personalInfoManager = PersonalInfoManager.this;
                    personalInfoManager.fireOnConsentStateChangeListeners(personalInfoManager.mPersonalInfoData.getConsentStatus(), PersonalInfoManager.this.mPersonalInfoData.getConsentStatus(), canCollectPersonalInformation2);
                }
            }
            String cachedLastAdUnitIdUsedForInit = PersonalInfoManager.this.mPersonalInfoData.getCachedLastAdUnitIdUsedForInit();
            if (!TextUtils.isEmpty(cachedLastAdUnitIdUsedForInit) && PersonalInfoManager.this.mPersonalInfoData.getAdUnitId().isEmpty()) {
                PersonalInfoManager.this.mPersonalInfoData.setAdUnit(cachedLastAdUnitIdUsedForInit);
            }
            PersonalInfoManager.this.mPersonalInfoData.setLastSuccessfullySyncedConsentStatus(PersonalInfoManager.this.mSyncRequestConsentStatus);
            PersonalInfoManager.this.mPersonalInfoData.setWhitelisted(syncResponse.isWhitelisted());
            PersonalInfoManager.this.mPersonalInfoData.setCurrentVendorListVersion(syncResponse.getCurrentVendorListVersion());
            PersonalInfoManager.this.mPersonalInfoData.setCurrentVendorListLink(syncResponse.getCurrentVendorListLink());
            PersonalInfoManager.this.mPersonalInfoData.setCurrentPrivacyPolicyVersion(syncResponse.getCurrentPrivacyPolicyVersion());
            PersonalInfoManager.this.mPersonalInfoData.setCurrentPrivacyPolicyLink(syncResponse.getCurrentPrivacyPolicyLink());
            String currentVendorListIabHash = syncResponse.getCurrentVendorListIabHash();
            String currentVendorListIabFormat = syncResponse.getCurrentVendorListIabFormat();
            if (!TextUtils.isEmpty(currentVendorListIabHash) && !currentVendorListIabHash.equals(PersonalInfoManager.this.mPersonalInfoData.getCurrentVendorListIabHash()) && !TextUtils.isEmpty(currentVendorListIabFormat)) {
                PersonalInfoManager.this.mPersonalInfoData.setCurrentVendorListIabFormat(currentVendorListIabFormat);
                PersonalInfoManager.this.mPersonalInfoData.setCurrentVendorListIabHash(currentVendorListIabHash);
            }
            String extras = syncResponse.getExtras();
            if (!TextUtils.isEmpty(extras)) {
                PersonalInfoManager.this.mPersonalInfoData.setExtras(extras);
            }
            String consentChangeReason = syncResponse.getConsentChangeReason();
            if (syncResponse.isForceExplicitNo()) {
                PersonalInfoManager.this.mServerOverrideListener.onForceExplicitNo(consentChangeReason);
            } else if (syncResponse.isInvalidateConsent()) {
                PersonalInfoManager.this.mServerOverrideListener.onInvalidateConsent(consentChangeReason);
            } else if (syncResponse.isReacquireConsent()) {
                PersonalInfoManager.this.mServerOverrideListener.onReacquireConsent(consentChangeReason);
            }
            String callAgainAfterSecs = syncResponse.getCallAgainAfterSecs();
            if (!TextUtils.isEmpty(callAgainAfterSecs)) {
                try {
                    long parseLong = Long.parseLong(callAgainAfterSecs);
                    if (parseLong > 0) {
                        PersonalInfoManager.this.mSyncDelayMs = parseLong * 1000;
                    } else {
                        MoPubLog.log(MoPubLog.ConsentLogEvent.CUSTOM, "callAgainAfterSecs is not positive: " + callAgainAfterSecs);
                    }
                } catch (NumberFormatException unused) {
                    MoPubLog.log(MoPubLog.ConsentLogEvent.CUSTOM, "Unable to parse callAgainAfterSecs. Ignoring value");
                }
            }
            if (!ConsentStatus.EXPLICIT_YES.equals(PersonalInfoManager.this.mSyncRequestConsentStatus)) {
                PersonalInfoManager.this.mPersonalInfoData.setUdid(null);
            }
            if (PersonalInfoManager.this.mForceGdprAppliesChangedSending) {
                PersonalInfoManager.this.mForceGdprAppliesChanged = false;
                PersonalInfoManager.this.mForceGdprAppliesChangedSending = false;
            }
            PersonalInfoManager.this.mPersonalInfoData.writeToDisk();
            PersonalInfoManager.this.mSyncRequestInFlight = false;
            if (ConsentStatus.POTENTIAL_WHITELIST.equals(PersonalInfoManager.this.mSyncRequestConsentStatus) && PersonalInfoManager.this.mPersonalInfoData.isWhitelisted()) {
                PersonalInfoManager.this.attemptStateTransition(ConsentStatus.EXPLICIT_YES, ConsentChangeReason.GRANTED_BY_WHITELISTED_PUB);
                PersonalInfoManager.this.requestSync(true);
            }
            if (PersonalInfoManager.this.mSdkInitializationListener != null) {
                PersonalInfoManager.this.mSdkInitializationListener.onInitializationFinished();
                PersonalInfoManager.this.mSdkInitializationListener = null;
            }
        }

        @Override
        public void onErrorResponse(VolleyError volleyError) {
            int intCode;
            String moPubErrorCode;
            boolean z = volleyError instanceof MoPubNetworkError;
            if (z) {
                intCode = ((MoPubNetworkError) volleyError).getReason().ordinal();
            } else {
                intCode = MoPubErrorCode.UNSPECIFIED.getIntCode();
            }
            if (z) {
                moPubErrorCode = volleyError.getMessage();
            } else {
                moPubErrorCode = MoPubErrorCode.UNSPECIFIED.toString();
            }
            MoPubLog.log(MoPubLog.ConsentLogEvent.SYNC_FAILED, Integer.valueOf(intCode), moPubErrorCode);
            PersonalInfoManager.this.mSyncRequestInFlight = false;
            if (PersonalInfoManager.this.mSdkInitializationListener != null) {
                MoPubLog.log(MoPubLog.ConsentLogEvent.CUSTOM, "Personal Info Manager initialization finished but ran into errors.");
                PersonalInfoManager.this.mSdkInitializationListener.onInitializationFinished();
                PersonalInfoManager.this.mSdkInitializationListener = null;
            }
        }
    }

    private class PersonalInfoServerOverrideListener implements MultiAdResponse.ServerOverrideListener {
        private PersonalInfoServerOverrideListener() {
        }

        @Override
        public void onForceExplicitNo(String str) {
            if (TextUtils.isEmpty(str)) {
                PersonalInfoManager.this.attemptStateTransition(ConsentStatus.EXPLICIT_NO, ConsentChangeReason.REVOKED_BY_SERVER);
            } else {
                PersonalInfoManager.this.attemptStateTransition(ConsentStatus.EXPLICIT_NO, str);
            }
        }

        @Override
        public void onInvalidateConsent(String str) {
            if (TextUtils.isEmpty(str)) {
                PersonalInfoManager.this.attemptStateTransition(ConsentStatus.UNKNOWN, ConsentChangeReason.REACQUIRE_BY_SERVER);
            } else {
                PersonalInfoManager.this.attemptStateTransition(ConsentStatus.UNKNOWN, str);
            }
        }

        @Override
        public void onReacquireConsent(String str) {
            if (!TextUtils.isEmpty(str)) {
                PersonalInfoManager.this.mPersonalInfoData.setConsentChangeReason(str);
            }
            PersonalInfoManager.this.mPersonalInfoData.setShouldReacquireConsent(true);
            PersonalInfoManager.this.mPersonalInfoData.writeToDisk();
        }

        @Override
        public void onForceGdprApplies() {
            PersonalInfoManager.this.forceGdprApplies();
        }

        @Override
        public void onRequestSuccess(String str) {
            if (!TextUtils.isEmpty(PersonalInfoManager.this.mPersonalInfoData.getAdUnitId()) || TextUtils.isEmpty(str)) {
                return;
            }
            PersonalInfoManager.this.mPersonalInfoData.setAdUnit(str);
            PersonalInfoManager.this.mPersonalInfoData.writeToDisk();
        }
    }

    @Deprecated
    PersonalInfoData getPersonalInfoData() {
        return this.mPersonalInfoData;
    }

    @Deprecated
    MultiAdResponse.ServerOverrideListener getServerOverrideListener() {
        return this.mServerOverrideListener;
    }
}