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


package com.huawei.updatesdk.b.h;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.text.TextUtils;
import com.huawei.updatesdk.a.a.d.d;
import java.io.File;
import java.lang.Thread;
import java.lang.reflect.Field;

public class b {
    private static Integer a = null;
    private static boolean b = false;
    private static boolean c = false;
    private static Field d;

    static class a implements Thread.UncaughtExceptionHandler {
        a() {
        }

        public final void uncaughtException(Thread thread, Throwable th) {
            com.huawei.updatesdk.a.a.c.a.a.a.a("PackageUtils", thread.getName() + " : " + th.getMessage());
        }
    }

    /* renamed from: com.huawei.updatesdk.b.h.b$b  reason: collision with other inner class name */
    public enum EnumC0078b {
        NOT_INSTALLED,
        INSTALLED,
        INSTALLED_LOWCODE
    }

    private static class c implements Runnable {
        private c() {
        }

        /* synthetic */ c(a aVar) {
            this();
        }

        public void run() {
            com.huawei.updatesdk.a.a.c.a.a.a.a("PackageManagerRunnable", "PackageManagerRunnable run!!!!");
            d.a(new File(com.huawei.updatesdk.b.d.d.b()));
        }
    }

    public static int a(PackageInfo packageInfo) {
        ApplicationInfo applicationInfo = packageInfo.applicationInfo;
        if ((applicationInfo.flags & 1) == 0) {
            return 0;
        }
        return a(applicationInfo) ? 1 : 2;
    }

    public static int a(String str) {
        ApplicationInfo applicationInfo;
        try {
            PackageInfo packageInfo = com.huawei.updatesdk.a.b.a.a.c().a().getPackageManager().getPackageInfo(str, 128);
            return (packageInfo == null || (applicationInfo = packageInfo.applicationInfo) == null || applicationInfo.metaData == null || !packageInfo.applicationInfo.metaData.containsKey("com.huawei.maple.flag")) ? 0 : 1;
        } catch (Exception unused) {
            com.huawei.updatesdk.a.a.c.a.a.a.d("PackageUtils", "getMapleStatus not found: " + str);
            return 0;
        }
    }

    public static PackageInfo a(String str, Context context) {
        try {
            return context.getPackageManager().getPackageInfo(str, 64);
        } catch (Exception unused) {
            com.huawei.updatesdk.a.a.c.a.a.a.d("PackageUtils", "not found: " + str);
            return null;
        }
    }

    public static EnumC0078b a(Context context, String str) {
        EnumC0078b bVar = EnumC0078b.NOT_INSTALLED;
        if (context == null) {
            return bVar;
        }
        try {
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo(str, 0);
            if (packageInfo == null) {
                return bVar;
            }
            com.huawei.updatesdk.a.a.a.b("PackageUtils", "appmarket info,versioncode = " + packageInfo.versionCode + "versioncode = " + packageInfo.versionName);
            return packageInfo.versionCode < 70203000 ? EnumC0078b.INSTALLED_LOWCODE : EnumC0078b.INSTALLED;
        } catch (Exception e) {
            com.huawei.updatesdk.a.a.c.a.a.a.d("PackageUtils", "isInstallByPackage Exception:" + e.toString());
            return bVar;
        }
    }

    public static void a() {
        Thread thread = new Thread(new c(null));
        thread.setName("delete market file task");
        thread.setUncaughtExceptionHandler(new a());
        thread.start();
    }

    public static boolean a(Context context, String str, boolean z) {
        return z || b(context, str) > 90000000;
    }

    private static boolean a(ApplicationInfo applicationInfo) {
        String str;
        StringBuilder sb;
        int i = applicationInfo.flags;
        Integer c2 = c();
        if (c2 != null && (i & c2.intValue()) != 0) {
            return true;
        }
        Field b2 = b();
        if (b2 == null) {
            return false;
        }
        try {
            return (b2.getInt(applicationInfo) & 33554432) != 0;
        } catch (IllegalAccessException e) {
            sb = new StringBuilder("can not get hwflags");
            str = e.toString();
            sb.append(str);
            com.huawei.updatesdk.a.a.c.a.a.a.a("PackageUtils", sb.toString());
            return false;
        } catch (IllegalArgumentException e2) {
            sb = new StringBuilder("can not get hwflags");
            str = e2.toString();
            sb.append(str);
            com.huawei.updatesdk.a.a.c.a.a.a.a("PackageUtils", sb.toString());
            return false;
        }
    }

    private static int b(Context context, String str) {
        try {
            return context.getPackageManager().getPackageInfo(str, 0).versionCode;
        } catch (Exception e) {
            com.huawei.updatesdk.a.a.c.a.a.a.d("PackageUtils", "isInstallByPackage:" + e.toString());
            return 0;
        }
    }

    public static Field b() {
        if (c) {
            return d;
        }
        try {
            d = ApplicationInfo.class.getField("hwFlags");
        } catch (NoSuchFieldException unused) {
            com.huawei.updatesdk.a.a.c.a.a.a.a("PackageUtils", "can not find hwFlags");
        }
        c = true;
        return d;
    }

    public static boolean b(Context context, String str, boolean z) {
        return z || b(context, str) > 100200000;
    }

    public static Integer c() {
        String str;
        StringBuilder sb;
        String str2;
        if (b) {
            return a;
        }
        try {
            Class<?> cls = Class.forName("android.content.pm.PackageParser");
            a = Integer.valueOf(cls.getDeclaredField("PARSE_IS_REMOVABLE_PREINSTALLED_APK").getInt(cls));
        } catch (NoSuchFieldException e) {
            sb = new StringBuilder("isDelApp error NoSuchFieldException:");
            str2 = e.toString();
        } catch (ClassNotFoundException e2) {
            sb = new StringBuilder("isDelApp error ClassNotFoundException:");
            str2 = e2.toString();
        } catch (IllegalAccessException e3) {
            sb = new StringBuilder("isDelApp error IllegalAccessException:");
            str2 = e3.toString();
        } catch (IllegalArgumentException e4) {
            sb = new StringBuilder("isDelApp error IllegalArgumentException:");
            str2 = e4.toString();
        } catch (Exception e5) {
            str = e5.toString();
            com.huawei.updatesdk.a.a.c.a.a.a.a("PackageUtils", str);
            b = true;
            return a;
        }
        b = true;
        return a;
        sb.append(str2);
        str = sb.toString();
        com.huawei.updatesdk.a.a.c.a.a.a.a("PackageUtils", str);
        b = true;
        return a;
    }

    public static String c(Context context, String str) {
        String str2;
        try {
            str2 = context.getPackageManager().getInstallerPackageName(str);
        } catch (Exception unused) {
            com.huawei.updatesdk.a.a.a.b("PackageUtils", "can not find installer pkg." + str);
            str2 = null;
        }
        com.huawei.updatesdk.a.a.c.a.a.a.c("PackageUtils", "installer pkg: " + str2);
        return str2;
    }

    public static boolean d(Context context, String str) {
        if (context != null && !TextUtils.isEmpty(str)) {
            try {
                return context.getPackageManager().getPackageInfo(str, 0) != null;
            } catch (Exception e) {
                com.huawei.updatesdk.a.a.c.a.a.a.d("PackageUtils", "isAppInstalled NameNotFoundException:" + e.toString());
            }
        }
        return false;
    }
}