- 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
233 lines
11 KiB
Java
233 lines
11 KiB
Java
package csdk.gluads.impl;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.content.pm.PackageManager;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import com.applovin.impl.sdk.utils.JsonUtils;
|
|
import com.fyber.inneractive.sdk.external.InneractiveMediationDefs;
|
|
import csdk.gluads.Consts;
|
|
import csdk.gluads.IAdvertising;
|
|
import csdk.gluads.IAdvertisingListener;
|
|
import csdk.gluads.PlacementEvent;
|
|
import csdk.gluads.jsevaluator.JsEvaluator;
|
|
import csdk.gluads.jsevaluator.interfaces.JsCallback;
|
|
import csdk.gluads.util.Common;
|
|
import csdk.gluads.util.ConfigUtil;
|
|
import csdk.gluads.util.JsonUtil;
|
|
import csdk.gluads.util.log.YLogger;
|
|
import csdk.gluads.util.log.YLoggerFactory;
|
|
import csdk.gluads.util.log.YLoggers;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public class SuppressionRulesProxy extends AdvertisingProxy {
|
|
private static final List<String> SUPPORTED_AD_TYPES = Arrays.asList("interstitial", "banner");
|
|
private ConcurrentHashMap<String, Object> mCustomData;
|
|
private final boolean mDebug;
|
|
private final long mInitializationTimestamp;
|
|
private final Long mInstallTimestamp;
|
|
private JsEvaluator mJsEvaluator;
|
|
private AtomicLong mLastAdShownTimestamp;
|
|
private final String mSuppressionRules;
|
|
private final boolean mSuppressionRulesDisabled;
|
|
private String mSuppressionRulesEvaluatorJsScript;
|
|
private final YLogger mLog = YLoggerFactory.getLogger(getClass());
|
|
private final Object lock = new Object();
|
|
|
|
public SuppressionRulesProxy(Callable<Activity> callable, Map<String, Object> map, long j) {
|
|
final Context context = (Context) Common.call(callable);
|
|
this.mSuppressionRules = getSuppressionRulesFromConfig(map);
|
|
this.mDebug = ConfigUtil.getBoolean(map, "csdk.gluAds.debug.all");
|
|
this.mLastAdShownTimestamp = new AtomicLong(0L);
|
|
this.mInitializationTimestamp = j;
|
|
this.mInstallTimestamp = getFirstInstallTime(context);
|
|
this.mCustomData = new ConcurrentHashMap<>();
|
|
boolean z = ConfigUtil.getBoolean(ConfigUtil.getMap(map, "csdk.gluAds.disabled"), Consts.SUPPRESSION_RULES);
|
|
this.mSuppressionRulesDisabled = z;
|
|
if (z) {
|
|
return;
|
|
}
|
|
this.mSuppressionRulesEvaluatorJsScript = getSuppressionRulesJsScriptAsString(context);
|
|
Common.runOnUIThread(new Runnable() { // from class: csdk.gluads.impl.SuppressionRulesProxy.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
SuppressionRulesProxy.this.mJsEvaluator = new JsEvaluator(context);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // csdk.gluads.impl.AdvertisingProxy, csdk.gluads.IAdvertising
|
|
public void load(@NonNull final String str, @NonNull final String str2, @Nullable final Map<String, Object> map) {
|
|
if (this.mSuppressionRulesDisabled || !SUPPORTED_AD_TYPES.contains(str)) {
|
|
super.load(str, str2, map);
|
|
return;
|
|
}
|
|
if (isLoaded(str, str2, map)) {
|
|
super.listener().onPlacementEvent(new PlacementEvent(str, str2, Consts.PLACEMENT_STATUS_LOAD_FINISHED, null, map));
|
|
return;
|
|
}
|
|
final String buildSuppressionRulesParameters = buildSuppressionRulesParameters();
|
|
final IAdvertising next = super.next();
|
|
final IAdvertisingListener listener = super.listener();
|
|
Common.runOnUIThread(new Runnable() { // from class: csdk.gluads.impl.SuppressionRulesProxy.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
SuppressionRulesProxy.this.mJsEvaluator.callFunction(SuppressionRulesProxy.this.mSuppressionRulesEvaluatorJsScript, new JsCallback() { // from class: csdk.gluads.impl.SuppressionRulesProxy.2.1
|
|
@Override // csdk.gluads.jsevaluator.interfaces.JsCallback
|
|
public void onResult(String str3) {
|
|
if (Boolean.valueOf(str3).booleanValue()) {
|
|
AnonymousClass2 anonymousClass2 = AnonymousClass2.this;
|
|
next.load(str, str2, map);
|
|
} else {
|
|
AnonymousClass2 anonymousClass22 = AnonymousClass2.this;
|
|
listener.onPlacementEvent(new PlacementEvent(str, str2, Consts.PLACEMENT_STATUS_LOAD_STARTED, new Exception("Load suppressed"), map));
|
|
}
|
|
}
|
|
|
|
@Override // csdk.gluads.jsevaluator.interfaces.JsCallback
|
|
public void onError(String str3) {
|
|
SuppressionRulesProxy.this.mLog.w("SUPPRESSION_RULES.CHECK.FAILED", "l", ConfigUtil.getString(map, Consts.MEDIATION_NETWORK), InneractiveMediationDefs.GENDER_MALE, str3);
|
|
AnonymousClass2 anonymousClass2 = AnonymousClass2.this;
|
|
next.load(str, str2, map);
|
|
}
|
|
}, "canLoadAd", str, SuppressionRulesProxy.this.mSuppressionRules, buildSuppressionRulesParameters, String.valueOf(SuppressionRulesProxy.this.mDebug));
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // csdk.gluads.impl.AdvertisingProxy, csdk.gluads.IAdvertising
|
|
public void show(@NonNull final String str, @NonNull final String str2, @Nullable final Map<String, Object> map) {
|
|
if (this.mSuppressionRulesDisabled || !SUPPORTED_AD_TYPES.contains(str)) {
|
|
super.show(str, str2, map);
|
|
return;
|
|
}
|
|
if (!isLoaded(str, str2, map)) {
|
|
super.listener().onPlacementEvent(new PlacementEvent(str, str2, Consts.PLACEMENT_STATUS_SHOW_STARTED, new IllegalStateException("Not ready"), map));
|
|
} else {
|
|
final String buildSuppressionRulesParameters = buildSuppressionRulesParameters();
|
|
final IAdvertising next = super.next();
|
|
final IAdvertisingListener listener = super.listener();
|
|
Common.runOnUIThread(new Runnable() { // from class: csdk.gluads.impl.SuppressionRulesProxy.3
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
SuppressionRulesProxy.this.mJsEvaluator.callFunction(SuppressionRulesProxy.this.mSuppressionRulesEvaluatorJsScript, new JsCallback() { // from class: csdk.gluads.impl.SuppressionRulesProxy.3.1
|
|
@Override // csdk.gluads.jsevaluator.interfaces.JsCallback
|
|
public void onResult(String str3) {
|
|
if (Boolean.valueOf(str3).booleanValue()) {
|
|
if (!str.equals("banner")) {
|
|
SuppressionRulesProxy.this.mLastAdShownTimestamp.set(System.currentTimeMillis());
|
|
}
|
|
AnonymousClass3 anonymousClass3 = AnonymousClass3.this;
|
|
next.show(str, str2, map);
|
|
return;
|
|
}
|
|
AnonymousClass3 anonymousClass32 = AnonymousClass3.this;
|
|
listener.onPlacementEvent(new PlacementEvent(str, str2, Consts.PLACEMENT_STATUS_SHOW_STARTED, new Exception("Show suppressed"), map));
|
|
}
|
|
|
|
@Override // csdk.gluads.jsevaluator.interfaces.JsCallback
|
|
public void onError(String str3) {
|
|
SuppressionRulesProxy.this.mLog.w("SUPPRESSION_RULES.CHECK.FAILED", "l", ConfigUtil.getString(map, Consts.MEDIATION_NETWORK), InneractiveMediationDefs.GENDER_MALE, str3);
|
|
AnonymousClass3 anonymousClass3 = AnonymousClass3.this;
|
|
next.show(str, str2, map);
|
|
}
|
|
}, "canShowAd", str, SuppressionRulesProxy.this.mSuppressionRules, buildSuppressionRulesParameters, String.valueOf(SuppressionRulesProxy.this.mDebug));
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
@Override // csdk.gluads.impl.AdvertisingProxy, csdk.gluads.IAdvertising
|
|
public void destroy() {
|
|
if (!this.mSuppressionRulesDisabled) {
|
|
Common.runOnUIThread(new Runnable() { // from class: csdk.gluads.impl.SuppressionRulesProxy.4
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
SuppressionRulesProxy.this.mJsEvaluator.destroy();
|
|
}
|
|
});
|
|
}
|
|
super.next().destroy();
|
|
}
|
|
|
|
@Override // csdk.gluads.impl.AdvertisingProxy, csdk.gluads.IAdvertising
|
|
public void setCustomProperties(@Nullable Map<String, Object> map) {
|
|
if (map == null) {
|
|
return;
|
|
}
|
|
synchronized (this.lock) {
|
|
this.mCustomData.putAll(map);
|
|
}
|
|
super.setCustomProperties(map);
|
|
}
|
|
|
|
private static String getSuppressionRulesJsScriptAsString(Context context) {
|
|
InputStream inputStream = null;
|
|
try {
|
|
inputStream = context.getAssets().open("js/SuppressionRulesEvaluator.js");
|
|
byte[] bArr = new byte[inputStream.available()];
|
|
inputStream.read(bArr);
|
|
inputStream.close();
|
|
String str = new String(bArr);
|
|
try {
|
|
inputStream.close();
|
|
return str;
|
|
} catch (IOException unused) {
|
|
return str;
|
|
}
|
|
} catch (IOException unused2) {
|
|
if (inputStream != null) {
|
|
try {
|
|
inputStream.close();
|
|
} catch (IOException unused3) {
|
|
}
|
|
}
|
|
return "";
|
|
} catch (Throwable th) {
|
|
if (inputStream != null) {
|
|
try {
|
|
inputStream.close();
|
|
} catch (IOException unused4) {
|
|
}
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
|
|
private String buildSuppressionRulesParameters() {
|
|
Map createMap = Common.createMap();
|
|
createMap.put("appInstallTimeInMs", this.mInstallTimestamp);
|
|
createMap.put("currentLaunchTimeInMs", Long.valueOf(this.mInitializationTimestamp));
|
|
createMap.put("currentTimeInMs", Long.valueOf(System.currentTimeMillis()));
|
|
createMap.put("lastAdDismissedTimeInMs", Long.valueOf(this.mLastAdShownTimestamp.get()));
|
|
createMap.putAll(this.mCustomData);
|
|
return JsonUtil.toJson(createMap);
|
|
}
|
|
|
|
private String getSuppressionRulesFromConfig(@NonNull Map<String, Object> map) {
|
|
if (this.mSuppressionRulesDisabled) {
|
|
YLoggers.sdkConfiguration(this.mLog, Consts.SUPPRESSION_RULES, "l", Consts.SDK_GLU_ADS, "enabled", Boolean.FALSE);
|
|
return null;
|
|
}
|
|
Map<String, Object> map2 = ConfigUtil.getMap(map, "csdk.gluAds.suppressionRules");
|
|
return map2 != null ? JsonUtil.toJson(map2) : JsonUtils.EMPTY_JSON;
|
|
}
|
|
|
|
private Long getFirstInstallTime(Context context) {
|
|
try {
|
|
return Long.valueOf(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).firstInstallTime);
|
|
} catch (PackageManager.NameNotFoundException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|