得物.apk(点击下载) / SocialApiIml.java


package com.tencent.open;

import a.f;
import a30.h;
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.sensorsdata.analytics.android.sdk.SensorsDataAutoTrackHelper;
import com.tencent.connect.auth.QQToken;
import com.tencent.connect.auth.c;
import com.tencent.connect.common.BaseApi;
import com.tencent.connect.common.UIListenerManager;
import com.tencent.open.c.b;
import com.tencent.open.log.SLog;
import com.tencent.open.utils.HttpUtils;
import com.tencent.open.utils.g;
import com.tencent.open.utils.i;
import com.tencent.open.utils.j;
import com.tencent.open.utils.k;
import com.tencent.open.utils.m;
import com.tencent.tauth.DefaultUiListener;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.UiError;
import org.json.JSONException;
import org.json.JSONObject;

/* compiled from: ProGuard */
public class SocialApiIml extends BaseApi {

    /* renamed from: a  reason: collision with root package name */
    private Activity f29327a;

    /* compiled from: ProGuard */
    public class a extends DefaultUiListener {
        private IUiListener b;

        /* renamed from: c  reason: collision with root package name */
        private String f29329c;
        private String d;
        private Bundle e;
        private Activity f;

        public a(Activity activity, IUiListener iUiListener, String str, String str2, Bundle bundle) {
            this.b = iUiListener;
            this.f29329c = str;
            this.d = str2;
            this.e = bundle;
            this.f = activity;
        }

        @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener
        public void onCancel() {
            this.b.onCancel();
        }

        @Override // com.tencent.tauth.IUiListener, com.tencent.tauth.DefaultUiListener
        public void onComplete(Object obj) {
            String str;
            try {
                str = ((JSONObject) obj).getString("encry_token");
            } catch (JSONException e6) {
                e6.printStackTrace();
                SLog.e("openSDK_LOG.SocialApiIml", "OpenApi, EncrytokenListener() onComplete error", e6);
                str = null;
            }
            this.e.putString("encrytoken", str);
            SocialApiIml socialApiIml = SocialApiIml.this;
            socialApiIml.a((SocialApiIml) socialApiIml.f29327a, (Context) this.f29329c, (String) this.e, (Bundle) this.d, (String) this.b);
            if (TextUtils.isEmpty(str)) {
                SLog.d("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, com.tencent.tauth.DefaultUiListener
        public void onError(UiError uiError) {
            StringBuilder h12 = f.h("OpenApi, EncryptTokenListener() onError");
            h12.append(uiError.errorMessage);
            SLog.d("openSDK_LOG.SocialApiIml", h12.toString());
            this.b.onError(uiError);
        }
    }

    public SocialApiIml(QQToken qQToken) {
        super(qQToken);
    }

    public void ask(Activity activity, Bundle bundle, IUiListener iUiListener) {
        a(activity, "action_ask", bundle, iUiListener);
    }

    @Override // com.tencent.connect.common.BaseApi
    public Intent b(String str) {
        Intent intent = new Intent();
        intent.setClassName("com.tencent.minihd.qq", str);
        if (m.c(g.a()) && k.a(g.a(), intent)) {
            return intent;
        }
        Intent intent2 = new Intent();
        intent2.setClassName("com.tencent.mobileqq", str);
        if (k.a(g.a(), intent2) && k.c(g.a(), "4.7") >= 0) {
            return intent2;
        }
        Intent intent3 = new Intent();
        intent3.setClassName("com.qzone", str);
        if (!k.a(g.a(), intent3) || k.a(k.a(g.a(), "com.qzone"), "4.2") < 0) {
            return null;
        }
        if (k.a(g.a(), intent3.getComponent().getPackageName(), "ec96e9ac1149251acbb1b0c5777cae95")) {
            return intent3;
        }
        return null;
    }

    public void gift(Activity activity, Bundle bundle, IUiListener iUiListener) {
        a(activity, "action_gift", bundle, iUiListener);
    }

    public void invite(Activity activity, Bundle bundle, IUiListener iUiListener) {
        this.f29327a = activity;
        Intent c5 = c("com.tencent.open.agent.SocialFriendChooser");
        if (c5 == null) {
            SLog.i("openSDK_LOG.SocialApiIml", "--invite--friend chooser not found");
            c5 = c("com.tencent.open.agent.AppInvitationActivity");
        }
        bundle.putAll(b());
        a(activity, c5, "action_invite", bundle, j.a().a(g.a(), "https://imgcache.qq.com/open/mobile/invite/sdk_invite.html?"), iUiListener, false);
    }

    public void story(Activity activity, Bundle bundle, IUiListener iUiListener) {
        this.f29327a = activity;
        Intent c5 = c("com.tencent.open.agent.SendStoryActivity");
        bundle.putAll(b());
        a(activity, c5, "action_story", bundle, j.a().a(g.a(), "https://imgcache.qq.com/open/mobile/sendstory/sdk_sendstory_v1.3.html?"), iUiListener, false);
    }

    @SuppressLint({"SetJavaScriptEnabled"})
    public void writeEncryToken(Context context) {
        String str;
        String accessToken = this.f27894c.getAccessToken();
        String appId = this.f27894c.getAppId();
        String openId = this.f27894c.getOpenId();
        if (accessToken == null || accessToken.length() <= 0 || appId == null || appId.length() <= 0 || openId == null || openId.length() <= 0) {
            str = null;
        } else {
            str = m.g("tencent&sdk&qazxc***14969%%" + accessToken + appId + openId + "qzone3.4");
        }
        b bVar = new b(context);
        WebSettings settings = bVar.getSettings();
        settings.setDomStorageEnabled(true);
        settings.setDatabaseEnabled(true);
        com.tencent.open.web.a.a(bVar);
        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.f27894c.getOpenId() + "_" + this.f27894c.getAppId() + "\"]=\"" + str + "\";</script></head><body></body></html>";
        String a5 = j.a().a(context, "https://imgcache.qq.com");
        bVar.loadDataWithBaseURL(a5, str2, "text/html", "utf-8", a5);
        SensorsDataAutoTrackHelper.loadDataWithBaseURL2(bVar, a5, str2, "text/html", "utf-8", a5);
    }

    public SocialApiIml(c cVar, QQToken qQToken) {
        super(cVar, qQToken);
    }

    private void a(Activity activity, String str, Bundle bundle, IUiListener iUiListener) {
        this.f29327a = activity;
        Intent c5 = c("com.tencent.open.agent.SocialFriendChooser");
        if (c5 == null) {
            SLog.i("openSDK_LOG.SocialApiIml", "--askgift--friend chooser not found");
            c5 = c("com.tencent.open.agent.RequestFreegiftActivity");
        }
        bundle.putAll(b());
        if ("action_ask".equals(str)) {
            bundle.putString("type", "request");
        } else if ("action_gift".equals(str)) {
            bundle.putString("type", "freegift");
        }
        a(activity, c5, str, bundle, j.a().a(g.a(), "https://imgcache.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 g3 = h.g("-->handleIntent action = ", str, ", activityIntent = null ? ");
        boolean z4 = true;
        g3.append(intent == null);
        SLog.i("openSDK_LOG.SocialApiIml", g3.toString());
        if (intent != null) {
            a(activity, intent, str, bundle, iUiListener);
            return;
        }
        i a5 = i.a(g.a(), this.f27894c.getAppId());
        if (!z && !a5.b("C_LoginH5")) {
            z4 = false;
        }
        if (z4) {
            a(activity, str, bundle, str2, iUiListener);
        } else {
            a(activity, bundle, iUiListener);
        }
    }

    private void a(Activity activity, Intent intent, String str, Bundle bundle, IUiListener iUiListener) {
        SLog.i("openSDK_LOG.SocialApiIml", "-->handleIntentWithAgent action = " + str);
        intent.putExtra("key_action", str);
        intent.putExtra("key_params", bundle);
        UIListenerManager.getInstance().setListenerWithRequestcode(11105, iUiListener);
        a(activity, intent, 11105);
    }

    private void a(Activity activity, String str, Bundle bundle, String str2, IUiListener iUiListener) {
        SLog.i("openSDK_LOG.SocialApiIml", "-->handleIntentWithH5 action = " + str);
        Intent c5 = c();
        a aVar = new a(activity, iUiListener, str, str2, bundle);
        Intent b = b("com.tencent.open.agent.EncryTokenActivity");
        if (b == null || c5 == null || c5.getComponent() == null || b.getComponent() == null || !c5.getComponent().getPackageName().equals(b.getComponent().getPackageName())) {
            SLog.i("openSDK_LOG.SocialApiIml", "-->handleIntentWithH5--token activity not found");
            String g3 = m.g("tencent&sdk&qazxc***14969%%" + this.f27894c.getAccessToken() + this.f27894c.getAppId() + this.f27894c.getOpenId() + "qzone3.4");
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("encry_token", g3);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            aVar.onComplete(jSONObject);
            return;
        }
        b.putExtra("oauth_consumer_key", this.f27894c.getAppId());
        b.putExtra("openid", this.f27894c.getOpenId());
        b.putExtra("access_token", this.f27894c.getAccessToken());
        b.putExtra("key_action", "action_check_token");
        SLog.i("openSDK_LOG.SocialApiIml", "-->handleIntentWithH5--found token activity");
        UIListenerManager.getInstance().setListenerWithRequestcode(11106, aVar);
        a(activity, b, 11106);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(Context context, String str, Bundle bundle, String str2, IUiListener iUiListener) {
        SLog.v("openSDK_LOG.SocialApiIml", "OpenUi, showDialog --start");
        CookieSyncManager.createInstance(context);
        bundle.putString("oauth_consumer_key", this.f27894c.getAppId());
        if (this.f27894c.isSessionValid()) {
            bundle.putString("access_token", this.f27894c.getAccessToken());
        }
        String openId = this.f27894c.getOpenId();
        if (openId != null) {
            bundle.putString("openid", openId);
        }
        try {
            bundle.putString("pf", g.a().getSharedPreferences("pfStore", 0).getString("pf", "openmobile_android"));
        } catch (Exception e) {
            e.printStackTrace();
            bundle.putString("pf", "openmobile_android");
        }
        StringBuilder h12 = f.h(str2);
        h12.append(HttpUtils.encodeUrl(bundle));
        String sb2 = h12.toString();
        SLog.d("openSDK_LOG.SocialApiIml", "OpenUi, showDialog TDialog");
        if ("action_challenge".equals(str) || "action_brag".equals(str)) {
            SLog.d("openSDK_LOG.SocialApiIml", "OpenUi, showDialog PKDialog");
            new d(this.f29327a, str, sb2, iUiListener, this.f27894c).show();
            return;
        }
        new TDialog(this.f29327a, str, sb2, iUiListener, this.f27894c).show();
    }
}