package com.tencent.open; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; import android.webkit.CookieSyncManager; import android.webkit.WebSettings; import com.facebook.AccessToken; import com.tencent.connect.auth.QQToken; import com.tencent.connect.common.BaseApi; import com.tencent.connect.common.UIListenerManager; import com.tencent.open.a.f; import com.tencent.open.utils.HttpUtils; import com.tencent.open.utils.d; import com.tencent.open.utils.e; import com.tencent.open.utils.g; import com.tencent.open.utils.i; import com.tencent.tauth.IUiListener; import com.tencent.tauth.UiError; import org.json.JSONException; import org.json.JSONObject; /* compiled from: ProGuard */ /* loaded from: classes.dex */ public class SocialApiIml extends BaseApi { private Activity c; /* compiled from: ProGuard */ private class a implements IUiListener { private IUiListener b; private String c; private String d; private Bundle e; private Activity f; a(Activity activity, IUiListener iUiListener, String str, String str2, Bundle bundle) { this.b = iUiListener; this.c = str; this.d = str2; this.e = bundle; } @Override // com.tencent.tauth.IUiListener public void onCancel() { this.b.onCancel(); } @Override // com.tencent.tauth.IUiListener public void onComplete(Object obj) { String str; try { str = ((JSONObject) obj).getString(SocialConstants.PARAM_ENCRY_EOKEN); } catch (JSONException e) { e.printStackTrace(); f.b("openSDK_LOG.SocialApiIml", "OpenApi, EncrytokenListener() onComplete error", e); str = null; } this.e.putString("encrytoken", str); SocialApiIml socialApiIml = SocialApiIml.this; socialApiIml.a((Context) socialApiIml.c, this.c, this.e, this.d, this.b); if (TextUtils.isEmpty(str)) { f.b("openSDK_LOG.SocialApiIml", "The token get from qq or qzone is empty. Write temp token to localstorage."); SocialApiIml.this.writeEncryToken(this.f); } } @Override // com.tencent.tauth.IUiListener public void onError(UiError uiError) { f.b("openSDK_LOG.SocialApiIml", "OpenApi, EncryptTokenListener() onError" + uiError.b); this.b.onError(uiError); } } public SocialApiIml(QQToken qQToken) { super(qQToken); } public void ask(Activity activity, Bundle bundle, IUiListener iUiListener) { a(activity, SocialConstants.ACTION_ASK, bundle, iUiListener); } @Override // com.tencent.connect.common.BaseApi protected Intent b(String str) { Intent intent = new Intent(); intent.setClassName("com.qzone", str); Intent intent2 = new Intent(); intent2.setClassName("com.tencent.mobileqq", str); Intent intent3 = new Intent(); intent3.setClassName("com.tencent.minihd.qq", str); if (i.d(d.a()) && g.a(d.a(), intent3)) { return intent3; } if (g.a(d.a(), intent2) && g.c(d.a(), "4.7") >= 0) { return intent2; } if (g.a(d.a(), intent) && g.a(g.a(d.a(), "com.qzone"), "4.2") >= 0 && g.a(d.a(), intent.getComponent().getPackageName(), "ec96e9ac1149251acbb1b0c5777cae95")) { return intent; } return null; } public void gift(Activity activity, Bundle bundle, IUiListener iUiListener) { a(activity, SocialConstants.ACTION_GIFT, bundle, iUiListener); } public void invite(Activity activity, Bundle bundle, IUiListener iUiListener) { this.c = activity; Intent c = c(SocialConstants.ACTIVITY_FRIEND_CHOOSER); if (c == null) { f.c("openSDK_LOG.SocialApiIml", "--invite--friend chooser not found"); c = c(SocialConstants.ACTIVITY_INVITE); } bundle.putAll(b()); a(activity, c, SocialConstants.ACTION_INVITE, bundle, com.tencent.open.utils.f.a().a(d.a(), "http://qzs.qq.com/open/mobile/invite/sdk_invite.html?"), iUiListener, false); } public void story(Activity activity, Bundle bundle, IUiListener iUiListener) { this.c = activity; Intent c = c(SocialConstants.ACTIVITY_STORY); bundle.putAll(b()); a(activity, c, SocialConstants.ACTION_STORY, bundle, com.tencent.open.utils.f.a().a(d.a(), "http://qzs.qq.com/open/mobile/sendstory/sdk_sendstory_v1.3.html?"), iUiListener, false); } @SuppressLint({"SetJavaScriptEnabled"}) public void writeEncryToken(Context context) { String str; String a2 = this.b.a(); String b = this.b.b(); String c = this.b.c(); if (a2 == null || a2.length() <= 0 || b == null || b.length() <= 0 || c == null || c.length() <= 0) { str = null; } else { str = i.f("tencent&sdk&qazxc***14969%%" + a2 + b + c + "qzone3.4"); } com.tencent.open.c.b bVar = new com.tencent.open.c.b(context); WebSettings settings = bVar.getSettings(); settings.setDomStorageEnabled(true); settings.setJavaScriptEnabled(true); settings.setDatabaseEnabled(true); String str2 = "