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.tencent.connect.auth.QQToken; import com.tencent.connect.auth.c; import com.tencent.open.TDialog; import com.tencent.open.log.SLog; import com.tencent.open.utils.HttpUtils; import com.tencent.open.utils.f; import com.tencent.open.utils.i; import com.tencent.open.utils.l; import com.tencent.tauth.IRequestListener; import com.tencent.tauth.IUiListener; import com.tencent.tauth.UiError; import com.xiaomi.mipush.sdk.Constants; import java.io.IOException; import java.net.MalformedURLException; import java.net.SocketTimeoutException; import java.util.Map; import org.apache.http.conn.ConnectTimeoutException; import org.json.JSONException; import org.json.JSONObject; /* compiled from: ProGuard */ public abstract class BaseApi { public static String businessId = null; public static String installChannel = null; public static boolean isOEM = false; public static String registerChannel; /* renamed from: b reason: collision with root package name */ public c f31008b; /* renamed from: c reason: collision with root package name */ public QQToken f31009c; /* compiled from: ProGuard */ public class TempRequestListener implements IRequestListener { /* renamed from: b reason: collision with root package name */ private final IUiListener f31011b; /* renamed from: c reason: collision with root package name */ private final Handler f31012c; public TempRequestListener(IUiListener iUiListener) { this.f31011b = iUiListener; this.f31012c = new Handler(f.a().getMainLooper(), BaseApi.this) { /* class com.tencent.connect.common.BaseApi.TempRequestListener.AnonymousClass1 */ public void handleMessage(Message message) { if (message.what == 0) { TempRequestListener.this.f31011b.onComplete(message.obj); } else { TempRequestListener.this.f31011b.onError(new UiError(message.what, (String) message.obj, null)); } } }; } @Override // com.tencent.tauth.IRequestListener public void onComplete(JSONObject jSONObject) { Message obtainMessage = this.f31012c.obtainMessage(); obtainMessage.obj = jSONObject; obtainMessage.what = 0; this.f31012c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onConnectTimeoutException(ConnectTimeoutException connectTimeoutException) { Message obtainMessage = this.f31012c.obtainMessage(); obtainMessage.obj = connectTimeoutException.getMessage(); obtainMessage.what = -7; this.f31012c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onHttpStatusException(HttpUtils.HttpStatusException httpStatusException) { Message obtainMessage = this.f31012c.obtainMessage(); obtainMessage.obj = httpStatusException.getMessage(); obtainMessage.what = -9; this.f31012c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onIOException(IOException iOException) { Message obtainMessage = this.f31012c.obtainMessage(); obtainMessage.obj = iOException.getMessage(); obtainMessage.what = -2; this.f31012c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onJSONException(JSONException jSONException) { Message obtainMessage = this.f31012c.obtainMessage(); obtainMessage.obj = jSONException.getMessage(); obtainMessage.what = -4; this.f31012c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onMalformedURLException(MalformedURLException malformedURLException) { Message obtainMessage = this.f31012c.obtainMessage(); obtainMessage.obj = malformedURLException.getMessage(); obtainMessage.what = -3; this.f31012c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onNetworkUnavailableException(HttpUtils.NetworkUnavailableException networkUnavailableException) { Message obtainMessage = this.f31012c.obtainMessage(); obtainMessage.obj = networkUnavailableException.getMessage(); obtainMessage.what = -10; this.f31012c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onSocketTimeoutException(SocketTimeoutException socketTimeoutException) { Message obtainMessage = this.f31012c.obtainMessage(); obtainMessage.obj = socketTimeoutException.getMessage(); obtainMessage.what = -8; this.f31012c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onUnknowException(Exception exc) { Message obtainMessage = this.f31012c.obtainMessage(); obtainMessage.obj = exc.getMessage(); obtainMessage.what = -6; this.f31012c.sendMessage(obtainMessage); } } public BaseApi(c cVar, QQToken qQToken) { this.f31008b = cVar; this.f31009c = qQToken; } public 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", Constants.SDK_VERSION); bundle.putString("sdkp", "a"); QQToken qQToken = this.f31009c; if (qQToken != null && qQToken.isSessionValid()) { bundle.putString("access_token", this.f31009c.getAccessToken()); bundle.putString("oauth_consumer_key", this.f31009c.getAppId()); bundle.putString("openid", this.f31009c.getOpenId()); bundle.putString("appid_for_getting_config", this.f31009c.getAppId()); } SharedPreferences sharedPreferences = f.a().getSharedPreferences(Constants.PREFERENCE_PF, 0); if (isOEM) { bundle.putString(Constants.PARAM_PLATFORM_ID, "desktop_m_qq-" + installChannel + Constants.ACCEPT_TIME_SEPARATOR_SERVER + "android" + Constants.ACCEPT_TIME_SEPARATOR_SERVER + registerChannel + Constants.ACCEPT_TIME_SEPARATOR_SERVER + businessId); } else { bundle.putString(Constants.PARAM_PLATFORM_ID, sharedPreferences.getString(Constants.PARAM_PLATFORM_ID, Constants.DEFAULT_PF)); } return bundle; } public Bundle b() { Bundle bundle = new Bundle(); bundle.putString("appid", this.f31009c.getAppId()); if (this.f31009c.isSessionValid()) { bundle.putString(Constants.PARAM_KEY_STR, this.f31009c.getAccessToken()); bundle.putString(Constants.PARAM_KEY_TYPE, "0x80"); } String openId = this.f31009c.getOpenId(); if (openId != null) { bundle.putString("hopenid", openId); } bundle.putString("platform", "androidqz"); SharedPreferences sharedPreferences = f.a().getSharedPreferences(Constants.PREFERENCE_PF, 0); if (isOEM) { bundle.putString(Constants.PARAM_PLATFORM_ID, "desktop_m_qq-" + installChannel + Constants.ACCEPT_TIME_SEPARATOR_SERVER + "android" + Constants.ACCEPT_TIME_SEPARATOR_SERVER + registerChannel + Constants.ACCEPT_TIME_SEPARATOR_SERVER + businessId); } else { bundle.putString(Constants.PARAM_PLATFORM_ID, sharedPreferences.getString(Constants.PARAM_PLATFORM_ID, Constants.DEFAULT_PF)); bundle.putString(Constants.PARAM_PLATFORM_ID, Constants.DEFAULT_PF); } bundle.putString("sdkv", Constants.SDK_VERSION); bundle.putString("sdkp", "a"); return bundle; } public Intent c(String str) { Intent intent = new Intent(); Intent b14 = b(str); if (b14 == null || b14.getComponent() == null) { return null; } intent.setClassName(b14.getComponent().getPackageName(), "com.tencent.open.agent.AgentActivity"); return intent; } public void releaseResource() { } public BaseApi(QQToken qQToken) { this(null, qQToken); } public String a(String str) { Bundle a14 = a(); StringBuilder sb3 = new StringBuilder(); if (!TextUtils.isEmpty(str)) { a14.putString("need_version", str); } sb3.append("https://openmobile.qq.com/oauth2.0/m_jump_by_version?"); sb3.append(HttpUtils.encodeUrl(a14)); return sb3.toString(); } public Intent b(String str) { Intent intent = new Intent(); if (l.c(f.a())) { intent.setClassName(Constants.PACKAGE_QQ_PAD, str); if (i.a(f.a(), intent)) { return intent; } } intent.setClassName("com.tencent.mobileqq", str); if (i.a(f.a(), intent)) { return intent; } intent.setClassName(Constants.PACKAGE_TIM, str); if (i.a(f.a(), intent)) { return intent; } intent.setClassName(Constants.PACKAGE_QQ_SPEED, str); if (i.a(f.a(), intent)) { return intent; } return null; } private Intent a(Activity activity, Intent intent, Map<String, Object> map) { Intent intent2 = new Intent(activity.getApplicationContext(), AssistActivity.class); intent2.putExtra("is_login", true); intent2.putExtra(AssistActivity.EXTRA_INTENT, intent); if (map == null) { return intent2; } try { if (map.containsKey(Constants.KEY_RESTORE_LANDSCAPE)) { intent2.putExtra(Constants.KEY_RESTORE_LANDSCAPE, ((Boolean) map.get(Constants.KEY_RESTORE_LANDSCAPE)).booleanValue()); } } catch (Exception e14) { SLog.e("openSDK_LOG.BaseApi", "Exception", e14); } return intent2; } public void a(Activity activity, int i10, Intent intent, boolean z14) { Intent intent2 = new Intent(activity.getApplicationContext(), AssistActivity.class); if (z14) { intent2.putExtra("is_qq_mobile_share", true); } intent2.putExtra(AssistActivity.EXTRA_INTENT, intent); activity.startActivityForResult(intent2, i10); } public void a(Activity activity, Intent intent, int i10) { a(activity, intent, i10, (Map<String, Object>) null); } public void a(Activity activity, Intent intent, int i10, Map<String, Object> map) { intent.putExtra(Constants.KEY_REQUEST_CODE, i10); activity.startActivityForResult(a(activity, intent, map), i10); } public void a(Fragment fragment, Intent intent, int i10, Map<String, Object> map) { intent.putExtra(Constants.KEY_REQUEST_CODE, i10); fragment.startActivityForResult(a(fragment.getActivity(), intent, map), i10); } public boolean a(Intent intent) { if (intent != null) { return i.a(f.a(), intent); } return false; } public void a(Activity activity, Bundle bundle, IUiListener iUiListener) { SLog.i("openSDK_LOG.BaseApi", "--handleDownloadLastestQQ"); new TDialog(activity, "", "https://login.imgcache.qq.com/ptlogin/static/qzsjump.html?" + HttpUtils.encodeUrl(bundle), null, this.f31009c).show(); } }