Apk Done v1.0版本的 MD5 值为:44cfb8e1ce639995aa7f0de6a3a6388b
以下内容为反编译后的 CriteoAdapter.java 源代码,内容仅作参考
package io.bidmachine.ads.networks.criteo;
import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import com.criteo.publisher.Bid;
import com.criteo.publisher.BidResponseListener;
import com.criteo.publisher.Criteo;
import com.criteo.publisher.CriteoErrorCode;
import com.criteo.publisher.model.AdUnit;
import io.bidmachine.AdRequest;
import io.bidmachine.AdsType;
import io.bidmachine.BidMachine;
import io.bidmachine.ContextProvider;
import io.bidmachine.HeaderBiddingAdRequestParams;
import io.bidmachine.HeaderBiddingAdapter;
import io.bidmachine.HeaderBiddingCollectParamsCallback;
import io.bidmachine.InitializationParams;
import io.bidmachine.NetworkConfigParams;
import io.bidmachine.models.AuctionResult;
import io.bidmachine.unified.UnifiedAdRequestParams;
import io.bidmachine.unified.UnifiedBannerAd;
import io.bidmachine.unified.UnifiedFullscreenAd;
import io.bidmachine.utils.BMError;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
class CriteoAdapter extends HeaderBiddingAdapter {
static final boolean $assertionsDisabled = false;
public CriteoAdapter() {
super(BuildConfig.ADAPTER_NAME, BuildConfig.ADAPTER_SDK_VERSION_NAME, "1.9.3.10", 16, new AdsType[]{AdsType.Banner, AdsType.Interstitial});
BidMachine.registerAdRequestListener(new AdRequest.AdRequestListener() {
static final boolean $assertionsDisabled = false;
@Override
public void onRequestSuccess(AdRequest adRequest, AuctionResult auctionResult) {
if (adRequest == null || isCriteoNetwork(CriteoAdapter.this.getKey(), auctionResult)) {
return;
}
CriteoBidTokenStorage.takeBid(adRequest.getAdRequestParameters());
}
@Override
public void onRequestFailed(AdRequest adRequest, BMError bMError) {
if (adRequest != null) {
CriteoBidTokenStorage.takeBid(adRequest.getAdRequestParameters());
}
}
@Override
public void onRequestExpired(AdRequest adRequest) {
if (adRequest != null) {
CriteoBidTokenStorage.takeBid(adRequest.getAdRequestParameters());
}
}
private boolean isCriteoNetwork(String str, AuctionResult auctionResult) {
if (auctionResult == null || TextUtils.isEmpty(str)) {
return false;
}
return str.equals(auctionResult.getNetworkKey());
}
});
}
@Override
public UnifiedBannerAd createBanner() {
return new CriteoBanner();
}
@Override
public UnifiedFullscreenAd createInterstitial() {
return new CriteoInterstitial();
}
@Override
public boolean onInitialize(ContextProvider contextProvider, InitializationParams initializationParams, NetworkConfigParams networkConfigParams) throws Throwable {
super.onInitialize(contextProvider, initializationParams, networkConfigParams);
Map<String, String> obtainNetworkParams = networkConfigParams.obtainNetworkParams();
if (obtainNetworkParams == null) {
logError("Initialize failed: network parameters not found");
return false;
}
String str = obtainNetworkParams.get("publisher_id");
if (TextUtils.isEmpty(str)) {
logError(String.format("Initialize failed: %s not provided", "publisher_id"));
return false;
}
List<AdUnit> extractAdUnits = CriteoAdUnitStorage.extractAdUnits(networkConfigParams);
if (extractAdUnits == null || extractAdUnits.size() == 0) {
logError("Initialize failed: AdUnits not found");
return false;
}
new Criteo.Builder((Application) contextProvider.getApplicationContext(), str).debugLogsEnabled(initializationParams.isTestMode()).adUnits(extractAdUnits).init();
return true;
}
@Override
protected boolean isNetworkInitialized(Context context) throws Throwable {
return Criteo.getInstance() != null;
}
@Override
protected void onCollectHeaderBiddingParams(ContextProvider contextProvider, final UnifiedAdRequestParams unifiedAdRequestParams, HeaderBiddingAdRequestParams headerBiddingAdRequestParams, final HeaderBiddingCollectParamsCallback headerBiddingCollectParamsCallback, Map<String, String> map) throws Throwable {
final String str = map.get("ad_unit_id");
if (TextUtils.isEmpty(str)) {
headerBiddingCollectParamsCallback.onCollectFail(BMError.adapterGetsParameter("ad_unit_id"));
return;
}
AdUnit adUnit = CriteoAdUnitStorage.getAdUnit(str);
if (adUnit == null) {
headerBiddingCollectParamsCallback.onCollectFail(BMError.adapterGetsParameter("AdUnit"));
} else {
Criteo.getInstance().loadBid(adUnit, new BidResponseListener() {
@Override
public final void onResponse(Bid bid) {
CriteoAdapter.lambda$onCollectHeaderBiddingParams$0(UnifiedAdRequestParams.this, str, headerBiddingCollectParamsCallback, bid);
}
});
}
}
public static void lambda$onCollectHeaderBiddingParams$0(UnifiedAdRequestParams unifiedAdRequestParams, String str, HeaderBiddingCollectParamsCallback headerBiddingCollectParamsCallback, Bid bid) {
if (bid != null) {
CriteoBidTokenStorage.storeBid(unifiedAdRequestParams.getAdRequestParameters(), bid);
HashMap hashMap = new HashMap();
hashMap.put("ad_unit_id", str);
hashMap.put("price", String.valueOf(bid.getPrice()));
headerBiddingCollectParamsCallback.onCollectFinished(hashMap);
return;
}
headerBiddingCollectParamsCallback.onCollectFail(BMError.adapterGetsParameter("Bid"));
}
public static class AnonymousClass2 {
static final int[] $SwitchMap$com$criteo$publisher$CriteoErrorCode;
static {
int[] iArr = new int[CriteoErrorCode.values().length];
$SwitchMap$com$criteo$publisher$CriteoErrorCode = iArr;
try {
iArr[CriteoErrorCode.ERROR_CODE_NO_FILL.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$criteo$publisher$CriteoErrorCode[CriteoErrorCode.ERROR_CODE_NETWORK_ERROR.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
public static BMError mapError(CriteoErrorCode criteoErrorCode) {
int i = AnonymousClass2.$SwitchMap$com$criteo$publisher$CriteoErrorCode[criteoErrorCode.ordinal()];
if (i != 1) {
if (i == 2) {
return BMError.NoConnection;
}
return BMError.internal("Unknown error");
}
return BMError.noFill();
}
}