atsameip v0.1版本的 MD5 值为:28547cf98b0a2d02acb37969dcfb83e9
以下内容为反编译后的 AdsLoader.java 源代码,内容仅作参考
package com.appsgeyser.sdk.ads;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebView;
import com.appsgeyser.sdk.BrowserActivity;
import com.appsgeyser.sdk.ads.AdsBannerWebViewClient;
import com.appsgeyser.sdk.ads.behavior.BehaviorAcceptor;
import com.appsgeyser.sdk.ads.behavior.BehaviorFactory;
import com.appsgeyser.sdk.ads.behavior.BehaviorVisitor;
import com.appsgeyser.sdk.ads.behavior.loaderBehaviors.LoaderBehavior;
import com.appsgeyser.sdk.configuration.Configuration;
import com.appsgeyser.sdk.configuration.Constants;
import com.appsgeyser.sdk.deviceidparser.DeviceIdParameters;
import com.appsgeyser.sdk.server.implementation.AppsgeyserServerClient;
import com.appsgeyser.sdk.server.network.NetworkManager;
import com.appsgeyser.sdk.utils.BannerUtils;
import com.appsgeyser.sdk.utils.EndpointGetter;
import com.yandex.metrica.YandexMetrica;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
public class AdsLoader implements AdsBannerWebViewClient.OnPageFinishedListener, AdsBannerWebViewClient.OnPageStartedListener, BehaviorAcceptor {
private AdView adView;
private String bannerUrl;
private BehaviorFactory.ClickBehavior clickBehavior;
private String clickUrl;
private HeadersReceiver headersReceiver;
private AdsLoadingFinishedListener loadingFinishedListener;
private final float DEFAULT_HIDE_TIMEOUT = 60000.0f;
private Thread closeBannerThread = null;
private Timer refreshTimer = new Timer();
private boolean openInNativeBrowser = true;
public interface AdsLoadingFinishedListener {
void onAdLoadFinished();
}
public interface HeadersReceiver {
boolean onAdHeadersReceived(Map<String, List<String>> map);
}
public void init(AdView adView, DeviceIdParameters deviceIdParameters) {
this.adView = adView;
adView.getBrowser().setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
CorrectClickStateHolder.getInstance().allowClick();
Log.d("AUTOCLICK_DETECT", "touch detected");
int action = motionEvent.getAction();
if ((action == 0 || action == 1) && !view.hasFocus()) {
view.requestFocus();
return false;
}
return false;
}
});
this.bannerUrl = createBannerUrl(deviceIdParameters);
this.clickBehavior = BehaviorFactory.ClickBehavior.HIDE;
this.closeBannerThread = new Thread() {
@Override
public void run() {
AdsLoader.this.refreshTimer.cancel();
if (AdsLoader.this.adView.getBrowser() != null) {
AdsLoader.this.adView.getBrowser().stopLoading();
}
AdsLoader.this.adView.hide();
}
};
}
private String createBannerUrl(DeviceIdParameters deviceIdParameters) {
String str;
Configuration configuration = Configuration.getInstance(this.adView.getContext());
if (deviceIdParameters != null) {
String advId = deviceIdParameters.getAdvId();
String lowerCase = deviceIdParameters.getLimitAdTrackingEnabled().toString().toLowerCase();
String str2 = deviceIdParameters.getaId();
if (!TextUtils.isEmpty(advId)) {
str = "&advid=" + advId + "&limit_ad_tracking_enabled=" + lowerCase;
} else {
str = "&aid=" + str2;
}
} else {
str = "&hid=&aid=";
}
return "http://ads.appsgeyser.com/" + ("?widgetid=" + configuration.getApplicationId() + "&guid=" + configuration.getAppGuid() + "&v=" + Constants.PLATFORM_VERSION + str + "&tlat=&tlon=&p=android&sdk=1&templateversion=" + configuration.getTemplateVersion());
}
public void setClickUrl(String str) {
this.clickUrl = str;
}
public void setHeaderReceiver(HeadersReceiver headersReceiver) {
this.headersReceiver = headersReceiver;
}
public void setAdsLoadingFinishedListener(AdsLoadingFinishedListener adsLoadingFinishedListener) {
this.loadingFinishedListener = adsLoadingFinishedListener;
}
public void reload() {
try {
new Thread() {
@Override
public void run() {
Map<String, List<String>> loadHeaders = NetworkManager.getInstance().loadHeaders(AdsLoader.this.bannerUrl);
if (loadHeaders != null) {
if ((AdsLoader.this.headersReceiver == null || AdsLoader.this.headersReceiver.onAdHeadersReceived(loadHeaders)) && AdsLoader.this.adView.getBrowser() != null) {
AdsLoader.this.adView.post(new Runnable() {
@Override
public void run() {
AdsLoader.this.adView.getBrowser().loadUrl(AdsLoader.this.bannerUrl);
}
});
}
} else if (AdsLoader.this.adView != null) {
AdsLoader.this.adView.post(new Runnable() {
@Override
public void run() {
AdsLoader.this.adView.hide();
}
});
}
}
}.start();
} catch (Exception e) {
Log.e("AdsLoader", e.getMessage());
}
}
public void changeClickBehavior(BehaviorFactory.ClickBehavior clickBehavior) {
this.clickBehavior = clickBehavior;
}
public void setRefreshTimeout(float f) {
if (f <= 0.0d) {
return;
}
this.refreshTimer.cancel();
Timer timer = new Timer();
this.refreshTimer = timer;
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
AdsLoader.this.reload();
AdsLoader.this.refreshTimer.cancel();
}
}, (int) (f * 1000.0f), 100L);
}
public void setHideTimeout(float f) {
if (f <= 0.0d) {
f = 60000.0f;
}
this.adView.removeCallbacks(this.closeBannerThread);
this.adView.postDelayed(this.closeBannerThread, f * 1000.0f);
}
public void acceptBehavior(BehaviorVisitor behaviorVisitor) {
if (behaviorVisitor instanceof LoaderBehavior) {
((LoaderBehavior) behaviorVisitor).visit((BehaviorAcceptor) this);
}
}
private void setDefaults() {
this.refreshTimer.cancel();
setHideTimeout(60000.0f);
this.adView.applyDefaultSettings();
}
@Override
public boolean loadStarted(WebView webView, String str, Bitmap bitmap) {
String str2;
Intent intent;
if (str == null) {
reload();
return true;
} else if (!EndpointGetter.getUrlWithoutArguments(str).equals(EndpointGetter.getUrlWithoutArguments(this.bannerUrl)) && !BannerUtils.isDataTextHtmlUrl(str)) {
if (!CorrectClickStateHolder.getInstance().isClickAllowed()) {
try {
str2 = URLEncoder.encode(str, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
str2 = "-1";
}
webView.loadUrl("javascript:processACWithUrl('" + str2 + "')");
return false;
}
CorrectClickStateHolder.getInstance().reset();
Log.d("AUTOCLICK_DETECT", "click ALLOWED!");
if (this.clickBehavior == BehaviorFactory.ClickBehavior.HIDE) {
this.adView.hide();
this.refreshTimer.cancel();
} else if (this.clickBehavior == BehaviorFactory.ClickBehavior.REMAIN_ON_SCREEN) {
reload();
}
webView.stopLoading();
if (this.openInNativeBrowser) {
intent = new Intent(this.adView.getContext(), BrowserActivity.class);
intent.putExtra("browser_url", str);
intent.putExtra("banner_type", "banner_type_small");
intent.putExtra("uniqid", this.adView.getUniqueId());
intent.addFlags(268435456);
} else {
intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
}
this.adView.getContext().startActivity(intent);
if (!TextUtils.isEmpty(this.clickUrl)) {
AppsgeyserServerClient.getInstance().sendClickInfo(this.clickUrl, webView.getContext());
YandexMetrica.reportEvent("small_banner_clicked");
}
return false;
} else {
this.adView.switchToHtmlBanner();
return true;
}
}
@Override
public void loadFinished(WebView webView, String str) {
if (str.equals("data:text/html,chromewebdata") || str.equals("about:blank")) {
this.adView.hide();
return;
}
this.adView.show();
this.adView.switchToHtmlBanner();
if (str.equalsIgnoreCase(this.bannerUrl) || BannerUtils.isDataTextHtmlUrl(str)) {
setDefaults();
AdsLoadingFinishedListener adsLoadingFinishedListener = this.loadingFinishedListener;
if (adsLoadingFinishedListener != null) {
adsLoadingFinishedListener.onAdLoadFinished();
}
}
}
public void stopLoading() {
this.adView.hide();
}
public void proceedClick(final String str) {
if (this.adView.getBrowser() != null) {
this.adView.getBrowser().post(new Runnable() {
@Override
public void run() {
AdsLoader.this.adView.getBrowser().loadUrl(str);
}
});
}
}
public void forceOpenInNativeBrowser(boolean z) {
this.openInNativeBrowser = z;
}
}