Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,531 @@
package com.tencent.connect.auth;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.NinePatch;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.graphics.drawable.PaintDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.CookieSyncManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.facebook.AccessToken;
import com.tencent.connect.common.BaseApi;
import com.tencent.connect.common.UIListenerManager;
import com.tencent.open.SocialConstants;
import com.tencent.open.TDialog;
import com.tencent.open.a.f;
import com.tencent.open.b.d;
import com.tencent.open.utils.HttpUtils;
import com.tencent.open.utils.e;
import com.tencent.open.utils.g;
import com.tencent.open.utils.h;
import com.tencent.open.utils.i;
import com.tencent.open.web.security.JniInterface;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.UiError;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.net.URLDecoder;
import org.json.JSONException;
import org.json.JSONObject;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class AuthAgent extends BaseApi {
public static String f = "libwbsafeedit";
public static String g;
private IUiListener c;
private String d;
private WeakReference<Activity> e;
/* compiled from: ProGuard */
private class c implements IUiListener {
private final IUiListener a;
private final boolean b;
private final Context c;
public c(Context context, IUiListener iUiListener, boolean z, boolean z2) {
this.c = context;
this.a = iUiListener;
this.b = z;
f.b("openSDK_LOG.AuthAgent", "OpenUi, TokenListener()");
}
@Override // com.tencent.tauth.IUiListener
public void onCancel() {
f.b("openSDK_LOG.AuthAgent", "OpenUi, TokenListener() onCancel");
this.a.onCancel();
f.b();
}
@Override // com.tencent.tauth.IUiListener
public void onComplete(Object obj) {
f.b("openSDK_LOG.AuthAgent", "OpenUi, TokenListener() onComplete");
JSONObject jSONObject = (JSONObject) obj;
try {
String string = jSONObject.getString(AccessToken.ACCESS_TOKEN_KEY);
String string2 = jSONObject.getString(AccessToken.EXPIRES_IN_KEY);
String string3 = jSONObject.getString(SocialConstants.PARAM_OPEN_ID);
if (string != null && ((BaseApi) AuthAgent.this).b != null && string3 != null) {
((BaseApi) AuthAgent.this).b.a(string, string2);
((BaseApi) AuthAgent.this).b.a(string3);
com.tencent.connect.a.a.d(this.c, ((BaseApi) AuthAgent.this).b);
}
String string4 = jSONObject.getString("pf");
if (string4 != null) {
try {
this.c.getSharedPreferences("pfStore", 0).edit().putString("pf", string4).commit();
} catch (Exception e) {
e.printStackTrace();
f.b("openSDK_LOG.AuthAgent", "OpenUi, TokenListener() onComplete error", e);
}
}
if (this.b) {
CookieSyncManager.getInstance().sync();
}
} catch (JSONException e2) {
e2.printStackTrace();
f.b("openSDK_LOG.AuthAgent", "OpenUi, TokenListener() onComplete error", e2);
}
this.a.onComplete(jSONObject);
AuthAgent.this.releaseResource();
f.b();
}
@Override // com.tencent.tauth.IUiListener
public void onError(UiError uiError) {
f.b("openSDK_LOG.AuthAgent", "OpenUi, TokenListener() onError");
this.a.onError(uiError);
f.b();
}
}
static {
g = f + ".so";
String str = Build.CPU_ABI;
if (str == null || str.equals("")) {
f = "libwbsafeedit";
g = f + ".so";
f.c("openSDK_LOG.AuthAgent", "is arm(default) architecture");
return;
}
if (str.equalsIgnoreCase("arm64-v8a")) {
f = "libwbsafeedit_64";
g = f + ".so";
f.c("openSDK_LOG.AuthAgent", "is arm64-v8a architecture");
return;
}
if (str.equalsIgnoreCase("x86")) {
f = "libwbsafeedit_x86";
g = f + ".so";
f.c("openSDK_LOG.AuthAgent", "is x86 architecture");
return;
}
if (str.equalsIgnoreCase("x86_64")) {
f = "libwbsafeedit_x86_64";
g = f + ".so";
f.c("openSDK_LOG.AuthAgent", "is x86_64 architecture");
return;
}
f = "libwbsafeedit";
g = f + ".so";
f.c("openSDK_LOG.AuthAgent", "is arm(default) architecture");
}
public AuthAgent(QQToken qQToken) {
super(qQToken);
}
@Override // com.tencent.connect.common.BaseApi
public void releaseResource() {
this.c = null;
}
public int a(Activity activity, String str, IUiListener iUiListener) {
return a(activity, str, iUiListener, false, null);
}
public int a(Activity activity, String str, IUiListener iUiListener, boolean z, Fragment fragment) {
this.d = str;
this.e = new WeakReference<>(activity);
this.c = iUiListener;
if (!e.a(activity, this.b.b()).b("C_LoginWeb") && a(activity, fragment, z)) {
f.c("openSDK_LOG.AuthAgent", "OpenUi, showUi, return Constants.UI_ACTIVITY");
d.a().a(this.b.c(), this.b.b(), "2", "1", "5", "0", "0", "0");
return 1;
}
d.a().a(this.b.c(), this.b.b(), "2", "1", "5", "1", "0", "0");
f.d("openSDK_LOG.AuthAgent", "doLogin startActivity fail show dialog.");
this.c = new b(this.c);
return a(z, this.c);
}
private int a(boolean z, IUiListener iUiListener) {
f.c("openSDK_LOG.AuthAgent", "OpenUi, showDialog -- start");
CookieSyncManager.createInstance(com.tencent.open.utils.d.a());
Bundle a = a();
if (z) {
a.putString("isadd", "1");
}
a.putString("scope", this.d);
a.putString("client_id", this.b.b());
if (BaseApi.isOEM) {
a.putString("pf", "desktop_m_qq-" + BaseApi.installChannel + "-android-" + BaseApi.registerChannel + "-" + BaseApi.businessId);
} else {
a.putString("pf", "openmobile_android");
}
String str = (System.currentTimeMillis() / 1000) + "";
a.putString("sign", g.b(com.tencent.open.utils.d.a(), str));
a.putString("time", str);
a.putString("display", "mobile");
a.putString("response_type", "token");
a.putString("redirect_uri", "auth://tauth.qq.com/");
a.putString("cancel_display", "1");
a.putString("switch", "1");
a.putString("status_userip", i.a());
final String str2 = com.tencent.open.utils.f.a().a(com.tencent.open.utils.d.a(), "https://openmobile.qq.com/oauth2.0/m_authorize?") + HttpUtils.encodeUrl(a);
final c cVar = new c(com.tencent.open.utils.d.a(), iUiListener, true, false);
f.b("openSDK_LOG.AuthAgent", "OpenUi, showDialog TDialog");
h.a(new Runnable() { // from class: com.tencent.connect.auth.AuthAgent.1
@Override // java.lang.Runnable
public void run() {
final Activity activity;
g.a(AuthAgent.f, AuthAgent.g, 3);
JniInterface.loadSo();
if (AuthAgent.this.e == null || (activity = (Activity) AuthAgent.this.e.get()) == null) {
return;
}
activity.runOnUiThread(new Runnable() { // from class: com.tencent.connect.auth.AuthAgent.1.1
@Override // java.lang.Runnable
public void run() {
if (!JniInterface.isJniOk) {
f.d("openSDK_LOG.AuthAgent", "OpenUi, secure so load failed, goto download QQ.");
TDialog tDialog = new TDialog(activity, "", AuthAgent.this.a(""), null, ((BaseApi) AuthAgent.this).b);
if (activity.isFinishing()) {
return;
}
tDialog.show();
return;
}
Activity activity2 = activity;
AnonymousClass1 anonymousClass1 = AnonymousClass1.this;
a aVar = new a(activity2, "action_login", str2, cVar, ((BaseApi) AuthAgent.this).b);
if (activity.isFinishing()) {
return;
}
aVar.show();
}
});
}
});
f.c("openSDK_LOG.AuthAgent", "OpenUi, showDialog -- end");
return 2;
}
/* compiled from: ProGuard */
private class b implements IUiListener {
IUiListener a;
/* compiled from: ProGuard */
private abstract class a implements View.OnClickListener {
Dialog a;
a(b bVar, Dialog dialog) {
this.a = dialog;
}
}
public b(IUiListener iUiListener) {
this.a = iUiListener;
}
private void a(String str, final IUiListener iUiListener, final Object obj) {
Activity activity;
PackageInfo packageInfo;
if (AuthAgent.this.e == null || (activity = (Activity) AuthAgent.this.e.get()) == null) {
return;
}
Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(1);
PackageManager packageManager = activity.getPackageManager();
try {
packageInfo = packageManager.getPackageInfo(activity.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
packageInfo = null;
}
Drawable loadIcon = packageInfo != null ? packageInfo.applicationInfo.loadIcon(packageManager) : null;
View.OnClickListener onClickListener = new a(dialog) { // from class: com.tencent.connect.auth.AuthAgent.b.1
@Override // android.view.View.OnClickListener
public void onClick(View view) {
b.this.a();
Dialog dialog2 = this.a;
if (dialog2 != null && dialog2.isShowing()) {
this.a.dismiss();
}
IUiListener iUiListener2 = iUiListener;
if (iUiListener2 != null) {
iUiListener2.onComplete(obj);
}
}
};
View.OnClickListener onClickListener2 = new a(this, dialog) { // from class: com.tencent.connect.auth.AuthAgent.b.2
@Override // android.view.View.OnClickListener
public void onClick(View view) {
Dialog dialog2 = this.a;
if (dialog2 != null && dialog2.isShowing()) {
this.a.dismiss();
}
IUiListener iUiListener2 = iUiListener;
if (iUiListener2 != null) {
iUiListener2.onComplete(obj);
}
}
};
ColorDrawable colorDrawable = new ColorDrawable();
colorDrawable.setAlpha(0);
dialog.getWindow().setBackgroundDrawable(colorDrawable);
dialog.setContentView(a(activity, loadIcon, str, onClickListener, onClickListener2));
dialog.setOnCancelListener(new DialogInterface.OnCancelListener(this) { // from class: com.tencent.connect.auth.AuthAgent.b.3
@Override // android.content.DialogInterface.OnCancelListener
public void onCancel(DialogInterface dialogInterface) {
IUiListener iUiListener2 = iUiListener;
if (iUiListener2 != null) {
iUiListener2.onComplete(obj);
}
}
});
if (activity == null || activity.isFinishing()) {
return;
}
dialog.show();
}
@Override // com.tencent.tauth.IUiListener
public void onCancel() {
IUiListener iUiListener = this.a;
if (iUiListener != null) {
iUiListener.onCancel();
}
}
@Override // com.tencent.tauth.IUiListener
public void onComplete(Object obj) {
JSONObject jSONObject;
String str;
if (obj == null || (jSONObject = (JSONObject) obj) == null) {
return;
}
try {
r2 = jSONObject.getInt("sendinstall") == 1;
str = jSONObject.getString("installwording");
} catch (JSONException unused) {
f.d("openSDK_LOG.AuthAgent", "FeedConfirmListener onComplete There is no value for sendinstall.");
str = "";
}
String decode = URLDecoder.decode(str);
f.a("openSDK_LOG.AuthAgent", " WORDING = " + decode + "xx");
if (r2 && !TextUtils.isEmpty(decode)) {
a(decode, this.a, obj);
return;
}
IUiListener iUiListener = this.a;
if (iUiListener != null) {
iUiListener.onComplete(obj);
}
}
@Override // com.tencent.tauth.IUiListener
public void onError(UiError uiError) {
IUiListener iUiListener = this.a;
if (iUiListener != null) {
iUiListener.onError(uiError);
}
}
private Drawable a(String str, Context context) {
Bitmap bitmap;
try {
InputStream open = context.getApplicationContext().getAssets().open(str);
if (open == null) {
return null;
}
if (str.endsWith(".9.png")) {
try {
bitmap = BitmapFactory.decodeStream(open);
} catch (OutOfMemoryError e) {
e.printStackTrace();
bitmap = null;
}
if (bitmap == null) {
return null;
}
byte[] ninePatchChunk = bitmap.getNinePatchChunk();
NinePatch.isNinePatchChunk(ninePatchChunk);
return new NinePatchDrawable(bitmap, ninePatchChunk, new Rect(), null);
}
Drawable createFromStream = Drawable.createFromStream(open, str);
open.close();
return createFromStream;
} catch (IOException e2) {
e2.printStackTrace();
return null;
}
}
private View a(Context context, Drawable drawable, String str, View.OnClickListener onClickListener, View.OnClickListener onClickListener2) {
DisplayMetrics displayMetrics = new DisplayMetrics();
((WindowManager) context.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
float f = displayMetrics.density;
RelativeLayout relativeLayout = new RelativeLayout(context);
ImageView imageView = new ImageView(context);
imageView.setImageDrawable(drawable);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setId(1);
int i = (int) (60.0f * f);
int i2 = (int) (f * 14.0f);
int i3 = (int) (18.0f * f);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(i, i);
layoutParams.addRule(9);
layoutParams.setMargins(0, i3, (int) (6.0f * f), i3);
relativeLayout.addView(imageView, layoutParams);
TextView textView = new TextView(context);
textView.setText(str);
textView.setTextSize(14.0f);
textView.setGravity(3);
textView.setIncludeFontPadding(false);
textView.setPadding(0, 0, 0, 0);
textView.setLines(2);
textView.setId(5);
textView.setMinWidth((int) (185.0f * f));
RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(-2, -2);
layoutParams2.addRule(1, 1);
layoutParams2.addRule(6, 1);
float f2 = 5.0f * f;
layoutParams2.setMargins(0, 0, (int) f2, 0);
relativeLayout.addView(textView, layoutParams2);
View view = new View(context);
view.setBackgroundColor(Color.rgb(214, 214, 214));
view.setId(3);
RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(-2, 2);
layoutParams3.addRule(3, 1);
layoutParams3.addRule(5, 1);
layoutParams3.addRule(7, 5);
int i4 = (int) (12.0f * f);
layoutParams3.setMargins(0, 0, 0, i4);
relativeLayout.addView(view, layoutParams3);
LinearLayout linearLayout = new LinearLayout(context);
RelativeLayout.LayoutParams layoutParams4 = new RelativeLayout.LayoutParams(-2, -2);
layoutParams4.addRule(5, 1);
layoutParams4.addRule(7, 5);
layoutParams4.addRule(3, 3);
Button button = new Button(context);
button.setText("跳过");
button.setBackgroundDrawable(a("buttonNegt.png", context));
button.setTextColor(Color.rgb(36, 97, 131));
button.setTextSize(20.0f);
button.setOnClickListener(onClickListener2);
button.setId(4);
int i5 = (int) (45.0f * f);
LinearLayout.LayoutParams layoutParams5 = new LinearLayout.LayoutParams(0, i5);
layoutParams5.rightMargin = i2;
int i6 = (int) (4.0f * f);
layoutParams5.leftMargin = i6;
layoutParams5.weight = 1.0f;
linearLayout.addView(button, layoutParams5);
Button button2 = new Button(context);
button2.setText("确定");
button2.setTextSize(20.0f);
button2.setTextColor(Color.rgb(255, 255, 255));
button2.setBackgroundDrawable(a("buttonPost.png", context));
button2.setOnClickListener(onClickListener);
LinearLayout.LayoutParams layoutParams6 = new LinearLayout.LayoutParams(0, i5);
layoutParams6.weight = 1.0f;
layoutParams6.rightMargin = i6;
linearLayout.addView(button2, layoutParams6);
relativeLayout.addView(linearLayout, layoutParams4);
ViewGroup.LayoutParams layoutParams7 = new FrameLayout.LayoutParams((int) (279.0f * f), (int) (f * 163.0f));
relativeLayout.setPadding(i2, 0, i4, i4);
relativeLayout.setLayoutParams(layoutParams7);
relativeLayout.setBackgroundColor(Color.rgb(247, 251, 247));
PaintDrawable paintDrawable = new PaintDrawable(Color.rgb(247, 251, 247));
paintDrawable.setCornerRadius(f2);
relativeLayout.setBackgroundDrawable(paintDrawable);
return relativeLayout;
}
protected void a() {
Activity activity;
Bundle b = AuthAgent.this.b();
if (AuthAgent.this.e == null || (activity = (Activity) AuthAgent.this.e.get()) == null) {
return;
}
HttpUtils.requestAsync(((BaseApi) AuthAgent.this).b, activity, "http://appsupport.qq.com/cgi-bin/qzapps/mapp_addapp.cgi", b, "POST", null);
}
}
private boolean a(Activity activity, Fragment fragment, boolean z) {
f.c("openSDK_LOG.AuthAgent", "startActionActivity() -- start");
Intent b2 = b("com.tencent.open.agent.AgentActivity");
if (b2 != null) {
Bundle a = a();
if (z) {
a.putString("isadd", "1");
}
a.putString("scope", this.d);
a.putString("client_id", this.b.b());
if (BaseApi.isOEM) {
a.putString("pf", "desktop_m_qq-" + BaseApi.installChannel + "-android-" + BaseApi.registerChannel + "-" + BaseApi.businessId);
} else {
a.putString("pf", "openmobile_android");
}
a.putString("need_pay", "1");
a.putString("oauth_app_name", g.a(com.tencent.open.utils.d.a()));
b2.putExtra("key_action", "action_login");
b2.putExtra("key_params", a);
b2.putExtra(SocialConstants.PARAM_APP_ID, this.b.b());
if (a(b2)) {
this.c = new b(this.c);
UIListenerManager.a().a(11101, this.c);
if (fragment != null) {
f.b("openSDK_LOG.AuthAgent", "startAssitActivity fragment");
a(fragment, b2, 11101);
} else {
f.b("openSDK_LOG.AuthAgent", "startAssitActivity activity");
a(activity, b2, 11101);
}
f.c("openSDK_LOG.AuthAgent", "startActionActivity() -- end, found activity for loginIntent");
d.a().a(0, "LOGIN_CHECK_SDK", "1000", this.b.b(), "", Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "");
return true;
}
}
d.a().a(1, "LOGIN_CHECK_SDK", "1000", this.b.b(), "", Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "startActionActivity fail");
f.c("openSDK_LOG.AuthAgent", "startActionActivity() -- end, no target activity for loginIntent");
return false;
}
}

View File

@@ -0,0 +1,42 @@
package com.tencent.connect.auth;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class QQToken {
private String a;
private String b;
private String c;
private long d = -1;
public QQToken(String str) {
this.a = str;
}
public String a() {
return this.b;
}
public String b() {
return this.a;
}
public String c() {
return this.c;
}
public boolean d() {
return this.b != null && System.currentTimeMillis() < this.d;
}
public void a(String str, String str2) throws NumberFormatException {
this.b = str;
this.d = 0L;
if (str2 != null) {
this.d = System.currentTimeMillis() + (Long.parseLong(str2) * 1000);
}
}
public void a(String str) {
this.c = str;
}
}

View File

@@ -0,0 +1,557 @@
package com.tencent.connect.auth;
import android.R;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
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.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.tencent.connect.auth.b;
import com.tencent.open.SocialConstants;
import com.tencent.open.a.f;
import com.tencent.open.b.g;
import com.tencent.open.utils.HttpUtils;
import com.tencent.open.utils.i;
import com.tencent.open.web.security.JniInterface;
import com.tencent.open.web.security.SecureJsInterface;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.UiError;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import org.json.JSONException;
import org.json.JSONObject;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class a extends Dialog {
private String a;
private b b;
private IUiListener c;
private Handler d;
private FrameLayout e;
private LinearLayout f;
private FrameLayout g;
private ProgressBar h;
private String i;
private com.tencent.open.c.c j;
private Context k;
private com.tencent.open.web.security.b l;
private boolean m;
private int n;
private String o;
private String p;
private long q;
private long r;
private HashMap<String, Runnable> s;
/* compiled from: ProGuard */
/* renamed from: com.tencent.connect.auth.a$a, reason: collision with other inner class name */
private class C0014a extends WebViewClient {
private C0014a() {
}
@Override // android.webkit.WebViewClient
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
f.a("openSDK_LOG.AuthDialog", "-->onPageFinished, url: " + str);
a.this.g.setVisibility(8);
if (a.this.j != null) {
a.this.j.setVisibility(0);
}
if (TextUtils.isEmpty(str)) {
return;
}
a.this.d.removeCallbacks((Runnable) a.this.s.remove(str));
}
@Override // android.webkit.WebViewClient
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
f.a("openSDK_LOG.AuthDialog", "-->onPageStarted, url: " + str);
super.onPageStarted(webView, str, bitmap);
a.this.g.setVisibility(0);
a.this.q = SystemClock.elapsedRealtime();
if (!TextUtils.isEmpty(a.this.o)) {
a.this.d.removeCallbacks((Runnable) a.this.s.remove(a.this.o));
}
a.this.o = str;
a aVar = a.this;
d dVar = aVar.new d(aVar.o);
a.this.s.put(str, dVar);
a.this.d.postDelayed(dVar, 120000L);
}
@Override // android.webkit.WebViewClient
public void onReceivedError(WebView webView, int i, String str, String str2) {
super.onReceivedError(webView, i, str, str2);
f.c("openSDK_LOG.AuthDialog", "-->onReceivedError, errorCode: " + i + " | description: " + str);
if (!i.b(a.this.k)) {
a.this.b.onError(new UiError(9001, "当前网络不可用,请稍后重试!", str2));
a.this.dismiss();
return;
}
if (a.this.o.startsWith("http://qzs.qq.com/open/mobile/login/qzsjump.html?")) {
a.this.b.onError(new UiError(i, str, str2));
a.this.dismiss();
return;
}
long elapsedRealtime = SystemClock.elapsedRealtime() - a.this.q;
if (a.this.n >= 1 || elapsedRealtime >= a.this.r) {
a.this.j.loadUrl(a.this.a());
} else {
a.m(a.this);
a.this.d.postDelayed(new Runnable() { // from class: com.tencent.connect.auth.a.a.1
@Override // java.lang.Runnable
public void run() {
a.this.j.loadUrl(a.this.o);
}
}, 500L);
}
}
@Override // android.webkit.WebViewClient
@TargetApi(8)
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
f.e("openSDK_LOG.AuthDialog", "-->onReceivedSslError " + sslError.getPrimaryError() + "请求不合法,请检查手机安全设置,如系统时间、代理等");
sslErrorHandler.cancel();
a.this.b.onError(new UiError(sslError.getPrimaryError(), "请求不合法,请检查手机安全设置,如系统时间、代理等。", "ssl error"));
a.this.dismiss();
}
@Override // android.webkit.WebViewClient
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
List<String> pathSegments;
f.a("openSDK_LOG.AuthDialog", "-->Redirect URL: " + str);
if (str.startsWith("auth://browser")) {
JSONObject c = i.c(str);
a aVar = a.this;
aVar.m = aVar.e();
if (!a.this.m) {
if (c.optString("fail_cb", null) != null) {
a.this.a(c.optString("fail_cb"), "");
} else if (c.optInt("fall_to_wv") == 1) {
a aVar2 = a.this;
a.a(aVar2, (Object) (aVar2.a.indexOf("?") > -1 ? "&" : "?"));
a.a(a.this, (Object) "browser_error=1");
a.this.j.loadUrl(a.this.a);
} else {
String optString = c.optString("redir", null);
if (optString != null) {
a.this.j.loadUrl(optString);
}
}
}
return true;
}
if (str.startsWith("auth://tauth.qq.com/")) {
a.this.b.onComplete(i.c(str));
a.this.dismiss();
return true;
}
if (str.startsWith("auth://cancel")) {
a.this.b.onCancel();
a.this.dismiss();
return true;
}
if (str.startsWith("auth://close")) {
a.this.dismiss();
return true;
}
if (str.startsWith("download://")) {
try {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(Uri.decode(str.substring(11))));
intent.addFlags(268435456);
a.this.k.startActivity(intent);
} catch (Exception e) {
f.b("openSDK_LOG.AuthDialog", "-->start download activity exception, e: ", e);
}
return true;
}
if (!str.startsWith("auth://progress")) {
if (str.startsWith("auth://onLoginSubmit")) {
try {
List<String> pathSegments2 = Uri.parse(str).getPathSegments();
if (!pathSegments2.isEmpty()) {
a.this.p = pathSegments2.get(0);
}
} catch (Exception unused) {
}
return true;
}
if (a.this.l.a(a.this.j, str)) {
return true;
}
f.c("openSDK_LOG.AuthDialog", "-->Redirect URL: return false");
return false;
}
try {
pathSegments = Uri.parse(str).getPathSegments();
} catch (Exception unused2) {
}
if (pathSegments.isEmpty()) {
return true;
}
int intValue = Integer.valueOf(pathSegments.get(0)).intValue();
if (intValue == 0) {
a.this.g.setVisibility(8);
a.this.j.setVisibility(0);
} else if (intValue == 1) {
a.this.g.setVisibility(0);
}
return true;
}
}
/* compiled from: ProGuard */
private class b implements IUiListener {
private String a;
String b;
private IUiListener c;
public b(String str, String str2, String str3, IUiListener iUiListener) {
this.a = str;
this.b = str2;
this.c = iUiListener;
}
@Override // com.tencent.tauth.IUiListener
public void onCancel() {
IUiListener iUiListener = this.c;
if (iUiListener != null) {
iUiListener.onCancel();
this.c = null;
}
}
@Override // com.tencent.tauth.IUiListener
public void onComplete(Object obj) {
JSONObject jSONObject = (JSONObject) obj;
g.a().a(this.a + "_H5", SystemClock.elapsedRealtime(), 0L, 0L, jSONObject.optInt("ret", -6), this.b, false);
IUiListener iUiListener = this.c;
if (iUiListener != null) {
iUiListener.onComplete(jSONObject);
this.c = null;
}
}
@Override // com.tencent.tauth.IUiListener
public void onError(UiError uiError) {
String str;
if (uiError.b != null) {
str = uiError.b + this.b;
} else {
str = this.b;
}
g.a().a(this.a + "_H5", SystemClock.elapsedRealtime(), 0L, 0L, uiError.a, str, false);
a.this.a(str);
IUiListener iUiListener = this.c;
if (iUiListener != null) {
iUiListener.onError(uiError);
this.c = null;
}
}
/* JADX INFO: Access modifiers changed from: private */
public void a(String str) {
try {
onComplete(i.d(str));
} catch (JSONException e) {
e.printStackTrace();
onError(new UiError(-4, "服务器返回数据格式有误!", str));
}
}
}
/* compiled from: ProGuard */
private class c extends Handler {
private b a;
public c(b bVar, Looper looper) {
super(looper);
this.a = bVar;
}
@Override // android.os.Handler
public void handleMessage(Message message) {
int i = message.what;
if (i == 1) {
this.a.a((String) message.obj);
} else if (i == 2) {
this.a.onCancel();
} else {
if (i != 3) {
return;
}
a.b(a.this.k, (String) message.obj);
}
}
}
/* compiled from: ProGuard */
class d implements Runnable {
String a;
public d(String str) {
this.a = "";
this.a = str;
}
@Override // java.lang.Runnable
public void run() {
f.a("openSDK_LOG.AuthDialog", "-->timeoutUrl: " + this.a + " | mRetryUrl: " + a.this.o);
if (this.a.equals(a.this.o)) {
a.this.b.onError(new UiError(9002, "请求页面超时,请稍后重试!", a.this.o));
a.this.dismiss();
}
}
}
public a(Context context, String str, String str2, IUiListener iUiListener, QQToken qQToken) {
super(context, R.style.Theme.Translucent.NoTitleBar);
this.m = false;
this.q = 0L;
this.r = 30000L;
this.k = context;
this.a = str2;
this.b = new b(str, str2, qQToken.b(), iUiListener);
this.d = new c(this.b, context.getMainLooper());
this.c = iUiListener;
this.i = str;
this.l = new com.tencent.open.web.security.b();
getWindow().setSoftInputMode(32);
}
static /* synthetic */ int m(a aVar) {
int i = aVar.n;
aVar.n = i + 1;
return i;
}
@Override // android.app.Dialog, android.content.DialogInterface
public void dismiss() {
this.s.clear();
this.d.removeCallbacksAndMessages(null);
if (isShowing()) {
super.dismiss();
}
com.tencent.open.c.c cVar = this.j;
if (cVar != null) {
cVar.destroy();
this.j = null;
}
}
@Override // android.app.Dialog
public void onBackPressed() {
if (!this.m) {
this.b.onCancel();
}
super.onBackPressed();
}
@Override // android.app.Dialog
protected void onCreate(Bundle bundle) {
requestWindowFeature(1);
super.onCreate(bundle);
b();
d();
this.s = new HashMap<>();
}
@Override // android.app.Dialog
protected void onStop() {
super.onStop();
}
@SuppressLint({"SetJavaScriptEnabled"})
private void d() {
this.j.setVerticalScrollBarEnabled(false);
this.j.setHorizontalScrollBarEnabled(false);
this.j.setWebViewClient(new C0014a());
this.j.setWebChromeClient(new WebChromeClient());
this.j.clearFormData();
this.j.clearSslPreferences();
this.j.setOnLongClickListener(new View.OnLongClickListener(this) { // from class: com.tencent.connect.auth.a.1
@Override // android.view.View.OnLongClickListener
public boolean onLongClick(View view) {
return true;
}
});
this.j.setOnTouchListener(new View.OnTouchListener(this) { // from class: com.tencent.connect.auth.a.2
@Override // android.view.View.OnTouchListener
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.j.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.k.getDir("databases", 0).getPath());
settings.setDomStorageEnabled(true);
f.a("openSDK_LOG.AuthDialog", "-->mUrl : " + this.a);
String str = this.a;
this.o = str;
this.j.loadUrl(str);
this.j.setVisibility(4);
this.j.getSettings().setSavePassword(false);
this.l.a(new SecureJsInterface(), "SecureJsInterface");
SecureJsInterface.isPWDEdit = false;
super.setOnDismissListener(new DialogInterface.OnDismissListener(this) { // from class: com.tencent.connect.auth.a.3
@Override // android.content.DialogInterface.OnDismissListener
public void onDismiss(DialogInterface dialogInterface) {
try {
JniInterface.clearAllPWD();
} catch (Exception unused) {
}
}
});
}
/* JADX INFO: Access modifiers changed from: private */
public boolean e() {
com.tencent.connect.auth.b b2 = com.tencent.connect.auth.b.b();
String a = b2.a();
String a2 = b2.a(new b.a());
String str = this.a;
String substring = str.substring(0, str.indexOf("?"));
Bundle b3 = i.b(this.a);
b3.putString("token_key", a);
b3.putString("serial", a2);
b3.putString("browser", "1");
this.a = substring + "?" + HttpUtils.encodeUrl(b3);
return i.a(this.k, this.a);
}
static /* synthetic */ String a(a aVar, Object obj) {
String str = aVar.a + obj;
aVar.a = str;
return str;
}
private void b() {
c();
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
this.j = new com.tencent.open.c.c(this.k);
if (Build.VERSION.SDK_INT >= 11) {
this.j.setLayerType(1, null);
}
this.j.setLayoutParams(layoutParams);
this.e = new FrameLayout(this.k);
layoutParams.gravity = 17;
this.e.setLayoutParams(layoutParams);
this.e.addView(this.j);
this.e.addView(this.g);
setContentView(this.e);
}
private void c() {
TextView textView;
this.h = new ProgressBar(this.k);
this.h.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
this.f = new LinearLayout(this.k);
if (this.i.equals("action_login")) {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
layoutParams.gravity = 16;
layoutParams.leftMargin = 5;
textView = new TextView(this.k);
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.f.setLayoutParams(layoutParams2);
this.f.addView(this.h);
if (textView != null) {
this.f.addView(textView);
}
this.g = new FrameLayout(this.k);
FrameLayout.LayoutParams layoutParams3 = new FrameLayout.LayoutParams(-1, -2);
layoutParams3.leftMargin = 80;
layoutParams3.rightMargin = 80;
layoutParams3.topMargin = 40;
layoutParams3.bottomMargin = 40;
layoutParams3.gravity = 17;
this.g.setLayoutParams(layoutParams3);
this.g.setBackgroundResource(R.drawable.alert_dark_frame);
this.g.addView(this.f);
}
/* JADX INFO: Access modifiers changed from: private */
public String a(String str) {
StringBuilder sb = new StringBuilder(str);
if (!TextUtils.isEmpty(this.p) && this.p.length() >= 4) {
String str2 = this.p;
String substring = str2.substring(str2.length() - 4);
sb.append("_u_");
sb.append(substring);
}
return sb.toString();
}
/* JADX INFO: Access modifiers changed from: private */
public String a() {
String str = this.a;
String str2 = "http://qzs.qq.com/open/mobile/login/qzsjump.html?" + str.substring(str.indexOf("?") + 1);
f.c("openSDK_LOG.AuthDialog", "-->generateDownloadUrl, url: http://qzs.qq.com/open/mobile/login/qzsjump.html?");
return str2;
}
/* JADX INFO: Access modifiers changed from: private */
public static void b(Context context, String str) {
try {
JSONObject d2 = i.d(str);
int i = d2.getInt("type");
Toast.makeText(context.getApplicationContext(), d2.getString(SocialConstants.PARAM_SEND_MSG), i).show();
} catch (JSONException e) {
e.printStackTrace();
}
}
public void a(String str, String str2) {
this.j.loadUrl("javascript:" + str + "(" + str2 + ");void(" + System.currentTimeMillis() + ");");
}
}

View File

@@ -0,0 +1,55 @@
package com.tencent.connect.auth;
import com.ubt.jimu.base.http.interceptor.CommonParamsInterceptor;
import java.util.HashMap;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class b {
private static int b;
public static b c;
public HashMap<String, a> a = new HashMap<>();
/* compiled from: ProGuard */
public static class a {
}
static {
b.class.desiredAssertionStatus();
b = 0;
}
public static b b() {
if (c == null) {
c = new b();
}
return c;
}
public static int c() {
int i = b + 1;
b = i;
return i;
}
public String a(a aVar) {
int c2 = c();
try {
this.a.put("" + c2, aVar);
} catch (Throwable th) {
th.printStackTrace();
}
return "" + c2;
}
public String a() {
int ceil = (int) Math.ceil((Math.random() * 20.0d) + 3.0d);
char[] charArray = CommonParamsInterceptor.CHARACTER.toCharArray();
int length = charArray.length;
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < ceil; i++) {
stringBuffer.append(charArray[(int) (Math.random() * length)]);
}
return stringBuffer.toString();
}
}

View File

@@ -0,0 +1,113 @@
package com.tencent.connect.auth;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import com.tencent.connect.common.BaseApi;
import com.tencent.open.a.f;
import com.tencent.open.utils.d;
import com.tencent.tauth.IUiListener;
import com.ubtrobot.jimu.robotapi.PeripheralType;
import java.io.File;
import java.util.Iterator;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public class c {
private AuthAgent a;
private QQToken b;
private c(String str, Context context) {
f.c("openSDK_LOG.QQAuth", "new QQAuth() --start");
this.b = new QQToken(str);
this.a = new AuthAgent(this.b);
com.tencent.connect.a.a.c(context, this.b);
f.c("openSDK_LOG.QQAuth", "new QQAuth() --end");
}
public static c a(String str, Context context) {
d.a(context.getApplicationContext());
f.c("openSDK_LOG.QQAuth", "QQAuth -- createInstance() --start");
try {
PackageManager packageManager = context.getPackageManager();
packageManager.getActivityInfo(new ComponentName(context.getPackageName(), "com.tencent.tauth.AuthActivity"), 0);
packageManager.getActivityInfo(new ComponentName(context.getPackageName(), "com.tencent.connect.common.AssistActivity"), 0);
c cVar = new c(str, context);
f.c("openSDK_LOG.QQAuth", "QQAuth -- createInstance() --end");
return cVar;
} catch (PackageManager.NameNotFoundException e) {
f.b("openSDK_LOG.QQAuth", "createInstance() error --end", e);
Toast.makeText(context.getApplicationContext(), "请参照文档在Androidmanifest.xml加上AuthActivity和AssitActivity的定义 ", 1).show();
return null;
}
}
public int a(Activity activity, String str, IUiListener iUiListener) {
f.c("openSDK_LOG.QQAuth", "login()");
return a(activity, str, iUiListener, "");
}
public int a(Activity activity, String str, IUiListener iUiListener, String str2) {
f.c("openSDK_LOG.QQAuth", "-->login activity: " + activity);
return a(activity, null, str, iUiListener, str2);
}
private int a(Activity activity, Fragment fragment, String str, IUiListener iUiListener, String str2) {
String packageName = activity.getApplicationContext().getPackageName();
String str3 = null;
try {
Iterator<ApplicationInfo> it = activity.getPackageManager().getInstalledApplications(PeripheralType.SERVO).iterator();
while (true) {
if (!it.hasNext()) {
break;
}
ApplicationInfo next = it.next();
if (packageName.equals(next.packageName)) {
str3 = next.sourceDir;
break;
}
}
if (str3 != null) {
String a = com.tencent.open.utils.a.a(new File(str3));
if (!TextUtils.isEmpty(a)) {
f.a("openSDK_LOG.QQAuth", "-->login channelId: " + a);
return a(activity, str, iUiListener, a, a, "");
}
}
} catch (Throwable th) {
f.b("openSDK_LOG.QQAuth", "-->login get channel id exception.", th);
th.printStackTrace();
}
f.b("openSDK_LOG.QQAuth", "-->login channelId is null ");
BaseApi.isOEM = false;
return this.a.a(activity, str, iUiListener, false, fragment);
}
@Deprecated
public int a(Activity activity, String str, IUiListener iUiListener, String str2, String str3, String str4) {
f.c("openSDK_LOG.QQAuth", "loginWithOEM");
BaseApi.isOEM = true;
if (str2.equals("")) {
str2 = "null";
}
if (str3.equals("")) {
str3 = "null";
}
if (str4.equals("")) {
str4 = "null";
}
BaseApi.installChannel = str3;
BaseApi.registerChannel = str2;
BaseApi.businessId = str4;
return this.a.a(activity, str, iUiListener);
}
public QQToken a() {
return this.b;
}
}