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 anet.channel.strategy.dispatch.DispatchConstants; import com.tencent.connect.common.BaseApi; import com.tencent.connect.common.Constants; import com.tencent.connect.common.UIListenerManager; import com.tencent.open.SocialConstants; import com.tencent.open.TDialog; import com.tencent.open.a.d; import com.tencent.open.log.SLog; import com.tencent.open.utils.HttpUtils; import com.tencent.open.utils.e; import com.tencent.open.utils.f; import com.tencent.open.utils.g; import com.tencent.open.utils.h; import com.tencent.open.utils.i; import com.tencent.open.utils.k; 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 */ public class AuthAgent extends BaseApi { public static final String KEY_FORCE_QR_LOGIN = "KEY_FORCE_QR_LOGIN"; public static final String SECURE_LIB_ARM64_FILE_NAME = "libwbsafeedit_64"; public static final String SECURE_LIB_ARM_FILE_NAME = "libwbsafeedit"; public static String SECURE_LIB_FILE_NAME = "libwbsafeedit"; public static String SECURE_LIB_NAME = null; public static final String SECURE_LIB_X86_64_FILE_NAME = "libwbsafeedit_x86_64"; public static final String SECURE_LIB_X86_FILE_NAME = "libwbsafeedit_x86"; /* renamed from: a reason: collision with root package name */ private IUiListener f11515a; private String d; private WeakReference<Activity> e; static { SECURE_LIB_NAME = SECURE_LIB_FILE_NAME + ".so"; String str = Build.CPU_ABI; if (str == null || str.equals("")) { SECURE_LIB_FILE_NAME = SECURE_LIB_ARM_FILE_NAME; SECURE_LIB_NAME = SECURE_LIB_FILE_NAME + ".so"; SLog.i("openSDK_LOG.AuthAgent", "is arm(default) architecture"); } else if (str.equalsIgnoreCase("arm64-v8a")) { SECURE_LIB_FILE_NAME = SECURE_LIB_ARM64_FILE_NAME; SECURE_LIB_NAME = SECURE_LIB_FILE_NAME + ".so"; SLog.i("openSDK_LOG.AuthAgent", "is arm64-v8a architecture"); } else if (str.equalsIgnoreCase("x86")) { SECURE_LIB_FILE_NAME = SECURE_LIB_X86_FILE_NAME; SECURE_LIB_NAME = SECURE_LIB_FILE_NAME + ".so"; SLog.i("openSDK_LOG.AuthAgent", "is x86 architecture"); } else if (str.equalsIgnoreCase("x86_64")) { SECURE_LIB_FILE_NAME = SECURE_LIB_X86_64_FILE_NAME; SECURE_LIB_NAME = SECURE_LIB_FILE_NAME + ".so"; SLog.i("openSDK_LOG.AuthAgent", "is x86_64 architecture"); } else { SECURE_LIB_FILE_NAME = SECURE_LIB_ARM_FILE_NAME; SECURE_LIB_NAME = SECURE_LIB_FILE_NAME + ".so"; SLog.i("openSDK_LOG.AuthAgent", "is arm(default) architecture"); } } public AuthAgent(QQToken qQToken) { super(qQToken); } /* access modifiers changed from: private */ /* compiled from: ProGuard */ public class c implements IUiListener { /* renamed from: b reason: collision with root package name */ private final IUiListener f11531b; private final boolean c; private final Context d; public c(Context context, IUiListener iUiListener, boolean z, boolean z2) { this.d = context; this.f11531b = iUiListener; this.c = z; SLog.d("openSDK_LOG.AuthAgent", "OpenUi, TokenListener()"); } @Override // com.tencent.tauth.IUiListener public void onComplete(Object obj) { SLog.d("openSDK_LOG.AuthAgent", "OpenUi, TokenListener() onComplete"); JSONObject jSONObject = (JSONObject) obj; try { String string = jSONObject.getString(Constants.PARAM_ACCESS_TOKEN); String string2 = jSONObject.getString(Constants.PARAM_EXPIRES_IN); String string3 = jSONObject.getString("openid"); if (!(string == null || AuthAgent.this.c == null || string3 == null)) { AuthAgent.this.c.setAccessToken(string, string2); AuthAgent.this.c.setOpenId(string3); com.tencent.connect.a.a.d(this.d, AuthAgent.this.c); } String string4 = jSONObject.getString(Constants.PARAM_PLATFORM_ID); if (string4 != null) { try { this.d.getSharedPreferences(Constants.PREFERENCE_PF, 0).edit().putString(Constants.PARAM_PLATFORM_ID, string4).commit(); } catch (Exception e) { e.printStackTrace(); SLog.e("openSDK_LOG.AuthAgent", "OpenUi, TokenListener() onComplete error", e); } } if (this.c) { CookieSyncManager.getInstance().sync(); } } catch (JSONException e2) { e2.printStackTrace(); SLog.e("openSDK_LOG.AuthAgent", "OpenUi, TokenListener() onComplete error", e2); } this.f11531b.onComplete(jSONObject); AuthAgent.this.releaseResource(); SLog.release(); } @Override // com.tencent.tauth.IUiListener public void onError(UiError uiError) { SLog.d("openSDK_LOG.AuthAgent", "OpenUi, TokenListener() onError"); this.f11531b.onError(uiError); SLog.release(); } @Override // com.tencent.tauth.IUiListener public void onCancel() { SLog.d("openSDK_LOG.AuthAgent", "OpenUi, TokenListener() onCancel"); this.f11531b.onCancel(); SLog.release(); } } public int doLogin(Activity activity, String str, IUiListener iUiListener) { return doLogin(activity, str, iUiListener, false, null); } public int doLogin(Activity activity, String str, IUiListener iUiListener, boolean z, Fragment fragment) { return doLogin(activity, str, iUiListener, z, fragment, false); } public int doLogin(Activity activity, String str, IUiListener iUiListener, boolean z, Fragment fragment, boolean z2) { this.d = str; this.e = new WeakReference<>(activity); this.f11515a = iUiListener; if (activity.getIntent().getBooleanExtra(KEY_FORCE_QR_LOGIN, false) || f.a(activity, this.c.getAppId()).b("C_LoginWeb") || !a(activity, fragment, z)) { d.a().a(this.c.getOpenId(), this.c.getAppId(), "2", "1", "5", "1", "0", "0"); SLog.w("openSDK_LOG.AuthAgent", "doLogin startActivity fail show dialog."); this.f11515a = new b(this.f11515a); return a(z, this.f11515a, z2); } SLog.i("openSDK_LOG.AuthAgent", "OpenUi, showUi, return Constants.UI_ACTIVITY"); d.a().a(this.c.getOpenId(), this.c.getAppId(), "2", "1", "5", "0", "0", "0"); return 1; } @Override // com.tencent.connect.common.BaseApi public void releaseResource() { this.f11515a = null; } private int a(boolean z, IUiListener iUiListener, boolean z2) { SLog.i("openSDK_LOG.AuthAgent", "OpenUi, showDialog -- start"); CookieSyncManager.createInstance(e.a()); Bundle a2 = a(); if (z) { a2.putString("isadd", "1"); } a2.putString(Constants.PARAM_SCOPE, this.d); a2.putString(Constants.PARAM_CLIENT_ID, this.c.getAppId()); if (isOEM) { a2.putString(Constants.PARAM_PLATFORM_ID, "desktop_m_qq-" + installChannel + "-" + DispatchConstants.ANDROID + "-" + registerChannel + "-" + businessId); } else { a2.putString(Constants.PARAM_PLATFORM_ID, Constants.DEFAULT_PF); } String str = (System.currentTimeMillis() / 1000) + ""; a2.putString("sign", h.b(e.a(), str)); a2.putString("time", str); a2.putString("display", "mobile"); a2.putString("response_type", "token"); a2.putString("redirect_uri", "auth://tauth.qq.com/"); a2.putString("cancel_display", "1"); a2.putString("switch", "1"); a2.putString("status_userip", k.a()); if (z2) { a2.putString("style", "qr"); } final String str2 = g.a().a(e.a(), "https://openmobile.qq.com/oauth2.0/m_authorize?") + HttpUtils.encodeUrl(a2); final c cVar = new c(e.a(), iUiListener, true, false); SLog.d("openSDK_LOG.AuthAgent", "OpenUi, showDialog TDialog"); i.a(new Runnable() { /* class com.tencent.connect.auth.AuthAgent.AnonymousClass1 */ /* JADX WARNING: Code restructure failed: missing block: B:3:0x0014, code lost: r0 = (android.app.Activity) r3.c.e.get(); */ public void run() { final Activity activity; h.a(AuthAgent.SECURE_LIB_FILE_NAME, AuthAgent.SECURE_LIB_NAME, 3); JniInterface.loadSo(); if (AuthAgent.this.e != null && activity != null) { activity.runOnUiThread(new Runnable() { /* class com.tencent.connect.auth.AuthAgent.AnonymousClass1.AnonymousClass1 */ public void run() { if (JniInterface.isJniOk) { a aVar = new a(activity, "action_login", str2, cVar, AuthAgent.this.c); if (!activity.isFinishing()) { aVar.show(); return; } return; } SLog.w("openSDK_LOG.AuthAgent", "OpenUi, secure so load failed, goto download QQ."); TDialog tDialog = new TDialog(activity, "", AuthAgent.this.a((AuthAgent) ""), null, AuthAgent.this.c); if (!activity.isFinishing()) { tDialog.show(); } } }); } } }); SLog.i("openSDK_LOG.AuthAgent", "OpenUi, showDialog -- end"); return 2; } private boolean a(Activity activity, Fragment fragment, boolean z) { SLog.i("openSDK_LOG.AuthAgent", "startActionActivity() -- start"); Intent b2 = b("com.tencent.open.agent.AgentActivity"); if (b2 != null) { Bundle a2 = a(); if (z) { a2.putString("isadd", "1"); } a2.putString(Constants.PARAM_SCOPE, this.d); a2.putString(Constants.PARAM_CLIENT_ID, this.c.getAppId()); if (isOEM) { a2.putString(Constants.PARAM_PLATFORM_ID, "desktop_m_qq-" + installChannel + "-" + DispatchConstants.ANDROID + "-" + registerChannel + "-" + businessId); } else { a2.putString(Constants.PARAM_PLATFORM_ID, Constants.DEFAULT_PF); } a2.putString("need_pay", "1"); a2.putString(Constants.KEY_APP_NAME, h.a(e.a())); b2.putExtra(Constants.KEY_ACTION, "action_login"); b2.putExtra(Constants.KEY_PARAMS, a2); b2.putExtra("appid", this.c.getAppId()); if (a(b2)) { this.f11515a = new b(this.f11515a); UIListenerManager.getInstance().setListenerWithRequestcode(Constants.REQUEST_LOGIN, this.f11515a); if (fragment != null) { SLog.d("openSDK_LOG.AuthAgent", "startAssitActivity fragment"); a(fragment, b2, Constants.REQUEST_LOGIN); } else { SLog.d("openSDK_LOG.AuthAgent", "startAssitActivity activity"); a(activity, b2, Constants.REQUEST_LOGIN); } SLog.i("openSDK_LOG.AuthAgent", "startActionActivity() -- end, found activity for loginIntent"); d.a().a(0, "LOGIN_CHECK_SDK", Constants.DEFAULT_UIN, this.c.getAppId(), "", Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, ""); return true; } } d.a().a(1, "LOGIN_CHECK_SDK", Constants.DEFAULT_UIN, this.c.getAppId(), "", Long.valueOf(SystemClock.elapsedRealtime()), 0, 1, "startActionActivity fail"); SLog.i("openSDK_LOG.AuthAgent", "startActionActivity() -- end, no target activity for loginIntent"); return false; } /* access modifiers changed from: protected */ public void a(IUiListener iUiListener) { String str; SLog.i("openSDK_LOG.AuthAgent", "reportDAU() -- start"); String accessToken = this.c.getAccessToken(); String openId = this.c.getOpenId(); String appId = this.c.getAppId(); if (TextUtils.isEmpty(accessToken) || TextUtils.isEmpty(openId) || TextUtils.isEmpty(appId)) { str = ""; } else { str = k.f("tencent&sdk&qazxc***14969%%" + accessToken + appId + openId + "qzone3.4"); } if (TextUtils.isEmpty(str)) { SLog.e("openSDK_LOG.AuthAgent", "reportDAU -- encrytoken is null"); return; } Bundle a2 = a(); a2.putString("encrytoken", str); HttpUtils.requestAsync(this.c, e.a(), "https://openmobile.qq.com/user/user_login_statis", a2, "POST", null); SLog.i("openSDK_LOG.AuthAgent", "reportDAU() -- end"); } /* access modifiers changed from: protected */ public void b(IUiListener iUiListener) { Bundle a2 = a(); a2.putString("reqType", "checkLogin"); HttpUtils.requestAsync(this.c, e.a(), "https://openmobile.qq.com/v3/user/get_info", a2, "GET", new BaseApi.TempRequestListener(new a(iUiListener))); } /* access modifiers changed from: private */ /* compiled from: ProGuard */ public class a implements IUiListener { /* renamed from: a reason: collision with root package name */ IUiListener f11520a; public a(IUiListener iUiListener) { this.f11520a = iUiListener; } @Override // com.tencent.tauth.IUiListener public void onComplete(Object obj) { String str; if (obj == null) { SLog.e("openSDK_LOG.AuthAgent", "CheckLoginListener response data is null"); return; } JSONObject jSONObject = (JSONObject) obj; try { int i = jSONObject.getInt("ret"); if (i == 0) { str = "success"; } else { str = jSONObject.getString(SocialConstants.PARAM_SEND_MSG); } if (this.f11520a != null) { this.f11520a.onComplete(new JSONObject().put("ret", i).put(SocialConstants.PARAM_SEND_MSG, str)); } } catch (JSONException e) { e.printStackTrace(); SLog.e("openSDK_LOG.AuthAgent", "CheckLoginListener response data format error"); } } @Override // com.tencent.tauth.IUiListener public void onError(UiError uiError) { IUiListener iUiListener = this.f11520a; if (iUiListener != null) { iUiListener.onError(uiError); } } @Override // com.tencent.tauth.IUiListener public void onCancel() { IUiListener iUiListener = this.f11520a; if (iUiListener != null) { iUiListener.onCancel(); } } } /* access modifiers changed from: private */ /* compiled from: ProGuard */ public class b implements IUiListener { /* renamed from: a reason: collision with root package name */ WeakReference<IUiListener> f11522a; private final String c = "sendinstall"; private final String d = "installwording"; private final String e = "http://appsupport.qq.com/cgi-bin/qzapps/mapp_addapp.cgi"; public b(IUiListener iUiListener) { this.f11522a = new WeakReference<>(iUiListener); } @Override // com.tencent.tauth.IUiListener public void onComplete(Object obj) { JSONObject jSONObject; String str; if (obj != null && (jSONObject = (JSONObject) obj) != null) { boolean z = false; try { if (jSONObject.getInt("sendinstall") == 1) { z = true; } str = jSONObject.getString("installwording"); } catch (JSONException unused) { SLog.w("openSDK_LOG.AuthAgent", "FeedConfirmListener onComplete There is no value for sendinstall."); str = ""; } String decode = URLDecoder.decode(str); SLog.i("openSDK_LOG.AuthAgent", " WORDING = " + decode + "xx,showConfirmDialog=" + z); if (z && !TextUtils.isEmpty(decode)) { a(decode, this.f11522a.get(), obj); SLog.i("openSDK_LOG.AuthAgent", " WORDING is not empty and return"); } else if (this.f11522a.get() != null) { if (AuthAgent.this.c != null) { AuthAgent.this.c.saveSession(jSONObject); } this.f11522a.get().onComplete(obj); } else { SLog.i("openSDK_LOG.AuthAgent", " userListener is null"); } } } /* compiled from: ProGuard */ private abstract class a implements View.OnClickListener { Dialog d; a(Dialog dialog) { this.d = dialog; } } private void a(String str, final IUiListener iUiListener, final Object obj) { PackageInfo packageInfo; if (AuthAgent.this.e == null) { SLog.i("openSDK_LOG.AuthAgent", "showFeedConfrimDialog mActivity null and return"); return; } Activity activity = (Activity) AuthAgent.this.e.get(); if (activity == null) { SLog.i("openSDK_LOG.AuthAgent", "showFeedConfrimDialog mActivity.get() null and return"); return; } Dialog dialog = new Dialog(activity); dialog.requestWindowFeature(1); PackageManager packageManager = activity.getPackageManager(); Drawable drawable = null; try { packageInfo = packageManager.getPackageInfo(activity.getPackageName(), 0); } catch (PackageManager.NameNotFoundException e2) { SLog.e("openSDK_LOG.AuthAgent", "showFeedConfrimDialog exception:" + e2.getStackTrace().toString()); packageInfo = null; } if (packageInfo != null) { drawable = packageInfo.applicationInfo.loadIcon(packageManager); } View.OnClickListener r6 = new a(dialog) { /* class com.tencent.connect.auth.AuthAgent.b.AnonymousClass1 */ public void onClick(View view) { b.this.a(); if (this.d != null && this.d.isShowing()) { this.d.dismiss(); } IUiListener iUiListener = iUiListener; if (iUiListener != null) { iUiListener.onComplete(obj); } } }; View.OnClickListener r7 = new a(dialog) { /* class com.tencent.connect.auth.AuthAgent.b.AnonymousClass2 */ public void onClick(View view) { if (this.d != null && this.d.isShowing()) { this.d.dismiss(); } IUiListener iUiListener = iUiListener; if (iUiListener != null) { iUiListener.onComplete(obj); } } }; ColorDrawable colorDrawable = new ColorDrawable(); colorDrawable.setAlpha(0); dialog.getWindow().setBackgroundDrawable(colorDrawable); dialog.setContentView(a(activity, drawable, str, r6, r7)); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { /* class com.tencent.connect.auth.AuthAgent.b.AnonymousClass3 */ public void onCancel(DialogInterface dialogInterface) { IUiListener iUiListener = iUiListener; if (iUiListener != null) { iUiListener.onComplete(obj); } } }); if (activity != null && !activity.isFinishing()) { dialog.show(); } } 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 e2) { e2.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 e3) { e3.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; } /* access modifiers changed from: protected */ public void a() { Activity activity; Bundle b2 = AuthAgent.this.b(); if (AuthAgent.this.e != null && (activity = (Activity) AuthAgent.this.e.get()) != null) { HttpUtils.requestAsync(AuthAgent.this.c, activity, "http://appsupport.qq.com/cgi-bin/qzapps/mapp_addapp.cgi", b2, "POST", null); } } @Override // com.tencent.tauth.IUiListener public void onError(UiError uiError) { if (this.f11522a.get() != null) { this.f11522a.get().onError(uiError); } } @Override // com.tencent.tauth.IUiListener public void onCancel() { if (this.f11522a.get() != null) { this.f11522a.get().onCancel(); } } } }