257 lines
11 KiB
Java
257 lines
11 KiB
Java
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 = "<!DOCTYPE HTML><html lang=\"en-US\"><head><meta charset=\"UTF-8\"><title>localStorage Test</title><script type=\"text/javascript\">document.domain = 'qq.com';localStorage[\"" + this.b.c() + "_" + this.b.b() + "\"]=\"" + str + "\";</script></head><body></body></html>";
|
|
String a3 = com.tencent.open.utils.f.a().a(context, "http://qzs.qq.com");
|
|
bVar.loadDataWithBaseURL(a3, str2, "text/html", "utf-8", a3);
|
|
}
|
|
|
|
public SocialApiIml(com.tencent.connect.auth.c cVar, QQToken qQToken) {
|
|
super(cVar, qQToken);
|
|
}
|
|
|
|
private void a(Activity activity, String str, Bundle bundle, IUiListener iUiListener) {
|
|
this.c = activity;
|
|
Intent c = c(SocialConstants.ACTIVITY_FRIEND_CHOOSER);
|
|
if (c == null) {
|
|
f.c("openSDK_LOG.SocialApiIml", "--askgift--friend chooser not found");
|
|
c = c(SocialConstants.ACTIVITY_ASK_GIFT);
|
|
}
|
|
Intent intent = c;
|
|
bundle.putAll(b());
|
|
if (SocialConstants.ACTION_ASK.equals(str)) {
|
|
bundle.putString("type", SocialConstants.TYPE_REQUEST);
|
|
} else if (SocialConstants.ACTION_GIFT.equals(str)) {
|
|
bundle.putString("type", SocialConstants.TYPE_FREEGIFT);
|
|
}
|
|
a(activity, intent, str, bundle, com.tencent.open.utils.f.a().a(d.a(), "http://qzs.qq.com/open/mobile/request/sdk_request.html?"), iUiListener, false);
|
|
}
|
|
|
|
private void a(Activity activity, Intent intent, String str, Bundle bundle, String str2, IUiListener iUiListener, boolean z) {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("-->handleIntent action = ");
|
|
sb.append(str);
|
|
sb.append(", activityIntent = null ? ");
|
|
boolean z2 = true;
|
|
sb.append(intent == null);
|
|
f.c("openSDK_LOG.SocialApiIml", sb.toString());
|
|
if (intent != null) {
|
|
a(activity, intent, str, bundle, iUiListener);
|
|
return;
|
|
}
|
|
e a2 = e.a(d.a(), this.b.b());
|
|
if (!z && !a2.b("C_LoginH5")) {
|
|
z2 = false;
|
|
}
|
|
if (z2) {
|
|
a(activity, str, bundle, str2, iUiListener);
|
|
} else {
|
|
a(activity, bundle, iUiListener);
|
|
}
|
|
}
|
|
|
|
private void a(Activity activity, Intent intent, String str, Bundle bundle, IUiListener iUiListener) {
|
|
f.c("openSDK_LOG.SocialApiIml", "-->handleIntentWithAgent action = " + str);
|
|
intent.putExtra("key_action", str);
|
|
intent.putExtra("key_params", bundle);
|
|
UIListenerManager.a().a(11105, iUiListener);
|
|
a(activity, intent, 11105);
|
|
}
|
|
|
|
private void a(Activity activity, String str, Bundle bundle, String str2, IUiListener iUiListener) {
|
|
f.c("openSDK_LOG.SocialApiIml", "-->handleIntentWithH5 action = " + str);
|
|
Intent b = b("com.tencent.open.agent.AgentActivity");
|
|
IUiListener aVar = new a(activity, iUiListener, str, str2, bundle);
|
|
Intent b2 = b("com.tencent.open.agent.EncryTokenActivity");
|
|
if (b2 != null && b != null && b.getComponent() != null && b2.getComponent() != null && b.getComponent().getPackageName().equals(b2.getComponent().getPackageName())) {
|
|
b2.putExtra(SocialConstants.PARAM_CONSUMER_KEY, this.b.b());
|
|
b2.putExtra(SocialConstants.PARAM_OPEN_ID, this.b.c());
|
|
b2.putExtra(AccessToken.ACCESS_TOKEN_KEY, this.b.a());
|
|
b2.putExtra("key_action", SocialConstants.ACTION_CHECK_TOKEN);
|
|
if (a(b2)) {
|
|
f.c("openSDK_LOG.SocialApiIml", "-->handleIntentWithH5--found token activity");
|
|
UIListenerManager.a().a(11106, aVar);
|
|
a(activity, b2, 11106);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
f.c("openSDK_LOG.SocialApiIml", "-->handleIntentWithH5--token activity not found");
|
|
String f = i.f("tencent&sdk&qazxc***14969%%" + this.b.a() + this.b.b() + this.b.c() + "qzone3.4");
|
|
JSONObject jSONObject = new JSONObject();
|
|
try {
|
|
jSONObject.put(SocialConstants.PARAM_ENCRY_EOKEN, f);
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
aVar.onComplete(jSONObject);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(Context context, String str, Bundle bundle, String str2, IUiListener iUiListener) {
|
|
f.a("openSDK_LOG.SocialApiIml", "OpenUi, showDialog --start");
|
|
CookieSyncManager.createInstance(context);
|
|
bundle.putString(SocialConstants.PARAM_CONSUMER_KEY, this.b.b());
|
|
if (this.b.d()) {
|
|
bundle.putString(AccessToken.ACCESS_TOKEN_KEY, this.b.a());
|
|
}
|
|
String c = this.b.c();
|
|
if (c != null) {
|
|
bundle.putString(SocialConstants.PARAM_OPEN_ID, c);
|
|
}
|
|
try {
|
|
bundle.putString("pf", d.a().getSharedPreferences("pfStore", 0).getString("pf", "openmobile_android"));
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
bundle.putString("pf", "openmobile_android");
|
|
}
|
|
String str3 = str2 + HttpUtils.encodeUrl(bundle);
|
|
f.b("openSDK_LOG.SocialApiIml", "OpenUi, showDialog TDialog");
|
|
if (!SocialConstants.ACTION_CHALLENGE.equals(str) && !SocialConstants.ACTION_BRAG.equals(str)) {
|
|
new TDialog(this.c, str, str3, iUiListener, this.b).show();
|
|
} else {
|
|
f.b("openSDK_LOG.SocialApiIml", "OpenUi, showDialog PKDialog");
|
|
new c(this.c, str, str3, iUiListener, this.b).show();
|
|
}
|
|
}
|
|
}
|