package cn.jpush.android.asus; import android.content.BroadcastReceiver; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.pm.PackageInfo; import android.os.Build; import android.text.TextUtils; import cn.jpush.android.c.b; import cn.jpush.android.cache.Key; import cn.jpush.android.cache.Sp; import cn.jpush.android.e.c; import cn.jpush.android.helper.JCoreHelper; import cn.jpush.android.helper.Logger; public class a { public static final String a = "asus".toLowerCase(); public static String b = ""; private static boolean c; private static boolean d; private static String e = null; private static ActivityInfo a(Context context, String str, Class<? extends BroadcastReceiver> cls) { if (context == null || TextUtils.isEmpty(str) || cls == null) { Logger.w("AsusPushHelper", "Action - hasComponent, invalid param, context:" + context + ",packageName:" + str + ",cls:" + cls); return null; } try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo(str, 2); if (packageInfo.receivers != null) { if (packageInfo.receivers.length != 0) { ActivityInfo[] activityInfoArr = packageInfo.receivers; for (ActivityInfo activityInfo : activityInfoArr) { try { if (cls.isAssignableFrom(Class.forName(activityInfo.name)) && activityInfo.enabled) { return activityInfo; } } catch (Throwable unused) { } } return null; } } return null; } catch (Throwable th) { Logger.ww("AsusPushHelper", "getReceiver error:" + th); } } private static boolean a() { boolean equalsIgnoreCase = "asus".equalsIgnoreCase(Build.BRAND); return !equalsIgnoreCase ? "asus".equalsIgnoreCase(Build.MANUFACTURER) : equalsIgnoreCase; } public static boolean a(Context context) { b(context); return c; } public static synchronized void b(Context context) { synchronized (a.class) { if (!d) { if (context == null) { Logger.ww("AsusPushHelper", "context is null"); return; } if (i(context) && (b.a(context) || a())) { c = true; } StringBuilder sb = new StringBuilder(); sb.append(c ? "support " : "not support "); sb.append(a); Logger.d("AsusPushHelper", sb.toString()); d = true; } } } public static void c(final Context context) { try { b(context); if (c) { b.a(context, e(context), new c() { /* class cn.jpush.android.asus.a.AnonymousClass1 */ public void a(cn.jpush.android.e.b bVar) { try { Logger.dd("AsusPushHelper", "tokenResult:" + bVar); cn.jpush.android.t.c.a().a(context, (byte) 6, bVar.a()); } catch (Throwable unused) { } } }); } } catch (Throwable th) { Logger.w("AsusPushHelper", "register error:" + th.getMessage()); } } public static byte d(Context context) { return 6; } public static String e(Context context) { return !TextUtils.isEmpty(b) ? b : JCoreHelper.getAppKey(context); } public static String f(Context context) { return ""; } public static String g(Context context) { return b.d(context); } public static boolean h(Context context) { Key[] keyArr; String str; String str2; String e2 = e(context); if (TextUtils.isEmpty(e2)) { str = "AsusPushHelper"; str2 = a + " appkey or appid is empty,need not clear plugin rid"; } else { String appKey = JCoreHelper.getAppKey(context); if (TextUtils.isEmpty(appKey)) { str = "AsusPushHelper"; str2 = "jpush appkey is empty,need not clear plugin rid"; } else { String str3 = (String) Sp.get(context, Key.ThirdPush_ClearFlag()); String md5 = b.toMD5(e2 + appKey + JCoreHelper.getJCoreSDKVersionInt() + JCoreHelper.getJPushSDKVersionInt()); if (TextUtils.isEmpty(str3)) { keyArr = new Key[]{Key.ThirdPush_ClearFlag().set(md5)}; } else if (TextUtils.isEmpty(md5)) { return true; } else { if (TextUtils.equals(str3, md5)) { return false; } Logger.d("AsusPushHelper", "local set changed,re bind token"); keyArr = new Key[]{Key.ThirdPush_ClearFlag().set(md5)}; } Sp.set(context, keyArr); return true; } } Logger.ii(str, str2); return false; } private static boolean i(Context context) { ActivityInfo a2 = a(context, context.getPackageName(), AsusPushMessageReceiver.class); if (a2 != null) { Logger.d("AsusPushHelper", "found receiver:" + a2.name); return true; } Logger.ww("AsusPushHelper", "AndroidManifest.xml missing receiver extends asus's AsusPushMessageReceiver"); return false; } }