大漢易經書院.apk(点击下载) / j.java


package com.huawei.hms.push;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import android.webkit.URLUtil;
import com.huawei.hms.common.PackageConstants;
import com.huawei.hms.framework.common.ContainerUtils;
import com.huawei.hms.support.log.HMSLog;
import com.huawei.hms.utils.ResourceLoaderUtil;
import com.huawei.hms.utils.Util;
import com.meizu.cloud.pushsdk.constants.PushConstants;
import java.util.ArrayList;

/* compiled from: SelfShowType */
public class j {
    public static final String[] a = {"url", PushConstants.EXTRA_APPLICATION_PENDING_INTENT, "cosa", "rp"};
    public Context b;
    public k c;

    public j(Context context, k kVar) {
        this.b = context;
        this.c = kVar;
    }

    public static boolean b(String str) {
        for (String str2 : a) {
            if (str2.equals(str)) {
                return true;
            }
        }
        return false;
    }

    public final void a() {
        try {
            StringBuilder sb = new StringBuilder();
            sb.append("enter launchApp, appPackageName =");
            sb.append(this.c.d());
            sb.append(",and msg.intentUri is ");
            sb.append(this.c.n());
            HMSLog.i("PushSelfShowLog", sb.toString());
            if (q.c(this.b, this.c.d())) {
                b();
            } else {
                d();
            }
        } catch (Exception e) {
            HMSLog.e("PushSelfShowLog", "launchApp error:" + e.toString());
        }
    }

    public void c() {
        k kVar;
        HMSLog.d("PushSelfShowLog", "enter launchNotify()");
        if (this.b == null || (kVar = this.c) == null) {
            HMSLog.d("PushSelfShowLog", "launchNotify  context or msg is null");
        } else if (PushConstants.EXTRA_APPLICATION_PENDING_INTENT.equals(kVar.i())) {
            a();
        } else if ("cosa".equals(this.c.i())) {
            b();
        } else if ("rp".equals(this.c.i())) {
            HMSLog.w("PushSelfShowLog", this.c.i() + " not support rich message.");
        } else if ("url".equals(this.c.i())) {
            HMSLog.w("PushSelfShowLog", this.c.i() + " not support URL.");
        } else {
            HMSLog.d("PushSelfShowLog", this.c.i() + " is not exist in hShowType");
        }
    }

    public final void d() {
        try {
            StringBuilder sb = new StringBuilder();
            if (!TextUtils.isEmpty(this.c.n())) {
                sb.append("&referrer=");
                sb.append(Uri.encode(a(this.c.n())));
            }
            String str = "market://details?id=" + this.c.d() + ((Object) sb);
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.setData(Uri.parse(str));
            intent.setPackage(PackageConstants.SERVICES_PACKAGE_APPMARKET);
            Intent intent2 = new Intent("android.intent.action.VIEW");
            intent2.setData(Uri.parse(str));
            intent2.setPackage("com.android.vending");
            if (q.a(this.b, "com.android.vending", intent2).booleanValue()) {
                intent2.setFlags(402653184);
                HMSLog.i("PushSelfShowLog", "open google play store's app detail, IntentUrl is:" + intent2.toURI());
                this.b.startActivity(intent2);
            } else if (q.a(this.b, PackageConstants.SERVICES_PACKAGE_APPMARKET, intent).booleanValue()) {
                intent.setFlags(402653184);
                HMSLog.i("PushSelfShowLog", "open HiApp's app detail, IntentUrl is:" + intent.toURI());
                this.b.startActivity(intent);
            } else {
                HMSLog.i("PushSelfShowLog", "open app detail by browser.");
                e();
            }
        } catch (Exception e) {
            HMSLog.e("PushSelfShowLog", "open market app detail failed,exception:" + e);
        }
    }

    /* JADX WARNING: Can't wrap try/catch for region: R(9:1|2|3|(2:4|5)|8|9|10|11|12) */
    /* JADX WARNING: Code restructure failed: missing block: B:13:0x002a, code lost:
        r0 = e;
     */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0026 */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x0095  */
    public final void e() {
        String str;
        String str2;
        String str3 = "";
        try {
            Uri parse = Uri.parse(Uri.decode(this.c.n()));
            try {
                str = parse.getQueryParameter("h_w_hiapp_referrer");
            } catch (Exception unused) {
                HMSLog.i("PushSelfShowLog", "parse h_w_hiapp_referrer failed");
                str = str3;
            }
            str3 = parse.getQueryParameter("h_w_gp_referrer");
            HMSLog.i("PushSelfShowLog", "parse h_w_hiapp_referrer failed");
        } catch (Exception e) {
            Exception e2 = e;
            str = str3;
            HMSLog.w("PushSelfShowLog", "parse intentUri error." + e2.toString());
            if (Util.isEMUI()) {
            }
            HMSLog.i("PushSelfShowLog", "not EMUI system or not in China, open google play web, referrer: " + str3);
            str2 = Uri.decode(str3);
            if (!URLUtil.isValidUrl(str2)) {
            }
            HMSLog.i("PushSelfShowLog", "open the URL by browser: " + str2);
            q.e(this.b, str2);
        }
        if (Util.isEMUI() || !Util.isChinaROM()) {
            HMSLog.i("PushSelfShowLog", "not EMUI system or not in China, open google play web, referrer: " + str3);
            str2 = Uri.decode(str3);
            if (!URLUtil.isValidUrl(str2)) {
                ResourceLoaderUtil.setmContext(this.b);
                str2 = ResourceLoaderUtil.getString("hms_push_google") + this.c.d();
            }
        } else {
            HMSLog.i("PushSelfShowLog", "It is China device, open Huawei market web, referrer: " + str);
            str2 = Uri.decode(str);
            if (!URLUtil.isValidUrl(str2)) {
                Context context = this.b;
                if (context != null) {
                    ResourceLoaderUtil.setmContext(context);
                    str2 = ResourceLoaderUtil.getString("hms_push_vmall");
                } else {
                    str2 = null;
                }
            }
        }
        HMSLog.i("PushSelfShowLog", "open the URL by browser: " + str2);
        q.e(this.b, str2);
    }

    public final void b() {
        HMSLog.i("PushSelfShowLog", "run into launchCosaApp");
        try {
            StringBuilder sb = new StringBuilder();
            sb.append("enter launchExistApp cosa, appPackageName =");
            sb.append(this.c.d());
            sb.append(",and msg.intentUri is ");
            sb.append(this.c.n());
            HMSLog.i("PushSelfShowLog", sb.toString());
            Intent b2 = q.b(this.b, this.c.d());
            boolean z = false;
            if (this.c.n() != null) {
                try {
                    Intent parseUri = Intent.parseUri(this.c.n(), 0);
                    parseUri.setSelector(null);
                    StringBuilder sb2 = new StringBuilder();
                    sb2.append("Intent.parseUri(msg.intentUri, 0), action:");
                    sb2.append(parseUri.getAction());
                    HMSLog.i("PushSelfShowLog", sb2.toString());
                    z = q.a(this.b, this.c.d(), parseUri).booleanValue();
                    if (z) {
                        b2 = parseUri;
                    }
                } catch (Exception e) {
                    HMSLog.w("PushSelfShowLog", "intentUri error." + e.toString());
                }
            } else {
                if (this.c.a() != null) {
                    Intent intent = new Intent(this.c.a());
                    if (q.a(this.b, this.c.d(), intent).booleanValue()) {
                        b2 = intent;
                    }
                }
                b2.setPackage(this.c.d());
            }
            if (b2 == null) {
                HMSLog.i("PushSelfShowLog", "launchCosaApp,intent == null");
                return;
            }
            if (z) {
                b2.addFlags(268435456);
            } else {
                b2.setFlags(805437440);
            }
            HMSLog.i("PushSelfShowLog", "start " + b2.toURI());
            this.b.startActivity(b2);
        } catch (Exception e2) {
            HMSLog.e("PushSelfShowLog", "launch Cosa App exception." + e2.toString());
        }
    }

    public final String a(String str) {
        try {
            int indexOf = str.indexOf(63);
            if (indexOf == -1) {
                return str;
            }
            int i = indexOf + 1;
            String[] split = str.substring(i).split(ContainerUtils.FIELD_DELIMITER);
            ArrayList arrayList = new ArrayList();
            for (String str2 : split) {
                if (!str2.startsWith("h_w_hiapp_referrer") && !str2.startsWith("h_w_gp_referrer")) {
                    arrayList.add(str2);
                }
            }
            StringBuilder sb = new StringBuilder();
            int size = arrayList.size();
            for (int i2 = 0; i2 < size; i2++) {
                sb.append((String) arrayList.get(i2));
                if (i2 < arrayList.size() - 1) {
                    sb.append(ContainerUtils.FIELD_DELIMITER);
                }
            }
            String substring = arrayList.size() == 0 ? str.substring(0, indexOf) : str.substring(0, i) + sb.toString();
            HMSLog.d("PushSelfShowLog", "after delete referrer, the new IntentUri is:" + substring);
            return substring;
        } catch (Exception e) {
            HMSLog.e("PushSelfShowLog", "delete referrer exception." + e.toString());
            return str;
        }
    }
}