正在查看: Oolka v2.4.42 应用的 HVRemoteConfigRepo.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Oolka v2.4.42 应用的 HVRemoteConfigRepo.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package co.hyperverge.hypersnapsdk.data.remote;
import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
import co.hyperverge.hypersnapsdk.data.RemoteConfig;
import co.hyperverge.hypersnapsdk.data.models.FeatureConfigResponse;
import co.hyperverge.hypersnapsdk.helpers.HVFeatureConfigHelper;
import co.hyperverge.hypersnapsdk.helpers.SDKInternalConfig;
import co.hyperverge.hypersnapsdk.objects.HVError;
import co.hyperverge.hypersnapsdk.utils.HVLogUtils;
import co.hyperverge.hypersnapsdk.utils.Utils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import okhttp3.Cache;
import retrofit2.b;
import retrofit2.c;
import retrofit2.w;
@SuppressLint({"LogNotTimber"})
public class HVRemoteConfigRepo {
static final boolean $assertionsDisabled = false;
private static final String TAG = "co.hyperverge.hypersnapsdk.data.remote.HVRemoteConfigRepo";
private static HVRemoteConfigRepo instance;
private final Cache cacheDir;
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
public interface HVCallback {
void onError(HVError hVError);
void onSuccess();
}
private HVRemoteConfigRepo(Cache cache) {
this.cacheDir = cache;
}
public static HVRemoteConfigRepo getInstance(Cache cache) {
if (instance == null) {
instance = new HVRemoteConfigRepo(cache);
}
return instance;
}
public void lambda$getFeatureConfigs$0(String str, String str2, HVCallback hVCallback) {
try {
RemoteConfigApiInterface remoteConfigService = ApiClient.getRemoteConfigService(this.cacheDir);
w execute = remoteConfigService.getFeatureRemoteConfig(str).execute();
w execute2 = remoteConfigService.getFeatureRemoteConfig(str2).execute();
if (execute.f()) {
SDKInternalConfig.getInstance().setFeatureConfigMap(HVFeatureConfigHelper.extractFeatureMap(((FeatureConfigResponse) execute.a()).getFeatures(), execute2.f() ? ((FeatureConfigResponse) execute2.a()).getFeatures() : new ArrayList<>()));
hVCallback.onSuccess();
return;
}
hVCallback.onError(new HVError(12, logServerError(execute) + "\n" + logServerError(execute2)));
} catch (Exception e) {
HVLogUtils.e(TAG, "getFeatureConfigs(): exception = [" + Utils.getErrorMessage(e) + "]", e);
hVCallback.onError(new HVError(12, Utils.getErrorMessage(e)));
}
}
public void logAPICallError(boolean z, String str, int i) {
HVLogUtils.d(TAG, "logAPICallError() called with: shouldLogForBrandingCheck = [" + z + "], errorMessage = [" + str + "], errorCode = [" + i + "]");
if (z) {
if (!SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() || SDKInternalConfig.getInstance().getAnalyticsTrackerService() == null) {
return;
}
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logCheckBrandingAPIError(str, i);
return;
}
if (!SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() || SDKInternalConfig.getInstance().getAnalyticsTrackerService() == null) {
return;
}
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logRemoteConfigAPIError(str, i);
}
public void logAPICallSuccess(boolean z) {
HVLogUtils.d(TAG, "logAPICallSuccess() called with: shouldLogForBrandingCheck = [" + z + "]");
if (z) {
if (!SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() || SDKInternalConfig.getInstance().getAnalyticsTrackerService() == null) {
return;
}
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logCheckBrandingAPISuccess();
return;
}
if (!SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser() || SDKInternalConfig.getInstance().getAnalyticsTrackerService() == null) {
return;
}
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logRemoteConfigAPISuccess();
}
private <T> String logServerError(w<T> wVar) {
String string;
if (wVar.f()) {
return "";
}
if (wVar.d() != null) {
try {
string = wVar.d().string();
} catch (IOException e) {
HVLogUtils.e(TAG, "logServerError(): exception = [" + Utils.getErrorMessage(e) + "]", e);
Utils.getErrorMessage(e);
}
logAPICallError(false, string, wVar.b());
return string;
}
string = "Server Error";
logAPICallError(false, string, wVar.b());
return string;
}
public void getFeatureConfigs(String str, final HVCallback hVCallback) {
String str2 = TAG;
HVLogUtils.d(str2, "getFeatureConfigs() called with: sdkVersion = [" + str + "], callback = [" + hVCallback + "]");
String s3FeatureConfigBaseUrl = SDKInternalConfig.getInstance().getS3FeatureConfigBaseUrl();
final String str3 = s3FeatureConfigBaseUrl + "sdkV2.json";
final String str4 = s3FeatureConfigBaseUrl + String.format("%s.json", str);
HVLogUtils.d(str2, "getFeatureConfigs(): sdkJsonUrl: " + str3);
HVLogUtils.d(str2, "getFeatureConfigs(): versionSpecificJsonUrl: " + str4);
this.executorService.submit(new Runnable() {
@Override
public final void run() {
HVRemoteConfigRepo.this.lambda$getFeatureConfigs$0(str3, str4, hVCallback);
}
});
}
public void getRemoteConfig(String str, final boolean z, final HVCallback hVCallback) {
HVLogUtils.d(TAG, "getRemoteConfig() called with: appId = [" + str + "], isForCheckBranding = [" + z + "], callback = [" + hVCallback + "]");
StringBuilder sb = new StringBuilder();
sb.append("https://s3-ap-south-1.amazonaws.com/hv-central-config/sdk-client-config/hypersnapsdk/v1/");
sb.append(str);
sb.append(".json");
ApiClient.getRemoteConfigService(this.cacheDir).getRemoteConfig(sb.toString()).C0(new c<RemoteConfig>() {
public void onFailure(@NonNull b<RemoteConfig> bVar, @NonNull Throwable th) {
HVLogUtils.d(HVRemoteConfigRepo.TAG, "getRemoteConfig(): onFailure() called with: call = [" + bVar + "], t = [" + th + "]");
if (z) {
HVRemoteConfigRepo.this.logAPICallError(true, Utils.getErrorMessage(th), 12);
}
SDKInternalConfig.getInstance().setRemoteConfig(new RemoteConfig());
hVCallback.onError(new HVError(12, "Could not get remote configs"));
}
public void onResponse(@NonNull b<RemoteConfig> bVar, @NonNull w<RemoteConfig> wVar) {
String string;
HVLogUtils.d(HVRemoteConfigRepo.TAG, "getRemoteConfig(): onResponse() called with: call = [" + bVar + "], response = [" + wVar + "]");
if (wVar.f()) {
HVRemoteConfigRepo.this.logAPICallSuccess(z);
SDKInternalConfig.getInstance().setRemoteConfig((RemoteConfig) wVar.a());
hVCallback.onSuccess();
return;
}
if (wVar.d() != null) {
try {
string = wVar.d().string();
} catch (IOException e) {
Utils.getErrorMessage(e);
}
HVRemoteConfigRepo.this.logAPICallError(z, string, wVar.b());
SDKInternalConfig.getInstance().createDefaultMixpanelConfigs();
hVCallback.onError(new HVError(wVar.b(), "Could not get remote configs"));
}
string = "Server Error";
HVRemoteConfigRepo.this.logAPICallError(z, string, wVar.b());
SDKInternalConfig.getInstance().createDefaultMixpanelConfigs();
hVCallback.onError(new HVError(wVar.b(), "Could not get remote configs"));
}
});
}
}