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.appcompat.widget.a; import androidx.fragment.app.Fragment; import com.meizu.cloud.pushsdk.constants.PushConstants; 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.g; import com.tencent.open.utils.k; import com.tencent.open.utils.m; import com.tencent.tauth.IRequestListener; import com.tencent.tauth.IUiListener; import com.tencent.tauth.UiError; import h.b; import java.io.IOException; import java.net.MalformedURLException; import java.net.SocketTimeoutException; import java.util.Map; import org.json.JSONException; import org.json.JSONObject; /* compiled from: ProGuard */ public abstract class BaseApi { public static String businessId; public static String installChannel; public static boolean isOEM; public static String registerChannel; public c b; /* renamed from: c reason: collision with root package name */ public QQToken f27894c; /* compiled from: ProGuard */ public class TempRequestListener implements IRequestListener { private final IUiListener b; /* renamed from: c reason: collision with root package name */ private final Handler f27896c; public TempRequestListener(IUiListener iUiListener) { this.b = iUiListener; this.f27896c = new Handler(g.a().getMainLooper(), BaseApi.this) { /* class com.tencent.connect.common.BaseApi.TempRequestListener.AnonymousClass1 */ public void handleMessage(Message message) { if (message.what == 0) { TempRequestListener.this.b.onComplete(message.obj); } else { TempRequestListener.this.b.onError(new UiError(message.what, (String) message.obj, null)); } } }; } @Override // com.tencent.tauth.IRequestListener public void onComplete(JSONObject jSONObject) { Message obtainMessage = this.f27896c.obtainMessage(); obtainMessage.obj = jSONObject; obtainMessage.what = 0; this.f27896c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onHttpStatusException(HttpUtils.HttpStatusException httpStatusException) { Message obtainMessage = this.f27896c.obtainMessage(); obtainMessage.obj = httpStatusException.getMessage(); obtainMessage.what = -9; this.f27896c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onIOException(IOException iOException) { Message obtainMessage = this.f27896c.obtainMessage(); obtainMessage.obj = iOException.getMessage(); obtainMessage.what = -2; this.f27896c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onJSONException(JSONException jSONException) { Message obtainMessage = this.f27896c.obtainMessage(); obtainMessage.obj = jSONException.getMessage(); obtainMessage.what = -4; this.f27896c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onMalformedURLException(MalformedURLException malformedURLException) { Message obtainMessage = this.f27896c.obtainMessage(); obtainMessage.obj = malformedURLException.getMessage(); obtainMessage.what = -3; this.f27896c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onNetworkUnavailableException(HttpUtils.NetworkUnavailableException networkUnavailableException) { Message obtainMessage = this.f27896c.obtainMessage(); obtainMessage.obj = networkUnavailableException.getMessage(); obtainMessage.what = -10; this.f27896c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onSocketTimeoutException(SocketTimeoutException socketTimeoutException) { Message obtainMessage = this.f27896c.obtainMessage(); obtainMessage.obj = socketTimeoutException.getMessage(); obtainMessage.what = -8; this.f27896c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onUnknowException(Exception exc) { Message obtainMessage = this.f27896c.obtainMessage(); obtainMessage.obj = exc.getMessage(); obtainMessage.what = -6; this.f27896c.sendMessage(obtainMessage); } } public BaseApi(c cVar, QQToken qQToken) { this.b = cVar; this.f27894c = qQToken; } public Bundle a() { Bundle d = a.d("format", "json"); d.putString("status_os", Build.VERSION.RELEASE); d.putString("status_machine", f.a().c(g.a())); d.putString("status_version", Build.VERSION.SDK); d.putString("sdkv", "3.5.13.lite"); d.putString("sdkp", "a"); QQToken qQToken = this.f27894c; if (qQToken != null && qQToken.isSessionValid()) { d.putString("access_token", this.f27894c.getAccessToken()); d.putString("oauth_consumer_key", this.f27894c.getAppId()); d.putString("openid", this.f27894c.getOpenId()); } SharedPreferences sharedPreferences = g.a().getSharedPreferences("pfStore", 0); if (isOEM) { StringBuilder h12 = a.f.h("desktop_m_qq-"); b.u(h12, installChannel, "-", "android", "-"); h12.append(registerChannel); h12.append("-"); h12.append(businessId); d.putString("pf", h12.toString()); } else { d.putString("pf", sharedPreferences.getString("pf", "openmobile_android")); } return d; } public Bundle b() { Bundle bundle = new Bundle(); bundle.putString("appid", this.f27894c.getAppId()); if (this.f27894c.isSessionValid()) { bundle.putString("keystr", this.f27894c.getAccessToken()); bundle.putString("keytype", "0x80"); } String openId = this.f27894c.getOpenId(); if (openId != null) { bundle.putString("hopenid", openId); } bundle.putString("platform", "androidqz"); SharedPreferences sharedPreferences = g.a().getSharedPreferences("pfStore", 0); if (isOEM) { StringBuilder h12 = a.f.h("desktop_m_qq-"); b.u(h12, installChannel, "-", "android", "-"); h12.append(registerChannel); h12.append("-"); h12.append(businessId); bundle.putString("pf", h12.toString()); } else { bundle.putString("pf", sharedPreferences.getString("pf", "openmobile_android")); bundle.putString("pf", "openmobile_android"); } bundle.putString("sdkv", "3.5.13.lite"); bundle.putString("sdkp", "a"); return bundle; } public Intent c() { Intent intent = new Intent(); if (m.c(g.a())) { intent.setClassName("com.tencent.minihd.qq", "com.tencent.open.agent.AgentActivity"); if (k.b(g.a(), intent)) { return intent; } } intent.setClassName("com.tencent.mobileqq", "com.tencent.open.agent.AgentActivity"); if (k.b(g.a(), intent)) { return intent; } intent.setClassName("com.tencent.tim", "com.tencent.open.agent.AgentActivity"); if (k.b(g.a(), intent)) { return intent; } return null; } public void releaseResource() { } public BaseApi(QQToken qQToken) { this(null, qQToken); } public Intent c(String str) { Intent intent = new Intent(); Intent b2 = b(str); if (b2 == null || b2.getComponent() == null) { return null; } intent.setClassName(b2.getComponent().getPackageName(), "com.tencent.open.agent.AgentActivity"); return intent; } public String a(String str) { Bundle a5 = a(); StringBuilder sb2 = new StringBuilder(); if (!TextUtils.isEmpty(str)) { a5.putString("need_version", str); } sb2.append("https://openmobile.qq.com/oauth2.0/m_jump_by_version?"); sb2.append(HttpUtils.encodeUrl(a5)); return sb2.toString(); } public Intent b(String str) { Intent intent = new Intent(); if (m.c(g.a())) { intent.setClassName("com.tencent.minihd.qq", str); if (k.a(g.a(), intent)) { return intent; } } intent.setClassName("com.tencent.mobileqq", str); if (k.a(g.a(), intent)) { return intent; } intent.setClassName("com.tencent.tim", str); if (k.a(g.a(), intent)) { return intent; } return null; } public void a(StringBuilder sb2, Activity activity) { if (sb2.indexOf("?") < 0) { sb2.append("?"); } else { sb2.append("&"); } a.n(sb2, "src_type", "=", PushConstants.EXTRA_APPLICATION_PENDING_INTENT); String appId = this.f27894c.getAppId(); String openId = this.f27894c.getOpenId(); if (!TextUtils.isEmpty(appId)) { a(sb2, "app_id", appId); } if (!TextUtils.isEmpty(openId)) { a(sb2, "open_id", m.k(openId)); } String a5 = m.a(activity); if (!TextUtils.isEmpty(a5)) { if (a5.length() > 20) { a5 = h6.a.k(a5, 0, 20, new StringBuilder(), "..."); } a(sb2, "app_name", m.k(a5)); } a(sb2, "sdk_version", m.k("3.5.13.lite")); } public void a(StringBuilder sb2, String str, String str2) { sb2.append("&"); sb2.append(str); sb2.append("="); sb2.append(m.f(str2)); } 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("openSDK_LOG.AssistActivity.ExtraIntent", 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 e) { SLog.e("openSDK_LOG.BaseApi", "Exception", e); } return intent2; } public void a(Activity activity, int i, Intent intent, boolean z) { Intent intent2 = new Intent(activity.getApplicationContext(), AssistActivity.class); if (z) { intent2.putExtra("is_qq_mobile_share", true); } intent2.putExtra("openSDK_LOG.AssistActivity.ExtraIntent", intent); try { activity.startActivityForResult(intent2, i); } catch (Exception e) { SLog.e("openSDK_LOG.BaseApi", "startAssistActivity exception", e); } } public void a(Activity activity, Intent intent, int i) { a(activity, intent, i, (Map<String, Object>) null); } public void a(Activity activity, Intent intent, int i, Map<String, Object> map) { intent.putExtra("key_request_code", i); try { activity.startActivityForResult(a(activity, intent, map), i); } catch (Exception e) { SLog.e("openSDK_LOG.BaseApi", "startAssitActivity exception", e); } } public void a(Fragment fragment, Intent intent, int i, Map<String, Object> map) { intent.putExtra("key_request_code", i); try { fragment.startActivityForResult(a(fragment.getActivity(), intent, map), i); } catch (Exception e) { SLog.e("openSDK_LOG.BaseApi", "startAssitActivity exception", e); } } public void a(Activity activity, Bundle bundle, IUiListener iUiListener) { SLog.i("openSDK_LOG.BaseApi", "--handleDownloadLastestQQ"); new TDialog(activity, "", "https://imgcache.qq.com/ptlogin/static/qzsjump.html?" + HttpUtils.encodeUrl(bundle), null, this.f27894c).show(); } }