GoooBet v1.0版本的 MD5 值为:ff9748f16167bfd7735b669c0a9931c5
以下内容为反编译后的 BidMachineImpl.java 源代码,内容仅作参考
package io.bidmachine;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import io.bidmachine.AdRequest;
import io.bidmachine.ApiRequest;
import io.bidmachine.NetworkRegistry;
import io.bidmachine.ads.networks.mraid.MraidAdapter;
import io.bidmachine.ads.networks.nast.NastAdapter;
import io.bidmachine.ads.networks.vast.VastAdapter;
import io.bidmachine.core.Logger;
import io.bidmachine.core.NetworkRequest;
import io.bidmachine.core.Utils;
import io.bidmachine.protobuf.AdNetwork;
import io.bidmachine.protobuf.InitRequest;
import io.bidmachine.protobuf.InitResponse;
import io.bidmachine.utils.ActivityHelper;
import io.bidmachine.utils.BMError;
import io.bidmachine.utils.BluetoothUtils;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
public final class BidMachineImpl {
private static final String DEF_AUCTION_URL = "https://api.appodealx.com/openrtb3/auction";
static String DEF_INIT_URL;
private static final long MAX_INIT_REQUEST_DELAY_MS;
private static final long MIN_INIT_REQUEST_DELAY_MS;
private static volatile BidMachineImpl instance;
Context appContext;
ApiRequest<InitRequest, InitResponse> currentInitRequest;
String ifv;
private boolean isInitialized;
private boolean isTestMode;
private Publisher publisher;
private String sellerId;
private SessionTracker sessionTracker;
private WeakReference<Activity> weakTopActivity;
private TargetingParams targetingParams = new TargetingParams();
private ExtraParams extraParams = new ExtraParams();
private final UserRestrictionParams userRestrictionParams = new UserRestrictionParams();
private final PriceFloorParams priceFloorParams = new PriceFloorParams().addPriceFloor(UUID.randomUUID().toString(), 0.01d);
private final DeviceParams deviceParams = new DeviceParams();
private final IABSharedPreference iabSharedPreference = new IABSharedPreference();
String currentInitUrl = DEF_INIT_URL;
String currentAuctionUrl = DEF_AUCTION_URL;
private final Map<TrackEventType, List<String>> trackingEventTypes = new EnumMap(TrackEventType.class);
private final List<NetworkConfig> initNetworkConfigList = new ArrayList();
private long initRequestDelayMs = 0;
private final Runnable rescheduleInitRunnable = new Runnable() {
@Override
public void run() {
BidMachineImpl bidMachineImpl = BidMachineImpl.this;
bidMachineImpl.requestInitData(bidMachineImpl.appContext, BidMachineImpl.this.sellerId, null);
}
};
private final TrackingObject trackingObject = new SimpleTrackingObject(BidMachineImpl.class.getSimpleName());
private final List<AdRequest.AdRequestListener> adRequestListeners = new CopyOnWriteArrayList();
BidMachineImpl() {
}
public static BidMachineImpl get() {
if (instance == null) {
synchronized (BidMachineImpl.class) {
if (instance == null) {
instance = new BidMachineImpl();
}
}
}
return instance;
}
static {
Logger.setMessageBuilder(new Logger.LoggerMessageBuilder() {
@Override
public String buildMessage(String str) {
return BidMachineImpl.get().isTestMode() ? String.format("(TEST MODE) %s", str) : str;
}
});
DEF_INIT_URL = "https://api.appodealx.com/init";
MIN_INIT_REQUEST_DELAY_MS = TimeUnit.SECONDS.toMillis(2L);
MAX_INIT_REQUEST_DELAY_MS = TimeUnit.SECONDS.toMillis(128L);
}
public synchronized void initialize(Context context, String str, InitializationCallback initializationCallback) {
if (this.isInitialized) {
return;
}
if (context == null) {
Logger.log("Initialization fail: Context is not provided");
return;
}
if (TextUtils.isEmpty(str)) {
Logger.log("Initialization fail: Seller id is not provided");
return;
}
Debugger.setup(context);
this.sellerId = str;
this.appContext = context.getApplicationContext();
this.sessionTracker = new SessionTrackerImpl();
loadStoredInitResponse(context);
this.iabSharedPreference.initialize(context);
setTopActivity(ActivityHelper.getTopActivity());
((Application) context.getApplicationContext()).registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks());
SessionManager.get().resume();
BluetoothUtils.register(context);
requestInitData(context, str, initializationCallback);
this.isInitialized = true;
}
public Context getAppContext() {
return this.appContext;
}
public String obtainIFV(Context context) {
if (!TextUtils.isEmpty(this.ifv)) {
return this.ifv;
}
String obtainIFV = BidMachineSharedPreference.obtainIFV(context);
this.ifv = obtainIFV;
return obtainIFV;
}
public void requestInitData(final Context context, final String str, final InitializationCallback initializationCallback) {
if (this.currentInitRequest != null) {
return;
}
BidMachineEvents.eventStart(this.trackingObject, TrackEventType.InitLoading, null);
Utils.onBackgroundThread(new Runnable() {
@Override
public void run() {
BidMachineImpl.this.currentInitRequest = new ApiRequest.Builder().url(BidMachineImpl.this.currentInitUrl).setDataBinder(new ApiRequest.ApiInitDataBinder()).setRequestData(OrtbUtils.obtainInitRequest(context, str, BidMachineImpl.this.targetingParams, BidMachineImpl.this.userRestrictionParams)).setCallback(new NetworkRequest.Callback<InitResponse, BMError>() {
@Override
public void onSuccess(InitResponse initResponse) {
BidMachineImpl.this.currentInitRequest = null;
if (initResponse != null) {
BidMachineImpl.this.handleInitResponse(initResponse);
BidMachineSharedPreference.storeInitResponse(context, initResponse);
BidMachineImpl.this.initializeNetworks(context, initResponse.getAdNetworksList());
}
BidMachineImpl.this.initRequestDelayMs = 0L;
Utils.cancelBackgroundThreadTask(BidMachineImpl.this.rescheduleInitRunnable);
BidMachineImpl.this.notifyInitializationFinished(initializationCallback);
BidMachineEvents.eventFinish(BidMachineImpl.this.trackingObject, TrackEventType.InitLoading, null, null);
}
@Override
public void onFail(BMError bMError) {
InitResponse initResponse;
BidMachineImpl.this.currentInitRequest = null;
if (BidMachineImpl.this.initRequestDelayMs <= 0) {
BidMachineImpl.this.initRequestDelayMs = BidMachineImpl.MIN_INIT_REQUEST_DELAY_MS;
} else {
BidMachineImpl.this.initRequestDelayMs *= 2;
if (BidMachineImpl.this.initRequestDelayMs >= BidMachineImpl.MAX_INIT_REQUEST_DELAY_MS) {
BidMachineImpl.this.initRequestDelayMs = BidMachineImpl.MAX_INIT_REQUEST_DELAY_MS;
}
}
if (!NetworkRegistry.isNetworksInitialized() && (initResponse = BidMachineSharedPreference.getInitResponse(context)) != null) {
BidMachineImpl.this.initializeNetworks(context, initResponse.getAdNetworksList());
}
Logger.log(String.format("reschedule init request (%s)", Long.valueOf(BidMachineImpl.this.initRequestDelayMs)));
Utils.onBackgroundThread(BidMachineImpl.this.rescheduleInitRunnable, BidMachineImpl.this.initRequestDelayMs);
BidMachineImpl.this.notifyInitializationFinished(initializationCallback);
BidMachineEvents.eventFinish(BidMachineImpl.this.trackingObject, TrackEventType.InitLoading, null, bMError);
}
}).request();
}
});
}
public void notifyInitializationFinished(final InitializationCallback initializationCallback) {
if (initializationCallback != null) {
Utils.onUiThread(new Runnable() {
@Override
public void run() {
initializationCallback.onInitialized();
}
});
}
}
public void handleInitResponse(InitResponse initResponse) {
if (!TextUtils.isEmpty(initResponse.getEndpoint())) {
this.currentAuctionUrl = initResponse.getEndpoint();
}
this.trackingEventTypes.clear();
OrtbUtils.prepareEvents(this.trackingEventTypes, initResponse.getEventList());
SessionManager.get().setSessionResetAfter(initResponse.getSessionResetAfter());
}
public void initializeNetworks(Context context, List<AdNetwork> list) {
NetworkConfig create;
if (NetworkRegistry.isNetworksInitialized()) {
return;
}
TargetingParams targetingParams = getTargetingParams();
UserRestrictionParams userRestrictionParams = getUserRestrictionParams();
if (list != null) {
for (AdNetwork adNetwork : list) {
if (!NetworkRegistry.isNetworkRegistered(adNetwork.getName()) && (create = NetworkConfigFactory.create(context, adNetwork)) != null) {
create.setRegisterSource(RegisterSource.Init);
NetworkRegistry.registerNetwork(create);
this.initNetworkConfigList.add(create);
}
}
}
Map map = null;
NetworkRegistry.registerNetwork(new NetworkConfig(map) {
@Override
protected NetworkAdapter createNetworkAdapter() {
return new MraidAdapter();
}
});
NetworkRegistry.registerNetwork(new NetworkConfig(map) {
@Override
protected NetworkAdapter createNetworkAdapter() {
return new VastAdapter();
}
});
NetworkRegistry.registerNetwork(new NetworkConfig(map) {
@Override
protected NetworkAdapter createNetworkAdapter() {
return new NastAdapter();
}
});
NetworkRegistry.initializeNetworks(new SimpleContextProvider(context), new UnifiedAdRequestParamsImpl(targetingParams, userRestrictionParams), new NetworkRegistry.NetworksInitializeCallback() {
@Override
public void onNetworksInitialized() {
AdRequestExecutor.get().enable();
}
});
}
private void loadStoredInitResponse(Context context) {
InitResponse initResponse = BidMachineSharedPreference.getInitResponse(context);
if (initResponse != null) {
handleInitResponse(initResponse);
}
}
public List<String> getTrackingUrls(TrackEventType trackEventType) {
return this.trackingEventTypes.get(trackEventType);
}
public List<NetworkConfig> getInitNetworkConfigList() {
return this.initNetworkConfigList;
}
public boolean isInitialized() {
return this.isInitialized;
}
public void setTestMode(boolean z) {
this.isTestMode = z;
}
public boolean isTestMode() {
return this.isTestMode;
}
public SessionTracker getSessionTracker() {
return this.sessionTracker;
}
public String getSellerId() {
return this.sellerId;
}
public void setTargetingParams(TargetingParams targetingParams) {
if (targetingParams == null) {
targetingParams = new TargetingParams();
}
this.targetingParams = targetingParams;
}
public TargetingParams getTargetingParams() {
return this.targetingParams;
}
public Publisher getPublisher() {
return this.publisher;
}
public void setPublisher(Publisher publisher) {
this.publisher = publisher;
}
void setExtraParams(ExtraParams extraParams) {
if (extraParams == null) {
extraParams = new ExtraParams();
}
this.extraParams = extraParams;
}
ExtraParams getExtraParams() {
return this.extraParams;
}
public UserRestrictionParams getUserRestrictionParams() {
return this.userRestrictionParams;
}
public PriceFloorParams getPriceFloorParams() {
return this.priceFloorParams;
}
public DeviceParams getDeviceParams() {
return this.deviceParams;
}
public IABSharedPreference getIabSharedPreference() {
return this.iabSharedPreference;
}
public void setEndpoint(String str) {
if (this.isInitialized) {
Logger.log("Can't change endpoint url after initialization");
return;
}
if (TextUtils.isEmpty(str)) {
Logger.log("Endpoint is empty or null, skipping setting new endpoint...");
return;
}
this.currentInitUrl = str + "/init";
this.currentAuctionUrl = str + "/openrtb3/auction";
}
public String getAuctionUrl() {
return this.currentAuctionUrl;
}
public Activity getTopActivity() {
WeakReference<Activity> weakReference = this.weakTopActivity;
if (weakReference != null) {
return weakReference.get();
}
return null;
}
public void setTopActivity(Activity activity) {
if (activity != null) {
this.weakTopActivity = new WeakReference<>(activity);
}
}
public void registerAdRequestListener(AdRequest.AdRequestListener adRequestListener) {
if (adRequestListener == null) {
return;
}
this.adRequestListeners.add(adRequestListener);
}
public void unregisterAdRequestListener(AdRequest.AdRequestListener adRequestListener) {
if (adRequestListener == null) {
return;
}
this.adRequestListeners.remove(adRequestListener);
}
public List<AdRequest.AdRequestListener> getAdRequestListeners() {
return this.adRequestListeners;
}
}