Kufar v3.2.0版本的 MD5 值为:6a4d203db1c561c7e3bcd50d23fed59f
以下内容为反编译后的 GrowthBookRemoteConfig.java 源代码,内容仅作参考
package by.kufar.feature.toggles.provider;
import androidx.exifinterface.media.ExifInterface;
import by.kufar.feature.toggles.ToggleKey;
import com.sdk.growthbook.GBSDKBuilder;
import com.sdk.growthbook.GrowthBookSDK;
import com.sdk.growthbook.Network.NetworkDispatcher;
import com.sdk.growthbook.model.GBExperiment;
import com.sdk.growthbook.model.GBExperimentResult;
import com.sdk.growthbook.model.GBFeatureResult;
import d80.p;
import d80.q;
import d80.u;
import e80.m0;
import e80.n0;
import java.io.IOException;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.s;
import o6.a;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
@Metadata(d1 = {"\u0000R\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\t\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\b\bÆ\u0002\u0018\u00002\u00020\u0001:\u0002!\"B\t\b\u0002¢\u0006\u0004\b\u001f\u0010 J\f\u0010\u0004\u001a\u00020\u0003*\u00020\u0002H\u0002J<\u0010\u0011\u001a\u00020\u000e2\u0006\u0010\u0006\u001a\u00020\u00052\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010\n\u001a\u00020\t2\u001c\u0010\u0010\u001a\u0018\u0012\u0004\u0012\u00020\f\u0012\u0004\u0012\u00020\r\u0012\u0004\u0012\u00020\u000e0\u000bj\u0002`\u000fJ\u0019\u0010\u0013\u001a\u0004\u0018\u00010\u00052\u0006\u0010\u0012\u001a\u00020\u0002H\u0016¢\u0006\u0004\b\u0013\u0010\u0014J\u0012\u0010\u0016\u001a\u0004\u0018\u00010\u00152\u0006\u0010\u0012\u001a\u00020\u0002H\u0016J\u0019\u0010\u0018\u001a\u0004\u0018\u00010\u00172\u0006\u0010\u0012\u001a\u00020\u0002H\u0016¢\u0006\u0004\b\u0018\u0010\u0019J\u0012\u0010\u001a\u001a\u0004\u0018\u00010\u00152\u0006\u0010\u0012\u001a\u00020\u0002H\u0016R\u0018\u0010\u001c\u001a\u0004\u0018\u00010\u001b8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u001c\u0010\u001dR\u0018\u0010\b\u001a\u0004\u0018\u00010\u00078\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\b\u0010\u001e¨\u0006#"}, d2 = {"Lby/kufar/feature/toggles/provider/GrowthBookRemoteConfig;", "Lby/kufar/feature/toggles/provider/ValuesProvider;", "Lby/kufar/feature/toggles/ToggleKey;", "Lby/kufar/feature/toggles/ToggleKey$GrowthBook;", "requireGrowthBook", "", "isDebug", "Lokhttp3/Call$Factory;", "callFactory", "Lo6/a$b;", "rudderAnonymousIdProvider", "Lkotlin/Function2;", "Lcom/sdk/growthbook/model/GBExperiment;", "Lcom/sdk/growthbook/model/GBExperimentResult;", "", "Lcom/sdk/growthbook/GBTrackingCallback;", "trackingCallback", "init", "toggleKey", "getBoolean", "(Lby/kufar/feature/toggles/ToggleKey;)Ljava/lang/Boolean;", "", "getString", "", "getLong", "(Lby/kufar/feature/toggles/ToggleKey;)Ljava/lang/Long;", "getExperimentGroup", "Lcom/sdk/growthbook/GrowthBookSDK;", "growthBookSdk", "Lcom/sdk/growthbook/GrowthBookSDK;", "Lokhttp3/Call$Factory;", "<init>", "()V", "Attributes", "GrowthBookNetworkDispatcher", "feature-toggles_googleRelease"}, k = 1, mv = {1, 9, 0})
public final class GrowthBookRemoteConfig implements ValuesProvider {
public static final GrowthBookRemoteConfig INSTANCE = new GrowthBookRemoteConfig();
private static Call.Factory callFactory;
private static GrowthBookSDK growthBookSdk;
@Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\bÂ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000¨\u0006\u0005"}, d2 = {"Lby/kufar/feature/toggles/provider/GrowthBookRemoteConfig$Attributes;", "", "()V", "DEVICE_ID", "", "feature-toggles_googleRelease"}, k = 1, mv = {1, 9, 0}, xi = 48)
public static final class Attributes {
public static final String DEVICE_ID = "deviceId";
public static final Attributes INSTANCE = new Attributes();
private Attributes() {
}
}
@Metadata(d1 = {"\u0000$\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0003\n\u0000\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J8\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\u0012\u0010\u0007\u001a\u000e\u0012\u0004\u0012\u00020\u0006\u0012\u0004\u0012\u00020\u00040\b2\u0012\u0010\t\u001a\u000e\u0012\u0004\u0012\u00020\n\u0012\u0004\u0012\u00020\u00040\bH\u0017¨\u0006\u000b"}, d2 = {"Lby/kufar/feature/toggles/provider/GrowthBookRemoteConfig$GrowthBookNetworkDispatcher;", "Lcom/sdk/growthbook/Network/NetworkDispatcher;", "()V", "consumeGETRequest", "", "request", "", "onSuccess", "Lkotlin/Function1;", "onError", "", "feature-toggles_googleRelease"}, k = 1, mv = {1, 9, 0}, xi = 48)
public static final class GrowthBookNetworkDispatcher implements NetworkDispatcher {
@Override
public void consumeGETRequest(String request, final Function1<? super String, Unit> onSuccess, final Function1<? super Throwable, Unit> onError) {
Call newCall;
s.j(request, "request");
s.j(onSuccess, "onSuccess");
s.j(onError, "onError");
Call.Factory factory = GrowthBookRemoteConfig.callFactory;
if (factory != null && (newCall = factory.newCall(new Request.Builder().url(request).get().build())) != null) {
newCall.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e11) {
s.j(call, "call");
s.j(e11, "e");
onError.invoke(e11);
}
@Override
public void onResponse(Call call, Response response) {
Object b11;
String str;
s.j(call, "call");
s.j(response, "response");
Function1<String, Unit> function1 = onSuccess;
Function1<Throwable, Unit> function12 = onError;
try {
p.Companion companion = p.INSTANCE;
ResponseBody body = response.body();
if (body != null) {
str = body.string();
} else {
str = null;
}
if (str != null) {
function1.invoke(str);
} else {
function12.invoke(new IOException("Failed to get response"));
}
b11 = p.b(Unit.f82492a);
} catch (Throwable th2) {
p.Companion companion2 = p.INSTANCE;
b11 = p.b(q.a(th2));
}
Function1<Throwable, Unit> function13 = onError;
Throwable e11 = p.e(b11);
if (e11 != null) {
function13.invoke(e11);
}
}
});
}
}
}
private GrowthBookRemoteConfig() {
}
private final ToggleKey.GrowthBook requireGrowthBook(ToggleKey toggleKey) {
if (toggleKey instanceof ToggleKey.GrowthBook) {
return (ToggleKey.GrowthBook) toggleKey;
}
throw new IllegalStateException("Must be ToggleKey.Growthbook");
}
@Override
public Boolean getBoolean(ToggleKey toggleKey) {
GBFeatureResult feature;
s.j(toggleKey, "toggleKey");
try {
requireGrowthBook(toggleKey);
GrowthBookSDK growthBookSDK = growthBookSdk;
if (growthBookSDK == null || (feature = growthBookSDK.feature(toggleKey.getId())) == null) {
return null;
}
return Boolean.valueOf(feature.getOn());
} catch (Throwable unused) {
return null;
}
}
@Override
public String getExperimentGroup(ToggleKey toggleKey) {
Integer num;
GBFeatureResult feature;
GBExperimentResult experimentResult;
s.j(toggleKey, "toggleKey");
try {
requireGrowthBook(toggleKey);
GrowthBookSDK growthBookSDK = growthBookSdk;
if (growthBookSDK != null && (feature = growthBookSDK.feature(toggleKey.getId())) != null && (experimentResult = feature.getExperimentResult()) != null) {
num = Integer.valueOf(experimentResult.getVariationId());
} else {
num = null;
}
if (num != null && num.intValue() == 0) {
return ExifInterface.GPS_MEASUREMENT_IN_PROGRESS;
}
if (num != null && num.intValue() == 1) {
return "B";
}
if (num.intValue() != 2) {
return ExifInterface.GPS_MEASUREMENT_IN_PROGRESS;
}
return "C";
} catch (Throwable unused) {
return null;
}
}
@Override
public Long getLong(ToggleKey toggleKey) {
GBFeatureResult feature;
Object value;
String obj;
s.j(toggleKey, "toggleKey");
try {
requireGrowthBook(toggleKey);
GrowthBookSDK growthBookSDK = growthBookSdk;
if (growthBookSDK == null || (feature = growthBookSDK.feature(toggleKey.getId())) == null || (value = feature.getValue()) == null || (obj = value.toString()) == null) {
return null;
}
return a90.q.r(obj);
} catch (Throwable unused) {
return null;
}
}
@Override
public String getString(ToggleKey toggleKey) {
GBFeatureResult feature;
Object value;
s.j(toggleKey, "toggleKey");
try {
requireGrowthBook(toggleKey);
GrowthBookSDK growthBookSDK = growthBookSdk;
if (growthBookSDK == null || (feature = growthBookSDK.feature(toggleKey.getId())) == null || (value = feature.getValue()) == null) {
return null;
}
return value.toString();
} catch (Throwable unused) {
return null;
}
}
public final void init(boolean isDebug, Call.Factory callFactory2, a.b rudderAnonymousIdProvider, Function2<? super GBExperiment, ? super GBExperimentResult, Unit> trackingCallback) {
Object b11;
s.j(callFactory2, "callFactory");
s.j(rudderAnonymousIdProvider, "rudderAnonymousIdProvider");
s.j(trackingCallback, "trackingCallback");
callFactory = callFactory2;
try {
p.Companion companion = p.INSTANCE;
GBSDKBuilder gBSDKBuilder = new GBSDKBuilder("sdk-cYqWVkVgAGEOVTrR", "https://growthbook-proxy.kufar.by", n0.h(), trackingCallback, null, 16, null);
gBSDKBuilder.setNetworkDispatcher(new GrowthBookNetworkDispatcher());
b11 = p.b(gBSDKBuilder.initialize());
} catch (Throwable th2) {
p.Companion companion2 = p.INSTANCE;
b11 = p.b(q.a(th2));
}
Throwable e11 = p.e(b11);
if (e11 != null) {
wc0.a.INSTANCE.d(e11);
}
if (isDebug) {
q.b(b11);
} else if (p.h(b11)) {
b11 = null;
}
GrowthBookSDK growthBookSDK = (GrowthBookSDK) b11;
growthBookSdk = growthBookSDK;
if (growthBookSDK != null) {
growthBookSDK.setAttributes(m0.e(u.a(Attributes.DEVICE_ID, rudderAnonymousIdProvider.a())));
}
}
}