- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
494 lines
19 KiB
Java
494 lines
19 KiB
Java
package com.helpshift.config;
|
|
|
|
import com.applovin.impl.sdk.utils.JsonUtils;
|
|
import com.ea.nimble.ApplicationEnvironment;
|
|
import com.facebook.share.internal.ShareConstants;
|
|
import com.glu.plugins.gluanalytics.AnalyticsData;
|
|
import com.helpshift.analytics.HSWebchatAnalyticsManager;
|
|
import com.helpshift.log.HSLogger;
|
|
import com.helpshift.platform.Device;
|
|
import com.helpshift.storage.HSPersistentStorage;
|
|
import com.helpshift.user.UserManager;
|
|
import com.helpshift.util.Utils;
|
|
import com.helpshift.util.ValuePair;
|
|
import com.ironsource.ad;
|
|
import com.ironsource.v8;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Date;
|
|
import java.util.Iterator;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class HSConfigManager {
|
|
public Device device;
|
|
public boolean hcIsSandbox;
|
|
public HSPersistentStorage persistentStorage;
|
|
public String sdkSource;
|
|
public UserManager userManager;
|
|
public HSWebchatAnalyticsManager webchatAnalyticsManager;
|
|
public ArrayList debugLogs = new ArrayList();
|
|
public ArrayList userTrailList = new ArrayList();
|
|
|
|
public void saveSDKSource(String str) {
|
|
this.sdkSource = str;
|
|
}
|
|
|
|
public HSConfigManager(HSPersistentStorage hSPersistentStorage, HSWebchatAnalyticsManager hSWebchatAnalyticsManager, Device device, UserManager userManager) {
|
|
this.persistentStorage = hSPersistentStorage;
|
|
this.webchatAnalyticsManager = hSWebchatAnalyticsManager;
|
|
this.device = device;
|
|
this.userManager = userManager;
|
|
}
|
|
|
|
public void saveInstallKeys(String str, String str2) {
|
|
String[] split = str2.split("\\.", 2);
|
|
this.persistentStorage.setDomain(split[0]);
|
|
this.persistentStorage.setHost(split[1]);
|
|
this.persistentStorage.setPlatformId(str);
|
|
}
|
|
|
|
public String getPlatformId() {
|
|
return this.persistentStorage.getPlatformId();
|
|
}
|
|
|
|
public String getDomain() {
|
|
return this.persistentStorage.getDomain();
|
|
}
|
|
|
|
public void saveConfig(Map map) {
|
|
this.persistentStorage.setConfig(Utils.mapToJsonString(map));
|
|
}
|
|
|
|
public void saveCustomIssueFields(Map map) {
|
|
this.persistentStorage.setCIFs(Utils.mapToJsonString(map));
|
|
}
|
|
|
|
public void saveLanguage(String str) {
|
|
this.persistentStorage.setLanguage(str);
|
|
}
|
|
|
|
public void saveUiConfigDataOfWebchat(String str) {
|
|
saveUiConfigDataFor("webchat", str);
|
|
}
|
|
|
|
public void saveUiConfigDataOfHelpcenter(String str) {
|
|
saveUiConfigDataFor("helpcenter", str);
|
|
}
|
|
|
|
public String getUiConfigDataOfWebchat() {
|
|
return getUiConfigDataFor("webchat");
|
|
}
|
|
|
|
public String getUiConfigDataOfHelpcenter() {
|
|
return getUiConfigDataFor("helpcenter");
|
|
}
|
|
|
|
public final void saveUiConfigDataFor(String str, String str2) {
|
|
if (Utils.isEmpty(str2) || !Utils.isValidJsonString(str2)) {
|
|
return;
|
|
}
|
|
try {
|
|
JSONObject jSONObject = new JSONObject(str2);
|
|
if ("webchat".equals(str)) {
|
|
this.persistentStorage.setWebchatUiConfigData(jSONObject.toString());
|
|
} else if ("helpcenter".equals(str)) {
|
|
this.persistentStorage.setHelpcenterUiConfigData(jSONObject.toString());
|
|
}
|
|
} catch (Exception e) {
|
|
HSLogger.e("ConfigMangr", "error in saving the ui config data for " + str, e);
|
|
}
|
|
}
|
|
|
|
public final String getUiConfigDataFor(String str) {
|
|
if ("webchat".equals(str)) {
|
|
return this.persistentStorage.getWebchatUiConfigData();
|
|
}
|
|
return "helpcenter".equals(str) ? this.persistentStorage.getHelpcenterUiConfigData() : "";
|
|
}
|
|
|
|
public String getCif() {
|
|
String cif = this.persistentStorage.getCIF();
|
|
return Utils.isEmpty(cif) ? JsonUtils.EMPTY_JSON : cif;
|
|
}
|
|
|
|
public String getHelpcenterConfigJs(String str, String str2, boolean z) {
|
|
JSONObject helpshiftConfig = getHelpshiftConfig(false);
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
if (Utils.isNotEmpty(str)) {
|
|
jSONObject.put("faqId", str);
|
|
}
|
|
if (Utils.isNotEmpty(str2)) {
|
|
jSONObject.put("sectionId", str2);
|
|
}
|
|
if (z) {
|
|
jSONObject.put("showChatIcon", false);
|
|
} else if (this.userManager.shouldShowChatIconInHelpcenter()) {
|
|
jSONObject.put("showChatIcon", true);
|
|
}
|
|
String additionalHelpcenterData = this.persistentStorage.getAdditionalHelpcenterData();
|
|
if (Utils.isNotEmpty(additionalHelpcenterData) && Utils.isValidJsonString(additionalHelpcenterData)) {
|
|
jSONObject.put("additionalInfo", new JSONObject(additionalHelpcenterData));
|
|
}
|
|
if (this.hcIsSandbox) {
|
|
jSONObject.put("hcIsSandbox", true);
|
|
}
|
|
helpshiftConfig.put("helpcenterConfig", jSONObject);
|
|
return helpshiftConfig.toString();
|
|
} catch (Exception e) {
|
|
HSLogger.e("ConfigMangr", "Error in generating the helpcenter config", e);
|
|
return helpshiftConfig.toString();
|
|
}
|
|
}
|
|
|
|
public String getWebchatConfigJs(boolean z) {
|
|
return getHelpshiftConfig(z).toString();
|
|
}
|
|
|
|
public final JSONObject getHelpshiftConfig(boolean z) {
|
|
String platformId = getPlatformId();
|
|
String domain = getDomain();
|
|
String config = this.persistentStorage.getConfig();
|
|
JSONObject liteSdkConfig = getLiteSdkConfig(z);
|
|
if (Utils.isEmpty(config)) {
|
|
config = JsonUtils.EMPTY_JSON;
|
|
}
|
|
try {
|
|
JSONObject jSONObject = new JSONObject(config);
|
|
jSONObject.put("platformId", platformId);
|
|
jSONObject.put("domain", domain);
|
|
addWidgetOption(jSONObject);
|
|
addLanguage(jSONObject);
|
|
addUserConfig(jSONObject);
|
|
addClearAnonymousUserConfig(jSONObject);
|
|
addSDKSource(jSONObject);
|
|
if ("proactive".equals(this.sdkSource)) {
|
|
addConfigForSubsequentProactiveIssues(jSONObject);
|
|
}
|
|
addAnonUserIdToLiteSDKConfig(liteSdkConfig);
|
|
if (!this.userTrailList.isEmpty()) {
|
|
jSONObject.put("userTrail", new JSONArray((Collection) this.userTrailList));
|
|
}
|
|
jSONObject.put("liteSdkConfig", liteSdkConfig);
|
|
return jSONObject;
|
|
} catch (JSONException e) {
|
|
HSLogger.e("ConfigMangr", "Error in creating the config object", e);
|
|
return new JSONObject();
|
|
}
|
|
}
|
|
|
|
public final void addAnonUserIdToLiteSDKConfig(JSONObject jSONObject) {
|
|
if (Utils.isNotEmpty(this.persistentStorage.getAnonymousUserIdMap())) {
|
|
String str = (String) Utils.jsonStringToMap(this.persistentStorage.getAnonymousUserIdMap()).get("userId");
|
|
if (Utils.isNotEmpty(str)) {
|
|
jSONObject.put("anonUserId", str);
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void addConfigForSubsequentProactiveIssues(JSONObject jSONObject) {
|
|
String localProactiveConfig = this.persistentStorage.getLocalProactiveConfig();
|
|
if (Utils.isEmpty(localProactiveConfig)) {
|
|
localProactiveConfig = JsonUtils.EMPTY_JSON;
|
|
}
|
|
try {
|
|
jSONObject.put("configForSubsequentProactiveIssues", new JSONObject(localProactiveConfig));
|
|
} catch (JSONException e) {
|
|
HSLogger.e("ConfigMangr", "Error in setting local proactive config ", e);
|
|
}
|
|
}
|
|
|
|
public final void addClearAnonymousUserConfig(JSONObject jSONObject) {
|
|
try {
|
|
jSONObject.put("clearAnonymousUserOnLogin", this.persistentStorage.isClearAnonymousUser());
|
|
} catch (JSONException e) {
|
|
HSLogger.e("ConfigMangr", "error in setting clear anonymous user flag ", e);
|
|
}
|
|
}
|
|
|
|
public final void addSDKSource(JSONObject jSONObject) {
|
|
HSLogger.d("ConfigMangr", "Adding sdk open source value to config : " + this.sdkSource);
|
|
if (Utils.isEmpty(this.sdkSource)) {
|
|
return;
|
|
}
|
|
jSONObject.put(ShareConstants.FEED_SOURCE_PARAM, this.sdkSource);
|
|
}
|
|
|
|
public final void addWidgetOption(JSONObject jSONObject) {
|
|
if (jSONObject.has("widgetOptions")) {
|
|
return;
|
|
}
|
|
JSONObject jSONObject2 = new JSONObject();
|
|
try {
|
|
jSONObject2.put("showLauncher", false);
|
|
jSONObject2.put("fullScreen", true);
|
|
jSONObject.put("widgetOptions", jSONObject2);
|
|
} catch (JSONException e) {
|
|
HSLogger.e("ConfigMangr", "Error in setting the widget option config", e);
|
|
}
|
|
}
|
|
|
|
public final void addLanguage(JSONObject jSONObject) {
|
|
if (jSONObject.has("language")) {
|
|
return;
|
|
}
|
|
try {
|
|
String language = this.persistentStorage.getLanguage();
|
|
if (Utils.isEmpty(language)) {
|
|
language = this.device.getLanguage();
|
|
}
|
|
jSONObject.put("language", language);
|
|
} catch (Exception e) {
|
|
HSLogger.e("ConfigMangr", "Error in setting the language", e);
|
|
}
|
|
}
|
|
|
|
public final void addUserConfig(JSONObject jSONObject) {
|
|
String activeUser = this.persistentStorage.getActiveUser();
|
|
if (Utils.isNotEmpty(activeUser)) {
|
|
try {
|
|
JSONObject jSONObject2 = new JSONObject(activeUser);
|
|
Iterator<String> keys = jSONObject2.keys();
|
|
while (keys.hasNext()) {
|
|
String next = keys.next();
|
|
jSONObject.put(next, jSONObject2.get(next));
|
|
}
|
|
} catch (JSONException e) {
|
|
HSLogger.e("ConfigMangr", "Error in setting the user config", e);
|
|
}
|
|
}
|
|
}
|
|
|
|
public synchronized void pushBreadCrumb(String str) {
|
|
try {
|
|
try {
|
|
String format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH).format(new Date());
|
|
JSONArray breadCrumbs = this.persistentStorage.getBreadCrumbs();
|
|
if (breadCrumbs == null) {
|
|
breadCrumbs = new JSONArray();
|
|
}
|
|
if (str.length() > 5000) {
|
|
str = str.substring(0, 5000);
|
|
}
|
|
breadCrumbs.put(jsonifyBreadCrumb(str.trim(), format));
|
|
int length = breadCrumbs.length();
|
|
if (length > 100) {
|
|
JSONArray jSONArray = new JSONArray();
|
|
for (int i = length - 100; i <= 100; i++) {
|
|
jSONArray.put(breadCrumbs.getJSONObject(i));
|
|
}
|
|
breadCrumbs = jSONArray;
|
|
}
|
|
this.persistentStorage.setBreadCrumbs(breadCrumbs.toString());
|
|
} catch (Exception e) {
|
|
HSLogger.e("ConfigMangr", "Error pushing BreadCrumbs", e);
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
public synchronized void clearBreadCrumbs() {
|
|
this.persistentStorage.setBreadCrumbs(new JSONArray().toString());
|
|
}
|
|
|
|
public final JSONObject jsonifyBreadCrumb(String str, String str2) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
jSONObject.put("a", str);
|
|
jSONObject.put("d", str2);
|
|
return jSONObject;
|
|
}
|
|
|
|
public synchronized JSONArray getDebugLogs(int i) {
|
|
JSONArray jSONArray;
|
|
jSONArray = new JSONArray();
|
|
try {
|
|
int min = Math.min(this.debugLogs.size(), i);
|
|
for (int i2 = 0; i2 < min; i2++) {
|
|
jSONArray.put(this.debugLogs.get(i2));
|
|
}
|
|
} catch (Exception e) {
|
|
HSLogger.e("ConfigMangr", "Error getting DebugLogs.", e);
|
|
}
|
|
return jSONArray;
|
|
}
|
|
|
|
public synchronized JSONArray getBreadCrumbs(int i) {
|
|
JSONArray jSONArray;
|
|
jSONArray = new JSONArray();
|
|
try {
|
|
JSONArray breadCrumbs = this.persistentStorage.getBreadCrumbs();
|
|
int length = breadCrumbs.length();
|
|
for (int i2 = i < length ? length - i : 0; i2 < length; i2++) {
|
|
jSONArray.put(breadCrumbs.get(i2));
|
|
}
|
|
} catch (Exception e) {
|
|
HSLogger.e("ConfigMangr", "Error getting breadcrumbs", e);
|
|
}
|
|
return jSONArray;
|
|
}
|
|
|
|
public final JSONObject getLiteSdkConfig(boolean z) {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
String localStorageData = this.persistentStorage.getLocalStorageData();
|
|
if (Utils.isNotEmpty(localStorageData)) {
|
|
jSONObject.put("localStorageData", new JSONObject(localStorageData));
|
|
}
|
|
jSONObject.put("metaData", generateDeviceMetadata());
|
|
jSONObject.put(ad.y, this.device.getOsType());
|
|
String currentPushToken = this.persistentStorage.getCurrentPushToken();
|
|
if (Utils.isNotEmpty(currentPushToken) && !this.userManager.isPushTokenSynced()) {
|
|
jSONObject.put("pushToken", currentPushToken);
|
|
}
|
|
jSONObject.put("analyticsData", new JSONObject(this.webchatAnalyticsManager.getAnalyticsDataMap()));
|
|
jSONObject.put("deviceId", this.device.getDeviceId());
|
|
jSONObject.put("launchedFromHelpcenter", z);
|
|
return jSONObject;
|
|
} catch (JSONException e) {
|
|
HSLogger.e("ConfigMangr", "error in generating liteSdkConfig", e);
|
|
return jSONObject;
|
|
}
|
|
}
|
|
|
|
public final JSONObject generateDeviceMetadata() {
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put(v8.i.W, this.device.getAppVersion());
|
|
jSONObject.put("appName", this.device.getAppName());
|
|
jSONObject.put("appIdentifier", this.device.getAppIdentifier());
|
|
jSONObject.put(v8.i.Y, this.device.getBatteryLevel());
|
|
jSONObject.put("batteryStatus", this.device.getBatteryStatus());
|
|
jSONObject.put(AnalyticsData.S_CARRIER_NAME, this.device.getCarrierName());
|
|
jSONObject.put(ApplicationEnvironment.NIMBLE_PARAMETER_COUNTRY_CODE, this.device.getCountryCode());
|
|
jSONObject.put("networkType", this.device.getNetworkType());
|
|
ValuePair diskSpace = this.device.getDiskSpace();
|
|
jSONObject.put("diskSpace", diskSpace.first);
|
|
jSONObject.put("freeSpace", diskSpace.second);
|
|
jSONObject.put(AnalyticsData.S_OS_VERSION, this.device.getOSVersion());
|
|
jSONObject.put("deviceModel", this.device.getDeviceModel());
|
|
jSONObject.put("liteSdkVersion", this.device.getSDKVersion());
|
|
jSONObject.put("pluginType", this.webchatAnalyticsManager.getCommonAnalyticsMap().get("s"));
|
|
String str = (String) this.webchatAnalyticsManager.getCommonAnalyticsMap().get("pv");
|
|
if (!Utils.isEmpty(str)) {
|
|
jSONObject.put("pluginVersion", str);
|
|
}
|
|
} catch (JSONException e) {
|
|
HSLogger.e("ConfigMangr", "error in generating device metadata", e);
|
|
}
|
|
return jSONObject;
|
|
}
|
|
|
|
public void setLocalStorageData(String str) {
|
|
if (Utils.isEmpty(str) || !Utils.isValidJsonString(str)) {
|
|
return;
|
|
}
|
|
try {
|
|
String localStorageData = this.persistentStorage.getLocalStorageData();
|
|
if (Utils.isNotEmpty(localStorageData)) {
|
|
JSONObject jSONObject = new JSONObject(str);
|
|
JSONObject jSONObject2 = new JSONObject(localStorageData);
|
|
Iterator<String> keys = jSONObject.keys();
|
|
while (keys.hasNext()) {
|
|
String next = keys.next();
|
|
jSONObject2.put(next, jSONObject.get(next));
|
|
}
|
|
this.persistentStorage.saveLocalStorageData(jSONObject2.toString());
|
|
return;
|
|
}
|
|
this.persistentStorage.saveLocalStorageData(str);
|
|
} catch (JSONException e) {
|
|
HSLogger.e("ConfigMangr", "error in storing local storage data", e);
|
|
}
|
|
}
|
|
|
|
public void removeLocalStorageData(String str) {
|
|
if (Utils.isEmpty(str) || !Utils.isValidJsonString(str)) {
|
|
return;
|
|
}
|
|
String localStorageData = this.persistentStorage.getLocalStorageData();
|
|
if (Utils.isEmpty(localStorageData)) {
|
|
return;
|
|
}
|
|
try {
|
|
JSONArray jSONArray = new JSONObject(str).getJSONArray("data");
|
|
JSONObject jSONObject = new JSONObject(localStorageData);
|
|
for (int i = 0; i < jSONArray.length(); i++) {
|
|
String string = jSONArray.getString(i);
|
|
if (jSONObject.has(string)) {
|
|
jSONObject.remove(string);
|
|
}
|
|
}
|
|
this.persistentStorage.saveLocalStorageData(jSONObject.toString());
|
|
} catch (JSONException e) {
|
|
HSLogger.e("ConfigMangr", "error in deleting local storage data", e);
|
|
}
|
|
}
|
|
|
|
public String getLocalStorageData() {
|
|
String localStorageData = this.persistentStorage.getLocalStorageData();
|
|
return Utils.isEmpty(localStorageData) ? JsonUtils.EMPTY_JSON : localStorageData;
|
|
}
|
|
|
|
public void setAdditionalHelpcenterData(String str) {
|
|
if (Utils.isEmpty(str) || !Utils.isValidJsonString(str)) {
|
|
return;
|
|
}
|
|
try {
|
|
String additionalHelpcenterData = this.persistentStorage.getAdditionalHelpcenterData();
|
|
if (Utils.isNotEmpty(additionalHelpcenterData)) {
|
|
JSONObject jSONObject = new JSONObject(str);
|
|
JSONObject jSONObject2 = new JSONObject(additionalHelpcenterData);
|
|
Iterator<String> keys = jSONObject.keys();
|
|
while (keys.hasNext()) {
|
|
String next = keys.next();
|
|
jSONObject2.put(next, jSONObject.get(next));
|
|
}
|
|
this.persistentStorage.saveAdditionalHelpcenterData(jSONObject2.toString());
|
|
return;
|
|
}
|
|
this.persistentStorage.saveAdditionalHelpcenterData(str);
|
|
} catch (Exception e) {
|
|
HSLogger.e("ConfigMangr", "error in storing additional Helpcenter data", e);
|
|
}
|
|
}
|
|
|
|
public String getAdditionalInfo() {
|
|
String additionalHelpcenterData = this.persistentStorage.getAdditionalHelpcenterData();
|
|
return Utils.isEmpty(additionalHelpcenterData) ? JsonUtils.EMPTY_JSON : additionalHelpcenterData;
|
|
}
|
|
|
|
public void removeAdditionalHelpcenterData(String str) {
|
|
if (Utils.isEmpty(str) || !Utils.isValidJsonString(str)) {
|
|
return;
|
|
}
|
|
String additionalHelpcenterData = this.persistentStorage.getAdditionalHelpcenterData();
|
|
if (Utils.isEmpty(additionalHelpcenterData)) {
|
|
return;
|
|
}
|
|
try {
|
|
JSONArray jSONArray = new JSONObject(str).getJSONArray("data");
|
|
JSONObject jSONObject = new JSONObject(additionalHelpcenterData);
|
|
for (int i = 0; i < jSONArray.length(); i++) {
|
|
String string = jSONArray.getString(i);
|
|
if (jSONObject.has(string)) {
|
|
jSONObject.remove(string);
|
|
}
|
|
}
|
|
this.persistentStorage.saveAdditionalHelpcenterData(jSONObject.toString());
|
|
} catch (Exception e) {
|
|
HSLogger.e("ConfigMangr", "error in deleting helpcenter data", e);
|
|
}
|
|
}
|
|
|
|
public void clearUserTrail() {
|
|
this.userTrailList.clear();
|
|
}
|
|
}
|