Cyber Surfer v5.2.5版本的 MD5 值为:db13c5fce988de393e52d2679f934b22
以下内容为反编译后的 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.safedk.android.analytics.brandsafety.BrandSafetyUtils;
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 c = 65535;
switch (str.hashCode()) {
case 126060329:
if (str.equals(UserDataManager.KEY_PUBLIC_GPP_ID)) {
c = 0;
break;
}
break;
case 743443760:
if (str.equals(UserDataManager.KEY_CCPA_PUBLIC_CONSENT)) {
c = 1;
break;
}
break;
case 969191740:
if (str.equals(UserDataManager.KEY_GDPR_PUBLIC_CONSENT)) {
c = 2;
break;
}
break;
case 1218895378:
if (str.equals(UserDataManager.KEY_GDPR_TCF_2_PUBLIC_CONSENT)) {
c = 3;
break;
}
break;
case 2023018157:
if (str.equals(UserDataManager.KEY_PUBLIC_GPP_STRING)) {
c = 4;
break;
}
break;
}
switch (c) {
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(KEY_PUBLIC_GPP_ID, null);
}
public String getPublicGppString(SharedPreferences sharedPreferences) {
return sharedPreferences.getString(KEY_PUBLIC_GPP_STRING, null);
}
public String getPublicTCF2Consent(SharedPreferences sharedPreferences) {
return sharedPreferences.getString(KEY_GDPR_TCF_2_PUBLIC_CONSENT, "");
}
public String getPublicTCFConsent(SharedPreferences sharedPreferences) {
return sharedPreferences.getString(KEY_GDPR_PUBLIC_CONSENT, "");
}
public void notifyConsentGiven(String str, boolean z) {
setConsentState(z ? 1 : 0);
}
private void processConsent(final boolean z) {
String advertisingId = HyBid.getDeviceInfo().getAdvertisingId();
if (!TextUtils.isEmpty(advertisingId)) {
notifyConsentGiven(advertisingId, z);
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, z);
}
}
}), new Void[0]);
} catch (Exception e) {
Logger.e(TAG, "Error executing HyBidAdvertisingId AsyncTask");
HyBid.reportException(e);
}
}
public static void safedk_Context_startActivity_97cb3195734cf5c9cc3418feeafa6dd6(Context context, Intent intent) {
com.safedk.android.utils.Logger.d("SafeDK-Special|SafeDK: Call> Landroid/content/Context;->startActivity(Landroid/content/Intent;)V");
if (intent == null) {
return;
}
BrandSafetyUtils.detectAdClick(intent, "net.pubnative");
context.startActivity(intent);
}
private void setConsentState(int i) {
if (i != 1 && i != 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, i);
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 i;
try {
i = Integer.parseInt(this.mAppPreferences.getString(KEY_GDPR_APPLIES, "0"));
} catch (Exception e) {
i = this.mAppPreferences.getInt(KEY_GDPR_APPLIES, 0);
HyBid.reportException(e);
}
return i == 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("gdpr_consent", null);
if (TextUtils.isEmpty(string)) {
String string2 = this.mAppPreferences.getString(KEY_GDPR_TCF_2_PUBLIC_CONSENT, 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("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("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) {
safedk_Context_startActivity_97cb3195734cf5c9cc3418feeafa6dd6(context, getConsentScreenIntent(context));
}
}