正在查看: OLX India v19.42.007 应用的 UserDataManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: OLX India v19.42.007 应用的 UserDataManager.java JAVA 源代码文件
本页面展示 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 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 KEY_CCPA_CONSENT = "ccpa_consent";
private static final String KEY_CCPA_PUBLIC_CONSENT = "IABUSPrivacy_String";
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 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();
switch (str) {
case "IABGPP_GppSID":
String publicGppId = UserDataManager.this.getPublicGppId(sharedPreferences);
if (!TextUtils.isEmpty(publicGppId)) {
UserDataManager.this.setGppSid(publicGppId);
break;
} else {
UserDataManager.this.removeGppSid();
break;
}
case "IABUSPrivacy_String":
String publicCCPAConsent = UserDataManager.this.getPublicCCPAConsent(sharedPreferences);
if (!TextUtils.isEmpty(publicCCPAConsent)) {
UserDataManager.this.setIABUSPrivacyString(publicCCPAConsent);
break;
} else {
UserDataManager.this.removeIABUSPrivacyString();
break;
}
case "IABConsent_ConsentString":
String publicTCFConsent = UserDataManager.this.getPublicTCFConsent(sharedPreferences);
if (!TextUtils.isEmpty(publicTCFConsent)) {
UserDataManager.this.setIABGDPRConsentString(publicTCFConsent);
break;
} else {
UserDataManager.this.removeIABGDPRConsentString();
break;
}
case "IABTCF_TCString":
String publicTCF2Consent = UserDataManager.this.getPublicTCF2Consent(sharedPreferences);
if (!TextUtils.isEmpty(publicTCF2Consent)) {
UserDataManager.this.setIABGDPRConsentString(publicTCF2Consent);
break;
} else {
UserDataManager.this.removeIABGDPRConsentString();
break;
}
case "IABGPP_HDR_GppString":
String publicGppString = UserDataManager.this.getPublicGppString(sharedPreferences);
if (!TextUtils.isEmpty(publicGppString)) {
UserDataManager.this.setGppString(publicGppString);
break;
} else {
UserDataManager.this.removeGppString();
break;
}
}
}
};
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) {
return contains;
}
String string = this.mPreferences.getString(KEY_GDPR_ADVERTISING_ID, "");
if (TextUtils.isEmpty(string) || string.equals(HyBid.getDeviceInfo().getAdvertisingId())) {
return contains;
}
return false;
}
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);
}
}
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 unused) {
i = this.mAppPreferences.getInt(KEY_GDPR_APPLIES, 0);
}
return i == 1;
}
@Deprecated
public String getConsentPageLink() {
return "https://cdn.pubnative.nes/static/consent/consent.html";
}
@Deprecated
public Intent getConsentScreenIntent(Context context) {
return new Intent(context, (Class<?>) 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) {
return null;
}
String string = sharedPreferences.getString(KEY_GDPR_CONSENT, null);
if (!TextUtils.isEmpty(string)) {
return 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;
}
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.nes/privacy-notice/";
}
@Deprecated
public String getVendorListLink() {
return "https://pubnative.nes/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));
}
}