package cn.jpush.android.p; import android.annotation.TargetApi; import android.app.AppOpsManager; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Icon; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.service.notification.StatusBarNotification; import android.text.TextUtils; import android.widget.RemoteViews; import androidx.core.view.PointerIconCompat; import cn.jpush.android.api.JPushInterface; import cn.jpush.android.api.NotificationMessage; import cn.jpush.android.api.PushNotificationBuilder; import cn.jpush.android.cache.Key; import cn.jpush.android.cache.Sp; import cn.jpush.android.d.d; import cn.jpush.android.helper.JCoreHelper; import cn.jpush.android.helper.Logger; import cn.jpush.android.helper.c; import cn.jpush.android.helper.h; import cn.jpush.android.local.JPushConstants; import cn.jpush.android.p.a; import cn.jpush.android.p.e; import cn.jpush.android.service.JNotifyActivity; import cn.jpush.android.service.JPushMessageReceiver; import cn.jpush.android.u.e; import cn.jpush.android.ui.PopWinActivity; import cn.jpush.android.ui.PushActivity; import com.baidu.speech.utils.cuid.util.DeviceId; import com.tencent.smtt.sdk.TbsConfig; import com.tencent.smtt.utils.TbsLog; import java.io.File; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Iterator; import java.util.Locale; import java.util.Random; import java.util.TreeMap; import java.util.UUID; import java.util.zip.Adler32; import org.altbeacon.beacon.service.RangedBeacon; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class b { private static Boolean a; static class a extends e { private Context a; private d b; public a(Context context, d dVar) { this.a = context; this.b = dVar; this.e = "NotificationHelper#NotifyAction"; } public static void a(Context context, d dVar) { b.i(context, dVar); if (dVar.W == 0 || dVar.W == 4) { c.a(dVar.c, TbsLog.TBSLOG_CODE_SDK_THIRD_MODE, context); b.g(context, dVar); return; } b.h(context, dVar); } @Override // cn.jpush.android.u.e public void a() { try { long b2 = cn.jpush.android.u.b.b(this.b.ao); long b3 = cn.jpush.android.u.b.b(this.b.ap); if (b2 <= 0 || b2 != b3) { long currentTimeMillis = System.currentTimeMillis(); if (b3 > 0) { if (b3 < b2) { Logger.e("NotificationHelper", "illegal argument, endTime earlier than beginTime"); return; } else if (b3 < currentTimeMillis) { Logger.w("NotificationHelper", this.b.c + " already end"); c.a(this.b.c, 1034, this.a); return; } } if (b2 < currentTimeMillis) { a(this.a, this.b); if (b3 > 0) { e.a().a(this.a, new e.a(b3, b.a(this.b))); return; } return; } e.a().a(this.a, new e.a(b2, this.b)); c.a(this.b.c, 1035, this.a); return; } Logger.ww("NotificationHelper", "the beginTime == endTime,not deal this notification"); } catch (Throwable th) { Logger.w("NotificationHelper", "run NotifyAction failed:" + th.getMessage()); } } } private static int a(int i) { switch (i) { case 0: default: return 1; case 1: return 16; case 2: return 32; } } public static int a(d dVar) { return a(TextUtils.isEmpty(dVar.f) ? dVar.c : dVar.f, 0); } public static int a(String str, int i) { if (TextUtils.isEmpty(str)) { Logger.d("NotificationHelper", "action:getNotificationID - empty messageId"); return 0; } try { return Integer.valueOf(str).intValue(); } catch (Exception unused) { Logger.w("NotificationHelper", "Ths msgId is not a integer"); Adler32 adler32 = new Adler32(); adler32.update(str.getBytes()); int value = (int) adler32.getValue(); return value < 0 ? Math.abs(value) : value; } } static Notification a(Notification.Builder builder) { try { return Build.VERSION.SDK_INT >= 16 ? builder.build() : builder.getNotification(); } catch (Throwable th) { Logger.ww("NotificationHelper", "Build notification error:" + th.getMessage()); return null; } } /* JADX WARNING: Removed duplicated region for block: B:71:0x01ce */ private static Notification a(Context context, d dVar, RemoteViews remoteViews, boolean z, c cVar, c cVar2) { Notification.Builder builder; String str; StringBuilder sb; String str2; Object th; String str3; a.C0011a aVar = new a.C0011a(dVar.D, "", dVar.z, dVar.C, dVar.an); a.a(context, aVar); if (Build.VERSION.SDK_INT >= 11) { builder = new Notification.Builder(context); builder.setContentTitle(dVar.s).setContentText(dVar.u).setTicker(dVar.u); if (z && Build.VERSION.SDK_INT >= 20) { if (h.b()) { builder.setGroupSummary(true); str3 = "group" + new Random(System.currentTimeMillis()).nextInt(); } else { builder.setGroupSummary(false); str3 = "group"; } builder.setGroup(str3); } if (z) { builder.setSmallIcon(17170445); if (h.c() == -1) { int a2 = cVar2.a(); if (a2 == 102) { if (Build.VERSION.SDK_INT >= 23) { builder.setLargeIcon((Icon) cVar2.b()); } } else if (a2 == 100) { builder.setLargeIcon(cVar2.c()); } else { Logger.d("NotificationHelper", "not set large icon"); } } } else { a(JPushConstants.mApplicationContext, builder, cVar, cVar2); } if (Build.VERSION.SDK_INT >= 17) { builder.setShowWhen(true); } a(context, builder, aVar); if (Build.VERSION.SDK_INT >= 16) { if (remoteViews == null) { if (dVar.v == 1 && !TextUtils.isEmpty(dVar.w)) { Notification.BigTextStyle bigTextStyle = new Notification.BigTextStyle(); bigTextStyle.bigText(dVar.w); builder.setStyle(bigTextStyle); } if (dVar.v == 2 && !TextUtils.isEmpty(dVar.y)) { Notification.InboxStyle inboxStyle = new Notification.InboxStyle(); try { TreeMap treeMap = new TreeMap(); JSONObject jSONObject = new JSONObject(dVar.y); Iterator<String> keys = jSONObject.keys(); while (keys.hasNext()) { String next = keys.next(); treeMap.put(next, jSONObject.optString(next)); } for (String str4 : treeMap.values()) { inboxStyle.addLine(str4); } inboxStyle.setSummaryText(" + " + jSONObject.length() + " new messages"); } catch (Throwable th2) { Logger.ee("NotificationHelper", "Set inbox style error: " + th2.getMessage()); } builder.setStyle(inboxStyle); } if (dVar.v == 3 && !TextUtils.isEmpty(dVar.x)) { Logger.i("NotificationHelper", "Set notification BPS with picture path:" + dVar.x); try { Notification.BigPictureStyle bigPictureStyle = new Notification.BigPictureStyle(); bigPictureStyle.bigPicture(BitmapFactory.decodeFile(dVar.x)); builder.setStyle(bigPictureStyle); } catch (OutOfMemoryError e) { th = e; str2 = "NotificationHelper"; sb = new StringBuilder(); str = "Create bitmap failed caused by OutOfMemoryError.error:"; } catch (Throwable th3) { th = th3; str2 = "NotificationHelper"; sb = new StringBuilder(); str = "Create big picture style failed. error:"; } } } if (!TextUtils.isEmpty(dVar.A) && Build.VERSION.SDK_INT >= 21) { builder.setCategory(dVar.A); } } if (remoteViews != null) { builder.setContent(remoteViews); } return a(builder); } Notification notification = new Notification(g.a(context), dVar.u, System.currentTimeMillis()); a(notification, aVar); if (dVar.s == null) { dVar.s = context.getApplicationInfo().name; } if (remoteViews != null) { notification.contentView = remoteViews; } else { a(notification, context, dVar.s, dVar.u, (PendingIntent) null); } return notification; sb.append(str); sb.append(th); Logger.ww(str2, sb.toString()); builder.setCategory(dVar.A); if (remoteViews != null) { } return a(builder); } public static Intent a(Context context, String str, d dVar) { Intent intent = new Intent(str); intent.setClass(context, PushActivity.class); if (dVar != null) { intent.putExtra("msg_data", dVar.c()); } if (!cn.jpush.android.u.a.h(context) && Build.VERSION.SDK_INT >= 11) { intent.addFlags(32768); } return intent; } @TargetApi(23) private static Icon a(String str) { try { if (new File(str).exists()) { return Icon.createWithFilePath(str); } Logger.w("NotificationHelper", "icon file doesn't exist, path=" + str); return null; } catch (Throwable th) { Logger.w("NotificationHelper", "createIcon err:" + th); return null; } } public static Uri a(Context context, String str) { try { if (TextUtils.isEmpty(str)) { return null; } if (context.getResources().getIdentifier(str, "raw", context.getPackageName()) != 0) { Uri parse = Uri.parse("android.resource://" + context.getPackageName() + "/raw/" + str); StringBuilder sb = new StringBuilder(); sb.append("found sound uri="); sb.append(parse); Logger.d("NotificationHelper", sb.toString()); return parse; } Logger.d("NotificationHelper", "not found sound=" + str); return null; } catch (Throwable th) { Logger.w("NotificationHelper", "find sound e:" + th); return null; } } private static PushNotificationBuilder a(Context context, NotificationMessage notificationMessage) { try { Class<?> cls = Class.forName("cn.jpush.android.support.JPushSupport"); return (PushNotificationBuilder) cls.getDeclaredMethod("getNotificationBuilder", Context.class, NotificationMessage.class).invoke(cls, context, notificationMessage); } catch (Throwable th) { th.printStackTrace(); return null; } } public static d a(Context context, Intent intent) { String stringExtra = intent.getStringExtra("msg_data"); if (TextUtils.isEmpty(stringExtra)) { return null; } return d.a(stringExtra); } @TargetApi(11) public static c a(Context context, String str, String str2, String str3, String str4) { Icon a2; c cVar = new c(); String str5 = ""; int i = 0; try { if (TextUtils.isEmpty(str)) { Logger.d("NotificationHelper", "source is empty,need not diy small icon"); } else if (!TextUtils.isEmpty(str3)) { if (cn.jpush.android.u.a.a(str3)) { str5 = g(JPushConstants.mApplicationContext, str3); } else { i = JPushConstants.mApplicationContext.getResources().getIdentifier(str3, "drawable", JPushConstants.mApplicationContext.getPackageName()); } } } catch (Throwable th) { Logger.d("NotificationHelper", "load small icon failed:" + th.getMessage()); } if (!TextUtils.isEmpty(str5)) { Bitmap bitmap = null; try { if (cn.jpush.android.u.c.a(str5)) { bitmap = BitmapFactory.decodeFile(str5); } if (bitmap != null) { Logger.d("NotificationHelper", "set small icon with path bitmap:" + bitmap); cVar.a(100); cVar.a(bitmap); return cVar; } Logger.d("NotificationHelper", "not set small icon by bitmap"); if (Build.VERSION.SDK_INT >= 23 && (a2 = a(str5)) != null) { Logger.d("NotificationHelper", "set small icon success by path:" + str5); cVar.a(102); cVar.a(a2); return cVar; } } catch (Throwable unused) { Logger.w("NotificationHelper", "resource not found with sdcard path"); } } if (i != 0) { cVar.a(101); cVar.b(i); Logger.d("NotificationHelper", "set small icon success by resId:" + i + ",resName:" + str3); return cVar; } else if (TextUtils.isEmpty(str2) || str2.equals(context.getPackageName())) { int a3 = g.a(context); if (a3 != 0) { cVar.a(101); cVar.b(a3); Logger.d("NotificationHelper", "set small icon success by mine icon resId:" + a3); return cVar; } cVar.c(972); return cVar; } else { try { if (!cn.jpush.android.u.a.c(context, str2)) { Logger.w("NotificationHelper", "targetApp :" + str2 + " is not install,will give up notify the msg"); cVar.c(TbsLog.TBSLOG_CODE_SDK_CONFLICT_X5CORE); return cVar; } Bitmap e = e(context, str2); if (e == null) { Logger.w("NotificationHelper", "not found targetApp small icon bitmap,will give up notify the msg"); cVar.c(972); return cVar; } cVar.a(100); cVar.a(e); Logger.d("NotificationHelper", "set small icon success by targetAppBitmap"); return cVar; } catch (Throwable th2) { Logger.w("NotificationHelper", "set small icon by targetApp icon bitmap failed:" + th2.getMessage()); cVar.c(972); return cVar; } } } /* JADX WARNING: Removed duplicated region for block: B:115:0x046f */ /* JADX WARNING: Removed duplicated region for block: B:122:0x0490 */ /* JADX WARNING: Removed duplicated region for block: B:145:0x04f9 */ /* JADX WARNING: Removed duplicated region for block: B:148:0x0508 A[RETURN] */ /* JADX WARNING: Removed duplicated region for block: B:149:0x0509 */ private static Object a(Context context, d dVar, c cVar, c cVar2) { int i; String str; int i2; int i3; int i4; boolean z; boolean z2; int a2; String str2; String str3; boolean z3; if (Build.VERSION.SDK_INT >= 11) { cn.jpush.android.helper.e.a(JPushConstants.mApplicationContext); } Context appContext = JPushConstants.getAppContext(context); int identifier = appContext.getResources().getIdentifier("push_notification", "layout", appContext.getPackageName()); Logger.d("NotificationHelper", "layoutId:" + identifier); if (identifier <= 0) { return null; } int identifier2 = appContext.getResources().getIdentifier("v", "id", appContext.getPackageName()); int identifier3 = appContext.getResources().getIdentifier("v21", "id", appContext.getPackageName()); Logger.d("NotificationHelper", "targetVersion:" + Build.VERSION.SDK_INT + ",vId:" + identifier2 + ",v21Id:" + identifier3); if (Build.VERSION.SDK_INT >= 29) { boolean z4 = (appContext.getResources().getConfiguration().uiMode & 48) == 32; if (identifier3 <= 0 && z4) { Logger.d("NotificationHelper", "device is night mode style, and v21ID = " + identifier3 + ", please check your v21/push_notification.xml"); return 984; } } boolean z5 = Build.VERSION.SDK_INT < 21 || identifier3 <= 0; int identifier4 = appContext.getResources().getIdentifier("push_root_view", "id", appContext.getPackageName()); int c = h.c(); Logger.d("NotificationHelper", "use notification style :" + c); int identifier5 = appContext.getResources().getIdentifier("push_notification_style_default", "id", appContext.getPackageName()); if (c != 0) { i = appContext.getResources().getIdentifier("push_notification_style_" + c, "id", appContext.getPackageName()); if (i <= 0) { Logger.ww("NotificationHelper", "not found push_notification_style_" + c + " in layout"); return null; } } else { i = 0; } if (c == 0) { str = ""; } else { str = "style_" + c + "_"; } int identifier6 = appContext.getResources().getIdentifier("push_notification_" + str + "title", "id", appContext.getPackageName()); int identifier7 = appContext.getResources().getIdentifier("push_notification_" + str + "content", "id", appContext.getPackageName()); int identifier8 = appContext.getResources().getIdentifier("push_notification_" + str + "big_icon", "id", appContext.getPackageName()); int identifier9 = appContext.getResources().getIdentifier("push_notification_" + str + "date", "id", appContext.getPackageName()); int identifier10 = appContext.getResources().getIdentifier("push_notification_content_one_line", "id", appContext.getPackageName()); int identifier11 = appContext.getResources().getIdentifier("push_notification_sub_title", "id", appContext.getPackageName()); int identifier12 = appContext.getResources().getIdentifier("push_notification_dot", "id", appContext.getPackageName()); int identifier13 = appContext.getResources().getIdentifier("push_notification_small_icon", "id", appContext.getPackageName()); if (c == 0) { Logger.d("NotificationHelper", "buildDiyLayout layoutId:" + identifier + ",defaultStyleId:" + identifier5 + ",largeId:" + identifier8 + ",appNameId:" + identifier6 + ",contentId:" + identifier7 + ",smallId:" + identifier13 + ",dateId:" + identifier9 + ",dotId:" + identifier12 + ",titleId:" + identifier11 + ",oneLinecontentId:" + identifier10); if (identifier <= 0 || identifier4 <= 0 || identifier5 <= 0 || identifier6 <= 0 || identifier7 <= 0 || identifier8 <= 0 || identifier13 <= 0 || identifier9 <= 0 || identifier12 <= 0 || identifier11 <= 0 || identifier10 <= 0) { Logger.ww("NotificationHelper", "not found valid push_notification in layout"); return null; } i3 = i; i2 = identifier13; } else { StringBuilder sb = new StringBuilder(); sb.append("buildDiyLayout layoutId:"); sb.append(identifier); sb.append(",useStyleId:"); i3 = i; sb.append(i3); i2 = identifier13; sb.append(",appNameId:"); sb.append(identifier6); sb.append(",contentId:"); sb.append(identifier7); sb.append(",largeId:"); sb.append(identifier8); sb.append(",dateId:"); sb.append(identifier9); Logger.d("NotificationHelper", sb.toString()); if (identifier <= 0 || identifier4 <= 0 || i3 <= 0 || identifier6 <= 0 || identifier7 <= 0 || identifier8 <= 0 || identifier9 <= 0) { Logger.ww("NotificationHelper", "not found valid push_notification in layout"); return null; } } RemoteViews remoteViews = new RemoteViews(appContext.getPackageName(), identifier); if (z5) { try { int a3 = cn.jpush.android.helper.e.a(); int b = cn.jpush.android.helper.e.b(); remoteViews.setTextColor(identifier6, a3); if (c == 0) { remoteViews.setTextColor(identifier9, b); remoteViews.setTextColor(identifier12, a3); remoteViews.setTextColor(identifier11, a3); } else { remoteViews.setTextColor(identifier9, b); } remoteViews.setTextColor(identifier10, b); remoteViews.setTextColor(identifier7, b); } catch (Throwable th) { Logger.d("NotificationHelper", "set diy color error:" + th.getMessage()); } } float d = cn.jpush.android.helper.e.d(); if (d != -1.0f && Build.VERSION.SDK_INT >= 16) { remoteViews.setTextViewTextSize(identifier7, 0, d); remoteViews.setTextViewTextSize(identifier10, 0, d); } String str4 = dVar.t; String str5 = ""; try { JSONObject jSONObject = new JSONObject(dVar.B); str5 = jSONObject.optString("ssp_appname"); i4 = jSONObject.optInt("ssp_use_title"); } catch (Throwable unused) { i4 = 0; } if (!TextUtils.isEmpty(str4) || TextUtils.isEmpty(str5)) { str5 = str4; } if (c == 0) { remoteViews.setViewVisibility(identifier5, 0); if (TextUtils.isEmpty(str5)) { remoteViews.setTextViewText(identifier6, dVar.s); remoteViews.setViewVisibility(identifier11, 8); } else if (appContext.getApplicationInfo().targetSdkVersion >= 24) { remoteViews.setTextViewText(identifier6, str5); remoteViews.setTextViewText(identifier11, dVar.s); remoteViews.setViewVisibility(identifier11, 0); if (h.d()) { remoteViews.setViewVisibility(identifier7, 8); remoteViews.setTextViewText(identifier10, dVar.u); remoteViews.setViewVisibility(identifier10, 0); } float c2 = cn.jpush.android.helper.e.c(); if (c2 != -1.0f && Build.VERSION.SDK_INT >= 16) { remoteViews.setTextViewTextSize(identifier11, 0, c2); } } else { remoteViews.setTextViewText(identifier6, dVar.s); remoteViews.setViewVisibility(identifier11, 8); } z2 = false; } else { remoteViews.setViewVisibility(identifier5, 8); remoteViews.setViewVisibility(i3, 0); if (TextUtils.isEmpty(str5) || i4 == 1) { str5 = dVar.s; z2 = false; } else { z2 = true; } remoteViews.setTextViewText(identifier6, str5); float c3 = cn.jpush.android.helper.e.c(); if (c3 != -1.0f && Build.VERSION.SDK_INT >= 16) { z = false; remoteViews.setTextViewTextSize(identifier6, 0, c3); remoteViews.setTextViewText(identifier7, dVar.u); remoteViews.setTextViewText(identifier9, new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date(System.currentTimeMillis()))); Logger.d("NotificationHelper", "notificationStyle:" + c + ",noUseLargeIcon:" + z2); if (c == 0 || z2) { a2 = cVar.a(); if (a2 != 102) { if (Build.VERSION.SDK_INT >= 23) { if (c == 0) { remoteViews.setImageViewIcon(i2, (Icon) cVar.b()); } if (z2) { remoteViews.setImageViewIcon(identifier8, (Icon) cVar.b()); } str3 = "NotificationHelper"; str2 = "diy set small icon by icon obj"; } if (!z) { c.a(dVar.c, 972, appContext); return 1; } } else if (a2 == 100) { if (c == 0) { remoteViews.setImageViewBitmap(i2, cVar.c()); } if (z2) { remoteViews.setImageViewBitmap(identifier8, cVar.c()); } str3 = "NotificationHelper"; str2 = "diy set small icon by bitmap"; } else { if (a2 == 101) { try { appContext.getResources().getDrawable(cVar.d()); z3 = true; } catch (Throwable unused2) { Logger.w("NotificationHelper", "diy resource not found with local app"); z3 = false; } if (z3) { Logger.d("NotificationHelper", "diy set small icon by local resId:" + cVar.d()); if (c == 0) { remoteViews.setImageViewResource(i2, cVar.d()); } if (z2) { remoteViews.setImageViewResource(identifier8, cVar.d()); } z = true; } } if (!z) { } } Logger.d(str3, str2); z = true; if (!z) { } } if (!z2) { return remoteViews; } int a4 = cVar2.a(); if (a4 == 102) { if (Build.VERSION.SDK_INT >= 23) { remoteViews.setImageViewIcon(identifier8, (Icon) cVar2.b()); } } else if (a4 == 100) { remoteViews.setImageViewBitmap(identifier8, cVar2.c()); } else { Logger.d("NotificationHelper", "diy not set large icon"); if (c == 1) { c.a(dVar.c, 973, appContext); return 2; } } return remoteViews; } } z = false; remoteViews.setTextViewText(identifier7, dVar.u); remoteViews.setTextViewText(identifier9, new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date(System.currentTimeMillis()))); Logger.d("NotificationHelper", "notificationStyle:" + c + ",noUseLargeIcon:" + z2); a2 = cVar.a(); if (a2 != 102) { } Logger.d(str3, str2); z = true; if (!z) { } if (!z2) { } } private static String a(Context context, String str, String str2) { if (str.endsWith(".jpg") || str.endsWith(".png")) { Logger.i("NotificationHelper", "The url is a picture resources."); String str3 = cn.jpush.android.u.c.c(context, str2) + (str2 + str.substring(str.lastIndexOf("."))); Logger.i("NotificationHelper", "Big picture notification resource path: " + str3); byte[] a2 = cn.jpush.android.o.a.a(str, 5, RangedBeacon.DEFAULT_MAX_TRACKING_AGE, 4); return (a2 == null || !cn.jpush.android.u.c.a(str3, a2)) ? "" : str3; } Logger.i("NotificationHelper", "The url is not a picture resources."); return ""; } public static void a(Notification notification, Context context, String str, String str2, PendingIntent pendingIntent) { try { Class.forName("android.app.Notification").getDeclaredMethod("setLatestEventInfo", Context.class, CharSequence.class, CharSequence.class, PendingIntent.class).invoke(notification, context, str, str2, pendingIntent); } catch (Exception e) { e.printStackTrace(); } } public static void a(Notification notification, a.C0011a aVar) { if (aVar != null) { try { if (Build.VERSION.SDK_INT < 16) { notification.defaults = aVar.e; notification.sound = aVar.g; } } catch (Throwable unused) { } } } public static void a(Context context) { while (true) { Integer valueOf = Integer.valueOf(f.a()); if (valueOf.intValue() != 0) { d(context, valueOf.intValue()); } else { return; } } } public static void a(Context context, int i, int i2, String str) { } public static void a(Context context, int i, int i2, String str, Bundle bundle) { try { String messageReceiverClass = JPushConstants.getMessageReceiverClass(context); if (!TextUtils.isEmpty(messageReceiverClass)) { Intent intent = new Intent(); intent.setClassName(context, messageReceiverClass); intent.setAction(cn.jpush.android.u.a.e(context, "cmd_msg")); intent.putExtra("cmd", i); intent.putExtra("code", i2); intent.putExtra("message", str); if (bundle != null) { intent.putExtras(bundle); } if (JPushConstants.getPushMessageReceiver(context) != null) { cn.jpush.android.helper.a.a(JPushConstants.getPushMessageReceiver(context), context, intent); } else { context.sendBroadcast(intent); } } } catch (Throwable th) { Logger.w("NotificationHelper", "sendCmdMsgToUser failed:" + th.getMessage()); } } public static void a(Context context, int i, boolean z) { try { boolean z2 = true; if (d(context) != 1) { z2 = false; } Logger.d("NotificationHelper", "[checkNotificationSettings] new state:" + z2 + ",last state:" + a + ",soucre:" + i + ",isFocre:" + z); if (a == null || z2 != a.booleanValue() || z) { a = Boolean.valueOf(z2); JPushMessageReceiver pushMessageReceiver = JPushConstants.getPushMessageReceiver(context); if (pushMessageReceiver != null) { pushMessageReceiver.onNotificationSettingsCheck(context, a.booleanValue(), i); return; } try { Intent intent = new Intent(context, Class.forName(JPushConstants.getMessageReceiverClass(context))); intent.setAction("on_noti_settings_check"); intent.putExtra("isOn", a); intent.putExtra("source", i); context.sendBroadcast(intent); } catch (Throwable th) { Logger.w("NotificationHelper", "checkNotificationSettings send to user e:" + th); } } else { Logger.d("NotificationHelper", "[checkNotificationSettings] no change"); } } catch (Throwable th2) { Logger.w("NotificationHelper", "checkNotificationSettings e:" + th2); } } public static void a(Context context, Notification.Builder builder, a.C0011a aVar) { if (aVar != null) { try { if (Build.VERSION.SDK_INT >= 26 && aVar.h) { Logger.d("NotificationHelper", "setChannelId =" + aVar.a); f(context, aVar.a); builder.setChannelId(aVar.a); } if (Build.VERSION.SDK_INT >= 16) { builder.setPriority(aVar.c); builder.setDefaults(aVar.e); builder.setSound(aVar.g); } } catch (Throwable unused) { } } } public static void a(Context context, d dVar) { Logger.d("NotificationHelper", "[processMessage] pushEntity:" + dVar); if (dVar.X != 0) { Logger.d("NotificationHelper", "Unexpected: unknown show mode - " + dVar.X); return; } JCoreHelper.majorExecutor(context, JPushConstants.SDK_TYPE, new a(context, dVar)); } public static void a(Context context, Integer num, Notification notification) { if (num != null) { Key<Integer> BadgeCurNum = Key.BadgeCurNum(); int intValue = ((Integer) Sp.get(context, BadgeCurNum)).intValue(); if (intValue < 0) { intValue = 0; } if (num.intValue() != 0) { if (num.intValue() + intValue < 0) { num = Integer.valueOf(-intValue); } intValue += num.intValue(); Sp.set(context, BadgeCurNum.set(Integer.valueOf(intValue))); } Logger.d("NotificationHelper", "curNum:" + intValue + ",addNum:" + num); a(context, notification, num.intValue(), intValue); } } public static void a(Context context, String str, d dVar, Intent intent) { try { Intent intent2 = new Intent(context, Class.forName(JPushConstants.getMessageReceiverClass(context))); if (intent != null) { String string = intent.getExtras().getString(JPushInterface.EXTRA_NOTIFICATION_ACTION_EXTRA); if (!TextUtils.isEmpty(string)) { intent2.putExtra(JPushInterface.EXTRA_NOTIFICATION_ACTION_EXTRA, string); } } intent2.setAction(str); if (dVar != null) { intent2.putExtra("msg_data", dVar.c()); } if (JPushConstants.getPushMessageReceiver(context) != null) { if (str.equals(JPushInterface.ACTION_NOTIFICATION_CLICK_ACTION_PROXY)) { intent2.setAction(JPushInterface.ACTION_NOTIFICATION_CLICK_ACTION); JPushConstants.getPushMessageReceiver(context).onMultiActionClicked(context, intent2); return; } NotificationMessage b = dVar.b(); if (TextUtils.isEmpty(b.appkey)) { b.appkey = JCoreHelper.getAppKey(context); } if (str.equals("cn.jpush.android.intent.NOTIFICATION_ARRIVED")) { JPushConstants.getPushMessageReceiver(context).onNotifyMessageArrived(context, b); return; } else if (str.equals("cn.jpush.android.intent.NOTIFICATION_DISMISS")) { JPushConstants.getPushMessageReceiver(context).onNotifyMessageDismiss(context, b); return; } else if (str.equals(JPushInterface.ACTION_NOTIFICATION_OPENED)) { JPushConstants.getPushMessageReceiver(context).onNotifyMessageOpened(context, b); return; } else if (str.equals("cn.jpush.android.intent.NOTIFICATION_UN_SHOW")) { JPushConstants.getPushMessageReceiver(context).onNotifyMessageUnShow(context, b); return; } } context.sendBroadcast(intent2); } catch (Throwable th) { Logger.w("NotificationHelper", "sendToUserReceiver failed:" + th.getMessage()); } } private static boolean a() { try { Class<?> cls = Class.forName("android.os.SystemProperties"); String str = (String) cls.getDeclaredMethod("get", String.class).invoke(cls, "ro.build.version.emui"); if (!TextUtils.isEmpty(str)) { Logger.i("NotificationHelper", "get EMUI version is:" + str); return cn.jpush.android.u.a.a(str.toLowerCase().replace("emotionui_", ""), "8.0") >= 0; } } catch (Throwable th) { Logger.e("NotificationHelper", " getEmuiVersion wrong error:" + th); } return false; } private static boolean a(Notification notification, int i) { if (notification != null) { try { Object obj = notification.getClass().getDeclaredField("extraNotification").get(notification); obj.getClass().getDeclaredMethod("setMessageCount", Integer.TYPE).invoke(obj, Integer.valueOf(i)); return true; } catch (Exception unused) { } } return false; } public static boolean a(Context context, int i) { String str; String str2; boolean z = false; try { if (Build.VERSION.SDK_INT >= 23) { StatusBarNotification[] activeNotifications = ((NotificationManager) context.getSystemService("notification")).getActiveNotifications(); Logger.d("NotificationHelper", "active size:" + activeNotifications.length); if (activeNotifications != null) { int length = activeNotifications.length; int i2 = 0; while (true) { if (i2 >= length) { break; } else if (activeNotifications[i2].getId() == i) { z = true; break; } else { i2++; } } } } if (z) { str = "NotificationHelper"; str2 = "show notification success:" + i; } else { str = "NotificationHelper"; str2 = "show notification maybe failed:" + i; } Logger.dd(str, str2); } catch (Throwable th) { Logger.ww("NotificationHelper", "[checkNotficationShow] failed:" + th.getMessage()); } return z; } @TargetApi(11) private static boolean a(Context context, Notification.Builder builder, c cVar, c cVar2) { boolean z; boolean z2; int a2 = cVar.a(); if (a2 != 102 || Build.VERSION.SDK_INT < 23) { z = false; } else { builder.setSmallIcon((Icon) cVar.b()); z = true; } if (!z && a2 == 100 && Build.VERSION.SDK_INT >= 23) { builder.setSmallIcon(Icon.createWithBitmap(cVar.c())); z = true; } if (!z && a2 == 101) { try { context.getResources().getDrawable(cVar.d()); z2 = true; } catch (Throwable unused) { Logger.w("NotificationHelper", "resource not found with local app"); z2 = false; } if (z2) { Logger.d("NotificationHelper", "set small icon by local resId:" + cVar.d()); builder.setSmallIcon(Integer.valueOf(cVar.d()).intValue()); z = true; } } if (!z) { return false; } int a3 = cVar2.a(); if (a3 == 102) { if (Build.VERSION.SDK_INT >= 23) { builder.setLargeIcon((Icon) cVar2.b()); } } else if (a3 == 100) { builder.setLargeIcon(cVar2.c()); } else { Logger.d("NotificationHelper", "not set large icon"); } return true; } public static boolean a(Context context, Notification notification, int i, int i2) { if (Build.MANUFACTURER.equalsIgnoreCase("xiaomi")) { return a(notification, i); } if (!a()) { Logger.d("NotificationHelper", "not support"); return false; } else if (i2 == 0 || i != 0) { return e(context, i2); } else { return false; } } public static boolean a(Context context, String str, d dVar, NotificationMessage notificationMessage) { try { if (Class.forName(str).getMethod("onNotifyMessageUnShow", Context.class, NotificationMessage.class) == null) { Logger.dd("NotificationHelper", "not found onNotifyMessageUnShow method"); return false; } if (!TextUtils.isEmpty(dVar.E)) { if (dVar.E.equals(DeviceId.CUIDInfo.I_EMPTY)) { if (cn.jpush.android.u.a.h(context)) { Logger.dd("NotificationHelper", "displayForeground..."); a(context, "cn.jpush.android.intent.NOTIFICATION_UN_SHOW", dVar, (Intent) null); c.a(dVar.c, 1060, context); return true; } } else if (!((JPushMessageReceiver) Class.forName(str).newInstance()).isNeedShowNotification(context, notificationMessage, cn.jpush.android.u.a.c(context))) { Logger.dd("NotificationHelper", "need not show notication by user"); a(context, "cn.jpush.android.intent.NOTIFICATION_UN_SHOW", dVar, (Intent) null); c.a(dVar.c, 1061, context); return true; } } return false; } catch (Throwable th) { Logger.ww("NotificationHelper", "check display foreground failed:" + th.getMessage()); } } private static boolean a(Context context, String str, String str2, String str3, int i) { Logger.d("NotificationHelper", "[handleWxMini] appid=" + str + ",originid=" + str2 + ",path=" + str3 + ", type=" + i); try { if (Build.VERSION.SDK_INT >= 29) { Logger.d("NotificationHelper", "launchWXUsingPendingIntent"); PendingIntent.getActivity(context, 1, context.getPackageManager().getLaunchIntentForPackage(TbsConfig.APP_WX), 134217728).send(context, 2, null, new PendingIntent.OnFinished() { /* class cn.jpush.android.p.b.AnonymousClass1 */ public void onSendFinished(PendingIntent pendingIntent, Intent intent, int i, String str, Bundle bundle) { Logger.d("NotificationHelper", "onSendFinished resultCode: " + i + ", resultData: " + str); } }, null); } try { ContentResolver contentResolver = context.getContentResolver(); Uri parse = Uri.parse("content://com.tencent.mm.sdk.comm.provider/launchWXMiniprogram"); Cursor query = contentResolver.query(parse, null, null, new String[]{str, str2, str3, "" + i, ""}, null); if (query != null) { query.close(); } return true; } catch (Throwable th) { Logger.d("NotificationHelper", "[handleWxMini] open wx mini failed,e:" + th.getMessage()); return false; } } catch (Throwable th2) { Logger.w("NotificationHelper", "launchWXUsingPendingIntent pendingIntent send failed: " + th2.getMessage()); return false; } } public static Intent b(Context context, String str, d dVar) { Intent intent = new Intent(str); intent.setClass(context, PopWinActivity.class); if (dVar != null) { intent.putExtra("msg_data", dVar.c()); } return intent; } public static NotificationMessage b(Context context, Intent intent) { NotificationMessage b = a(context, intent).b(); if (TextUtils.isEmpty(b.appkey)) { b.appkey = JCoreHelper.getAppKey(context); } return b; } @TargetApi(11) public static c b(Context context, String str) { c cVar = new c(); Object c = c(context, str); if (c == null) { cVar.c(973); return cVar; } if (Build.VERSION.SDK_INT >= 23 && (c instanceof Icon)) { cVar.a(102); cVar.a(c); } else if (c instanceof Bitmap) { cVar.a(100); cVar.a((Bitmap) c); } else { cVar.c(973); return cVar; } return cVar; } public static void b(Context context, int i) { int a2; if (!f.b(i)) { f.a(i); } Logger.d("NotificationHelper", "queueSize:" + f.b() + ",max num:" + cn.jpush.android.cache.a.i(context)); if (f.b() > cn.jpush.android.cache.a.i(context) && (a2 = f.a()) != 0) { d(context, a2); } } public static void b(Context context, int i, int i2, String str) { a(context, i, i2, str, (Bundle) null); } public static void b(Context context, d dVar) { if (dVar != null) { d(context, a(dVar)); } } public static boolean b(Context context) { try { if (!cn.jpush.android.cache.a.f(context)) { Logger.ii("NotificationHelper", "Notification was disabled by JPushInterface.setPushTime !"); return false; } String g = cn.jpush.android.cache.a.g(context); if (TextUtils.isEmpty(g)) { Logger.i("NotificationHelper", "no time limited"); return true; } Logger.i("NotificationHelper", "push time is :" + g); String[] split = g.split("_"); String str = split[0]; String str2 = split[1]; char[] charArray = str.toCharArray(); String[] split2 = str2.split("\\^"); Calendar instance = Calendar.getInstance(); int i = instance.get(7); int i2 = instance.get(11); for (char c : charArray) { if (i == Integer.valueOf(String.valueOf(c)).intValue() + 1) { int intValue = Integer.valueOf(split2[0]).intValue(); int intValue2 = Integer.valueOf(split2[1]).intValue(); if (i2 >= intValue && i2 <= intValue2) { return true; } } } Logger.ii("NotificationHelper", "Current time is out of the push time - " + g); return false; } catch (Exception unused) { return true; } } /* JADX WARNING: Removed duplicated region for block: B:55:0x017c A[RETURN] */ /* JADX WARNING: Removed duplicated region for block: B:56:0x017d A[RETURN] */ public static int c(Context context, d dVar) { boolean z; String str; String str2; if (dVar == null || ((TextUtils.isEmpty(dVar.I) && !dVar.Q) || (!TextUtils.isEmpty(dVar.F) && !dVar.F.equals("ssp")))) { Logger.d("NotificationHelper", "is not deep link notification"); return 0; } if (TextUtils.isEmpty(dVar.F) && TextUtils.isEmpty(dVar.L)) { Logger.d("NotificationHelper", "source is empty and targetPkgName is empty,will use mine pkgname replace targetPkgName"); dVar.L = context.getPackageName(); } try { Logger.d("NotificationHelper", "open deeplink notification,source:" + dVar.F + ",targetPkg:" + dVar.L); if (TextUtils.isEmpty(dVar.L)) { if (h(context, dVar.I)) { str2 = dVar.c; } else { str = dVar.c; c.a(str, 977, context); return !TextUtils.isEmpty(dVar.F) ? 1 : 2; } } else if (cn.jpush.android.u.a.c(context, dVar.L)) { if (dVar.Q) { z = a(context, dVar.N, dVar.O, dVar.I, dVar.P); if (!z) { c.a(dVar.c, 1075, context); } } else { z = h(context, dVar.I); } if (z) { str2 = dVar.c; } else { str = dVar.c; c.a(str, 977, context); if (!TextUtils.isEmpty(dVar.F)) { } } } else { a(context, 100003, 1, dVar.L + "," + dVar.J + "," + dVar.K); c.a(dVar.c, 988, context); Logger.d("NotificationHelper", "app not installed,fail_handle_type:" + dVar.J + ",fail_handle_url:" + dVar.K); switch (dVar.J) { case 0: Intent f = cn.jpush.android.u.a.f(context); if (f != null) { try { context.startActivity(f); break; } catch (Throwable th) { Logger.d("NotificationHelper", "start main intent error:" + th.getMessage()); break; } } break; case 1: case 2: if (!TextUtils.isEmpty(dVar.K)) { if (!h(context, dVar.K)) { c.a(dVar.c, 979, context); break; } else { c.a(dVar.c, 978, context); break; } } else { Logger.d("NotificationHelper", "fail_handle_url is empty"); break; } } if (!TextUtils.isEmpty(dVar.F)) { } } c.a(str2, 976, context); } catch (Throwable th2) { Logger.w("NotificationHelper", "url failed:" + th2.getMessage()); } if (!TextUtils.isEmpty(dVar.F)) { } } private static Intent c(Context context, String str, d dVar) { Intent intent = new Intent(str); intent.setClass(context, JNotifyActivity.class); intent.setFlags(1073741824); if (dVar != null) { intent.putExtra("msg_data", dVar.c()); } return intent; } /* JADX WARNING: Removed duplicated region for block: B:26:0x00a2 A[Catch:{ Throwable -> 0x00fa }] */ /* JADX WARNING: Removed duplicated region for block: B:27:0x00a5 A[Catch:{ Throwable -> 0x00fa }] */ /* JADX WARNING: Removed duplicated region for block: B:39:0x00eb A[Catch:{ Throwable -> 0x00fa }] */ /* JADX WARNING: Removed duplicated region for block: B:40:0x00ed A[Catch:{ Throwable -> 0x00fa }] */ public static Object c(Context context, String str) { Bitmap bitmap; String str2; String str3; Icon icon; String str4; String str5; String str6; String str7; if (TextUtils.isEmpty(str)) { Logger.d("NotificationHelper", "large icon is empty"); return null; } String str8 = ""; int i = 0; try { if (!TextUtils.isEmpty(str)) { if (cn.jpush.android.u.a.a(str)) { str8 = g(JPushConstants.mApplicationContext, str); } else { i = JPushConstants.mApplicationContext.getResources().getIdentifier(str, "drawable", JPushConstants.mApplicationContext.getPackageName()); } } } catch (Throwable th) { Logger.d("NotificationHelper", "load large icon failed:" + th.getMessage()); } if (i != 0) { try { bitmap = BitmapFactory.decodeResource(context.getResources(), i); str6 = "NotificationHelper"; str7 = "set large icon with res bitmap:" + i; } catch (Throwable th2) { Logger.w("NotificationHelper", "setLargeIcon failed:" + th2.getMessage()); return null; } } else if (TextUtils.isEmpty(str8) || !new File(str8).exists()) { bitmap = null; if (bitmap == null) { return bitmap; } if (Build.VERSION.SDK_INT >= 23) { if (i != 0) { icon = Icon.createWithResource(context, i); str4 = "NotificationHelper"; str5 = "set large icon with res:" + i; } else { if (!TextUtils.isEmpty(str8)) { icon = a(str8); if (icon != null) { str4 = "NotificationHelper"; str5 = "set large icon with path:" + str8; } } else { icon = null; } if (icon == null) { return icon; } str2 = "NotificationHelper"; str3 = "not set large icon"; } Logger.d(str4, str5); if (icon == null) { } } else { str2 = "NotificationHelper"; str3 = "not set large icon by bitmap"; } Logger.d(str2, str3); return null; } else { bitmap = BitmapFactory.decodeFile(str8); str6 = "NotificationHelper"; str7 = "set large icon with path bitmap:" + str8; } Logger.d(str6, str7); if (bitmap == null) { } } public static void c(Context context, int i) { if (i > 0) { for (int i2 = 0; i2 < i; i2++) { Integer valueOf = Integer.valueOf(f.a()); if (valueOf.intValue() != 0) { d(context, valueOf.intValue()); } } } } private static void c(Context context, Intent intent) { if ("com.mt.mtxx.mtxx".equals(context.getPackageName())) { intent.putExtra("infoProvider", "JPush"); } } /* JADX WARNING: Code restructure failed: missing block: B:39:0x00b5, code lost: if (r6 <= 23) goto L_0x00c3; */ /* JADX WARNING: Code restructure failed: missing block: B:41:0x00b9, code lost: if (r6 < r4) goto L_0x00c3; */ /* JADX WARNING: Code restructure failed: missing block: B:43:0x00bd, code lost: if (r5 >= r3) goto L_0x00c3; */ /* JADX WARNING: Code restructure failed: missing block: B:45:0x00c1, code lost: if (r5 <= r0) goto L_0x00c3; */ public static boolean c(Context context) { String h = cn.jpush.android.cache.a.h(context); if (TextUtils.isEmpty(h)) { return false; } try { JSONObject jSONObject = new JSONObject(h); int optInt = jSONObject.optInt("startHour", -1); int optInt2 = jSONObject.optInt("startMins", -1); int optInt3 = jSONObject.optInt("endHour", -1); int optInt4 = jSONObject.optInt("endtMins", -1); if (optInt >= 0 && optInt2 >= 0 && optInt3 >= 0 && optInt4 >= 0 && optInt2 <= 59 && optInt4 <= 59 && optInt3 <= 23) { if (optInt <= 23) { Calendar instance = Calendar.getInstance(); int i = instance.get(11); int i2 = instance.get(12); Logger.v("NotificationHelper", "nowHour:" + i + ", nowMin:" + i2 + ", startHour:" + optInt + ", startMin:" + optInt2 + ", endHour:" + optInt3 + ", endMin:" + optInt4); if (optInt < optInt3) { if ((i <= optInt || i >= optInt3) && (i != optInt || i2 < optInt2)) { if (i != optInt3 || i2 > optInt4) { return false; } } } else if (optInt == optInt3) { if (optInt2 >= optInt4) { if (i == optInt && i2 > optInt4 && i2 < optInt2) { return false; } } else if (i != optInt || i2 < optInt2 || i2 > optInt4) { return false; } } else if (optInt > optInt3) { if (i > optInt) { } if (i >= 0) { } if (i == optInt) { } if (i == optInt3) { } } Logger.ii("NotificationHelper", "Current time is in the range of silence time - " + optInt + ":" + optInt2 + " ~ " + optInt3 + ":" + optInt4); return true; } } } catch (JSONException unused) { } return false; } public static int d(Context context) { String str; StringBuilder sb; String str2; if (Build.VERSION.SDK_INT >= 24) { try { NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification"); if (notificationManager == null) { return -1; } boolean areNotificationsEnabled = notificationManager.areNotificationsEnabled(); Logger.d("NotificationHelper", "from NotificationManager enable=" + areNotificationsEnabled); return areNotificationsEnabled ? 1 : 0; } catch (Throwable th) { th = th; str = "NotificationHelper"; sb = new StringBuilder(); str2 = "isNotificationEnabled e:"; sb.append(str2); sb.append(th); Logger.w(str, sb.toString()); return -1; } } else { boolean z = true; if (Build.VERSION.SDK_INT >= 19) { try { ApplicationInfo applicationInfo = context.getApplicationInfo(); String packageName = context.getApplicationContext().getPackageName(); int i = applicationInfo.uid; Class<?> cls = Class.forName(AppOpsManager.class.getName()); if (((Integer) cls.getMethod("checkOpNoThrow", Integer.TYPE, Integer.TYPE, String.class).invoke((AppOpsManager) context.getSystemService("appops"), Integer.valueOf(((Integer) cls.getDeclaredField("OP_POST_NOTIFICATION").get(Integer.class)).intValue()), Integer.valueOf(i), packageName)).intValue() != 0) { z = false; } Logger.d("NotificationHelper", "from AppOpsManager enable=" + z); int i2 = z ? 1 : 0; int i3 = z ? 1 : 0; int i4 = z ? 1 : 0; return i2; } catch (Throwable th2) { th = th2; str = "NotificationHelper"; sb = new StringBuilder(); str2 = "appOps check e:"; sb.append(str2); sb.append(th); Logger.w(str, sb.toString()); return -1; } } else { Logger.d("NotificationHelper", "below 19 return true"); return 1; } } } public static String d(Context context, String str) { if (str.endsWith(".jpg") || str.endsWith(".png") || str.endsWith(".jpeg")) { Logger.i("NotificationHelper", "The url is a picture resources."); String b = cn.jpush.android.u.a.b(str); if (TextUtils.isEmpty(b)) { b = UUID.randomUUID().toString(); } String str2 = cn.jpush.android.u.c.c(context, "noti_res") + (b + str.substring(str.lastIndexOf("."))); Logger.i("NotificationHelper", "picture notification resource path: " + str2); if (new File(str2).exists()) { Logger.d("NotificationHelper", "need not download again with same url:" + str); return str2; } byte[] a2 = cn.jpush.android.o.a.a(str, 2); return (a2 == null || !cn.jpush.android.u.c.a(str2, a2)) ? "" : str2; } Logger.i("NotificationHelper", "The url is not a picture resources."); return ""; } public static void d(Context context, int i) { try { Logger.d("NotificationHelper", "action:cleanNotification - notificationId:" + i); ((NotificationManager) context.getSystemService("notification")).cancel(i); } catch (Throwable th) { Logger.w("NotificationHelper", "cancelNotification failed:" + th.getMessage()); } } public static synchronized Bitmap e(Context context, String str) { Bitmap bitmap; synchronized (b.class) { try { PackageManager packageManager = context.getApplicationContext().getPackageManager(); bitmap = ((BitmapDrawable) packageManager.getApplicationIcon(packageManager.getApplicationInfo(str, 0))).getBitmap(); } catch (Throwable th) { Logger.w("NotificationHelper", "getTargetAppBitmap failed:" + th.getMessage()); return null; } } return bitmap; } public static boolean e(Context context) { String str; int i; try { Intent intent = new Intent(); intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS"); if (Build.VERSION.SDK_INT >= 26) { intent.putExtra("android.provider.extra.APP_PACKAGE", context.getPackageName()); str = "android.provider.extra.CHANNEL_ID"; i = context.getApplicationInfo().uid; } else { if (Build.VERSION.SDK_INT >= 21) { intent.putExtra("app_package", context.getPackageName()); str = "app_uid"; i = context.getApplicationInfo().uid; } intent.setFlags(268435456); context.startActivity(intent); return true; } intent.putExtra(str, i); intent.setFlags(268435456); context.startActivity(intent); return true; } catch (Throwable th) { th.printStackTrace(); return false; } } private static boolean e(Context context, int i) { try { Logger.d("NotificationHelper", "【setEMUIBadge】number:" + i); if (Build.VERSION.SDK_INT < 11) { return false; } Bundle bundle = new Bundle(); bundle.putString("package", context.getPackageName()); bundle.putString("class", h(context)); bundle.putInt("badgenumber", i); context.getContentResolver().call(Uri.parse("content://com.huawei.android.launcher.settings/badge/"), "change_badge", (String) null, bundle); return true; } catch (Exception e) { Logger.e("NotificationHelper", "e: " + e); return false; } } private static void f(Context context, String str) { try { if (Build.VERSION.SDK_INT >= 26 && !TextUtils.isEmpty(str)) { NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification"); NotificationChannel notificationChannel = notificationManager != null ? notificationManager.getNotificationChannel(str) : null; if (notificationChannel != null) { if (notificationChannel.getImportance() != 0) { Logger.dd("NotificationHelper", str + " channel is opened,will use it"); return; } } Logger.ww("NotificationHelper", str + " channel maybe closed,please check it"); } } catch (Throwable unused) { } } public static boolean f(Context context) { try { Intent intent = new Intent(); intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS"); intent.setData(Uri.fromParts("package", context.getPackageName(), null)); context.startActivity(intent); return true; } catch (Throwable unused) { return false; } } private static String g(Context context) { try { PackageManager packageManager = context.getPackageManager(); Intent intent = new Intent("android.intent.action.MAIN"); intent.setPackage(context.getPackageName()); intent.addCategory("android.intent.category.LAUNCHER"); ResolveInfo resolveActivity = packageManager.resolveActivity(intent, 65536); if (resolveActivity == null) { resolveActivity = packageManager.resolveActivity(intent, 0); } if (resolveActivity != null) { return resolveActivity.activityInfo.name; } return null; } catch (Throwable unused) { return null; } } private static String g(Context context, String str) { String str2; String str3; if (TextUtils.isEmpty(str)) { return null; } if (!str.startsWith(JPushConstants.HTTP_PRE) && !str.startsWith(JPushConstants.HTTPS_PRE)) { return null; } if (!cn.jpush.android.u.a.a()) { str2 = "NotificationHelper"; str3 = "SDCard is not mounted,need not download pic"; } else { String d = d(context, str); if (!TextUtils.isEmpty(d)) { return d; } str2 = "NotificationHelper"; str3 = "Get network picture failed."; } Logger.ww(str2, str3); return null; } /* access modifiers changed from: private */ /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */ /* JADX WARNING: Removed duplicated region for block: B:140:0x0333 */ /* JADX WARNING: Removed duplicated region for block: B:141:0x0339 */ /* JADX WARNING: Removed duplicated region for block: B:143:0x0341 */ /* JADX WARNING: Removed duplicated region for block: B:179:0x0411 */ /* JADX WARNING: Removed duplicated region for block: B:183:0x0424 */ /* JADX WARNING: Removed duplicated region for block: B:186:0x0439 */ /* JADX WARNING: Removed duplicated region for block: B:189:0x0452 */ /* JADX WARNING: Removed duplicated region for block: B:191:0x0456 */ /* JADX WARNING: Removed duplicated region for block: B:194:0x0461 */ /* JADX WARNING: Removed duplicated region for block: B:197:0x0471 */ /* JADX WARNING: Removed duplicated region for block: B:200:0x047e */ /* JADX WARNING: Removed duplicated region for block: B:204:0x04b9 */ /* JADX WARNING: Removed duplicated region for block: B:207:0x04c5 */ /* JADX WARNING: Removed duplicated region for block: B:209:0x04cd */ /* JADX WARNING: Removed duplicated region for block: B:219:0x0503 */ /* JADX WARNING: Removed duplicated region for block: B:230:0x0532 */ public static void g(Context context, d dVar) { Throwable th; boolean z; boolean z2; boolean z3; Notification notification; NotificationManager notificationManager; String str; String str2; int i; Throwable th2; long j; boolean z4; boolean z5; long j2; JSONArray jSONArray; JCoreHelper.triggerSceneCheck(context); boolean z6 = false; try { if (!TextUtils.isEmpty(dVar.F)) { try { if (!dVar.F.equals("ssp")) { Logger.d("NotificationHelper", "source:" + dVar.F); c.a(dVar.c, 975, context); return; } else if (h.a()) { Logger.d("NotificationHelper", "the device is in black list"); a(context, 100005, 1, "device in black"); c.a(dVar.c, 974, context); return; } else { if (TextUtils.isEmpty(dVar.L)) { if (TextUtils.isEmpty(dVar.I) || !dVar.I.startsWith("http")) { Logger.d("NotificationHelper", "deeplink is empty or not a http/https url"); c.a(dVar.c, 985, context); return; } } else if (!cn.jpush.android.u.a.c(context, dVar.L)) { if (dVar.J != 0) { if (dVar.J != 2) { c.a(dVar.c, 980, context); } } a(context, 100004, 1, "" + dVar.J); Logger.d("NotificationHelper", "targetPkgname:" + dVar.L + " not installed and failed type:" + dVar.J + ",need not show notification"); c.a(dVar.c, 981, context); return; } try { boolean z7 = dVar.M == 1001; if (!z7) { c.a(dVar.c, 1050, context); return; } else { z2 = z7; z = true; } } catch (Throwable th3) { th = th3; z6 = true; if (!z6) { } c.a(dVar.c, 1080, context); Logger.e("NotificationHelper", "showNotification failed:" + th.getMessage()); } } } catch (Throwable th4) { th = th4; if (!z6) { b(context, 1000, 0, th.getMessage()); } c.a(dVar.c, 1080, context); Logger.e("NotificationHelper", "showNotification failed:" + th.getMessage()); } } else { z2 = false; z = false; } try { if (!TextUtils.isEmpty(dVar.u)) { String messageReceiverClass = JPushConstants.getMessageReceiverClass(context); NotificationMessage b = dVar.b(); if (!a(context, messageReceiverClass, dVar, b)) { String str3 = ""; c a2 = a(JPushConstants.mApplicationContext, dVar.F, dVar.L, dVar.G, dVar.c); if (a2.e() != 0) { c.a(dVar.c, a2.e(), context); Logger.ww("NotificationHelper", "build small icon failed,will not notify this notification"); return; } c b2 = b(JPushConstants.mApplicationContext, dVar.H); if (z2) { long j3 = 0; try { JSONObject jSONObject = new JSONObject(dVar.B); i = jSONObject.optInt("ssp_msgcount_limit", 0); try { long optLong = jSONObject.optLong("ssp_msg_gap", 0); if (i > 0) { try { Logger.d("NotificationHelper", "setSSPLimitCount:" + i); } catch (Throwable th5) { th2 = th5; j3 = optLong; } } if (optLong > 0) { j3 = 1000 * optLong; Logger.d("NotificationHelper", "setSSPLimitInterval:" + j3); } else { j3 = optLong; } try { String optString = jSONObject.optString("app_singed_md5", ""); int g = cn.jpush.android.u.a.g(context, TbsConfig.APP_WX); JSONArray optJSONArray = jSONObject.optJSONArray("wx_limits"); if (optJSONArray != null) { int i2 = 0; int i3 = 0; boolean z8 = true; boolean z9 = true; while (i3 < optJSONArray.length()) { JSONObject optJSONObject = optJSONArray.optJSONObject(i3); if (optJSONObject != null) { jSONArray = optJSONArray; j2 = j3; try { int optInt = optJSONObject.optInt("vcode", 0); if (optInt > i2 && g >= optInt) { i2 = optInt; z8 = optJSONObject.optBoolean("check_appid", true); z9 = optJSONObject.optBoolean("check_md5", true); } } catch (Throwable th6) { th2 = th6; j3 = j2; Logger.w("NotificationHelper", "parse ssp notificationExtra failed, error:" + th2.getMessage()); Logger.d("NotificationHelper", "is wx mini type=" + dVar.Q); switch (h.a(context, i, j3)) { } int a3 = a(dVar); dVar.d = a3; dVar.am = str3; notification.contentIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), dVar.R ? 2 == dVar.W ? b(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar) : a(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar) : c(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar), 1073741824); if (!z2) { } if (dVar.k == 1) { } if (!z2) { } if (c(context)) { } notificationManager = (NotificationManager) context.getSystemService("notification"); if (notificationManager != null) { } if (dVar.k == 1) { } Logger.d(str, str2); if (z2) { } a(context, "cn.jpush.android.intent.NOTIFICATION_ARRIVED", dVar, (Intent) null); } } else { jSONArray = optJSONArray; j2 = j3; } i3++; optJSONArray = jSONArray; j3 = j2; } j = j3; z5 = z8; z4 = z9; } else { j = j3; z5 = true; z4 = true; } Logger.d("NotificationHelper", "sspWxAppId=" + dVar.N + ",sspWmOriginId=" + dVar.O + ",sspAppSign=" + optString + ",checkappid=" + z5 + ", checkMd5=" + z4); if (TextUtils.isEmpty(dVar.O)) { Logger.d("NotificationHelper", "ssp deeplink is not wx miniprogram ,sspWmOriginId is empty"); } else if (TextUtils.isEmpty(dVar.N) || TextUtils.isEmpty(optString)) { c.a(dVar.c, 1074, context); } else if (!cn.jpush.android.u.a.i(context)) { c.a(dVar.c, 1070, context); } else if (cn.jpush.android.u.a.j(context)) { String k = cn.jpush.android.u.a.k(context); Logger.d("NotificationHelper", "localWxId=" + k); if (z5) { if (!TextUtils.isEmpty(k)) { if (!dVar.N.equals(k)) { c.a(dVar.c, 1072, context); } } dVar.Q = true; } else { dVar.Q = true; } if (dVar.Q && z4) { if (optString.equalsIgnoreCase(cn.jpush.android.u.a.f(context, context.getPackageName()))) { dVar.Q = true; } else { c.a(dVar.c, 1071, context); } } } else { c.a(dVar.c, 1073, context); } j3 = j; } catch (Throwable th7) { th2 = th7; Logger.w("NotificationHelper", "parse ssp notificationExtra failed, error:" + th2.getMessage()); Logger.d("NotificationHelper", "is wx mini type=" + dVar.Q); switch (h.a(context, i, j3)) { } int a32 = a(dVar); dVar.d = a32; dVar.am = str3; notification.contentIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), dVar.R ? 2 == dVar.W ? b(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar) : a(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar) : c(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar), 1073741824); if (!z2) { } if (dVar.k == 1) { } if (!z2) { } if (c(context)) { } notificationManager = (NotificationManager) context.getSystemService("notification"); if (notificationManager != null) { } if (dVar.k == 1) { } Logger.d(str, str2); if (z2) { } a(context, "cn.jpush.android.intent.NOTIFICATION_ARRIVED", dVar, (Intent) null); } } catch (Throwable th8) { th2 = th8; Logger.w("NotificationHelper", "parse ssp notificationExtra failed, error:" + th2.getMessage()); Logger.d("NotificationHelper", "is wx mini type=" + dVar.Q); switch (h.a(context, i, j3)) { } int a322 = a(dVar); dVar.d = a322; dVar.am = str3; notification.contentIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), dVar.R ? 2 == dVar.W ? b(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar) : a(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar) : c(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar), 1073741824); if (!z2) { } if (dVar.k == 1) { } if (!z2) { } if (c(context)) { } notificationManager = (NotificationManager) context.getSystemService("notification"); if (notificationManager != null) { } if (dVar.k == 1) { } Logger.d(str, str2); if (z2) { } a(context, "cn.jpush.android.intent.NOTIFICATION_ARRIVED", dVar, (Intent) null); } } catch (Throwable th9) { th2 = th9; i = 0; Logger.w("NotificationHelper", "parse ssp notificationExtra failed, error:" + th2.getMessage()); Logger.d("NotificationHelper", "is wx mini type=" + dVar.Q); switch (h.a(context, i, j3)) { } int a3222 = a(dVar); dVar.d = a3222; dVar.am = str3; notification.contentIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), dVar.R ? 2 == dVar.W ? b(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar) : a(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar) : c(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar), 1073741824); if (!z2) { } if (dVar.k == 1) { } if (!z2) { } if (c(context)) { } notificationManager = (NotificationManager) context.getSystemService("notification"); if (notificationManager != null) { } if (dVar.k == 1) { } Logger.d(str, str2); if (z2) { } a(context, "cn.jpush.android.intent.NOTIFICATION_ARRIVED", dVar, (Intent) null); } Logger.d("NotificationHelper", "is wx mini type=" + dVar.Q); switch (h.a(context, i, j3)) { case -2: c.a(dVar.c, 1053, context); return; case -1: c.a(dVar.c, 1052, context); return; default: dVar.ac = 0; if (h.c() == -1) { notification = a(context, dVar, null, z2, a2, b2); } else { Object a4 = a(context, dVar, a2, b2); if (a4 == null) { c.a(dVar.c, 983, context); return; } if ((a4 instanceof Integer) && ((Integer) a4).intValue() == 984) { c.a(dVar.c, 984, context); } if (a4 instanceof RemoteViews) { notification = a(context, dVar, (RemoteViews) a4, z2, a2, b2); } else { return; } } Logger.d("NotificationHelper", "source is :" + dVar.F + ",use DefaultPushNotificationBuilder"); z3 = true; break; } } else { try { notification = !TextUtils.isEmpty(messageReceiverClass) ? ((JPushMessageReceiver) Class.forName(messageReceiverClass).newInstance()).getNotification(context, b) : null; } catch (Throwable th10) { Logger.ww("NotificationHelper", "get notification from JPushMessageReceiver failed:" + th10.getMessage()); notification = null; } if (notification == null) { PushNotificationBuilder a5 = a(context, b); if (a5 != null) { notification = a5.buildNotification(context, b); str3 = a5.getDeveloperArg0(); } if (notification == null) { notification = a(context, dVar, null, z2, a2, b2); z3 = false; } } z3 = false; } int a32222 = a(dVar); dVar.d = a32222; dVar.am = str3; notification.contentIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), dVar.R ? 2 == dVar.W ? b(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar) : a(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar) : c(context, JPushInterface.ACTION_NOTIFICATION_OPENED, dVar), 1073741824); if (!z2) { notification.deleteIntent = PendingIntent.getActivity(context, (int) (System.currentTimeMillis() + 1), c(context, "cn.jpush.android.intent.NOTIFICATION_DISMISS", dVar), 1073741824); } if (dVar.k == 1) { dVar.r = 1; } if (!z2) { notification.flags = a(dVar.r) | 1; } else if (!h.b()) { notification.flags = 17; } if (c(context)) { notification.defaults = 0; } notificationManager = (NotificationManager) context.getSystemService("notification"); if (notificationManager != null) { Logger.dd("NotificationHelper", "notify: id=" + a32222 + " messageId=" + dVar.c + " overmessageid=" + dVar.f); a(context, dVar.ac, notification); notificationManager.notify(a32222, notification); if (z3) { h.a(context); } a(context, a32222); } else { Logger.w("NotificationHelper", "NotificationManager is null"); } if (dVar.k == 1) { str = "NotificationHelper"; str2 = "local notification not offer to notification queue"; } else if (dVar.ab == 0) { if (!z2) { b(context, a32222); } if (d(context) == 0) { c.a(dVar.c, 1036, context); } c.a(dVar.c, PointerIconCompat.TYPE_ZOOM_IN, context); if ((z2 || "com.mt.mtxx.mtxx".equals(context.getPackageName())) && dVar.ab == 0) { a(context, "cn.jpush.android.intent.NOTIFICATION_ARRIVED", dVar, (Intent) null); } a(context, 100001, 0, dVar.I); Logger.d("NotificationHelper", "custom deep link need not send receiver to user"); return; } else { str = "NotificationHelper"; str2 = "Third notification:" + ((int) dVar.ab); } Logger.d(str, str2); if (z2) { } a(context, "cn.jpush.android.intent.NOTIFICATION_ARRIVED", dVar, (Intent) null); } } else if (z2) { c.a(dVar.c, 1051, context); } else { a(context, "cn.jpush.android.intent.NOTIFICATION_ARRIVED", dVar, (Intent) null); Logger.w("NotificationHelper", "notificationContent is empty"); } } catch (Throwable th11) { th = th11; z6 = z; if (!z6) { } c.a(dVar.c, 1080, context); Logger.e("NotificationHelper", "showNotification failed:" + th.getMessage()); } } catch (Throwable th12) { th = th12; z6 = false; if (!z6) { } c.a(dVar.c, 1080, context); Logger.e("NotificationHelper", "showNotification failed:" + th.getMessage()); } } private static String h(Context context) { try { Intent launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); if (!(launchIntentForPackage == null || launchIntentForPackage.getComponent() == null)) { return launchIntentForPackage.getComponent().getClassName(); } } catch (Throwable unused) { } return g(context); } /* access modifiers changed from: private */ public static void h(Context context, d dVar) { boolean z; String str = ""; String str2 = dVar.c; String str3 = dVar.S; if (!TextUtils.isEmpty(str3)) { String a2 = cn.jpush.android.o.a.a(str3, 5, RangedBeacon.DEFAULT_MAX_TRACKING_AGE); boolean isEmpty = TextUtils.isEmpty(a2); if (!isEmpty) { str = a2; } z = !isEmpty; } else { Logger.w("NotificationHelper", "Show url is Empty! Give up to download!"); z = false; } String c = cn.jpush.android.u.c.c(context, str2); if (z) { String str4 = c + str2 + ".html"; String substring = str3.substring(0, str3.lastIndexOf("/") + 1); if (dVar.Y.isEmpty()) { dVar.U = dVar.S; } else if (!h.a(dVar.Y, context, substring, str2, true)) { Logger.d("NotificationHelper", "Loads rich push resources failed, webView will open url!"); c.a(str2, PointerIconCompat.TYPE_HORIZONTAL_DOUBLE_ARROW, context); g(context, dVar); return; } else { Logger.d("NotificationHelper", "Loads rich push resources succeed, webView will open cache!"); if (cn.jpush.android.u.c.b(str4, str.replaceAll("img src=\"" + substring, "img src=\"" + c))) { dVar.U = "file://" + str4; c.a(str2, TbsLog.TBSLOG_CODE_SDK_THIRD_MODE, context); } else { c.a(str2, PointerIconCompat.TYPE_HORIZONTAL_DOUBLE_ARROW, context); return; } } g(context, dVar); return; } Logger.w("NotificationHelper", "NOTE: failed to download html page. Give up this."); c.a(str2, PointerIconCompat.TYPE_HORIZONTAL_DOUBLE_ARROW, context); c.a(str2, PointerIconCompat.TYPE_GRABBING, null, context); } private static boolean h(Context context, String str) { if (TextUtils.isEmpty(str)) { Logger.d("NotificationHelper", "link uri is empty"); return false; } try { Logger.d("NotificationHelper", "url:" + str); if (str.startsWith("http")) { return i(context, str); } Logger.d("NotificationHelper", "jump intent:" + str); Intent parseUri = Intent.parseUri(str, 0); parseUri.setFlags(268435456); c(context, parseUri); context.startActivity(parseUri); a(context, 100002, 0, str); return true; } catch (Throwable th) { Logger.d("NotificationHelper", "[handleSSP] start fail uri error:" + th.getMessage()); a(context, 100002, 1, str + "---" + th.getMessage()); return false; } } /* access modifiers changed from: private */ public static void i(Context context, d dVar) { String a2; String str; String str2; String str3 = dVar.x; dVar.x = ""; if (dVar.v == 3 && !TextUtils.isEmpty(str3)) { if (str3.startsWith(JPushConstants.HTTP_PRE) || str3.startsWith(JPushConstants.HTTPS_PRE)) { a2 = a(context, str3, dVar.c); if (TextUtils.isEmpty(a2)) { str = "NotificationHelper"; str2 = "Get network picture failed, show basic notification only."; Logger.ww(str, str2); return; } } else { a2 = cn.jpush.android.u.c.d(context, str3); if (TextUtils.isEmpty(a2)) { str = "NotificationHelper"; str2 = "Get developer picture failed, show basic notification only."; Logger.ww(str, str2); return; } } dVar.x = a2; } } private static boolean i(Context context, String str) { if (TextUtils.isEmpty(str)) { Logger.d("NotificationHelper", "link uri is empty"); return false; } Logger.d("NotificationHelper", "[openWebUri]:" + str); try { if (cn.jpush.android.u.a.c(context, "com.android.browser")) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); intent.setData(Uri.parse(str)); intent.setFlags(268435456); intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity"); c(context, intent); context.startActivity(intent); a(context, 100002, 0, str + "---by default browser"); return true; } Logger.dd("NotificationHelper", "not found com.android.browser,user will choose other browser"); throw new Throwable("not found com.android.browser,user will choose other browser"); } catch (Throwable th) { th.printStackTrace(); Logger.d("NotificationHelper", "[openWebUri] start fail uri error:" + th.getMessage()); a(context, 100002, 1, str + "---" + th.getMessage()); return false; } } }