翰林优商.apk(点击下载) / c.java


package com.mbridge.msdk.click;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.text.TextUtils;
import android.view.ContextThemeWrapper;
import android.webkit.MimeTypeMap;
import android.widget.Toast;
import com.mbridge.msdk.MBridgeConstans;
import com.mbridge.msdk.c.a;
import com.mbridge.msdk.foundation.controller.a;
import com.mbridge.msdk.foundation.db.e;
import com.mbridge.msdk.foundation.db.i;
import com.mbridge.msdk.foundation.entity.CampaignEx;
import com.mbridge.msdk.foundation.entity.f;
import com.mbridge.msdk.foundation.same.f.b;
import com.mbridge.msdk.foundation.same.report.d;
import com.mbridge.msdk.foundation.tools.SameMD5;
import com.mbridge.msdk.foundation.tools.ac;
import com.mbridge.msdk.foundation.tools.af;
import com.mbridge.msdk.foundation.tools.n;
import com.mbridge.msdk.foundation.tools.r;
import com.mbridge.msdk.foundation.tools.s;
import com.mbridge.msdk.foundation.tools.w;
import com.mbridge.msdk.mbbid.common.BidResponsedEx;
import com.umeng.commonsdk.framework.UMModuleRegister;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;

/* compiled from: CommonClickUtil */
public class c {
    static Handler a = new Handler(Looper.getMainLooper()) {
        /* class com.mbridge.msdk.click.c.AnonymousClass1 */

        public final void handleMessage(Message message) {
            String str;
            String str2;
            String str3;
            super.handleMessage(message);
            try {
                if (message.what == 1000) {
                    int i = message.arg1;
                    int i2 = message.arg2;
                    Bundle data = message.getData();
                    if (data != null) {
                        String string = data.getString("rid");
                        String string2 = data.getString("rid_n");
                        str = data.getString(BidResponsedEx.KEY_CID);
                        str3 = string;
                        str2 = string2;
                    } else {
                        str3 = "";
                        str2 = str3;
                        str = str2;
                    }
                    new d(a.f().j()).a(i, i2, str3, str2, str);
                }
            } catch (Throwable th) {
                if (MBridgeConstans.DEBUG) {
                    th.printStackTrace();
                }
            }
        }
    };
    private static volatile boolean b = false;

    public static String a(String str) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        if (str.lastIndexOf("/") == -1) {
            return str.hashCode() + "";
        }
        return (str.hashCode() + str.substring(str.lastIndexOf("/") + 1).hashCode()) + "";
    }

    public static void a(Context context, String str) {
        if (str != null && context != null) {
            try {
                Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
                intent.addFlags(268435456);
                ResolveInfo resolveActivity = context.getPackageManager().resolveActivity(intent, 65536);
                if (resolveActivity != null) {
                    intent.setClassName(resolveActivity.activityInfo.packageName, resolveActivity.activityInfo.name);
                }
                context.startActivity(intent);
            } catch (Exception e) {
                e.printStackTrace();
                try {
                    Intent intent2 = new Intent("android.intent.action.VIEW", Uri.parse(str));
                    intent2.addFlags(268435456);
                    context.startActivity(intent2);
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            }
        }
    }

    public static void b(Context context, String str) {
        if (context != null && str != null) {
            try {
                Class.forName("com.mbridge.msdk.activity.MBCommonActivity");
                Intent intent = new Intent(context, Class.forName("com.mbridge.msdk.activity.MBCommonActivity"));
                intent.putExtra("url", str);
                if (!(context instanceof ContextThemeWrapper)) {
                    intent.setFlags(268435456);
                }
                context.startActivity(intent);
            } catch (ClassNotFoundException e) {
                w.d("CommonClickUtil", e.getMessage());
            } catch (Throwable th) {
                w.d("CommonClickUtil", th.getMessage());
            }
        }
    }

    public static void a(Activity activity, int i, boolean z, Context context) {
        w.a("======", "======onActivityStarted:" + i + "---" + z);
        if (Build.VERSION.SDK_INT >= 29 && !z && i == 0) {
            w.a("======", "======onActivityStarted:inner");
            f a2 = e.a(i.a(context)).a();
            if (a2 != null) {
                w.a("======", "======dlinfo:" + a2.toString());
                String a3 = a2.a();
                if (!TextUtils.isEmpty(a3)) {
                    File file = new File(a3);
                    if (file.exists()) {
                        String c = a2.c();
                        a(context, Uri.fromFile(file), a2.b(), a2.c());
                        com.mbridge.msdk.foundation.same.report.e.a(context, c, a2.d(), a2.e(), a2.f(), a2.h(), a2.g());
                    }
                }
            }
        }
    }

    public static void c(Context context, String str) {
        e a2 = e.a(i.a(context));
        int c = a2.c(str);
        if ((Build.VERSION.SDK_INT >= 29 && a.f().b() == 0) && c == 1) {
            a2.a(str);
        }
        if (c == 10) {
            a2.a(str, 11);
        }
    }

    public static boolean a(CampaignEx campaignEx) {
        if (campaignEx != null) {
            String akdlui = campaignEx.getAkdlui();
            if (TextUtils.isEmpty(akdlui)) {
                akdlui = SameMD5.getMD5(campaignEx.getClickURL());
            }
            String obj = ac.b(a.f().j(), akdlui, "").toString();
            if (!TextUtils.isEmpty(obj)) {
                return !new File(obj).exists();
            }
            Context j = a.f().j();
            int intValue = ((Integer) ac.b(j, akdlui + UMModuleRegister.PROCESS, 0)).intValue();
            int myPid = Process.myPid();
            if (intValue != 0 && intValue == myPid) {
                Context j2 = a.f().j();
                if (((Long) ac.b(j2, akdlui + "isDowning", 0L)).longValue() != 0) {
                    return false;
                }
            }
        }
        return true;
    }

    /* JADX WARNING: Missing exception handler attribute for start block: B:57:0x0182 */
    public static void a(Context context, Uri uri, String str, String str2) {
        File file;
        int intValue;
        int intValue2;
        String str3;
        String str4;
        StringBuilder sb;
        Class<?> cls;
        if (b) {
            synchronized (c.class) {
                if (b) {
                    return;
                }
            }
        }
        b = true;
        Uri uri2 = null;
        try {
            file = new File(new URI(uri.toString()));
        } catch (URISyntaxException e) {
            e.printStackTrace();
            file = null;
        }
        Intent intent = new Intent();
        intent.addFlags(268435456);
        intent.setAction("android.intent.action.VIEW");
        try {
            if (!af.b(context)) {
                b(context, str, str2);
            } else if (af.d(context)) {
                if (Build.VERSION.SDK_INT >= 24) {
                    try {
                        if (!TextUtils.isEmpty(MBridgeConstans.FILE_PROVIDE_CUSTOM_PATH)) {
                            cls = Class.forName(MBridgeConstans.FILE_PROVIDE_CUSTOM_PATH);
                        } else {
                            cls = Class.forName("com.mbridge.msdk.foundation.tools.MBFileProvider");
                        }
                        uri2 = (Uri) cls.getMethod("getUriForFile", Context.class, String.class, File.class).invoke(null, context, context.getApplicationContext().getPackageName() + ".mbFileProvider", file);
                    } catch (ClassNotFoundException e2) {
                        e2.printStackTrace();
                    } catch (NoSuchMethodException e3) {
                        e3.printStackTrace();
                    } catch (SecurityException e4) {
                        e4.printStackTrace();
                    } catch (IllegalAccessException e5) {
                        e5.printStackTrace();
                    } catch (IllegalArgumentException e6) {
                        e6.printStackTrace();
                    } catch (InvocationTargetException e7) {
                        e7.printStackTrace();
                    }
                    if (uri2 != null) {
                        intent.addFlags(1);
                        intent.setDataAndType(uri2, context.getContentResolver().getType(uri2));
                        c(context, str2);
                        context.startActivity(intent);
                    } else {
                        b(context, str, str2);
                    }
                } else {
                    intent.setDataAndType(Uri.fromFile(file), a(file));
                    c(context, str2);
                    context.startActivity(intent);
                }
            } else if (af.e(context)) {
                b(context, str, str2);
            } else {
                intent.setDataAndType(Uri.fromFile(file), a(file));
                c(context, str2);
                context.startActivity(intent);
            }
            b = false;
            intValue = ((Integer) ac.b(context, str2 + "downloadType", -1)).intValue();
            intValue2 = ((Integer) ac.b(context, str2 + "linkType", -1)).intValue();
            str3 = (String) ac.b(context, str2 + "rid", "");
            str4 = (String) ac.b(context, str2 + "rid_n", "");
            sb = new StringBuilder();
        } catch (Exception e8) {
            e8.printStackTrace();
            b(context, str, str2);
            b = false;
            intValue = ((Integer) ac.b(context, str2 + "downloadType", -1)).intValue();
            intValue2 = ((Integer) ac.b(context, str2 + "linkType", -1)).intValue();
            str3 = (String) ac.b(context, str2 + "rid", "");
            str4 = (String) ac.b(context, str2 + "rid_n", "");
            sb = new StringBuilder();
        } catch (Throwable unknown) {
            try {
                b(context, str, str2);
                b = false;
                intValue = ((Integer) ac.b(context, str2 + "downloadType", -1)).intValue();
                intValue2 = ((Integer) ac.b(context, str2 + "linkType", -1)).intValue();
                str3 = (String) ac.b(context, str2 + "rid", "");
                str4 = (String) ac.b(context, str2 + "rid_n", "");
                sb = new StringBuilder();
            } catch (Throwable th) {
                b = false;
                a(((Integer) ac.b(context, str2 + "downloadType", -1)).intValue(), ((Integer) ac.b(context, str2 + "linkType", -1)).intValue(), (String) ac.b(context, str2 + "rid", ""), (String) ac.b(context, str2 + "rid_n", ""), (String) ac.b(context, str2 + BidResponsedEx.KEY_CID, ""));
                throw th;
            }
        }
        sb.append(str2);
        sb.append(BidResponsedEx.KEY_CID);
        a(intValue, intValue2, str3, str4, (String) ac.b(context, sb.toString(), ""));
    }

    private static void a(int i, int i2, String str, String str2, String str3) {
        try {
            if (Looper.myLooper() == Looper.getMainLooper()) {
                new d(a.f().j()).a(i, i2, str, str2, str3);
                return;
            }
            Message obtain = Message.obtain();
            obtain.what = 1000;
            obtain.arg1 = i;
            obtain.arg2 = i2;
            Bundle bundle = new Bundle();
            bundle.putString("rid", str);
            bundle.putString("rid_n", str2);
            bundle.putString(BidResponsedEx.KEY_CID, str3);
            obtain.setData(bundle);
            a.sendMessage(obtain);
        } catch (Throwable th) {
            if (MBridgeConstans.DEBUG) {
                th.printStackTrace();
            }
        }
    }

    public static void a(Context context, String str, String str2) {
        try {
            Context j = a.f().j();
            ac.a(j, str2 + "downloadType", 3);
            a(context, str);
            int intValue = ((Integer) ac.b(context, str2 + "downloadType", -1)).intValue();
            int intValue2 = ((Integer) ac.b(context, str2 + "linkType", -1)).intValue();
            a(intValue, intValue2, (String) ac.b(context, str2 + "rid", ""), (String) ac.b(context, str2 + "rid_n", ""), (String) ac.b(context, str2 + BidResponsedEx.KEY_CID, ""));
        } catch (Throwable th) {
            if (MBridgeConstans.DEBUG) {
                th.printStackTrace();
            }
        }
    }

    private static void b(Context context, String str, String str2) {
        try {
            Context j = a.f().j();
            ac.a(j, str2 + "downloadType", 3);
            a(context, str);
        } catch (Throwable th) {
            if (MBridgeConstans.DEBUG) {
                th.printStackTrace();
            }
        }
    }

    private static String a(File file) {
        String name = file.getName();
        return MimeTypeMap.getSingleton().getMimeTypeFromExtension(name.substring(name.lastIndexOf(".") + 1, name.length()).toLowerCase());
    }

    public static boolean d(Context context, String str) {
        if (str != null && !"".equals(str)) {
            try {
                PackageInfo packageInfo = context.getPackageManager().getPackageInfo(str, 8192);
                if (packageInfo != null) {
                    return str.equals(packageInfo.packageName);
                }
            } catch (Exception unused) {
            }
        }
        return false;
    }

    public static boolean e(Context context, String str) {
        try {
            if (TextUtils.isEmpty(str)) {
                return false;
            }
            Uri parse = Uri.parse(str);
            Intent intent = new Intent("android.intent.action.VIEW", parse);
            intent.setData(parse);
            if ((parse.getScheme().startsWith(r.b("L7QthdSsLkP8")) || n.a().a(str)) && a(context, intent)) {
                return true;
            }
            intent.setFlags(268435456);
            context.startActivity(intent);
            return true;
        } catch (Throwable th) {
            w.b("SDKCLICK", th.getMessage(), th);
            return false;
        }
    }

    private static boolean a(Context context, Intent intent) {
        try {
            if (context instanceof Activity) {
                context.startActivity(intent);
                return true;
            } else if (a.f().c() == null) {
                return false;
            } else {
                a.f().c().startActivity(intent);
                return true;
            }
        } catch (Throwable th) {
            w.b("SDKCLICK", th.getMessage(), th);
            return false;
        }
    }

    public static void b(final CampaignEx campaignEx) {
        b.a().execute(new Runnable() {
            /* class com.mbridge.msdk.click.c.AnonymousClass2 */

            public final void run() {
                try {
                    CampaignEx campaignEx = CampaignEx.this;
                    if (campaignEx != null && !TextUtils.isEmpty(campaignEx.getDeepLinkURL())) {
                        String deepLinkURL = CampaignEx.this.getDeepLinkURL();
                        if (Uri.parse(deepLinkURL).getScheme().startsWith(r.b("L7QthdSsLkP8")) || n.a().a(deepLinkURL)) {
                            e.a(i.a(a.f().j())).a(CampaignEx.this);
                        }
                    }
                } catch (Throwable th) {
                    w.d("SDKCLICK", th.getMessage());
                }
            }
        });
    }

    public static void f(Context context, String str) {
        Intent launchIntentForPackage;
        List<ResolveInfo> queryIntentActivities;
        ResolveInfo next;
        try {
            if (!TextUtils.isEmpty(str) && d(context, str) && (launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(str)) != null && (queryIntentActivities = context.getPackageManager().queryIntentActivities(launchIntentForPackage, 0)) != null && queryIntentActivities.size() > 0 && (next = queryIntentActivities.iterator().next()) != null) {
                ComponentName componentName = new ComponentName(next.activityInfo.packageName, next.activityInfo.name);
                Intent intent = new Intent();
                intent.setComponent(componentName);
                intent.addFlags(268435456);
                context.startActivity(intent);
            }
        } catch (Exception e) {
            Toast.makeText(context, "The app connot start up", 0).show();
            e.printStackTrace();
        }
    }

    private static String a(String str, List<String> list, String str2) {
        if (list != null) {
            for (String str3 : list) {
                if (!TextUtils.isEmpty(str3)) {
                    str = str.replaceAll(str3, str2);
                }
            }
        }
        return str;
    }

    public static String a(String str, String str2, String str3) {
        Map<String, a.C0196a> ay;
        try {
            if (TextUtils.isEmpty(str)) {
                return str;
            }
            String host = Uri.parse(str).getHost();
            com.mbridge.msdk.c.a b2 = com.mbridge.msdk.c.b.a().b(com.mbridge.msdk.foundation.controller.a.f().k());
            if (b2 == null || (ay = b2.ay()) == null || TextUtils.isEmpty(host)) {
                return str;
            }
            for (Map.Entry<String, a.C0196a> entry : ay.entrySet()) {
                String key = entry.getKey();
                if (!TextUtils.isEmpty(key) && host.contains(key)) {
                    a.C0196a aVar = ay.get(key);
                    return a(a(a(a(str, aVar.d(), String.valueOf((float) s.y(com.mbridge.msdk.foundation.controller.a.f().j()))), aVar.c(), String.valueOf((float) s.x(com.mbridge.msdk.foundation.controller.a.f().j()))), aVar.a(), str2), aVar.b(), str3);
                }
            }
            return str;
        } catch (Exception e) {
            e.printStackTrace();
            return str;
        }
    }
}