APKPure.apk分析 / CaptchaWebViewActivity.java
package com.apkpure.aegon.main.activity;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import androidx.appcompat.widget.Toolbar;
import com.apkpure.aegon.R;
import com.apkpure.aegon.application.AegonApplication;
import com.apkpure.aegon.application.RealApplicationLike;
import com.apkpure.aegon.widgets.webview.CustomWebView;
import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;
import e.g.a.i0.u0;
import e.g.a.i0.w;
import e.g.a.m0.m0.c;
import e.g.a.t.a.g;
import e.g.a.v.s.i;
import e.w.e.a.b.l.b;
import e.w.e.a.b.t.d.c.a;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import o.s.c.j;
import o.y.l;
import okhttp3.Cookie;
import okhttp3.HttpUrl;
public final class CaptchaWebViewActivity extends e.g.a.t.b.a {
/* renamed from: l reason: collision with root package name */
public static a f1704l;
/* renamed from: g reason: collision with root package name */
public FrameLayout f1705g;
/* renamed from: h reason: collision with root package name */
public Toolbar f1706h;
/* renamed from: i reason: collision with root package name */
public CustomWebView f1707i;
/* renamed from: j reason: collision with root package name */
public final String f1708j = e.g.a.s.l.a.L();
/* renamed from: k reason: collision with root package name */
public boolean f1709k;
public interface a {
}
public static final class b extends e.g.a.m0.m0.b {
/* renamed from: a reason: collision with root package name */
public final /* synthetic */ CaptchaWebViewActivity f1710a;
public b(CaptchaWebViewActivity captchaWebViewActivity) {
this.f1710a = captchaWebViewActivity;
}
public void onPageFinished(WebView webView, String str) {
Set<String> set;
super.onPageFinished(webView, str);
if (str != null) {
CaptchaWebViewActivity captchaWebViewActivity = this.f1710a;
try {
set = Uri.parse(str).getQueryParameterNames();
} catch (Exception unused) {
set = null;
}
if (set != null && j.a(str, "https://api.pureapk.com/m/v3/cf-challenge") && !set.isEmpty() && set.contains("__cf_chl_captcha_tk__")) {
String cookie = CookieManager.getInstance().getCookie(str);
if (!(cookie == null || cookie.length() == 0)) {
j.d(cookie, "cookieStr");
List<String> C = l.C(cookie, new String[]{";"}, false, 0, 6);
HttpUrl httpUrl = HttpUrl.get(str);
ArrayList arrayList = new ArrayList();
for (String str2 : C) {
if (l.E(l.M(str2).toString(), "__cf", false, 2) || l.E(l.M(str2).toString(), "cf_", false, 2)) {
Cookie parse = Cookie.parse(httpUrl, str2);
if (parse != null) {
arrayList.add(parse);
} else {
return;
}
}
}
if (!arrayList.isEmpty()) {
if (!TextUtils.isEmpty(str) && HttpUrl.parse(str) != null) {
SetCookieCache setCookieCache = new SetCookieCache();
int i2 = AegonApplication.f1165e;
SharedPrefsCookiePersistor sharedPrefsCookiePersistor = new SharedPrefsCookiePersistor(RealApplicationLike.getContext());
setCookieCache.addAll(sharedPrefsCookiePersistor.d());
Arrays.toString(new List[]{arrayList});
setCookieCache.addAll(arrayList);
ArrayList arrayList2 = new ArrayList();
arrayList2.addAll(arrayList);
sharedPrefsCookiePersistor.a(arrayList2);
}
a aVar = CaptchaWebViewActivity.f1704l;
if (aVar != null) {
e.g.a.v.s.j jVar = (e.g.a.v.s.j) aVar;
u0.f6569a = null;
u0.b = null;
u0.f6570e = null;
u0.d = null;
i.b(jVar.f7351a, jVar.b, jVar.c, jVar.d, jVar.f7352e, jVar.f7353f, jVar.f7354g);
}
captchaWebViewActivity.finish();
} else {
return;
}
} else {
return;
}
}
}
CaptchaWebViewActivity captchaWebViewActivity2 = this.f1710a;
if (captchaWebViewActivity2.f1709k) {
e.g.a.d0.b.d(c.a.CAPTCHA_WEB_VIEW_ACTIVITY, captchaWebViewActivity2.f1708j, "https://api.pureapk.com/m/v3/cf-challenge");
}
}
@Override // e.g.a.m0.m0.b
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
Set<String> set = e.w.e.a.b.t.d.c.a.b;
a.b.f12432a.b(webView);
super.onPageStarted(webView, str, bitmap);
CaptchaWebViewActivity captchaWebViewActivity = this.f1710a;
if (captchaWebViewActivity.f1709k) {
e.g.a.d0.b.e(c.a.CAPTCHA_WEB_VIEW_ACTIVITY, captchaWebViewActivity.f1708j, "https://api.pureapk.com/m/v3/cf-challenge");
}
}
}
@Override // e.g.a.t.b.a
public int K1() {
return R.layout.arg_RES_2131492966;
}
@Override // e.g.a.t.b.a
public void O1() {
CustomWebView customWebView = this.f1707i;
if (customWebView != null) {
i.i.d.c.E(customWebView, true);
c.a aVar = c.a.CAPTCHA_WEB_VIEW_ACTIVITY;
e.g.a.d0.b.h(aVar, this.f1708j, "https://api.pureapk.com/m/v3/cf-challenge");
i.i.d.c.b0(I1(), "https://api.pureapk.com/m/v3/cf-challenge");
CustomWebView customWebView2 = this.f1707i;
if (customWebView2 != null) {
customWebView2.setWebViewClient(new b(this));
}
this.f1709k = true;
CustomWebView customWebView3 = this.f1707i;
if (customWebView3 != null) {
customWebView3.f("https://api.pureapk.com/m/v3/cf-challenge");
}
e.g.a.d0.b.c(aVar, this.f1708j, "https://api.pureapk.com/m/v3/cf-challenge");
}
}
@Override // e.g.a.t.b.a
public void R1() {
View findViewById = findViewById(R.id.arg_RES_2131298934);
j.d(findViewById, "findViewById(R.id.webViewContainer)");
this.f1705g = (FrameLayout) findViewById;
View findViewById2 = findViewById(R.id.arg_RES_2131298935);
j.d(findViewById2, "findViewById(R.id.webViewToolbar)");
this.f1706h = (Toolbar) findViewById2;
c.a aVar = c.a.CAPTCHA_WEB_VIEW_ACTIVITY;
e.g.a.d0.b.f(aVar, this.f1708j, "https://api.pureapk.com/m/v3/cf-challenge");
String string = getString(R.string.arg_RES_2131820734);
j.d(string, "getString(title)");
Toolbar toolbar = this.f1706h;
if (toolbar != null) {
setSupportActionBar(toolbar);
i.b.c.a supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.n(false);
supportActionBar.m(true);
Toolbar toolbar2 = this.f1706h;
if (toolbar2 != null) {
toolbar2.setTitle(string);
toolbar2.setNavigationOnClickListener(new g(this));
} else {
j.n("webViewToolbar");
throw null;
}
}
w wVar = w.f6575a;
Toolbar toolbar3 = this.f1706h;
if (toolbar3 != null) {
wVar.g(toolbar3, this);
e.g.a.d0.b.i(aVar, this.f1708j, "https://api.pureapk.com/m/v3/cf-challenge");
try {
CustomWebView customWebView = new CustomWebView(H1(), null);
this.f1707i = customWebView;
if (customWebView != null) {
customWebView.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
}
FrameLayout frameLayout = this.f1705g;
if (frameLayout != null) {
CustomWebView customWebView2 = this.f1707i;
if (customWebView2 != null) {
frameLayout.addView(customWebView2);
return;
}
return;
}
j.n("webViewContainer");
throw null;
} catch (Exception unused) {
a aVar2 = f1704l;
if (aVar2 != null) {
String string2 = getString(R.string.arg_RES_2131820733);
j.d(string2, "getString(R.string.captcha_failed)");
((e.g.a.v.s.j) aVar2).f7354g.a("INVALID_RESULT", string2);
}
finish();
}
} else {
j.n("webViewToolbar");
throw null;
}
} else {
j.n("webViewToolbar");
throw null;
}
}
@Override // androidx.activity.ComponentActivity, i.o.c.l, i.i.c.g, e.g.a.t.b.a, i.b.c.i
@Override
public boolean dispatchTouchEvent(MotionEvent motionEvent) {
b.C0315b.f12266a.c(this, motionEvent, false, true);
boolean dispatchTouchEvent = super.dispatchTouchEvent(motionEvent);
b.C0315b.f12266a.c(this, motionEvent, dispatchTouchEvent, false);
return dispatchTouchEvent;
}
@Override // androidx.activity.ComponentActivity, i.o.c.l, i.i.c.g, e.g.a.t.b.a, i.b.c.i
@Override
public void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
b.C0315b.f12266a.b(this, configuration);
}
@Override // androidx.activity.ComponentActivity, i.o.c.l, i.i.c.g, e.g.a.t.b.a
public void onCreate(Bundle bundle) {
e.g.a.d0.b.g(c.a.CAPTCHA_WEB_VIEW_ACTIVITY, this.f1708j, "https://api.pureapk.com/m/v3/cf-challenge");
super.onCreate(bundle);
}
@Override // i.o.c.l, e.g.a.t.b.a, i.b.c.i
public void onDestroy() {
super.onDestroy();
FrameLayout frameLayout = this.f1705g;
if (frameLayout != null) {
frameLayout.removeAllViews();
CustomWebView customWebView = this.f1707i;
if (customWebView != null) {
customWebView.removeAllViews();
}
CustomWebView customWebView2 = this.f1707i;
if (customWebView2 != null) {
customWebView2.c();
return;
}
return;
}
j.n("webViewContainer");
throw null;
}
@Override // i.b.c.i
public boolean onKeyDown(int i2, KeyEvent keyEvent) {
CustomWebView customWebView = this.f1707i;
if (customWebView == null) {
return super.onKeyDown(i2, keyEvent);
}
if (i2 == 4) {
if (customWebView.b()) {
customWebView.d();
return true;
}
a aVar = f1704l;
if (aVar != null) {
String string = getString(R.string.arg_RES_2131820733);
j.d(string, "getString(R.string.captcha_failed)");
((e.g.a.v.s.j) aVar).f7354g.a("INVALID_RESULT", string);
}
}
return super.onKeyDown(i2, keyEvent);
}
@Override // i.o.c.l, e.g.a.t.b.a
public void onPause() {
super.onPause();
CustomWebView customWebView = this.f1707i;
if (customWebView != null) {
customWebView.g();
}
}
@Override // i.o.c.l, e.g.a.t.b.a
public void onResume() {
super.onResume();
CustomWebView customWebView = this.f1707i;
if (customWebView != null) {
customWebView.h();
}
}
}