jimu-decompiled/sources/com/tencent/connect/common/BaseApi.java
2025-05-13 19:24:51 +02:00

276 lines
10 KiB
Java

package com.tencent.connect.common;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import androidx.fragment.app.Fragment;
import com.facebook.AccessToken;
import com.tencent.connect.auth.QQToken;
import com.tencent.connect.auth.c;
import com.tencent.open.SocialConstants;
import com.tencent.open.TDialog;
import com.tencent.open.a.f;
import com.tencent.open.utils.HttpUtils;
import com.tencent.open.utils.d;
import com.tencent.open.utils.g;
import com.tencent.open.utils.i;
import com.tencent.tauth.IRequestListener;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.UiError;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import org.apache.http.conn.ConnectTimeoutException;
import org.json.JSONException;
import org.json.JSONObject;
/* compiled from: ProGuard */
/* loaded from: classes.dex */
public abstract class BaseApi {
public static String businessId = null;
public static String installChannel = null;
public static boolean isOEM = false;
public static String registerChannel;
protected c a;
protected QQToken b;
/* compiled from: ProGuard */
public class TempRequestListener implements IRequestListener {
private final IUiListener a;
private final Handler b;
public TempRequestListener(BaseApi baseApi, IUiListener iUiListener) {
this.a = iUiListener;
this.b = new Handler(d.a().getMainLooper(), baseApi) { // from class: com.tencent.connect.common.BaseApi.TempRequestListener.1
@Override // android.os.Handler
public void handleMessage(Message message) {
if (message.what == 0) {
TempRequestListener.this.a.onComplete(message.obj);
} else {
TempRequestListener.this.a.onError(new UiError(message.what, (String) message.obj, null));
}
}
};
}
@Override // com.tencent.tauth.IRequestListener
public void a(JSONObject jSONObject) {
Message obtainMessage = this.b.obtainMessage();
obtainMessage.obj = jSONObject;
obtainMessage.what = 0;
this.b.sendMessage(obtainMessage);
}
@Override // com.tencent.tauth.IRequestListener
public void a(IOException iOException) {
Message obtainMessage = this.b.obtainMessage();
obtainMessage.obj = iOException.getMessage();
obtainMessage.what = -2;
this.b.sendMessage(obtainMessage);
}
@Override // com.tencent.tauth.IRequestListener
public void a(MalformedURLException malformedURLException) {
Message obtainMessage = this.b.obtainMessage();
obtainMessage.obj = malformedURLException.getMessage();
obtainMessage.what = -3;
this.b.sendMessage(obtainMessage);
}
@Override // com.tencent.tauth.IRequestListener
public void a(JSONException jSONException) {
Message obtainMessage = this.b.obtainMessage();
obtainMessage.obj = jSONException.getMessage();
obtainMessage.what = -4;
this.b.sendMessage(obtainMessage);
}
@Override // com.tencent.tauth.IRequestListener
public void a(ConnectTimeoutException connectTimeoutException) {
Message obtainMessage = this.b.obtainMessage();
obtainMessage.obj = connectTimeoutException.getMessage();
obtainMessage.what = -7;
this.b.sendMessage(obtainMessage);
}
@Override // com.tencent.tauth.IRequestListener
public void a(SocketTimeoutException socketTimeoutException) {
Message obtainMessage = this.b.obtainMessage();
obtainMessage.obj = socketTimeoutException.getMessage();
obtainMessage.what = -8;
this.b.sendMessage(obtainMessage);
}
@Override // com.tencent.tauth.IRequestListener
public void a(HttpUtils.NetworkUnavailableException networkUnavailableException) {
Message obtainMessage = this.b.obtainMessage();
obtainMessage.obj = networkUnavailableException.getMessage();
obtainMessage.what = -10;
this.b.sendMessage(obtainMessage);
}
@Override // com.tencent.tauth.IRequestListener
public void a(HttpUtils.HttpStatusException httpStatusException) {
Message obtainMessage = this.b.obtainMessage();
obtainMessage.obj = httpStatusException.getMessage();
obtainMessage.what = -9;
this.b.sendMessage(obtainMessage);
}
@Override // com.tencent.tauth.IRequestListener
public void a(Exception exc) {
Message obtainMessage = this.b.obtainMessage();
obtainMessage.obj = exc.getMessage();
obtainMessage.what = -6;
this.b.sendMessage(obtainMessage);
}
}
public BaseApi(c cVar, QQToken qQToken) {
this.a = cVar;
this.b = qQToken;
}
protected Bundle a() {
Bundle bundle = new Bundle();
bundle.putString("format", "json");
bundle.putString("status_os", Build.VERSION.RELEASE);
bundle.putString("status_machine", Build.MODEL);
bundle.putString("status_version", Build.VERSION.SDK);
bundle.putString("sdkv", "3.3.0.lite");
bundle.putString("sdkp", "a");
QQToken qQToken = this.b;
if (qQToken != null && qQToken.d()) {
bundle.putString(AccessToken.ACCESS_TOKEN_KEY, this.b.a());
bundle.putString(SocialConstants.PARAM_CONSUMER_KEY, this.b.b());
bundle.putString(SocialConstants.PARAM_OPEN_ID, this.b.c());
bundle.putString("appid_for_getting_config", this.b.b());
}
SharedPreferences sharedPreferences = d.a().getSharedPreferences("pfStore", 0);
if (isOEM) {
bundle.putString("pf", "desktop_m_qq-" + installChannel + "-android-" + registerChannel + "-" + businessId);
} else {
bundle.putString("pf", sharedPreferences.getString("pf", "openmobile_android"));
}
return bundle;
}
protected Bundle b() {
Bundle bundle = new Bundle();
bundle.putString(SocialConstants.PARAM_APP_ID, this.b.b());
if (this.b.d()) {
bundle.putString("keystr", this.b.a());
bundle.putString("keytype", "0x80");
}
String c = this.b.c();
if (c != null) {
bundle.putString(SocialConstants.PARAM_HOPEN_ID, c);
}
bundle.putString("platform", "androidqz");
SharedPreferences sharedPreferences = d.a().getSharedPreferences("pfStore", 0);
if (isOEM) {
bundle.putString("pf", "desktop_m_qq-" + installChannel + "-android-" + registerChannel + "-" + businessId);
} else {
bundle.putString("pf", sharedPreferences.getString("pf", "openmobile_android"));
bundle.putString("pf", "openmobile_android");
}
bundle.putString("sdkv", "3.3.0.lite");
bundle.putString("sdkp", "a");
return bundle;
}
protected Intent c(String str) {
Intent intent = new Intent();
Intent b = b(str);
if (b == null || b.getComponent() == null) {
return null;
}
intent.setClassName(b.getComponent().getPackageName(), "com.tencent.open.agent.AgentActivity");
return intent;
}
public void releaseResource() {
}
public BaseApi(QQToken qQToken) {
this(null, qQToken);
}
protected Intent b(String str) {
Intent intent = new Intent();
if (i.d(d.a())) {
intent.setClassName("com.tencent.minihd.qq", str);
if (g.a(d.a(), intent)) {
return intent;
}
}
intent.setClassName("com.tencent.mobileqq", str);
if (g.a(d.a(), intent)) {
return intent;
}
intent.setClassName("com.tencent.tim", str);
if (g.a(d.a(), intent)) {
return intent;
}
intent.setClassName("com.tencent.qim", str);
if (g.a(d.a(), intent)) {
return intent;
}
return null;
}
protected String a(String str) {
Bundle a = a();
StringBuilder sb = new StringBuilder();
if (!TextUtils.isEmpty(str)) {
a.putString("need_version", str);
}
sb.append("http://openmobile.qq.com/oauth2.0/m_jump_by_version?");
sb.append(HttpUtils.encodeUrl(a));
return sb.toString();
}
private Intent a(Activity activity, Intent intent) {
Intent intent2 = new Intent(activity.getApplicationContext(), (Class<?>) AssistActivity.class);
intent2.putExtra("is_login", true);
intent2.putExtra("openSDK_LOG.AssistActivity.ExtraIntent", intent);
return intent2;
}
protected void a(Activity activity, int i, Intent intent, boolean z) {
Intent intent2 = new Intent(activity.getApplicationContext(), (Class<?>) AssistActivity.class);
if (z) {
intent2.putExtra("is_qq_mobile_share", true);
}
intent2.putExtra("openSDK_LOG.AssistActivity.ExtraIntent", intent);
activity.startActivityForResult(intent2, i);
}
protected void a(Activity activity, Intent intent, int i) {
intent.putExtra("key_request_code", i);
activity.startActivityForResult(a(activity, intent), i);
}
protected void a(Fragment fragment, Intent intent, int i) {
intent.putExtra("key_request_code", i);
fragment.startActivityForResult(a(fragment.getActivity(), intent), i);
}
protected boolean a(Intent intent) {
if (intent != null) {
return g.a(d.a(), intent);
}
return false;
}
protected void a(Activity activity, Bundle bundle, IUiListener iUiListener) {
f.c("openSDK_LOG.BaseApi", "--handleDownloadLastestQQ");
new TDialog(activity, "", "http://qzs.qq.com/open/mobile/login/qzsjump.html?" + HttpUtils.encodeUrl(bundle), null, this.b).show();
}
}