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.huawei.hms.support.api.entity.common.CommonConstant; 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 com.tencent.wcdb.database.SQLiteDatabase; import io.sentry.android.core.protocol.Browser; import java.util.HashMap; import java.util.List; import java.util.Locale; 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 f30893a; /* renamed from: b reason: collision with root package name */ private b f30894b; /* renamed from: c reason: collision with root package name */ private IUiListener f30895c; /* renamed from: d reason: collision with root package name */ private Handler f30896d; /* renamed from: e reason: collision with root package name */ private FrameLayout f30897e; /* renamed from: f reason: collision with root package name */ private LinearLayout f30898f; /* renamed from: g reason: collision with root package name */ private FrameLayout f30899g; /* renamed from: h reason: collision with root package name */ private ProgressBar f30900h; /* renamed from: i reason: collision with root package name */ private Button f30901i; /* renamed from: j reason: collision with root package name */ private String f30902j; /* renamed from: k reason: collision with root package name */ private com.tencent.open.b.c f30903k; /* renamed from: l reason: collision with root package name */ private Context f30904l; /* renamed from: m reason: collision with root package name */ private com.tencent.open.web.security.b f30905m; /* renamed from: n reason: collision with root package name */ private boolean f30906n = false; /* renamed from: o reason: collision with root package name */ private int f30907o; /* renamed from: p reason: collision with root package name */ private String f30908p; /* renamed from: q reason: collision with root package name */ private String f30909q; /* renamed from: r reason: collision with root package name */ private long f30910r = 0; /* renamed from: s reason: collision with root package name */ private long f30911s = com.igexin.push.config.c.f25221k; /* renamed from: t reason: collision with root package name */ private HashMap<String, Runnable> f30912t; /* renamed from: com.tencent.connect.auth.a$a reason: collision with other inner class name */ /* compiled from: ProGuard */ public class C0439a extends WebViewClient { private C0439a() { } public void onPageFinished(WebView webView, String str) { super.onPageFinished(webView, str); SLog.v("openSDK_LOG.AuthDialog", "-->onPageFinished, url: " + str); a.this.f30899g.setVisibility(8); if (a.this.f30903k != null) { a.this.f30903k.setVisibility(0); } if (!TextUtils.isEmpty(str)) { a.this.f30896d.removeCallbacks((Runnable) a.this.f30912t.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.f30899g.setVisibility(0); a.this.f30910r = SystemClock.elapsedRealtime(); if (!TextUtils.isEmpty(a.this.f30908p)) { a.this.f30896d.removeCallbacks((Runnable) a.this.f30912t.remove(a.this.f30908p)); } a.this.f30908p = str; a aVar = a.this; d dVar = new d(aVar.f30908p); a.this.f30912t.put(str, dVar); a.this.f30896d.postDelayed(dVar, com.igexin.push.config.c.f25222l); } 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.f30904l)) { a.this.f30894b.onError(new UiError(9001, "当前网络不可用,请稍后重试!", str2)); a.this.dismiss(); } else if (!a.this.f30908p.startsWith("https://login.imgcache.qq.com/ptlogin/static/qzsjump.html?")) { long elapsedRealtime = SystemClock.elapsedRealtime() - a.this.f30910r; if (a.this.f30907o >= 1 || elapsedRealtime >= a.this.f30911s) { a.this.f30903k.loadUrl(a.this.a()); return; } a.m(a.this); a.this.f30896d.postDelayed(new Runnable() { /* class com.tencent.connect.auth.a.C0439a.AnonymousClass1 */ public void run() { a.this.f30903k.loadUrl(a.this.f30908p); } }, 500); } else { a.this.f30894b.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.f30904l); builder.setMessage(str2); builder.setPositiveButton(str, new DialogInterface.OnClickListener() { /* class com.tencent.connect.auth.a.C0439a.AnonymousClass2 */ public void onClick(DialogInterface dialogInterface, int i10) { sslErrorHandler.proceed(); } }); builder.setNegativeButton(str3, new DialogInterface.OnClickListener() { /* class com.tencent.connect.auth.a.C0439a.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 c14 = l.c(str); a aVar = a.this; aVar.f30906n = aVar.f(); if (!a.this.f30906n) { if (c14.optString("fail_cb", null) != null) { a.this.a(c14.optString("fail_cb"), ""); } else if (c14.optInt("fall_to_wv") == 1) { a aVar2 = a.this; StringBuilder sb3 = new StringBuilder(); sb3.append(a.this.f30893a); String str2 = "?"; if (a.this.f30893a.indexOf(str2) > -1) { str2 = "&"; } sb3.append(str2); aVar2.f30893a = sb3.toString(); a aVar3 = a.this; aVar3.f30893a = a.this.f30893a + "browser_error=1"; a.this.f30903k.loadUrl(a.this.f30893a); } else { String optString = c14.optString("redir", null); if (optString != null) { a.this.f30903k.loadUrl(optString); } } } return true; } else if (str.startsWith("auth://tauth.qq.com/")) { a.this.f30894b.onComplete(l.c(str)); a.this.dismiss(); return true; } else if (str.startsWith(Constants.CANCEL_URI)) { a.this.f30894b.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(CommonConstant.ACTION.HWID_SCHEME_URL, uri); intent.addFlags(SQLiteDatabase.CREATE_IF_NECESSARY); a.this.f30904l.startActivity(intent); } catch (Exception e14) { SLog.e("openSDK_LOG.AuthDialog", "-->start download activity exception, e: ", e14); } 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.f30899g.setVisibility(8); a.this.f30903k.setVisibility(0); } else if (intValue == 1) { a.this.f30899g.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.f30909q = pathSegments2.get(0); } } catch (Exception unused2) { } return true; } else if (a.this.f30905m.a(a.this.f30903k, 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 f30923a; /* renamed from: b reason: collision with root package name */ public String f30924b; /* renamed from: d reason: collision with root package name */ private String f30926d; /* renamed from: e reason: collision with root package name */ private IUiListener f30927e; public b(String str, String str2, String str3, IUiListener iUiListener) { this.f30926d = str; this.f30923a = str2; this.f30924b = str3; this.f30927e = iUiListener; } @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener public void onCancel() { IUiListener iUiListener = this.f30927e; if (iUiListener != null) { iUiListener.onCancel(); this.f30927e = null; } } @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener public void onComplete(Object obj) { JSONObject jSONObject = (JSONObject) obj; g a14 = g.a(); a14.a(this.f30926d + "_H5", SystemClock.elapsedRealtime(), 0, 0, jSONObject.optInt("ret", -6), this.f30923a, false); IUiListener iUiListener = this.f30927e; if (iUiListener != null) { iUiListener.onComplete(jSONObject); this.f30927e = 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.f30923a; } else { str = this.f30923a; } g.a().a(this.f30926d + "_H5", SystemClock.elapsedRealtime(), 0, 0, uiError.errorCode, str, false); a.this.a((a) str); IUiListener iUiListener = this.f30927e; if (iUiListener != null) { iUiListener.onError(uiError); this.f30927e = null; } } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a(String str) { try { onComplete(l.d(str)); } catch (JSONException e14) { e14.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 f30929b; public c(b bVar, Looper looper) { super(looper); this.f30929b = bVar; } public void handleMessage(Message message) { int i10 = message.what; if (i10 == 1) { this.f30929b.a((String) message.obj); } else if (i10 == 2) { this.f30929b.onCancel(); } else if (i10 == 3) { a.b(a.this.f30904l, (String) message.obj); } } } /* compiled from: ProGuard */ public class d implements Runnable { /* renamed from: a reason: collision with root package name */ public String f30930a = ""; public d(String str) { this.f30930a = str; } public void run() { SLog.v("openSDK_LOG.AuthDialog", "-->timeoutUrl: " + this.f30930a + " | mRetryUrl: " + a.this.f30908p); if (this.f30930a.equals(a.this.f30908p)) { a.this.f30894b.onError(new UiError(9002, "请求页面超时,请稍后重试!", a.this.f30908p)); a.this.dismiss(); } } } public a(Context context, String str, String str2, IUiListener iUiListener, QQToken qQToken) { super(context, 16973840); this.f30904l = context; this.f30893a = str2; this.f30894b = new b(str, str2, qQToken.getAppId(), iUiListener); this.f30896d = new c(this.f30894b, context.getMainLooper()); this.f30895c = iUiListener; this.f30902j = str; this.f30905m = new com.tencent.open.web.security.b(); getWindow().setSoftInputMode(32); } public static /* synthetic */ int m(a aVar) { int i10 = aVar.f30907o; aVar.f30907o = i10 + 1; return i10; } public void dismiss() { this.f30912t.clear(); this.f30896d.removeCallbacksAndMessages(null); try { Context context = this.f30904l; if ((context instanceof Activity) && !((Activity) context).isFinishing() && isShowing()) { super.dismiss(); SLog.i("openSDK_LOG.AuthDialog", "-->dismiss dialog"); } } catch (Exception e14) { SLog.e("openSDK_LOG.AuthDialog", "-->dismiss dialog exception:", e14); } com.tencent.open.b.c cVar = this.f30903k; if (cVar != null) { cVar.destroy(); this.f30903k = null; } } public void onBackPressed() { if (!this.f30906n) { this.f30894b.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(1280); } } b(); e(); this.f30912t = new HashMap<>(); } public void onStop() { super.onStop(); } @SuppressLint({"SetJavaScriptEnabled"}) private void e() { this.f30903k.setVerticalScrollBarEnabled(false); this.f30903k.setHorizontalScrollBarEnabled(false); this.f30903k.setWebViewClient(new C0439a()); this.f30903k.setWebChromeClient(new WebChromeClient()); this.f30903k.clearFormData(); this.f30903k.clearSslPreferences(); this.f30903k.setOnLongClickListener(new View.OnLongClickListener() { /* class com.tencent.connect.auth.a.AnonymousClass2 */ public boolean onLongClick(View view) { return true; } }); this.f30903k.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.f30903k.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.f30904l.getDir("databases", 0).getPath()); settings.setDomStorageEnabled(true); SLog.v("openSDK_LOG.AuthDialog", "-->mUrl : " + this.f30893a); String str = this.f30893a; this.f30908p = str; this.f30903k.loadUrl(str); this.f30903k.setVisibility(4); this.f30903k.getSettings().setSavePassword(false); this.f30905m.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 a14 = b.a(); String c14 = a14.c(); b.a aVar = new b.a(); aVar.f30937a = this.f30895c; aVar.f30938b = this; aVar.f30939c = c14; String a15 = a14.a(aVar); String str = this.f30893a; String substring = str.substring(0, str.indexOf("?")); Bundle b14 = l.b(this.f30893a); b14.putString("token_key", c14); b14.putString(dh2.b.f68845e, a15); b14.putString(Browser.TYPE, "1"); String str2 = substring + "?" + HttpUtils.encodeUrl(b14); this.f30893a = str2; return l.a(this.f30904l, 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.f30904l); this.f30903k = cVar; if (Build.VERSION.SDK_INT >= 11) { cVar.setLayerType(1, null); } this.f30903k.setLayoutParams(layoutParams); FrameLayout frameLayout = new FrameLayout(this.f30904l); this.f30897e = frameLayout; layoutParams.gravity = 17; frameLayout.setLayoutParams(layoutParams); this.f30897e.addView(this.f30903k); this.f30897e.addView(this.f30899g); String string = l.b(this.f30893a).getString("style"); if (string != null && "qr".equals(string)) { this.f30897e.addView(this.f30901i); } setContentView(this.f30897e); } private void c() { Button button = new Button(this.f30904l); this.f30901i = button; button.setBackgroundDrawable(l.a("h5_qr_back.png", this.f30904l)); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2); layoutParams.leftMargin = com.tencent.connect.avatar.a.a(this.f30904l, 20.0f); layoutParams.topMargin = com.tencent.connect.avatar.a.a(this.f30904l, 10.0f); this.f30901i.setLayoutParams(layoutParams); this.f30901i.setOnClickListener(new View.OnClickListener() { /* class com.tencent.connect.auth.a.AnonymousClass1 */ public void onClick(View view) { a.this.dismiss(); if (!a.this.f30906n && a.this.f30894b != null) { a.this.f30894b.onCancel(); } } }); } private void d() { TextView textView; this.f30900h = new ProgressBar(this.f30904l); this.f30900h.setLayoutParams(new LinearLayout.LayoutParams(-2, -2)); this.f30898f = new LinearLayout(this.f30904l); if (this.f30902j.equals("action_login")) { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2); layoutParams.gravity = 16; layoutParams.leftMargin = 5; textView = new TextView(this.f30904l); 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.f30898f.setLayoutParams(layoutParams2); this.f30898f.addView(this.f30900h); if (textView != null) { this.f30898f.addView(textView); } this.f30899g = new FrameLayout(this.f30904l); FrameLayout.LayoutParams layoutParams3 = new FrameLayout.LayoutParams(-1, -1); layoutParams3.gravity = 17; this.f30899g.setLayoutParams(layoutParams3); this.f30899g.setBackgroundColor(Color.parseColor("#B3000000")); this.f30899g.addView(this.f30898f); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private String a(String str) { StringBuilder sb3 = new StringBuilder(str); if (!TextUtils.isEmpty(this.f30909q) && this.f30909q.length() >= 4) { String str2 = this.f30909q; String substring = str2.substring(str2.length() - 4); sb3.append("_u_"); sb3.append(substring); } return sb3.toString(); } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private String a() { String str = this.f30893a; 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.f30903k.loadUrl("javascript:" + str + "(" + str2 + ");void(" + System.currentTimeMillis() + ");"); } /* access modifiers changed from: private */ public static void b(Context context, String str) { try { JSONObject d14 = l.d(str); int i10 = d14.getInt("type"); Toast.makeText(context.getApplicationContext(), d14.getString("msg"), i10).show(); } catch (JSONException e14) { e14.printStackTrace(); } } }