Financial Wallet v1.0.7版本的 MD5 值为:2850d883110aa6930773a8b5cb1cd25e
以下内容为反编译后的 PrefHelper.java 源代码,内容仅作参考
package io.branch.referral;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.URLUtil;
import io.branch.referral.Defines;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.json.JSONException;
import org.json.JSONObject;
public class PrefHelper {
static final String BRANCH_BASE_URL_V1 = "https://api.branch.io/";
static final String BRANCH_BASE_URL_V2 = "https://api2.branch.io/";
static final String BRANCH_CDN_BASE_URL = "https://cdn.branch.io/";
private static final int INTERVAL_RETRY = 1000;
private static final String KEY_ACTIONS = "bnc_actions";
static final String KEY_AD_NETWORK_CALLOUTS_DISABLED = "bnc_ad_network_callouts_disabled";
private static final String KEY_APP_LINK = "bnc_app_link";
private static final String KEY_APP_VERSION = "bnc_app_version";
private static final String KEY_BRANCH_KEY = "bnc_branch_key";
private static final String KEY_BRANCH_VIEW_NUM_OF_USE = "bnc_branch_view_use";
private static final String KEY_BUCKETS = "bnc_buckets";
private static final String KEY_CREDIT_BASE = "bnc_credit_base_";
private static final String KEY_DEVICE_FINGERPRINT_ID = "bnc_device_fingerprint_id";
private static final String KEY_EXTERNAL_INTENT_EXTRA = "bnc_external_intent_extra";
private static final String KEY_EXTERNAL_INTENT_URI = "bnc_external_intent_uri";
private static final String KEY_GOOGLE_PLAY_INSTALL_REFERRER_EXTRA = "bnc_google_play_install_referrer_extras";
private static final String KEY_GOOGLE_SEARCH_INSTALL_IDENTIFIER = "bnc_google_search_install_identifier";
private static final String KEY_IDENTITY = "bnc_identity";
private static final String KEY_IDENTITY_ID = "bnc_identity_id";
private static final String KEY_INITIAL_REFERRER = "bnc_initial_referrer";
static final String KEY_INSTALL_BEGIN_TS = "bnc_install_begin_ts";
private static final String KEY_INSTALL_PARAMS = "bnc_install_params";
private static final String KEY_INSTALL_REFERRER = "bnc_install_referrer";
private static final String KEY_IS_FULL_APP_CONVERSION = "bnc_is_full_app_conversion";
private static final String KEY_IS_TRIGGERED_BY_FB_APP_LINK = "bnc_triggered_by_fb_app_link";
static final String KEY_LAST_KNOWN_UPDATE_TIME = "bnc_last_known_update_time";
private static final String KEY_LAST_READ_SYSTEM = "bnc_system_read_date";
private static final String KEY_LAST_STRONG_MATCH_TIME = "bnc_branch_strong_match_time";
private static final String KEY_LATD_ATTRIBUTION_WINDOW = "bnc_latd_attributon_window";
private static final String KEY_LIMIT_FACEBOOK_TRACKING = "bnc_limit_facebook_tracking";
private static final String KEY_LINK_CLICK_ID = "bnc_link_click_id";
private static final String KEY_LINK_CLICK_IDENTIFIER = "bnc_link_click_identifier";
static final String KEY_ORIGINAL_INSTALL_TIME = "bnc_original_install_time";
static final String KEY_PREVIOUS_UPDATE_TIME = "bnc_previous_update_time";
private static final String KEY_PUSH_IDENTIFIER = "bnc_push_identifier";
static final String KEY_REFERRER_CLICK_TS = "bnc_referrer_click_ts";
private static final String KEY_RETRY_COUNT = "bnc_retry_count";
private static final String KEY_RETRY_INTERVAL = "bnc_retry_interval";
private static final String KEY_SESSION_ID = "bnc_session_id";
private static final String KEY_SESSION_PARAMS = "bnc_session_params";
private static final String KEY_TIMEOUT = "bnc_timeout";
private static final String KEY_TOTAL_BASE = "bnc_total_base_";
static final String KEY_TRACKING_STATE = "bnc_tracking_state";
private static final String KEY_UNIQUE_BASE = "bnc_balance_base_";
private static final String KEY_USER_URL = "bnc_user_url";
private static final int MAX_RETRIES = 3;
public static final String NO_STRING_VALUE = "bnc_no_value";
private static final String SHARED_PREF_FILE = "branch_referral_shared_pref";
private static final String TAG = "BranchSDK";
static final int TIMEOUT = 5500;
private static String customCDNBaseURL_ = null;
private static String customServerURL_ = null;
private static boolean enableLogging_ = false;
private static PrefHelper prefHelper_;
private final SharedPreferences appSharedPrefs_;
private SharedPreferences.Editor prefsEditor_;
private final JSONObject requestMetadata = new JSONObject();
private final JSONObject installMetadata = new JSONObject();
private final JSONObject secondaryRequestMetadata = new JSONObject();
final BranchPartnerParameters partnerParams_ = new BranchPartnerParameters();
private PrefHelper(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_PREF_FILE, 0);
this.appSharedPrefs_ = sharedPreferences;
this.prefsEditor_ = sharedPreferences.edit();
}
public static void Debug(String str) {
if (!enableLogging_ || TextUtils.isEmpty(str)) {
return;
}
Log.i(TAG, str);
}
public static void LogAlways(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
Log.i(TAG, str);
}
public static void LogException(String str, Exception exc) {
if (TextUtils.isEmpty(str)) {
return;
}
Log.e(TAG, str, exc);
}
private void clearPrefOnBranchKeyChange() {
String linkClickID = getLinkClickID();
String linkClickIdentifier = getLinkClickIdentifier();
String appLink = getAppLink();
String pushIdentifier = getPushIdentifier();
this.prefsEditor_.clear();
setLinkClickID(linkClickID);
setLinkClickIdentifier(linkClickIdentifier);
setAppLink(appLink);
setPushIdentifier(pushIdentifier);
this.prefsEditor_.apply();
}
private ArrayList<String> deserializeString(String str) {
ArrayList<String> arrayList = new ArrayList<>();
Collections.addAll(arrayList, str.split(","));
return arrayList;
}
public static void enableLogging(boolean z) {
enableLogging_ = z;
}
private ArrayList<String> getActions() {
String string = getString(KEY_ACTIONS);
return string.equals(NO_STRING_VALUE) ? new ArrayList<>() : deserializeString(string);
}
private ArrayList<String> getBuckets() {
String string = getString(KEY_BUCKETS);
return string.equals(NO_STRING_VALUE) ? new ArrayList<>() : deserializeString(string);
}
public static String getCDNBaseUrl() {
return !TextUtils.isEmpty(customCDNBaseURL_) ? customCDNBaseURL_ : BRANCH_CDN_BASE_URL;
}
public static PrefHelper getInstance(Context context) {
if (prefHelper_ == null) {
prefHelper_ = new PrefHelper(context);
}
return prefHelper_;
}
public static boolean isValidBranchKey(String str) {
if (str != null) {
return str.startsWith(BranchUtil.isTestModeEnabled() ? "key_test_" : "key_");
}
return false;
}
static void loadPartnerParams(JSONObject jSONObject, BranchPartnerParameters branchPartnerParameters) {
if (jSONObject == null) {
return;
}
JSONObject jSONObject2 = new JSONObject();
for (Map.Entry<String, ConcurrentHashMap<String, String>> entry : branchPartnerParameters.allParams().entrySet()) {
JSONObject jSONObject3 = new JSONObject();
for (Map.Entry<String, String> entry2 : entry.getValue().entrySet()) {
jSONObject3.put(entry2.getKey(), entry2.getValue());
}
jSONObject2.put(entry.getKey(), jSONObject3);
}
jSONObject.put(Defines.Jsonkey.PartnerData.getKey(), jSONObject2);
}
private String serializeArrayList(ArrayList<String> arrayList) {
Iterator<String> it = arrayList.iterator();
String str = "";
while (it.hasNext()) {
str = str + it.next() + ",";
}
return str.substring(0, str.length() - 1);
}
public static void setAPIUrl(String str) {
customServerURL_ = str;
}
private void setActions(ArrayList<String> arrayList) {
setString(KEY_ACTIONS, arrayList.size() == 0 ? NO_STRING_VALUE : serializeArrayList(arrayList));
}
private void setBuckets(ArrayList<String> arrayList) {
setString(KEY_BUCKETS, arrayList.size() == 0 ? NO_STRING_VALUE : serializeArrayList(arrayList));
}
public static void setCDNBaseUrl(String str) {
customCDNBaseURL_ = str;
}
public static void shutDown() {
PrefHelper prefHelper = prefHelper_;
if (prefHelper != null) {
prefHelper.prefsEditor_ = null;
}
enableLogging_ = false;
prefHelper_ = null;
customServerURL_ = null;
customCDNBaseURL_ = null;
}
public void addInstallMetadata(String str, String str2) {
if (str == null) {
return;
}
try {
this.installMetadata.putOpt(str, str2);
} catch (JSONException unused) {
}
}
public void addSecondaryRequestMetadata(String str, String str2) {
if (str == null) {
return;
}
try {
this.secondaryRequestMetadata.putOpt(str, str2);
} catch (JSONException unused) {
}
}
public void clearSystemReadStatus() {
setLong(KEY_LAST_READ_SYSTEM, Calendar.getInstance().getTimeInMillis() / 1000);
}
public void clearUserValues() {
Iterator<String> it = getBuckets().iterator();
while (it.hasNext()) {
setCreditCount(it.next(), 0);
}
setBuckets(new ArrayList<>());
Iterator<String> it2 = getActions().iterator();
while (it2.hasNext()) {
String next = it2.next();
setActionTotalCount(next, 0);
setActionUniqueCount(next, 0);
}
setActions(new ArrayList<>());
}
public String getAPIBaseUrl() {
return URLUtil.isHttpsUrl(customServerURL_) ? customServerURL_ : Build.VERSION.SDK_INT >= 20 ? BRANCH_BASE_URL_V2 : BRANCH_BASE_URL_V1;
}
public int getActionTotalCount(String str) {
return getInteger(KEY_TOTAL_BASE + str);
}
public int getActionUniqueCount(String str) {
return getInteger(KEY_UNIQUE_BASE + str);
}
public boolean getAdNetworkCalloutsDisabled() {
return getBool(KEY_AD_NETWORK_CALLOUTS_DISABLED);
}
public String getAppLink() {
return getString(KEY_APP_LINK);
}
public String getAppVersion() {
return getString(KEY_APP_VERSION);
}
public boolean getBool(String str) {
return this.appSharedPrefs_.getBoolean(str, false);
}
public String getBranchKey() {
return getString(KEY_BRANCH_KEY);
}
public int getBranchViewUsageCount(String str) {
return getInteger("bnc_branch_view_use_" + str, 0);
}
public int getCreditCount() {
return getCreditCount(Defines.Jsonkey.DefaultBucket.getKey());
}
public int getCreditCount(String str) {
return getInteger(KEY_CREDIT_BASE + str);
}
public String getDeviceFingerPrintID() {
return getString(KEY_DEVICE_FINGERPRINT_ID);
}
public String getExternalIntentExtra() {
return getString(KEY_EXTERNAL_INTENT_EXTRA);
}
public String getExternalIntentUri() {
return getString(KEY_EXTERNAL_INTENT_URI);
}
public float getFloat(String str) {
return this.appSharedPrefs_.getFloat(str, 0.0f);
}
public String getGooglePlayReferrer() {
return getString(KEY_GOOGLE_PLAY_INSTALL_REFERRER_EXTRA);
}
public String getGoogleSearchInstallIdentifier() {
return getString(KEY_GOOGLE_SEARCH_INSTALL_IDENTIFIER);
}
public String getIdentity() {
return getString(KEY_IDENTITY);
}
public String getIdentityID() {
return getString(KEY_IDENTITY_ID);
}
public String getInitialReferrer() {
return getString(KEY_INITIAL_REFERRER);
}
public String getInstallMetaData(String str) {
if (str == null) {
return null;
}
try {
return this.installMetadata.get(str).toString();
} catch (JSONException unused) {
return null;
}
}
public JSONObject getInstallMetadata() {
return this.installMetadata;
}
public String getInstallParams() {
return getString(KEY_INSTALL_PARAMS);
}
public String getInstallReferrerParams() {
return getString(KEY_INSTALL_REFERRER);
}
public int getInteger(String str) {
return getInteger(str, 0);
}
public int getInteger(String str, int i) {
return this.appSharedPrefs_.getInt(str, i);
}
public boolean getIsAppLinkTriggeredInit() {
return getBool(KEY_IS_TRIGGERED_BY_FB_APP_LINK);
}
public int getLATDAttributionWindow() {
return getInteger(KEY_LATD_ATTRIBUTION_WINDOW, -1);
}
public long getLastStrongMatchTime() {
return getLong(KEY_LAST_STRONG_MATCH_TIME);
}
public String getLinkClickID() {
return getString(KEY_LINK_CLICK_ID);
}
public String getLinkClickIdentifier() {
return getString(KEY_LINK_CLICK_IDENTIFIER);
}
public long getLong(String str) {
return this.appSharedPrefs_.getLong(str, 0L);
}
public String getPushIdentifier() {
return getString(KEY_PUSH_IDENTIFIER);
}
public JSONObject getRequestMetadata() {
return this.requestMetadata;
}
public int getRetryCount() {
return getInteger(KEY_RETRY_COUNT, 3);
}
public int getRetryInterval() {
return getInteger(KEY_RETRY_INTERVAL, 1000);
}
public String getSecondaryRequestMetaData(String str) {
if (str == null) {
return null;
}
try {
return this.secondaryRequestMetadata.get(str).toString();
} catch (JSONException unused) {
return null;
}
}
public String getSessionID() {
return getString(KEY_SESSION_ID);
}
public String getSessionParams() {
return getString(KEY_SESSION_PARAMS);
}
public String getString(String str) {
return this.appSharedPrefs_.getString(str, NO_STRING_VALUE);
}
public int getTimeout() {
return getInteger(KEY_TIMEOUT, TIMEOUT);
}
public String getUserURL() {
return getString(KEY_USER_URL);
}
public boolean hasPrefValue(String str) {
return this.appSharedPrefs_.contains(str);
}
public boolean hasValidBranchKey() {
return isValidBranchKey(getBranchKey());
}
public boolean isAppTrackingLimited() {
return getBool(KEY_LIMIT_FACEBOOK_TRACKING);
}
public boolean isFullAppConversion() {
return getBool(KEY_IS_FULL_APP_CONVERSION);
}
public void loadPartnerParams(JSONObject jSONObject) {
loadPartnerParams(jSONObject, this.partnerParams_);
}
public void removePrefValue(String str) {
this.prefsEditor_.remove(str).apply();
}
public void saveLastStrongMatchTime(long j) {
setLong(KEY_LAST_STRONG_MATCH_TIME, j);
}
public void setActionTotalCount(String str, int i) {
ArrayList<String> actions = getActions();
if (!actions.contains(str)) {
actions.add(str);
setActions(actions);
}
setInteger(KEY_TOTAL_BASE + str, i);
}
public void setActionUniqueCount(String str, int i) {
setInteger(KEY_UNIQUE_BASE + str, i);
}
public void setAdNetworkCalloutsDisabled(boolean z) {
setBool(KEY_AD_NETWORK_CALLOUTS_DISABLED, Boolean.valueOf(z));
}
public void setAppLink(String str) {
setString(KEY_APP_LINK, str);
}
public void setAppVersion(String str) {
setString(KEY_APP_VERSION, str);
}
public void setBool(String str, Boolean bool) {
this.prefsEditor_.putBoolean(str, bool.booleanValue()).apply();
}
public boolean setBranchKey(String str) {
if (getString(KEY_BRANCH_KEY).equals(str)) {
return false;
}
clearPrefOnBranchKeyChange();
setString(KEY_BRANCH_KEY, str);
if (Branch.getInstance() == null) {
return true;
}
Branch.getInstance().linkCache_.clear();
Branch.getInstance().requestQueue_.clear();
return true;
}
public void setCreditCount(int i) {
setCreditCount(Defines.Jsonkey.DefaultBucket.getKey(), i);
}
public void setCreditCount(String str, int i) {
ArrayList<String> buckets = getBuckets();
if (!buckets.contains(str)) {
buckets.add(str);
setBuckets(buckets);
}
setInteger(KEY_CREDIT_BASE + str, i);
}
public void setDeviceFingerPrintID(String str) {
setString(KEY_DEVICE_FINGERPRINT_ID, str);
}
public void setExternalIntentExtra(String str) {
setString(KEY_EXTERNAL_INTENT_EXTRA, str);
}
public void setExternalIntentUri(String str) {
setString(KEY_EXTERNAL_INTENT_URI, str);
}
public void setFloat(String str, float f) {
this.prefsEditor_.putFloat(str, f).apply();
}
public void setGooglePlayReferrer(String str) {
setString(KEY_GOOGLE_PLAY_INSTALL_REFERRER_EXTRA, str);
}
public void setGoogleSearchInstallIdentifier(String str) {
setString(KEY_GOOGLE_SEARCH_INSTALL_IDENTIFIER, str);
}
public void setIdentity(String str) {
setString(KEY_IDENTITY, str);
}
public void setIdentityID(String str) {
setString(KEY_IDENTITY_ID, str);
}
public void setInitialReferrer(String str) {
setString(KEY_INITIAL_REFERRER, str);
}
public void setInstallParams(String str) {
setString(KEY_INSTALL_PARAMS, str);
}
public void setInstallReferrerParams(String str) {
setString(KEY_INSTALL_REFERRER, str);
}
public void setInteger(String str, int i) {
this.prefsEditor_.putInt(str, i).apply();
}
public void setIsAppLinkTriggeredInit(Boolean bool) {
setBool(KEY_IS_TRIGGERED_BY_FB_APP_LINK, bool);
}
public void setIsFullAppConversion(boolean z) {
setBool(KEY_IS_FULL_APP_CONVERSION, Boolean.valueOf(z));
}
public void setLATDAttributionWindow(int i) {
setInteger(KEY_LATD_ATTRIBUTION_WINDOW, i);
}
public void setLimitFacebookTracking(boolean z) {
setBool(KEY_LIMIT_FACEBOOK_TRACKING, Boolean.valueOf(z));
}
public void setLinkClickID(String str) {
setString(KEY_LINK_CLICK_ID, str);
}
public void setLinkClickIdentifier(String str) {
setString(KEY_LINK_CLICK_IDENTIFIER, str);
}
public void setLong(String str, long j) {
this.prefsEditor_.putLong(str, j).apply();
}
public void setPushIdentifier(String str) {
setString(KEY_PUSH_IDENTIFIER, str);
}
public void setRequestMetadata(String str, String str2) {
if (str == null) {
return;
}
if (this.requestMetadata.has(str) && str2 == null) {
this.requestMetadata.remove(str);
}
try {
this.requestMetadata.put(str, str2);
} catch (JSONException unused) {
}
}
public void setRetryCount(int i) {
setInteger(KEY_RETRY_COUNT, i);
}
public void setRetryInterval(int i) {
setInteger(KEY_RETRY_INTERVAL, i);
}
public void setSessionID(String str) {
setString(KEY_SESSION_ID, str);
}
public void setSessionParams(String str) {
setString(KEY_SESSION_PARAMS, str);
}
public void setString(String str, String str2) {
this.prefsEditor_.putString(str, str2).apply();
}
public void setTimeout(int i) {
setInteger(KEY_TIMEOUT, i);
}
public void setUserURL(String str) {
setString(KEY_USER_URL, str);
}
public boolean shouldAddModules() {
try {
return this.secondaryRequestMetadata.length() != 0;
} catch (Exception unused) {
return false;
}
}
public void updateBranchViewUsageCount(String str) {
setInteger("bnc_branch_view_use_" + str, getBranchViewUsageCount(str) + 1);
}
}