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.huawei.hms.framework.common.ContainerUtils; import com.tencent.connect.auth.QQToken; import com.tencent.connect.auth.c; import com.tencent.connect.common.Constants; 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 com.xiaomi.mipush.sdk.Constants; import java.io.IOException; import java.net.MalformedURLException; import java.net.SocketTimeoutException; import java.util.Map; import org.json.JSONException; import org.json.JSONObject; import tv.danmaku.ijk.media.player.IjkMediaMeta; /* compiled from: ProGuard */ public abstract class BaseApi { public static String businessId; public static String installChannel; public static boolean isOEM; public static String registerChannel; protected c b; /* renamed from: c reason: collision with root package name */ protected QQToken f1863c; public void releaseResource() { } public BaseApi(c cVar, QQToken qQToken) { this.b = cVar; this.f1863c = qQToken; } public BaseApi(QQToken qQToken) { this(null, qQToken); } /* access modifiers changed from: protected */ public Bundle a() { Bundle bundle = new Bundle(); bundle.putString(IjkMediaMeta.IJKM_KEY_FORMAT, "json"); bundle.putString("status_os", Build.VERSION.RELEASE); bundle.putString("status_machine", f.a().c(g.a())); bundle.putString("status_version", Build.VERSION.SDK); bundle.putString("sdkv", Constants.SDK_VERSION); bundle.putString("sdkp", "a"); QQToken qQToken = this.f1863c; if (qQToken != null && qQToken.isSessionValid()) { bundle.putString(Constants.PARAM_ACCESS_TOKEN, this.f1863c.getAccessToken()); bundle.putString("oauth_consumer_key", this.f1863c.getAppId()); bundle.putString("openid", this.f1863c.getOpenId()); } SharedPreferences sharedPreferences = g.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; } /* access modifiers changed from: protected */ public String a(String str) { Bundle a = a(); StringBuilder sb = new StringBuilder(); if (!TextUtils.isEmpty(str)) { a.putString("need_version", str); } sb.append("https://openmobile.qq.com/oauth2.0/m_jump_by_version?"); sb.append(HttpUtils.encodeUrl(a)); return sb.toString(); } /* access modifiers changed from: protected */ public void a(StringBuilder sb, Activity activity) { if (sb.indexOf("?") < 0) { sb.append("?"); } else { sb.append(ContainerUtils.FIELD_DELIMITER); } sb.append(Constants.JumpUrlConstants.URL_KEY_SRC); sb.append(ContainerUtils.KEY_VALUE_DELIMITER); sb.append("app"); String appId = this.f1863c.getAppId(); String openId = this.f1863c.getOpenId(); if (!TextUtils.isEmpty(appId)) { a(sb, "app_id", appId); } if (!TextUtils.isEmpty(openId)) { a(sb, Constants.JumpUrlConstants.URL_KEY_OPENID, m.k(openId)); } String a = m.a(activity); if (!TextUtils.isEmpty(a)) { if (a.length() > 20) { a = a.substring(0, 20) + "..."; } a(sb, "app_name", m.k(a)); } a(sb, "sdk_version", m.k(Constants.SDK_VERSION)); } /* access modifiers changed from: protected */ public void a(StringBuilder sb, String str, String str2) { sb.append(ContainerUtils.FIELD_DELIMITER); sb.append(str); sb.append(ContainerUtils.KEY_VALUE_DELIMITER); sb.append(m.f(str2)); } /* access modifiers changed from: protected */ public Bundle b() { Bundle bundle = new Bundle(); bundle.putString("appid", this.f1863c.getAppId()); if (this.f1863c.isSessionValid()) { bundle.putString(Constants.PARAM_KEY_STR, this.f1863c.getAccessToken()); bundle.putString(Constants.PARAM_KEY_TYPE, "0x80"); } String openId = this.f1863c.getOpenId(); if (openId != null) { bundle.putString("hopenid", openId); } bundle.putString("platform", "androidqz"); SharedPreferences sharedPreferences = g.a().getSharedPreferences(Constants.PREFERENCE_PF, 0); if (isOEM) { bundle.putString(Constants.PARAM_PLATFORM_ID, "desktop_m_qq-" + installChannel + com.xiaomi.mipush.sdk.Constants.ACCEPT_TIME_SEPARATOR_SERVER + "android" + com.xiaomi.mipush.sdk.Constants.ACCEPT_TIME_SEPARATOR_SERVER + registerChannel + com.xiaomi.mipush.sdk.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; } 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 e) { SLog.e("openSDK_LOG.BaseApi", "Exception", e); } return intent2; } /* access modifiers changed from: protected */ 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(AssistActivity.EXTRA_INTENT, intent); try { activity.startActivityForResult(intent2, i); } catch (Exception e) { SLog.e("openSDK_LOG.BaseApi", "startAssistActivity exception", e); } } /* access modifiers changed from: protected */ public void a(Activity activity, Intent intent, int i) { a(activity, intent, i, (Map<String, Object>) null); } /* access modifiers changed from: protected */ public void a(Activity activity, Intent intent, int i, Map<String, Object> map) { intent.putExtra(Constants.KEY_REQUEST_CODE, i); try { activity.startActivityForResult(a(activity, intent, map), i); } catch (Exception e) { SLog.e("openSDK_LOG.BaseApi", "startAssitActivity exception", e); } } /* access modifiers changed from: protected */ public void a(Fragment fragment, Intent intent, int i, Map<String, Object> map) { intent.putExtra(Constants.KEY_REQUEST_CODE, i); try { fragment.startActivityForResult(a(fragment.getActivity(), intent, map), i); } catch (Exception e) { SLog.e("openSDK_LOG.BaseApi", "startAssitActivity exception", e); } } /* access modifiers changed from: protected */ public boolean a(Intent intent) { if (intent != null) { return k.b(g.a(), intent); } return false; } /* access modifiers changed from: protected */ public Intent b(String str) { Intent intent = new Intent(); if (m.c(g.a())) { intent.setClassName(Constants.PACKAGE_QQ_PAD, 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(Constants.PACKAGE_TIM, str); if (k.a(g.a(), intent)) { return intent; } return null; } /* access modifiers changed from: protected */ public Intent c() { Intent intent = new Intent(); if (m.c(g.a())) { intent.setClassName(Constants.PACKAGE_QQ_PAD, "com.tencent.open.agent.AgentActivity"); if (k.c(g.a(), intent)) { return intent; } } intent.setClassName("com.tencent.mobileqq", "com.tencent.open.agent.AgentActivity"); if (k.c(g.a(), intent)) { return intent; } intent.setClassName(Constants.PACKAGE_TIM, "com.tencent.open.agent.AgentActivity"); if (k.c(g.a(), intent)) { return intent; } return null; } /* access modifiers changed from: protected */ 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.f1863c).show(); } /* access modifiers changed from: protected */ 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; } /* compiled from: ProGuard */ public class TempRequestListener implements IRequestListener { private final IUiListener b; /* renamed from: c reason: collision with root package name */ private final Handler f1864c; public TempRequestListener(IUiListener iUiListener) { this.b = iUiListener; this.f1864c = 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.f1864c.obtainMessage(); obtainMessage.obj = jSONObject; obtainMessage.what = 0; this.f1864c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onIOException(IOException iOException) { Message obtainMessage = this.f1864c.obtainMessage(); obtainMessage.obj = iOException.getMessage(); obtainMessage.what = -2; this.f1864c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onMalformedURLException(MalformedURLException malformedURLException) { Message obtainMessage = this.f1864c.obtainMessage(); obtainMessage.obj = malformedURLException.getMessage(); obtainMessage.what = -3; this.f1864c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onJSONException(JSONException jSONException) { Message obtainMessage = this.f1864c.obtainMessage(); obtainMessage.obj = jSONException.getMessage(); obtainMessage.what = -4; this.f1864c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onSocketTimeoutException(SocketTimeoutException socketTimeoutException) { Message obtainMessage = this.f1864c.obtainMessage(); obtainMessage.obj = socketTimeoutException.getMessage(); obtainMessage.what = -8; this.f1864c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onNetworkUnavailableException(HttpUtils.NetworkUnavailableException networkUnavailableException) { Message obtainMessage = this.f1864c.obtainMessage(); obtainMessage.obj = networkUnavailableException.getMessage(); obtainMessage.what = -10; this.f1864c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onHttpStatusException(HttpUtils.HttpStatusException httpStatusException) { Message obtainMessage = this.f1864c.obtainMessage(); obtainMessage.obj = httpStatusException.getMessage(); obtainMessage.what = -9; this.f1864c.sendMessage(obtainMessage); } @Override // com.tencent.tauth.IRequestListener public void onUnknowException(Exception exc) { Message obtainMessage = this.f1864c.obtainMessage(); obtainMessage.obj = exc.getMessage(); obtainMessage.what = -6; this.f1864c.sendMessage(obtainMessage); } } }