package cn.jpush.android.j; import android.app.Activity; import android.app.Service; import android.content.BroadcastReceiver; import android.content.ContentProvider; import android.content.Context; import android.content.pm.ComponentInfo; import android.content.pm.PackageInfo; import android.os.Build; import android.text.TextUtils; import cn.jpush.android.i.b; public final class a { private static String a = ""; private static String b = ""; private static final String c = "".toLowerCase(); public static ComponentInfo a(Context context, String str, Class<?> cls) { ComponentInfo[] componentInfoArr; if (context == null || TextUtils.isEmpty(str)) { b.d("AndroidUtils", "Action - hasComponent, invalide param, context:" + context + ",packageName:" + str + ",cls:" + cls); return null; } try { int i = Service.class.isAssignableFrom(cls) ? 4 : BroadcastReceiver.class.isAssignableFrom(cls) ? 2 : Activity.class.isAssignableFrom(cls) ? 1 : ContentProvider.class.isAssignableFrom(cls) ? 8 : 0; PackageInfo packageInfo = context.getPackageManager().getPackageInfo(str, i); if (i == 4) { componentInfoArr = packageInfo.services; } else if (i != 8) { switch (i) { case 1: componentInfoArr = packageInfo.activities; break; case 2: componentInfoArr = packageInfo.receivers; break; default: componentInfoArr = null; break; } } else { componentInfoArr = packageInfo.providers; } if (componentInfoArr == null) { return null; } for (ComponentInfo componentInfo : componentInfoArr) { try { if (cls.isAssignableFrom(Class.forName(componentInfo.name))) { return componentInfo; } } catch (Throwable th) { b.d("AndroidUtils", "check component e:" + th); } } return null; } catch (Throwable th2) { b.e("AndroidUtils", "hasComponent error:" + th2); } } public static boolean a(Context context) { String str; String str2; if (context == null) { str = "AndroidUtils"; str2 = "context was null"; } else { String str3 = null; try { str3 = Build.MANUFACTURER; b.a("AndroidUtils", "MANUFACTURER:" + str3); } catch (Throwable th) { b.e("AndroidUtils", "get MANUFACTURER failed - error:" + th); } if (!TextUtils.isEmpty(str3)) { return TextUtils.isEmpty(c) || TextUtils.equals(c, str3.toLowerCase()); } str = "AndroidUtils"; str2 = "MANUFACTURER was empty"; } b.e(str, str2); return false; } }