MyRecorder v1.01.90.0219版本的 MD5 值为:c361f51174a0bf833abfa72929caf8d3

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


package net.pubnative.lite.sdk;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import com.facebook.appevents.AppEventsConstants;
import net.pubnative.lite.sdk.consent.UserConsentActivity;
import net.pubnative.lite.sdk.utils.HyBidAdvertisingId;
import net.pubnative.lite.sdk.utils.Logger;
import net.pubnative.lite.sdk.utils.PNAsyncUtils;
public class UserDataManager {
    private static final int CONSENT_STATE_ACCEPTED = 1;
    private static final int CONSENT_STATE_DENIED = 0;
    private static final String DEVICE_ID_TYPE = "gaid";
    private static final String KEY_CCPA_CONSENT = "ccpa_consent";
    private static final String KEY_CCPA_PUBLIC_CONSENT = "IABUSPrivacy_String";
    private static final String KEY_CMP_PRESENT_PUBLIC = "IABConsent_CMPPresent";
    private static final String KEY_GDPR_ADVERTISING_ID = "gdpr_advertising_id";
    private static final String KEY_GDPR_APPLIES = "IABTCF_gdprApplies";
    private static final String KEY_GDPR_CONSENT = "gdpr_consent";
    private static final String KEY_GDPR_CONSENT_STATE = "gdpr_consent_state";
    private static final String KEY_GDPR_PUBLIC_CONSENT = "IABConsent_ConsentString";
    private static final String KEY_GDPR_TCF_2_PUBLIC_CONSENT = "IABTCF_TCString";
    private static final String KEY_GPP_ID = "gpp_id";
    private static final String KEY_GPP_STRING = "gpp_string";
    private static final String KEY_PUBLIC_GPP_ID = "IABGPP_GppSID";
    private static final String KEY_PUBLIC_GPP_STRING = "IABGPP_HDR_GppString";
    private static final String KEY_SUBJECT_TO_GDPR_PUBLIC = "IABConsent_SubjectToGDPR";
    private static final String PREFERENCES_CONSENT = "net.pubnative.lite.dataconsent";
    private static final String TAG = "UserDataManager";
    private final SharedPreferences mAppPreferences;
    private final SharedPreferences.OnSharedPreferenceChangeListener mAppPrefsListener;
    private final Context mContext;
    private final SharedPreferences mPreferences;

    public UserDataManager(Context context) {
        SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
            @Override
            public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String str) {
                if (TextUtils.isEmpty(str)) {
                    return;
                }
                str.hashCode();
                char c10 = 65535;
                switch (str.hashCode()) {
                    case 126060329:
                        if (str.equals("IABGPP_GppSID")) {
                            c10 = 0;
                            break;
                        }
                        break;
                    case 743443760:
                        if (str.equals(UserDataManager.KEY_CCPA_PUBLIC_CONSENT)) {
                            c10 = 1;
                            break;
                        }
                        break;
                    case 969191740:
                        if (str.equals(UserDataManager.KEY_GDPR_PUBLIC_CONSENT)) {
                            c10 = 2;
                            break;
                        }
                        break;
                    case 1218895378:
                        if (str.equals("IABTCF_TCString")) {
                            c10 = 3;
                            break;
                        }
                        break;
                    case 2023018157:
                        if (str.equals("IABGPP_HDR_GppString")) {
                            c10 = 4;
                            break;
                        }
                        break;
                }
                switch (c10) {
                    case 0:
                        String publicGppId = UserDataManager.this.getPublicGppId(sharedPreferences);
                        if (TextUtils.isEmpty(publicGppId)) {
                            UserDataManager.this.removeGppSid();
                            return;
                        } else {
                            UserDataManager.this.setGppSid(publicGppId);
                            return;
                        }
                    case 1:
                        String publicCCPAConsent = UserDataManager.this.getPublicCCPAConsent(sharedPreferences);
                        if (TextUtils.isEmpty(publicCCPAConsent)) {
                            UserDataManager.this.removeIABUSPrivacyString();
                            return;
                        } else {
                            UserDataManager.this.setIABUSPrivacyString(publicCCPAConsent);
                            return;
                        }
                    case 2:
                        String publicTCFConsent = UserDataManager.this.getPublicTCFConsent(sharedPreferences);
                        if (TextUtils.isEmpty(publicTCFConsent)) {
                            UserDataManager.this.removeIABGDPRConsentString();
                            return;
                        } else {
                            UserDataManager.this.setIABGDPRConsentString(publicTCFConsent);
                            return;
                        }
                    case 3:
                        String publicTCF2Consent = UserDataManager.this.getPublicTCF2Consent(sharedPreferences);
                        if (TextUtils.isEmpty(publicTCF2Consent)) {
                            UserDataManager.this.removeIABGDPRConsentString();
                            return;
                        } else {
                            UserDataManager.this.setIABGDPRConsentString(publicTCF2Consent);
                            return;
                        }
                    case 4:
                        String publicGppString = UserDataManager.this.getPublicGppString(sharedPreferences);
                        if (TextUtils.isEmpty(publicGppString)) {
                            UserDataManager.this.removeGppString();
                            return;
                        } else {
                            UserDataManager.this.setGppString(publicGppString);
                            return;
                        }
                    default:
                        return;
                }
            }
        };
        this.mAppPrefsListener = onSharedPreferenceChangeListener;
        Context applicationContext = context.getApplicationContext();
        this.mContext = applicationContext;
        this.mPreferences = applicationContext.getSharedPreferences(PREFERENCES_CONSENT, 0);
        SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext.getApplicationContext());
        this.mAppPreferences = defaultSharedPreferences;
        if (defaultSharedPreferences != null) {
            defaultSharedPreferences.registerOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener);
        }
        updatePublicConsent(defaultSharedPreferences);
    }

    private boolean askedForGDPRConsent() {
        boolean contains = this.mPreferences.contains(KEY_GDPR_CONSENT_STATE);
        if (contains) {
            String string = this.mPreferences.getString(KEY_GDPR_ADVERTISING_ID, "");
            if (TextUtils.isEmpty(string) || string.equals(HyBid.getDeviceInfo().getAdvertisingId())) {
                return contains;
            }
            return false;
        }
        return contains;
    }

    public String getPublicCCPAConsent(SharedPreferences sharedPreferences) {
        return sharedPreferences.getString(KEY_CCPA_PUBLIC_CONSENT, "");
    }

    public String getPublicGppId(SharedPreferences sharedPreferences) {
        return sharedPreferences.getString("IABGPP_GppSID", null);
    }

    public String getPublicGppString(SharedPreferences sharedPreferences) {
        return sharedPreferences.getString("IABGPP_HDR_GppString", null);
    }

    public String getPublicTCF2Consent(SharedPreferences sharedPreferences) {
        return sharedPreferences.getString("IABTCF_TCString", "");
    }

    public String getPublicTCFConsent(SharedPreferences sharedPreferences) {
        return sharedPreferences.getString(KEY_GDPR_PUBLIC_CONSENT, "");
    }

    public void notifyConsentGiven(String str, boolean z7) {
        setConsentState(z7 ? 1 : 0);
    }

    private void processConsent(final boolean z7) {
        String advertisingId = HyBid.getDeviceInfo().getAdvertisingId();
        if (!TextUtils.isEmpty(advertisingId)) {
            notifyConsentGiven(advertisingId, z7);
            return;
        }
        try {
            PNAsyncUtils.safeExecuteOnExecutor(new HyBidAdvertisingId(this.mContext, new HyBidAdvertisingId.Listener() {
                @Override
                public void onHyBidAdvertisingIdFinish(String str, Boolean bool) {
                    if (TextUtils.isEmpty(str)) {
                        Logger.e(UserDataManager.TAG, "Consent request failed with an empty advertising ID.");
                    } else {
                        UserDataManager.this.notifyConsentGiven(str, z7);
                    }
                }
            }), new Void[0]);
        } catch (Exception e10) {
            Logger.e(TAG, "Error executing HyBidAdvertisingId AsyncTask");
            HyBid.reportException(e10);
        }
    }

    private void setConsentState(int i10) {
        if (i10 != 1 && i10 != 0) {
            throw new RuntimeException("Illegal consent state provided");
        }
        SharedPreferences.Editor edit = this.mPreferences.edit();
        edit.putString(KEY_GDPR_ADVERTISING_ID, HyBid.getDeviceInfo().getAdvertisingId());
        edit.putInt(KEY_GDPR_CONSENT_STATE, i10);
        edit.apply();
    }

    private void updatePublicConsent(SharedPreferences sharedPreferences) {
        if (sharedPreferences != null) {
            String publicTCF2Consent = getPublicTCF2Consent(sharedPreferences);
            String publicTCFConsent = getPublicTCFConsent(sharedPreferences);
            String publicCCPAConsent = getPublicCCPAConsent(sharedPreferences);
            String publicGppString = getPublicGppString(sharedPreferences);
            String publicGppId = getPublicGppId(sharedPreferences);
            if (!TextUtils.isEmpty(publicTCF2Consent)) {
                setIABGDPRConsentString(publicTCF2Consent);
            } else if (!TextUtils.isEmpty(publicTCFConsent)) {
                setIABGDPRConsentString(publicTCFConsent);
            }
            if (!TextUtils.isEmpty(publicCCPAConsent)) {
                setIABUSPrivacyString(publicCCPAConsent);
            }
            if (!TextUtils.isEmpty(publicGppString)) {
                setGppString(publicGppString);
            }
            if (TextUtils.isEmpty(publicGppId)) {
                return;
            }
            setGppSid(publicGppId);
        }
    }

    public boolean canCollectData() {
        if (gdprApplies()) {
            return askedForGDPRConsent() && this.mPreferences.getInt(KEY_GDPR_CONSENT_STATE, 0) == 1;
        }
        return true;
    }

    @Deprecated
    public void denyConsent() {
        processConsent(false);
    }

    public boolean gdprApplies() {
        int i10;
        try {
            i10 = Integer.parseInt(this.mAppPreferences.getString("IABTCF_gdprApplies", AppEventsConstants.EVENT_PARAM_VALUE_NO));
        } catch (Exception e10) {
            i10 = this.mAppPreferences.getInt("IABTCF_gdprApplies", 0);
            HyBid.reportException(e10);
        }
        return i10 == 1;
    }

    @Deprecated
    public String getConsentPageLink() {
        return "https://cdn.pubnative.net/static/consent/consent.html";
    }

    @Deprecated
    public Intent getConsentScreenIntent(Context context) {
        return new Intent(context, UserConsentActivity.class);
    }

    public String getGppSid() {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            return sharedPreferences.getString(KEY_GPP_ID, null);
        }
        return null;
    }

    public String getGppString() {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            return sharedPreferences.getString(KEY_GPP_STRING, null);
        }
        return null;
    }

    public String getIABGDPRConsentString() {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            String string = sharedPreferences.getString(KEY_GDPR_CONSENT, null);
            if (TextUtils.isEmpty(string)) {
                String string2 = this.mAppPreferences.getString("IABTCF_TCString", null);
                return TextUtils.isEmpty(string2) ? this.mAppPreferences.getString(KEY_GDPR_PUBLIC_CONSENT, null) : string2;
            }
            return string;
        }
        return null;
    }

    public String getIABUSPrivacyString() {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            return sharedPreferences.getString(KEY_CCPA_CONSENT, null);
        }
        return null;
    }

    @Deprecated
    public String getPrivacyPolicyLink() {
        return "https://pubnative.net/privacy-notice/";
    }

    @Deprecated
    public String getVendorListLink() {
        return "https://pubnative.net/monetization-partners/";
    }

    @Deprecated
    public void grantConsent() {
        processConsent(true);
    }

    public boolean isCCPAOptOut() {
        String iABUSPrivacyString = getIABUSPrivacyString();
        if (TextUtils.isEmpty(iABUSPrivacyString) || iABUSPrivacyString.length() < 3) {
            return false;
        }
        char charAt = iABUSPrivacyString.charAt(2);
        return charAt == 'y' || charAt == 'Y';
    }

    public boolean isConsentDenied() {
        return this.mPreferences.contains(KEY_GDPR_CONSENT_STATE) && this.mPreferences.getInt(KEY_GDPR_CONSENT_STATE, 0) == 0;
    }

    public void removeGppData() {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            sharedPreferences.edit().remove(KEY_GPP_STRING).apply();
            this.mPreferences.edit().remove(KEY_GPP_ID).apply();
        }
    }

    public void removeGppSid() {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            sharedPreferences.edit().remove(KEY_GPP_ID).apply();
        }
    }

    public void removeGppString() {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            sharedPreferences.edit().remove(KEY_GPP_STRING).apply();
        }
    }

    public void removeIABGDPRConsentString() {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            sharedPreferences.edit().remove(KEY_GDPR_CONSENT).apply();
        }
    }

    public void removeIABUSPrivacyString() {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            sharedPreferences.edit().remove(KEY_CCPA_CONSENT).apply();
        }
    }

    @Deprecated
    public void revokeConsent() {
        denyConsent();
    }

    public void setGppSid(String str) {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            sharedPreferences.edit().putString(KEY_GPP_ID, str).apply();
        }
    }

    public void setGppString(String str) {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            sharedPreferences.edit().putString(KEY_GPP_STRING, str).apply();
        }
    }

    public void setIABGDPRConsentString(String str) {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            sharedPreferences.edit().putString(KEY_GDPR_CONSENT, str).apply();
        }
    }

    public void setIABUSPrivacyString(String str) {
        SharedPreferences sharedPreferences = this.mPreferences;
        if (sharedPreferences != null) {
            sharedPreferences.edit().putString(KEY_CCPA_CONSENT, str).apply();
        }
    }

    @Deprecated
    public boolean shouldAskConsent() {
        return gdprApplies() && !askedForGDPRConsent();
    }

    @Deprecated
    public void showConsentRequestScreen(Context context) {
        context.startActivity(getConsentScreenIntent(context));
    }
}