atsameip v0.1版本的 MD5 值为:28547cf98b0a2d02acb37969dcfb83e9
以下内容为反编译后的 f.java 源代码,内容仅作参考
package com.appnext.core;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
public class f {
private static f cF;
private a cA;
private Runnable cB;
private List cC;
private final ArrayList<b> cD = new ArrayList<>();
private int cE;
private Context context;
private WebView cy;
private WebView cz;
private Handler handler;
public interface a {
void error(String str);
void onMarket(String str);
}
public class b {
String cN;
String cO;
a cP;
String cQ;
long cR;
String v;
b(String str, String str2, String str3, String str4, a aVar, long j) {
this.cN = str;
this.cO = str2;
this.v = str3;
this.cP = aVar;
this.cQ = str4;
this.cR = j;
}
}
public static f b(Context context) {
if (cF == null) {
synchronized (f.class) {
if (cF == null) {
cF = new f(context);
}
}
}
return cF;
}
private f(Context context) {
try {
this.context = context.getApplicationContext();
this.handler = new Handler(Looper.getMainLooper());
this.cE = 0;
this.cA = new a() {
@Override
public final void onMarket(String str) {
try {
f.this.b(0);
if (f.this.cD.size() == 0) {
return;
}
b bVar = (b) f.this.cD.get(0);
if (bVar.cP != null) {
bVar.cP.onMarket(str);
}
String str2 = "";
try {
if (f.this.cD != null && !f.this.cD.isEmpty()) {
str2 = "https://admin.appnext.com/tools/navtac.html?bid=" + ((b) f.this.cD.get(0)).cQ + "&guid=" + g.e("admin.appnext.com", "applink") + "&url=" + URLEncoder.encode(str, "UTF-8");
}
if (f.this.cz == null) {
f.this.cz = new WebView(f.this.context);
f.this.cz.getSettings().setJavaScriptEnabled(true);
f.this.cz.getSettings().setDomStorageEnabled(true);
if (Build.VERSION.SDK_INT >= 21) {
f.this.cz.getSettings().setMixedContentMode(0);
}
f.this.cz.setWebViewClient(new WebViewClient() {
@Override
public final boolean shouldOverrideUrlLoading(WebView webView, String str3) {
if (str3 == null) {
return false;
}
try {
if (str3.contains("about:blank")) {
return false;
}
webView.loadUrl(str3);
return true;
} catch (Throwable th) {
com.appnext.base.a.a("AppnextCK$AppnextCK", th);
return false;
}
}
@Override
public final boolean onRenderProcessGone(WebView webView, RenderProcessGoneDetail renderProcessGoneDetail) {
if (Build.VERSION.SDK_INT < 26 || renderProcessGoneDetail.didCrash()) {
return false;
}
if (f.this.cz != null) {
f.this.cz.destroy();
f.this.cz = null;
return true;
}
return true;
}
});
}
f.this.cz.loadUrl("about:blank");
f.this.cz.loadUrl(str2);
new StringBuilder("store url: ").append(str2);
f.this.U();
f.this.T();
} catch (UnsupportedEncodingException e) {
com.appnext.base.a.a("AppnextCK$AppnextCK", e);
f.this.T();
}
} catch (Throwable th) {
com.appnext.base.a.a("AppnextCK$AppnextCK", th);
}
}
@Override
public final void error(String str) {
f.this.b(0);
if (f.this.cD.size() == 0) {
return;
}
b bVar = (b) f.this.cD.get(0);
if (bVar.cP != null) {
bVar.cP.error(str);
}
f.this.T();
}
};
this.cB = new Runnable() {
@Override
public final void run() {
if (f.this.cA != null && f.this.cy != null) {
f.this.cA.error(f.this.cy.getUrl());
f.this.cy.stopLoading();
}
f.this.T();
}
};
} catch (Throwable th) {
com.appnext.base.a.a("AppnextCK$AppnextCK", th);
}
}
public final void a(String str, String str2, String str3, String str4, a aVar) {
a(str, str2, str3, str4, aVar, 16000L);
}
public final void a(String str, String str2, String str3, String str4, a aVar, long j) {
try {
if (this.context == null) {
return;
}
if (str3 != null) {
Iterator<b> it = this.cD.iterator();
while (it.hasNext()) {
b next = it.next();
if (!TextUtils.isEmpty(next.v) && next.v.equals(str3)) {
return;
}
}
if (str3.endsWith("&ox=0")) {
this.cD.add(new b(str, str2, str3, str4, aVar, j));
} else {
this.cE = 0;
if (this.cD.size() > 0 && !this.cD.get(0).v.endsWith("&ox=0")) {
new StringBuilder("--ck-- out ").append(this.cD.get(0).v);
this.cD.get(0).cP = null;
this.cD.remove(0);
new StringBuilder("--ck-- size ").append(this.cD.size());
}
this.cD.add(0, new b(str, str2, str3, str4, aVar, j));
}
new StringBuilder("--ck-- in ").append(str3);
}
if (this.cD.size() <= 0 || this.cE == 1) {
StringBuilder sb = new StringBuilder("vta waiting - ");
sb.append(str4);
sb.append(" - ");
sb.append(str3);
return;
}
this.cE = 1;
StringBuilder sb2 = new StringBuilder("vta load - ");
sb2.append(this.cD.get(0).cQ);
sb2.append(" - ");
sb2.append(this.cD.get(0).v);
a(this.cD.get(0));
} catch (Throwable th) {
com.appnext.base.a.a("AppnextCK$load", th);
}
}
public void b(int i) {
this.cE = i;
}
public void U() {
Handler handler = this.handler;
if (handler != null) {
handler.removeCallbacksAndMessages(null);
}
}
private boolean n(String str) {
try {
this.context.getPackageManager().getPackageInfo(str, 0);
return true;
} catch (PackageManager.NameNotFoundException unused) {
return false;
}
}
public void openMarket(String str) {
try {
if ((str.startsWith("market://") || str.startsWith("https://play.google.com/store")) && n("com.android.vending")) {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
Iterator<ResolveInfo> it = this.context.getPackageManager().queryIntentActivities(intent, 0).iterator();
while (true) {
if (!it.hasNext()) {
break;
}
ResolveInfo next = it.next();
if (next.activityInfo.applicationInfo.packageName.equals("com.android.vending")) {
ActivityInfo activityInfo = next.activityInfo;
ComponentName componentName = new ComponentName(activityInfo.applicationInfo.packageName, activityInfo.name);
intent.addFlags(268435456);
intent.addFlags(2097152);
intent.addFlags(131072);
intent.addFlags(67108864);
intent.setComponent(componentName);
this.context.startActivity(intent);
break;
}
}
} else {
Intent intent2 = new Intent("android.intent.action.VIEW", Uri.parse(str));
intent2.setFlags(268435456);
this.context.startActivity(intent2);
}
if (this.cA != null) {
this.cA.onMarket(str);
}
} catch (Throwable th) {
com.appnext.base.a.a("AppnextCK$openMarket", th);
a aVar = this.cA;
if (aVar != null) {
aVar.error(str);
}
}
}
public final void a(String str, a aVar) {
if (!TextUtils.isEmpty(str)) {
openMarket(str);
} else if (aVar != null) {
aVar.error(str);
}
}
private void a(final b bVar) {
try {
new StringBuilder("ClickMarketUrl - ").append(bVar.cO);
if (!TextUtils.isEmpty(bVar.cO)) {
openMarket(bVar.cO);
n.aa().a(new Runnable() {
@Override
public final void run() {
try {
g.a(f.this.context, bVar.cN, null);
} catch (Throwable unused) {
}
}
});
return;
}
U();
if (this.cy == null) {
WebView webView = new WebView(this.context);
this.cy = webView;
webView.getSettings().setJavaScriptEnabled(true);
this.cy.getSettings().setDomStorageEnabled(true);
if (Build.VERSION.SDK_INT >= 21) {
this.cy.getSettings().setMixedContentMode(0);
}
this.cy.setWebViewClient(new WebViewClient() {
@Override
public final boolean shouldOverrideUrlLoading(WebView webView2, String str) {
String str2;
List<ResolveInfo> queryIntentActivities;
if (str == null) {
return false;
}
new StringBuilder("redirect url: ").append(str);
if (str.startsWith("https://play.google.com/store/apps/")) {
str = str.replace("https://play.google.com/store/apps/", "market://");
}
if (str.contains("about:blank")) {
return false;
}
if (!str.startsWith("http://") && !str.startsWith("https://")) {
if (str.startsWith("intent://")) {
try {
Intent parseUri = Intent.parseUri(str, 1);
if (f.this.context.getPackageManager().resolveActivity(parseUri, 65536) != null) {
f.this.U();
if (f.this.cA != null) {
f.this.cA.onMarket(parseUri.getData().toString());
}
return true;
}
if (parseUri.getExtras() != null && parseUri.getExtras().containsKey("browser_fallback_url") && !parseUri.getExtras().getString("browser_fallback_url").equals("")) {
str2 = parseUri.getExtras().getString("browser_fallback_url");
} else if (parseUri.getExtras().containsKey("market_referrer") && !parseUri.getExtras().getString("market_referrer").equals("")) {
str2 = "market://details?id=" + parseUri.getPackage() + "&referrer=" + parseUri.getExtras().getString("market_referrer");
} else {
f.this.U();
if (f.this.cA != null) {
f.this.cA.error(str);
}
return true;
}
f.this.U();
if (f.this.cA != null) {
f.this.cA.onMarket(str2);
}
return true;
} catch (Throwable unused) {
return false;
}
}
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse(str));
try {
queryIntentActivities = f.this.context.getPackageManager().queryIntentActivities(intent, 0);
} catch (Throwable unused2) {
}
if (queryIntentActivities != null && queryIntentActivities.size() > 0) {
f.this.U();
f.this.openMarket(str);
if (f.this.cA != null) {
f.this.cA.onMarket(str);
}
return true;
}
webView2.loadUrl(str);
return false;
}
Intent a2 = f.this.a(f.o(str).setComponent(null));
if (a2 != null) {
f.this.U();
if (f.this.cA != null) {
f.this.cA.onMarket(str);
}
a2.addFlags(268435456);
f.this.context.startActivity(a2);
return true;
}
webView2.loadUrl(str);
return true;
}
@Override
public final boolean onRenderProcessGone(WebView webView2, RenderProcessGoneDetail renderProcessGoneDetail) {
if (Build.VERSION.SDK_INT < 26 || renderProcessGoneDetail.didCrash()) {
return false;
}
if (f.this.cy != null) {
f.this.cy.destroy();
f.this.cy = null;
return true;
}
return true;
}
});
}
this.cy.stopLoading();
this.cy.loadUrl("about:blank");
this.cC = a(this.context, o(bVar.v).setComponent(null));
this.cy.loadUrl(bVar.v);
new StringBuilder("appurl: ").append(bVar.v);
this.handler.postDelayed(this.cB, bVar.v.endsWith("&ox=0") ? 15000L : bVar.cR);
} catch (Throwable th) {
com.appnext.base.a.a("AppnextCK$load1", th);
a aVar = this.cA;
if (aVar != null) {
aVar.error(bVar.v);
}
T();
}
}
public final void d(final AppnextAd appnextAd) {
n.aa().a(new Runnable() {
@Override
public final void run() {
try {
g.a(f.this.context, appnextAd.getImpressionURL(), null);
} catch (Throwable th) {
com.appnext.base.a.a("AppnextCK$adImpression", th);
}
}
});
}
private static List a(Context context, Intent intent) {
List<ResolveInfo> queryIntentActivities = context.getPackageManager().queryIntentActivities(intent, 0);
ArrayList arrayList = new ArrayList();
for (ResolveInfo resolveInfo : queryIntentActivities) {
arrayList.add(new ComponentName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name));
}
return arrayList;
}
public final Intent a(Intent intent) {
List<ComponentName> a2 = a(this.context, intent);
new HashSet();
for (ComponentName componentName : a2) {
if (!this.cC.contains(componentName)) {
Intent intent2 = new Intent();
intent2.setComponent(componentName);
return intent2;
}
}
return null;
}
public static Intent o(String str) {
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse(str));
return intent;
}
public void T() {
try {
this.cE = 0;
if (this.cD.size() == 0) {
return;
}
new StringBuilder("--ck-- out ").append(this.cD.get(0).v);
this.cD.get(0).cP = null;
this.cD.remove(0);
new StringBuilder("--ck-- size ").append(this.cD.size());
a(null, null, null, null, null);
} catch (Throwable th) {
com.appnext.base.a.a("AppnextCK$loadNext", th);
}
}
}