atsameip v0.1版本的 MD5 值为:28547cf98b0a2d02acb37969dcfb83e9
以下内容为反编译后的 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.InitialRequest;
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.Utils;
import io.bidmachine.protobuf.AdNetwork;
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;
public final class BidMachineImpl {
private static final String DEF_AUCTION_PATH = "/auction/rtb/v3";
private static final String DEF_AUCTION_URL = "https://api.appodealx.com/auction/rtb/v3";
static final String DEF_INIT_PATH = "/auction/init";
static final String DEF_INIT_URL = "https://api.appodealx.com/auction/init";
private static volatile BidMachineImpl instance;
Context appContext;
String ifv;
InitialRequest initialRequest;
private boolean isInitialized;
private boolean isTestMode;
private Publisher publisher;
private String sellerId;
private SessionTracker sessionTracker;
private WeakReference<Activity> weakTopActivity;
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();
private final Map<TrackEventType, List<String>> trackingEventTypes = new EnumMap(TrackEventType.class);
private final List<NetworkConfig> initNetworkConfigList = new ArrayList();
private final List<AdRequest.AdRequestListener> adRequestListeners = new CopyOnWriteArrayList();
private TargetingParams targetingParams = new TargetingParams();
private CustomParams customParams = new CustomParams();
String initUrl = DEF_INIT_URL;
String auctionUrl = DEF_AUCTION_URL;
int requestTimeOutMs = 0;
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;
}
});
}
public synchronized void initialize(Context context, final String str, final InitializationCallback initializationCallback) {
if (this.isInitialized) {
return;
}
if (context == null) {
Logger.log("Initialization fail: Context is not provided");
} else if (TextUtils.isEmpty(str)) {
Logger.log("Initialization fail: Source id is not provided");
} else {
final Context applicationContext = context.getApplicationContext();
this.appContext = applicationContext;
this.sellerId = str;
this.sessionTracker = new SessionTrackerImpl();
setTopActivity(ActivityHelper.getTopActivity());
((Application) applicationContext).registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks());
SessionManager.get().resume();
BluetoothUtils.register(applicationContext);
Utils.onBackgroundThread(new Runnable() {
@Override
public void run() {
try {
Debugger.setup(applicationContext);
BidMachineImpl.this.iabSharedPreference.initialize(applicationContext);
BidMachineImpl.this.loadStoredInitResponse(applicationContext);
BidMachineImpl.this.requestInitData(applicationContext, str, initializationCallback);
} catch (Throwable th) {
th.printStackTrace();
}
}
});
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 loadStoredInitResponse(Context context) {
InitResponse initResponse = BidMachineSharedPreference.getInitResponse(context);
if (initResponse != null) {
handleInitResponse(initResponse);
}
}
public void requestInitData(final Context context, String str, final InitializationCallback initializationCallback) {
if (this.initialRequest != null) {
return;
}
InitialRequest initialRequest = new InitialRequest(context, this.initUrl, str);
this.initialRequest = initialRequest;
initialRequest.setListener(new InitialRequest.Listener() {
@Override
public void onSuccess(InitResponse initResponse) {
BidMachineImpl.this.initialRequest = null;
if (initResponse != null) {
BidMachineImpl.this.handleInitResponse(initResponse);
BidMachineSharedPreference.storeInitResponse(context, initResponse);
BidMachineImpl.this.initializeNetworks(context, initResponse.getAdNetworksList());
}
BidMachineImpl.this.notifyInitializationFinished(initializationCallback);
}
@Override
public void onFail(BMError bMError) {
InitResponse initResponse;
if (!NetworkRegistry.isNetworksInitialized() && (initResponse = BidMachineSharedPreference.getInitResponse(context)) != null) {
BidMachineImpl.this.initializeNetworks(context, initResponse.getAdNetworksList());
}
BidMachineImpl.this.notifyInitializationFinished(initializationCallback);
}
});
this.initialRequest.request();
}
public void handleInitResponse(InitResponse initResponse) {
String endpoint = initResponse.getEndpoint();
if (!TextUtils.isEmpty(endpoint)) {
this.auctionUrl = endpoint;
}
this.trackingEventTypes.clear();
OrtbUtils.prepareEvents(this.trackingEventTypes, initResponse.getEventList());
SessionManager.get().setSessionResetAfter(initResponse.getSessionResetAfter());
this.requestTimeOutMs = initResponse.getAdRequestTmax();
AdResponseManager.setAdCachePlacementControlMap(initResponse.getAdCachePlacementControlMap());
}
public void initializeNetworks(Context context, List<AdNetwork> list) {
initializeNetworks(context, list, new NetworkRegistry.NetworksInitializeCallback() {
@Override
public void onNetworksInitialized() {
AdRequestExecutor.get().enable();
}
});
}
void initializeNetworks(Context context, List<AdNetwork> list, NetworkRegistry.NetworksInitializeCallback networksInitializeCallback) {
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);
}
}
}
NetworkRegistry.registerNetwork(new NetworkConfig(null) {
@Override
protected NetworkAdapter createNetworkAdapter() {
return new MraidAdapter();
}
});
NetworkRegistry.registerNetwork(new NetworkConfig(null) {
@Override
protected NetworkAdapter createNetworkAdapter() {
return new VastAdapter();
}
});
NetworkRegistry.registerNetwork(new NetworkConfig(null) {
@Override
protected NetworkAdapter createNetworkAdapter() {
return new NastAdapter();
}
});
NetworkRegistry.initializeNetworks(new SimpleContextProvider(context), new InitializationParamsImpl(targetingParams, userRestrictionParams), networksInitializeCallback);
}
public void notifyInitializationFinished(final InitializationCallback initializationCallback) {
if (initializationCallback != null) {
Utils.onUiThread(new Runnable() {
@Override
public void run() {
initializationCallback.onInitialized();
}
});
}
}
public List<String> getTrackingUrls(TrackEventType trackEventType) {
return this.trackingEventTypes.get(trackEventType);
}
public List<NetworkConfig> getInitNetworkConfigList() {
return this.initNetworkConfigList;
}
public int getRequestTimeOutMs() {
return this.requestTimeOutMs;
}
public boolean isInitialized() {
return this.isInitialized;
}
public boolean isTestMode() {
return this.isTestMode;
}
public void setTestMode(boolean z) {
this.isTestMode = z;
}
public SessionTracker getSessionTracker() {
return this.sessionTracker;
}
public String getSellerId() {
return this.sellerId;
}
public TargetingParams getTargetingParams() {
return this.targetingParams;
}
public void setTargetingParams(TargetingParams targetingParams) {
if (targetingParams == null) {
targetingParams = new TargetingParams();
}
this.targetingParams = targetingParams;
}
public Publisher getPublisher() {
return this.publisher;
}
public void setPublisher(Publisher publisher) {
this.publisher = publisher;
}
CustomParams getCustomParams() {
return this.customParams;
}
void setCustomParams(CustomParams customParams) {
if (customParams == null) {
customParams = new CustomParams();
}
this.customParams = customParams;
}
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");
} else if (TextUtils.isEmpty(str)) {
Logger.log("Endpoint is empty or null, skipping setting new endpoint...");
} else {
this.initUrl = str + DEF_INIT_PATH;
this.auctionUrl = str + DEF_AUCTION_PATH;
}
}
public String getAuctionUrl() {
return this.auctionUrl;
}
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;
}
}