package com.tencent.connect.auth; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Color; import android.net.Uri; import android.net.http.SslError; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.SystemClock; import android.text.TextUtils; import android.view.MotionEvent; import android.view.View; import android.view.Window; import android.webkit.SslErrorHandler; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Button; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.alibaba.security.realidentity.build.bg; import com.didiglobal.booster.instrument.ShadowToast; import com.google.android.exoplayer2.text.ttml.TtmlNode; import com.tencent.connect.auth.b; import com.tencent.connect.common.Constants; import com.tencent.open.a.g; import com.tencent.open.log.SLog; import com.tencent.open.utils.HttpUtils; import com.tencent.open.utils.l; import com.tencent.open.web.security.JniInterface; import com.tencent.open.web.security.SecureJsInterface; import com.tencent.tauth.DefaultUiListener; import com.tencent.tauth.IUiListener; import com.tencent.tauth.UiError; import io.flutter.plugin.platform.PlatformPlugin; import java.util.HashMap; import java.util.List; import java.util.Locale; import op.e; import org.json.JSONException; import org.json.JSONObject; /* compiled from: ProGuard */ public class a extends Dialog { /* renamed from: a reason: collision with root package name */ private String f41406a; /* renamed from: b reason: collision with root package name */ private b f41407b; /* renamed from: c reason: collision with root package name */ private IUiListener f41408c; /* renamed from: d reason: collision with root package name */ private Handler f41409d; /* renamed from: e reason: collision with root package name */ private FrameLayout f41410e; /* renamed from: f reason: collision with root package name */ private LinearLayout f41411f; /* renamed from: g reason: collision with root package name */ private FrameLayout f41412g; /* renamed from: h reason: collision with root package name */ private ProgressBar f41413h; /* renamed from: i reason: collision with root package name */ private Button f41414i; /* renamed from: j reason: collision with root package name */ private String f41415j; /* renamed from: k reason: collision with root package name */ private com.tencent.open.b.c f41416k; /* renamed from: l reason: collision with root package name */ private Context f41417l; /* renamed from: m reason: collision with root package name */ private com.tencent.open.web.security.b f41418m; /* renamed from: n reason: collision with root package name */ private boolean f41419n = false; /* renamed from: o reason: collision with root package name */ private int f41420o; /* renamed from: p reason: collision with root package name */ private String f41421p; /* renamed from: q reason: collision with root package name */ private String f41422q; /* renamed from: r reason: collision with root package name */ private long f41423r = 0; /* renamed from: s reason: collision with root package name */ private long f41424s = 30000; /* renamed from: t reason: collision with root package name */ private HashMap<String, Runnable> f41425t; /* renamed from: com.tencent.connect.auth.a$a reason: collision with other inner class name */ /* compiled from: ProGuard */ public class C0375a extends WebViewClient { private C0375a() { } public void onPageFinished(WebView webView, String str) { super.onPageFinished(webView, str); SLog.v("openSDK_LOG.AuthDialog", "-->onPageFinished, url: " + str); a.this.f41412g.setVisibility(8); if (a.this.f41416k != null) { a.this.f41416k.setVisibility(0); } if (!TextUtils.isEmpty(str)) { a.this.f41409d.removeCallbacks((Runnable) a.this.f41425t.remove(str)); } } public void onPageStarted(WebView webView, String str, Bitmap bitmap) { SLog.v("openSDK_LOG.AuthDialog", "-->onPageStarted, url: " + str); super.onPageStarted(webView, str, bitmap); a.this.f41412g.setVisibility(0); a.this.f41423r = SystemClock.elapsedRealtime(); if (!TextUtils.isEmpty(a.this.f41421p)) { a.this.f41409d.removeCallbacks((Runnable) a.this.f41425t.remove(a.this.f41421p)); } a.this.f41421p = str; a aVar = a.this; d dVar = new d(aVar.f41421p); a.this.f41425t.put(str, dVar); a.this.f41409d.postDelayed(dVar, 120000); } public void onReceivedError(WebView webView, int i10, String str, String str2) { super.onReceivedError(webView, i10, str, str2); SLog.i("openSDK_LOG.AuthDialog", "-->onReceivedError, errorCode: " + i10 + " | description: " + str); if (!l.b(a.this.f41417l)) { a.this.f41407b.onError(new UiError(9001, "当前网络不可用,请稍后重试!", str2)); a.this.dismiss(); } else if (!a.this.f41421p.startsWith("https://login.imgcache.qq.com/ptlogin/static/qzsjump.html?")) { long elapsedRealtime = SystemClock.elapsedRealtime() - a.this.f41423r; if (a.this.f41420o >= 1 || elapsedRealtime >= a.this.f41424s) { a.this.f41416k.loadUrl(a.this.a()); return; } a.m(a.this); a.this.f41409d.postDelayed(new Runnable() { /* class com.tencent.connect.auth.a.C0375a.AnonymousClass1 */ public void run() { a.this.f41416k.loadUrl(a.this.f41421p); } }, 500); } else { a.this.f41407b.onError(new UiError(i10, str, str2)); a.this.dismiss(); } } @TargetApi(8) public void onReceivedSslError(WebView webView, final SslErrorHandler sslErrorHandler, SslError sslError) { String str; String str2; String str3; SLog.e("openSDK_LOG.AuthDialog", "-->onReceivedSslError " + sslError.getPrimaryError() + "请求不合法,请检查手机安全设置,如系统时间、代理等"); if (Locale.getDefault().getLanguage().equals("zh")) { str2 = "ssl证书无效,是否继续访问?"; str = "是"; str3 = "否"; } else { str2 = "The SSL certificate is invalid,do you countinue?"; str = "yes"; str3 = "no"; } AlertDialog.Builder builder = new AlertDialog.Builder(a.this.f41417l); builder.setMessage(str2); builder.setPositiveButton(str, new DialogInterface.OnClickListener() { /* class com.tencent.connect.auth.a.C0375a.AnonymousClass2 */ public void onClick(DialogInterface dialogInterface, int i10) { sslErrorHandler.proceed(); } }); builder.setNegativeButton(str3, new DialogInterface.OnClickListener() { /* class com.tencent.connect.auth.a.C0375a.AnonymousClass3 */ public void onClick(DialogInterface dialogInterface, int i10) { sslErrorHandler.cancel(); a.this.dismiss(); } }); builder.create().show(); } @Override // android.webkit.WebViewClient public boolean shouldOverrideUrlLoading(WebView webView, String str) { Uri uri; SLog.v("openSDK_LOG.AuthDialog", "-->Redirect URL: " + str); if (str.startsWith("auth://browser")) { JSONObject c10 = l.c(str); a aVar = a.this; aVar.f41419n = aVar.f(); if (!a.this.f41419n) { if (c10.optString("fail_cb", null) != null) { a.this.a(c10.optString("fail_cb"), ""); } else if (c10.optInt("fall_to_wv") == 1) { a aVar2 = a.this; StringBuilder sb2 = new StringBuilder(); sb2.append(a.this.f41406a); String str2 = "?"; if (a.this.f41406a.indexOf(str2) > -1) { str2 = "&"; } sb2.append(str2); aVar2.f41406a = sb2.toString(); a aVar3 = a.this; aVar3.f41406a = a.this.f41406a + "browser_error=1"; a.this.f41416k.loadUrl(a.this.f41406a); } else { String optString = c10.optString("redir", null); if (optString != null) { a.this.f41416k.loadUrl(optString); } } } return true; } else if (str.startsWith("auth://tauth.qq.com/")) { a.this.f41407b.onComplete(l.c(str)); a.this.dismiss(); return true; } else if (str.startsWith(Constants.CANCEL_URI)) { a.this.f41407b.onCancel(); a.this.dismiss(); return true; } else if (str.startsWith(Constants.CLOSE_URI)) { a.this.dismiss(); return true; } else if (str.startsWith(Constants.DOWNLOAD_URI) || str.endsWith(".apk")) { try { if (str.startsWith(Constants.DOWNLOAD_URI)) { uri = Uri.parse(Uri.decode(str.substring(11))); } else { uri = Uri.parse(Uri.decode(str)); } Intent intent = new Intent("android.intent.action.VIEW", uri); intent.addFlags(268435456); a.this.f41417l.startActivity(intent); } catch (Exception e10) { SLog.e("openSDK_LOG.AuthDialog", "-->start download activity exception, e: ", e10); } return true; } else if (str.startsWith("auth://progress")) { try { List<String> pathSegments = Uri.parse(str).getPathSegments(); if (pathSegments.isEmpty()) { return true; } int intValue = Integer.valueOf(pathSegments.get(0)).intValue(); if (intValue == 0) { a.this.f41412g.setVisibility(8); a.this.f41416k.setVisibility(0); } else if (intValue == 1) { a.this.f41412g.setVisibility(0); } return true; } catch (Exception unused) { } } else if (str.startsWith("auth://onLoginSubmit")) { try { List<String> pathSegments2 = Uri.parse(str).getPathSegments(); if (!pathSegments2.isEmpty()) { a.this.f41422q = pathSegments2.get(0); } } catch (Exception unused2) { } return true; } else if (a.this.f41418m.a(a.this.f41416k, str)) { return true; } else { SLog.i("openSDK_LOG.AuthDialog", "-->Redirect URL: return false"); return false; } } } /* compiled from: ProGuard */ public class b extends DefaultUiListener { /* renamed from: a reason: collision with root package name */ public String f41436a; /* renamed from: b reason: collision with root package name */ public String f41437b; /* renamed from: d reason: collision with root package name */ private String f41439d; /* renamed from: e reason: collision with root package name */ private IUiListener f41440e; public b(String str, String str2, String str3, IUiListener iUiListener) { this.f41439d = str; this.f41436a = str2; this.f41437b = str3; this.f41440e = iUiListener; } @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener public void onCancel() { IUiListener iUiListener = this.f41440e; if (iUiListener != null) { iUiListener.onCancel(); this.f41440e = null; } } @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener public void onComplete(Object obj) { JSONObject jSONObject = (JSONObject) obj; g a10 = g.a(); a10.a(this.f41439d + "_H5", SystemClock.elapsedRealtime(), 0, 0, jSONObject.optInt("ret", -6), this.f41436a, false); IUiListener iUiListener = this.f41440e; if (iUiListener != null) { iUiListener.onComplete(jSONObject); this.f41440e = null; } } @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener public void onError(UiError uiError) { String str; if (uiError.errorMessage != null) { str = uiError.errorMessage + this.f41436a; } else { str = this.f41436a; } g.a().a(this.f41439d + "_H5", SystemClock.elapsedRealtime(), 0, 0, uiError.errorCode, str, false); a.this.a((a) str); IUiListener iUiListener = this.f41440e; if (iUiListener != null) { iUiListener.onError(uiError); this.f41440e = null; } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a(String str) { try { onComplete(l.d(str)); } catch (JSONException e10) { e10.printStackTrace(); onError(new UiError(-4, Constants.MSG_JSON_ERROR, str)); } } } /* compiled from: ProGuard */ public class c extends Handler { /* renamed from: b reason: collision with root package name */ private b f41442b; public c(b bVar, Looper looper) { super(looper); this.f41442b = bVar; } public void handleMessage(Message message) { int i10 = message.what; if (i10 == 1) { this.f41442b.a((String) message.obj); } else if (i10 == 2) { this.f41442b.onCancel(); } else if (i10 == 3) { a.b(a.this.f41417l, (String) message.obj); } } } /* compiled from: ProGuard */ public class d implements Runnable { /* renamed from: a reason: collision with root package name */ public String f41443a = ""; public d(String str) { this.f41443a = str; } public void run() { SLog.v("openSDK_LOG.AuthDialog", "-->timeoutUrl: " + this.f41443a + " | mRetryUrl: " + a.this.f41421p); if (this.f41443a.equals(a.this.f41421p)) { a.this.f41407b.onError(new UiError(9002, "请求页面超时,请稍后重试!", a.this.f41421p)); a.this.dismiss(); } } } public a(Context context, String str, String str2, IUiListener iUiListener, QQToken qQToken) { super(context, 16973840); this.f41417l = context; this.f41406a = str2; this.f41407b = new b(str, str2, qQToken.getAppId(), iUiListener); this.f41409d = new c(this.f41407b, context.getMainLooper()); this.f41408c = iUiListener; this.f41415j = str; this.f41418m = new com.tencent.open.web.security.b(); getWindow().setSoftInputMode(32); } public static /* synthetic */ int m(a aVar) { int i10 = aVar.f41420o; aVar.f41420o = i10 + 1; return i10; } public void dismiss() { this.f41425t.clear(); this.f41409d.removeCallbacksAndMessages(null); try { Context context = this.f41417l; if ((context instanceof Activity) && !((Activity) context).isFinishing() && isShowing()) { super.dismiss(); SLog.i("openSDK_LOG.AuthDialog", "-->dismiss dialog"); } } catch (Exception e10) { SLog.e("openSDK_LOG.AuthDialog", "-->dismiss dialog exception:", e10); } com.tencent.open.b.c cVar = this.f41416k; if (cVar != null) { cVar.destroy(); this.f41416k = null; } } public void onBackPressed() { if (!this.f41419n) { this.f41407b.onCancel(); } super.onBackPressed(); } public void onCreate(Bundle bundle) { requestWindowFeature(1); Window window = getWindow(); if (window != null) { window.setFlags(1024, 1024); } super.onCreate(bundle); if (window != null) { View decorView = window.getDecorView(); if (Build.VERSION.SDK_INT >= 16) { decorView.setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); } } b(); e(); this.f41425t = new HashMap<>(); } public void onStop() { super.onStop(); } @SuppressLint({"SetJavaScriptEnabled"}) private void e() { this.f41416k.setVerticalScrollBarEnabled(false); this.f41416k.setHorizontalScrollBarEnabled(false); this.f41416k.setWebViewClient(new C0375a()); this.f41416k.setWebChromeClient(new WebChromeClient()); this.f41416k.clearFormData(); this.f41416k.clearSslPreferences(); this.f41416k.setOnLongClickListener(new View.OnLongClickListener() { /* class com.tencent.connect.auth.a.AnonymousClass2 */ public boolean onLongClick(View view) { return true; } }); this.f41416k.setOnTouchListener(new View.OnTouchListener() { /* class com.tencent.connect.auth.a.AnonymousClass3 */ public boolean onTouch(View view, MotionEvent motionEvent) { int action = motionEvent.getAction(); if ((action != 0 && action != 1) || view.hasFocus()) { return false; } view.requestFocus(); return false; } }); WebSettings settings = this.f41416k.getSettings(); settings.setSavePassword(false); settings.setSaveFormData(false); settings.setCacheMode(-1); settings.setNeedInitialFocus(false); settings.setBuiltInZoomControls(true); settings.setSupportZoom(true); settings.setRenderPriority(WebSettings.RenderPriority.HIGH); settings.setJavaScriptEnabled(true); settings.setDatabaseEnabled(true); settings.setDatabasePath(this.f41417l.getDir(e.f100620c, 0).getPath()); settings.setDomStorageEnabled(true); SLog.v("openSDK_LOG.AuthDialog", "-->mUrl : " + this.f41406a); String str = this.f41406a; this.f41421p = str; this.f41416k.loadUrl(str); this.f41416k.setVisibility(4); this.f41416k.getSettings().setSavePassword(false); this.f41418m.a(new SecureJsInterface(), "SecureJsInterface"); SecureJsInterface.isPWDEdit = false; super.setOnDismissListener(new DialogInterface.OnDismissListener() { /* class com.tencent.connect.auth.a.AnonymousClass4 */ public void onDismiss(DialogInterface dialogInterface) { try { if (JniInterface.isJniOk) { JniInterface.clearAllPWD(); } } catch (Exception unused) { } } }); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private boolean f() { b a10 = b.a(); String c10 = a10.c(); b.a aVar = new b.a(); aVar.f41450a = this.f41408c; aVar.f41451b = this; aVar.f41452c = c10; String a11 = a10.a(aVar); String str = this.f41406a; String substring = str.substring(0, str.indexOf("?")); Bundle b10 = l.b(this.f41406a); b10.putString("token_key", c10); b10.putString("serial", a11); b10.putString("browser", "1"); String str2 = substring + "?" + HttpUtils.encodeUrl(b10); this.f41406a = str2; return l.a(this.f41417l, str2); } private void b() { d(); c(); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1); com.tencent.open.b.c cVar = new com.tencent.open.b.c(this.f41417l); this.f41416k = cVar; if (Build.VERSION.SDK_INT >= 11) { cVar.setLayerType(1, null); } this.f41416k.setLayoutParams(layoutParams); FrameLayout frameLayout = new FrameLayout(this.f41417l); this.f41410e = frameLayout; layoutParams.gravity = 17; frameLayout.setLayoutParams(layoutParams); this.f41410e.addView(this.f41416k); this.f41410e.addView(this.f41412g); String string = l.b(this.f41406a).getString(TtmlNode.TAG_STYLE); if (string != null && "qr".equals(string)) { this.f41410e.addView(this.f41414i); } setContentView(this.f41410e); } private void c() { Button button = new Button(this.f41417l); this.f41414i = button; button.setBackgroundDrawable(l.a("h5_qr_back.png", this.f41417l)); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2); layoutParams.leftMargin = com.tencent.connect.avatar.a.a(this.f41417l, 20.0f); layoutParams.topMargin = com.tencent.connect.avatar.a.a(this.f41417l, 10.0f); this.f41414i.setLayoutParams(layoutParams); this.f41414i.setOnClickListener(new View.OnClickListener() { /* class com.tencent.connect.auth.a.AnonymousClass1 */ public void onClick(View view) { a.this.dismiss(); if (!a.this.f41419n && a.this.f41407b != null) { a.this.f41407b.onCancel(); } } }); } private void d() { TextView textView; this.f41413h = new ProgressBar(this.f41417l); this.f41413h.setLayoutParams(new LinearLayout.LayoutParams(-2, -2)); this.f41411f = new LinearLayout(this.f41417l); if (this.f41415j.equals("action_login")) { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2); layoutParams.gravity = 16; layoutParams.leftMargin = 5; textView = new TextView(this.f41417l); if (Locale.getDefault().getLanguage().equals("zh")) { textView.setText("登录中..."); } else { textView.setText("Logging in..."); } textView.setTextColor(Color.rgb(255, 255, 255)); textView.setTextSize(18.0f); textView.setLayoutParams(layoutParams); } else { textView = null; } FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(-2, -2); layoutParams2.gravity = 17; this.f41411f.setLayoutParams(layoutParams2); this.f41411f.addView(this.f41413h); if (textView != null) { this.f41411f.addView(textView); } this.f41412g = new FrameLayout(this.f41417l); FrameLayout.LayoutParams layoutParams3 = new FrameLayout.LayoutParams(-1, -1); layoutParams3.gravity = 17; this.f41412g.setLayoutParams(layoutParams3); this.f41412g.setBackgroundColor(Color.parseColor("#B3000000")); this.f41412g.addView(this.f41411f); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private String a(String str) { StringBuilder sb2 = new StringBuilder(str); if (!TextUtils.isEmpty(this.f41422q) && this.f41422q.length() >= 4) { String str2 = this.f41422q; String substring = str2.substring(str2.length() - 4); sb2.append("_u_"); sb2.append(substring); } return sb2.toString(); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private String a() { String str = this.f41406a; String str2 = "https://login.imgcache.qq.com/ptlogin/static/qzsjump.html?" + str.substring(str.indexOf("?") + 1); SLog.i("openSDK_LOG.AuthDialog", "-->generateDownloadUrl, url: https://login.imgcache.qq.com/ptlogin/static/qzsjump.html?"); return str2; } public void a(String str, String str2) { this.f41416k.loadUrl(bg.f26088j + str + "(" + str2 + ");void(" + System.currentTimeMillis() + ");"); } /* access modifiers changed from: private */ public static void b(Context context, String str) { try { JSONObject d10 = l.d(str); int i10 = d10.getInt("type"); ShadowToast.show(Toast.makeText(context.getApplicationContext(), d10.getString("msg"), i10)); } catch (JSONException e10) { e10.printStackTrace(); } } }