MD5 校验值:8df004f6dd2453bdf1d8ecd51cca1137
BrazeNotificationUtils.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.braze.push; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.AlarmManager; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.UiModeManager; import android.content.Context; import android.content.Intent; import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.PowerManager; import android.os.SystemClock; import androidx.core.app.o; import com.braze.Braze; import com.braze.BrazeInternal; import com.braze.Constants; import com.braze.IBrazeNotificationFactory; import com.braze.configuration.BrazeConfigurationProvider; import com.braze.enums.BrazePushEventType; import com.braze.enums.BrazeViewBounds; import com.braze.enums.Channel; import com.braze.models.push.BrazeNotificationPayload; import com.braze.push.support.HtmlUtils; import com.braze.support.BrazeLogger; import com.braze.support.IntentUtils; import com.braze.support.JsonUtils; import com.braze.support.PermissionUtils; import com.braze.ui.BrazeDeeplinkHandler; import com.braze.ui.actions.UriAction; import com.braze.ui.support.UriUtils; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import kotlin.NoWhenBranchMatchedException; import kotlin.jvm.internal.p; import tg.r; public final class BrazeNotificationUtils { public static final BrazeNotificationUtils INSTANCE = new BrazeNotificationUtils(); private static final String TAG = BrazeLogger.getBrazeLogTag((Class<?>) BrazeNotificationUtils.class); public enum BrazeNotificationBroadcastType { OPENED(BrazePushEventType.NOTIFICATION_OPENED), RECEIVED(BrazePushEventType.NOTIFICATION_RECEIVED), DELETED(BrazePushEventType.NOTIFICATION_DELETED); private final BrazePushEventType brazePushEventType; BrazeNotificationBroadcastType(BrazePushEventType brazePushEventType) { this.brazePushEventType = brazePushEventType; } public final BrazePushEventType getBrazePushEventType() { return this.brazePushEventType; } } public class WhenMappings { public static final int[] $EnumSwitchMapping$0; static { int[] iArr = new int[BrazeNotificationBroadcastType.values().length]; try { iArr[BrazeNotificationBroadcastType.OPENED.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { iArr[BrazeNotificationBroadcastType.RECEIVED.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { iArr[BrazeNotificationBroadcastType.DELETED.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } $EnumSwitchMapping$0 = iArr; } } private BrazeNotificationUtils() { } public static final void cancelNotification(Context context, int i10) { p.g(context, "context"); try { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$cancelNotification$1(i10), 3, (Object) null); Intent intent = new Intent("com.braze.action.CANCEL_NOTIFICATION").setClass(context, getNotificationReceiverClass()); p.f(intent, "Intent(Constants.BRAZE_C…otificationReceiverClass)"); intent.setPackage(context.getPackageName()); intent.putExtra("nid", i10); IntentUtils.addComponentAndSendBroadcast(context, intent); } catch (Exception e10) { BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e10, BrazeNotificationUtils$cancelNotification$2.INSTANCE); } } public static final IBrazeNotificationFactory getActiveNotificationFactory() { IBrazeNotificationFactory customBrazeNotificationFactory = Braze.Companion.getCustomBrazeNotificationFactory(); if (customBrazeNotificationFactory == null) { return BrazeNotificationFactory.Companion.getInstance(); } return customBrazeNotificationFactory; } public static final int getNotificationId(BrazeNotificationPayload payload) { int i10; p.g(payload, "payload"); Integer customNotificationId = payload.getCustomNotificationId(); if (customNotificationId != null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$getNotificationId$1(customNotificationId), 3, (Object) null); return customNotificationId.intValue(); } String titleText = payload.getTitleText(); String str = ""; if (titleText != null) { str = "" + titleText; } String contentText = payload.getContentText(); if (contentText != null) { str = str + contentText; } if (str != null) { i10 = str.hashCode(); } else { i10 = 0; } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$getNotificationId$4(i10), 3, (Object) null); return i10; } public static final int getNotificationPriority(BrazeNotificationPayload payload) { p.g(payload, "payload"); Integer notificationPriorityInt = payload.getNotificationPriorityInt(); Integer notificationPriorityInt2 = payload.getNotificationPriorityInt(); if (notificationPriorityInt2 != null) { int intValue = notificationPriorityInt2.intValue(); if (-2 <= intValue && intValue < 3) { return intValue; } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.W, (Throwable) null, new BrazeNotificationUtils$getNotificationPriority$1$1(notificationPriorityInt), 2, (Object) null); return 0; } return 0; } public static final Class<?> getNotificationReceiverClass() { if (Constants.isAmazonDevice()) { return BrazeAmazonDeviceMessagingReceiver.class; } return BrazePushReceiver.class; } public static final String getOrCreateNotificationChannelId(BrazeNotificationPayload payload) { Object obj; String str; p.g(payload, "payload"); String notificationChannelId = payload.getNotificationChannelId(); if (Build.VERSION.SDK_INT < 26) { if (notificationChannelId == null) { return "com_appboy_default_notification_channel"; } return notificationChannelId; } Context context = payload.getContext(); BrazeConfigurationProvider configurationProvider = payload.getConfigurationProvider(); String str2 = null; if (context != null) { obj = context.getSystemService("notification"); } else { obj = null; } p.e(obj, "null cannot be cast to non-null type android.app.NotificationManager"); NotificationManager notificationManager = (NotificationManager) obj; if (notificationChannelId != null) { if (notificationManager.getNotificationChannel(notificationChannelId) != null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$getOrCreateNotificationChannelId$1(notificationChannelId), 3, (Object) null); return notificationChannelId; } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$getOrCreateNotificationChannelId$2(notificationChannelId), 3, (Object) null); } if (notificationManager.getNotificationChannel("com_appboy_default_notification_channel") == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$getOrCreateNotificationChannelId$3.INSTANCE, 3, (Object) null); if (configurationProvider != null) { str = configurationProvider.getDefaultNotificationChannelName(); } else { str = null; } NotificationChannel notificationChannel = new NotificationChannel("com_appboy_default_notification_channel", str, 3); if (configurationProvider != null) { str2 = configurationProvider.getDefaultNotificationChannelDescription(); } notificationChannel.setDescription(str2); notificationManager.createNotificationChannel(notificationChannel); } return "com_appboy_default_notification_channel"; } private final PendingIntent getPushActionPendingIntent(Context context, String str, Bundle bundle) { Intent intent = new Intent(str).setClass(context, NotificationTrampolineActivity.class); p.f(intent, "Intent(action).setClass(…lineActivity::class.java)"); if (bundle != null) { intent.putExtras(bundle); } PendingIntent activity = PendingIntent.getActivity(context, IntentUtils.getRequestCode(), intent, 1073741824 | IntentUtils.getImmutablePendingIntentFlags()); p.f(activity, "getActivity(context, get… pushActionIntent, flags)"); return activity; } @TargetApi(26) public static final NotificationChannel getValidNotificationChannel(NotificationManager notificationManager, Bundle bundle) { boolean t10; p.g(notificationManager, "notificationManager"); if (bundle == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$getValidNotificationChannel$1.INSTANCE, 3, (Object) null); return null; } String string = bundle.getString("ab_nc", null); if (string != null) { t10 = r.t(string); if (!t10) { NotificationChannel notificationChannel = notificationManager.getNotificationChannel(string); if (notificationChannel != null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$getValidNotificationChannel$2(string), 3, (Object) null); return notificationChannel; } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$getValidNotificationChannel$3(string), 3, (Object) null); } } NotificationChannel notificationChannel2 = notificationManager.getNotificationChannel("com_appboy_default_notification_channel"); if (notificationChannel2 != null) { return notificationChannel2; } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$getValidNotificationChannel$4.INSTANCE, 3, (Object) null); return null; } public static final void handleCancelNotificationAction(Context context, Intent intent) { p.g(context, "context"); p.g(intent, "intent"); try { if (intent.hasExtra("nid")) { int intExtra = intent.getIntExtra("nid", -1); BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$handleCancelNotificationAction$1(intExtra), 3, (Object) null); Object systemService = context.getSystemService("notification"); p.e(systemService, "null cannot be cast to non-null type android.app.NotificationManager"); ((NotificationManager) systemService).cancel("appboy_notification", intExtra); } } catch (Exception e10) { BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e10, BrazeNotificationUtils$handleCancelNotificationAction$2.INSTANCE); } } public static final void handleContentCardsSerializedCardIfPresent(BrazeNotificationPayload payload) { p.g(payload, "payload"); String contentCardSyncData = payload.getContentCardSyncData(); String contentCardSyncUserId = payload.getContentCardSyncUserId(); Context context = payload.getContext(); if (contentCardSyncData != null && context != null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$handleContentCardsSerializedCardIfPresent$1(contentCardSyncUserId, contentCardSyncData), 3, (Object) null); BrazeInternal.addSerializedContentCardToStorage(context, contentCardSyncData, contentCardSyncUserId); } } public static final void handleNotificationDeleted(Context context, Intent intent) { p.g(context, "context"); p.g(intent, "intent"); try { BrazeLogger brazeLogger = BrazeLogger.INSTANCE; BrazeNotificationUtils brazeNotificationUtils = INSTANCE; BrazeLogger.brazelog$default(brazeLogger, brazeNotificationUtils, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$handleNotificationDeleted$1.INSTANCE, 3, (Object) null); Bundle extras = intent.getExtras(); if (extras != null) { brazeNotificationUtils.sendPushActionIntent(context, BrazeNotificationBroadcastType.DELETED, extras, new BrazeNotificationPayload(extras, null, context, null, 10, null)); } else { sendPushActionIntent$default(brazeNotificationUtils, context, BrazeNotificationBroadcastType.DELETED, extras, null, 8, null); } } catch (Exception e10) { BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e10, BrazeNotificationUtils$handleNotificationDeleted$2.INSTANCE); } } public static final void handleNotificationOpened(Context context, Intent intent) { p.g(context, "context"); p.g(intent, "intent"); try { Braze.Companion.getInstance(context).logPushNotificationOpened(intent); sendNotificationOpenedBroadcast(context, intent); if (new BrazeConfigurationProvider(context).getDoesHandlePushDeepLinksAutomatically()) { routeUserWithNotificationOpenedIntent(context, intent); } else { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.I, (Throwable) null, BrazeNotificationUtils$handleNotificationOpened$1.INSTANCE, 2, (Object) null); } } catch (Exception e10) { BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e10, BrazeNotificationUtils$handleNotificationOpened$2.INSTANCE); } } public static final void handlePushStoryPageClicked(Context context, Intent intent) { boolean t10; boolean t11; p.g(context, "context"); p.g(intent, "intent"); try { Braze.Companion.getInstance(context).logPushStoryPageClicked(intent.getStringExtra("braze_campaign_id"), intent.getStringExtra("braze_story_page_id")); BrazeConfigurationProvider brazeConfigurationProvider = new BrazeConfigurationProvider(context); int intExtra = intent.getIntExtra("nid", 0); if (brazeConfigurationProvider.getDoesPushStoryDismissOnClick() && intExtra != 0) { cancelNotification(context, intExtra); } String stringExtra = intent.getStringExtra("braze_action_uri"); if (stringExtra != null) { t10 = r.t(stringExtra); if (!t10) { intent.putExtra("uri", intent.getStringExtra("braze_action_uri")); String stringExtra2 = intent.getStringExtra("braze_action_use_webview"); if (stringExtra2 != null) { t11 = r.t(stringExtra2); if (!t11) { intent.putExtra("ab_use_webview", stringExtra2); } } sendNotificationOpenedBroadcast(context, intent); if (!brazeConfigurationProvider.getDoesHandlePushDeepLinksAutomatically()) { routeUserWithNotificationOpenedIntent(context, intent); return; } else { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.I, (Throwable) null, new BrazeNotificationUtils$handlePushStoryPageClicked$1(stringExtra), 2, (Object) null); return; } } } intent.removeExtra("uri"); sendNotificationOpenedBroadcast(context, intent); if (!brazeConfigurationProvider.getDoesHandlePushDeepLinksAutomatically()) { } } catch (Exception e10) { BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e10, BrazeNotificationUtils$handlePushStoryPageClicked$2.INSTANCE); } } public static final boolean isBrazePushMessage(Intent intent) { boolean r10; p.g(intent, "<this>"); Bundle extras = intent.getExtras(); if (extras != null) { r10 = r.r("true", extras.getString("_ab"), true); return r10; } return false; } public static final boolean isNotificationMessage(Intent intent) { p.g(intent, "intent"); Bundle extras = intent.getExtras(); if (extras == null || !extras.containsKey("t") || !extras.containsKey("a")) { return false; } return true; } @TargetApi(21) public static final boolean isValidNotificationVisibility(int i10) { if (i10 == -1 || i10 == 0 || i10 == 1) { return true; } return false; } public static final void prefetchBitmapsIfNewlyReceivedStoryPush(BrazeNotificationPayload payload) { p.g(payload, "payload"); Context context = payload.getContext(); if (context != null && payload.isPushStory() && payload.isNewlyReceivedPushStory()) { List<BrazeNotificationPayload.PushStoryPage> pushStoryPages = payload.getPushStoryPages(); ArrayList<String> arrayList = new ArrayList(); Iterator<T> it = pushStoryPages.iterator(); while (it.hasNext()) { String bitmapUrl = ((BrazeNotificationPayload.PushStoryPage) it.next()).getBitmapUrl(); if (bitmapUrl != null) { arrayList.add(bitmapUrl); } } for (String str : arrayList) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.V, (Throwable) null, new BrazeNotificationUtils$prefetchBitmapsIfNewlyReceivedStoryPush$2$1(str), 2, (Object) null); Braze.Companion.getInstance(context).getImageLoader().getPushBitmapFromUrl(context, payload.getBrazeExtras(), str, BrazeViewBounds.NOTIFICATION_ONE_IMAGE_STORY); } payload.setNewlyReceivedPushStory(false); } } public static final boolean refreshFeatureFlagsIfAppropriate(BrazeNotificationPayload payload) { p.g(payload, "payload"); Context context = payload.getContext(); if (payload.getShouldRefreshFeatureFlags() && context != null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$refreshFeatureFlagsIfAppropriate$1.INSTANCE, 3, (Object) null); BrazeInternal.refreshFeatureFlags(context); return true; } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.V, (Throwable) null, BrazeNotificationUtils$refreshFeatureFlagsIfAppropriate$2.INSTANCE, 2, (Object) null); return false; } public static final boolean requestGeofenceRefreshIfAppropriate(BrazeNotificationPayload payload) { p.g(payload, "payload"); Context context = payload.getContext(); if (payload.getShouldSyncGeofences() && context != null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$requestGeofenceRefreshIfAppropriate$1.INSTANCE, 3, (Object) null); BrazeInternal.requestGeofenceRefresh(context, true); return true; } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$requestGeofenceRefreshIfAppropriate$2.INSTANCE, 3, (Object) null); return false; } public static final void routeUserWithNotificationOpenedIntent(Context context, Intent intent) { boolean t10; boolean r10; p.g(context, "context"); p.g(intent, "intent"); Bundle bundleExtra = intent.getBundleExtra("extra"); if (bundleExtra == null) { bundleExtra = new Bundle(); } bundleExtra.putString("cid", intent.getStringExtra("cid")); bundleExtra.putString("source", "Appboy"); String stringExtra = intent.getStringExtra("uri"); if (stringExtra != null) { t10 = r.t(stringExtra); if (!t10) { r10 = r.r("true", intent.getStringExtra("ab_use_webview"), true); BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$routeUserWithNotificationOpenedIntent$1(stringExtra, r10), 3, (Object) null); bundleExtra.putString("uri", stringExtra); bundleExtra.putBoolean("ab_use_webview", r10); BrazeDeeplinkHandler.Companion companion = BrazeDeeplinkHandler.Companion; UriAction createUriActionFromUrlString = companion.getInstance().createUriActionFromUrlString(stringExtra, bundleExtra, r10, Channel.PUSH); if (createUriActionFromUrlString != null) { companion.getInstance().gotoUri(context, createUriActionFromUrlString); return; } return; } } Intent mainActivityIntent = UriUtils.getMainActivityIntent(context, bundleExtra); BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$routeUserWithNotificationOpenedIntent$3(mainActivityIntent), 3, (Object) null); context.startActivity(mainActivityIntent); } public static final void sendNotificationOpenedBroadcast(Context context, Intent intent) { p.g(context, "context"); p.g(intent, "intent"); BrazeLogger brazeLogger = BrazeLogger.INSTANCE; BrazeNotificationUtils brazeNotificationUtils = INSTANCE; BrazeLogger.brazelog$default(brazeLogger, brazeNotificationUtils, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$sendNotificationOpenedBroadcast$1.INSTANCE, 3, (Object) null); Bundle extras = intent.getExtras(); if (extras != null) { brazeNotificationUtils.sendPushActionIntent(context, BrazeNotificationBroadcastType.OPENED, extras, new BrazeNotificationPayload(extras, null, context, null, 10, null)); } else { sendPushActionIntent$default(brazeNotificationUtils, context, BrazeNotificationBroadcastType.OPENED, extras, null, 8, null); } } private final void sendPushActionIntent(Context context, BrazeNotificationBroadcastType brazeNotificationBroadcastType, Bundle bundle, BrazeNotificationPayload brazeNotificationPayload) { Intent intent; int i10 = WhenMappings.$EnumSwitchMapping$0[brazeNotificationBroadcastType.ordinal()]; if (i10 == 1) { intent = new Intent("com.braze.push.intent.NOTIFICATION_OPENED").setPackage(context.getPackageName()); p.f(intent, "{\n Intent…ackageName)\n }"); } else if (i10 == 2) { intent = new Intent("com.braze.push.intent.NOTIFICATION_RECEIVED").setPackage(context.getPackageName()); p.f(intent, "{\n Intent…ackageName)\n }"); } else { if (i10 != 3) { throw new NoWhenBranchMatchedException(); } intent = new Intent("com.braze.push.intent.NOTIFICATION_DELETED").setPackage(context.getPackageName()); p.f(intent, "{\n Intent…ackageName)\n }"); } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.V, (Throwable) null, new BrazeNotificationUtils$sendPushActionIntent$1(brazeNotificationBroadcastType), 2, (Object) null); sendPushActionIntent(context, intent, bundle); if (brazeNotificationPayload != null) { BrazeInternal.INSTANCE.publishBrazePushAction(context, brazeNotificationBroadcastType.getBrazePushEventType(), brazeNotificationPayload); } } static void sendPushActionIntent$default(BrazeNotificationUtils brazeNotificationUtils, Context context, BrazeNotificationBroadcastType brazeNotificationBroadcastType, Bundle bundle, BrazeNotificationPayload brazeNotificationPayload, int i10, Object obj) { if ((i10 & 8) != 0) { brazeNotificationPayload = null; } brazeNotificationUtils.sendPushActionIntent(context, brazeNotificationBroadcastType, bundle, brazeNotificationPayload); } public static final void sendPushMessageReceivedBroadcast(Context context, Bundle notificationExtras, BrazeNotificationPayload payload) { p.g(context, "context"); p.g(notificationExtras, "notificationExtras"); p.g(payload, "payload"); BrazeLogger brazeLogger = BrazeLogger.INSTANCE; BrazeNotificationUtils brazeNotificationUtils = INSTANCE; BrazeLogger.brazelog$default(brazeLogger, brazeNotificationUtils, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$sendPushMessageReceivedBroadcast$1.INSTANCE, 3, (Object) null); brazeNotificationUtils.sendPushActionIntent(context, BrazeNotificationBroadcastType.RECEIVED, notificationExtras, payload); } public static final void setAccentColorIfPresentAndSupported(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); Integer accentColor = payload.getAccentColor(); if (accentColor != null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setAccentColorIfPresentAndSupported$1.INSTANCE, 3, (Object) null); notificationBuilder.o(accentColor.intValue()); return; } BrazeConfigurationProvider configurationProvider = payload.getConfigurationProvider(); if (configurationProvider != null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setAccentColorIfPresentAndSupported$2$1.INSTANCE, 3, (Object) null); notificationBuilder.o(configurationProvider.getDefaultNotificationAccentColor()); } } public static final void setCategoryIfPresentAndSupported(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); String notificationCategory = payload.getNotificationCategory(); if (notificationCategory != null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setCategoryIfPresentAndSupported$1.INSTANCE, 3, (Object) null); notificationBuilder.m(notificationCategory); } else { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setCategoryIfPresentAndSupported$2.INSTANCE, 3, (Object) null); } } public static final void setContentIfPresent(o.e notificationBuilder, BrazeNotificationPayload payload) { BrazeConfigurationProvider configurationProvider; p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setContentIfPresent$1.INSTANCE, 3, (Object) null); String contentText = payload.getContentText(); if (contentText == null || (configurationProvider = payload.getConfigurationProvider()) == null) { return; } notificationBuilder.q(HtmlUtils.getHtmlSpannedTextIfEnabled(contentText, configurationProvider)); } public static final void setContentIntentIfPresent(Context context, o.e notificationBuilder, Bundle bundle) { p.g(context, "context"); p.g(notificationBuilder, "notificationBuilder"); try { notificationBuilder.p(INSTANCE.getPushActionPendingIntent(context, "com.braze.action.BRAZE_PUSH_CLICKED", bundle)); } catch (Exception e10) { BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e10, BrazeNotificationUtils$setContentIntentIfPresent$1.INSTANCE); } } public static final void setDeleteIntent(Context context, o.e notificationBuilder, Bundle bundle) { p.g(context, "context"); p.g(notificationBuilder, "notificationBuilder"); try { Intent intent = new Intent("com.braze.action.BRAZE_PUSH_DELETED").setClass(context, getNotificationReceiverClass()); p.f(intent, "Intent(Constants.BRAZE_P…otificationReceiverClass)"); if (bundle != null) { intent.putExtras(bundle); } notificationBuilder.v(PendingIntent.getBroadcast(context, IntentUtils.getRequestCode(), intent, IntentUtils.getImmutablePendingIntentFlags() | 1073741824)); } catch (Exception e10) { BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e10, BrazeNotificationUtils$setDeleteIntent$1.INSTANCE); } } public static final boolean setLargeIconIfPresentAndSupported(o.e notificationBuilder, BrazeNotificationPayload payload) { BrazeConfigurationProvider configurationProvider; BrazeLogger brazeLogger; BrazeNotificationUtils brazeNotificationUtils; String largeIcon; p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); if (payload.isPushStory()) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setLargeIconIfPresentAndSupported$1.INSTANCE, 3, (Object) null); return false; } Context context = payload.getContext(); if (context == null || (configurationProvider = payload.getConfigurationProvider()) == null) { return false; } try { brazeLogger = BrazeLogger.INSTANCE; brazeNotificationUtils = INSTANCE; BrazeLogger.brazelog$default(brazeLogger, brazeNotificationUtils, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setLargeIconIfPresentAndSupported$2.INSTANCE, 3, (Object) null); largeIcon = payload.getLargeIcon(); } catch (Exception e10) { BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e10, BrazeNotificationUtils$setLargeIconIfPresentAndSupported$6.INSTANCE); } if (largeIcon != null) { notificationBuilder.x(Braze.Companion.getInstance(context).getImageLoader().getPushBitmapFromUrl(context, null, largeIcon, BrazeViewBounds.NOTIFICATION_LARGE_ICON)); return true; } BrazeLogger.brazelog$default(brazeLogger, brazeNotificationUtils, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setLargeIconIfPresentAndSupported$4.INSTANCE, 3, (Object) null); int largeNotificationIconResourceId = configurationProvider.getLargeNotificationIconResourceId(); if (largeNotificationIconResourceId != 0) { notificationBuilder.x(BitmapFactory.decodeResource(context.getResources(), largeNotificationIconResourceId)); return true; } BrazeLogger.brazelog$default(brazeLogger, brazeNotificationUtils, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setLargeIconIfPresentAndSupported$5.INSTANCE, 3, (Object) null); BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setLargeIconIfPresentAndSupported$7.INSTANCE, 3, (Object) null); return false; } public static final void setNotificationBadgeNumberIfPresent(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); if (Build.VERSION.SDK_INT < 26) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setNotificationBadgeNumberIfPresent$1.INSTANCE, 3, (Object) null); return; } Integer notificationBadgeNumber = payload.getNotificationBadgeNumber(); if (notificationBadgeNumber != null) { notificationBuilder.A(notificationBadgeNumber.intValue()); } } public static final void setNotificationDurationAlarm(Context context, Class<?> cls, int i10, int i11) { p.g(context, "context"); Intent intent = new Intent(context, cls); intent.setAction("com.braze.action.CANCEL_NOTIFICATION"); intent.putExtra("nid", i10); PendingIntent broadcast = PendingIntent.getBroadcast(context, 0, intent, 134217728 | IntentUtils.getImmutablePendingIntentFlags()); Object systemService = context.getSystemService("alarm"); p.e(systemService, "null cannot be cast to non-null type android.app.AlarmManager"); AlarmManager alarmManager = (AlarmManager) systemService; if (i11 >= 1000) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$setNotificationDurationAlarm$1(i11), 3, (Object) null); alarmManager.set(3, SystemClock.elapsedRealtime() + i11, broadcast); } } public static final void setPriorityIfPresentAndSupported(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setPriorityIfPresentAndSupported$1.INSTANCE, 3, (Object) null); notificationBuilder.C(getNotificationPriority(payload)); } public static final void setPublicVersionIfPresentAndSupported(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); Context context = payload.getContext(); BrazeConfigurationProvider configurationProvider = payload.getConfigurationProvider(); if (context != null && payload.getPublicNotificationExtras() != null && configurationProvider != null) { String orCreateNotificationChannelId = getOrCreateNotificationChannelId(payload); Bundle parseJsonObjectIntoBundle = JsonUtils.parseJsonObjectIntoBundle(payload.getPublicNotificationExtras()); if (parseJsonObjectIntoBundle.isEmpty()) { return; } BrazeNotificationPayload brazeNotificationPayload = new BrazeNotificationPayload(parseJsonObjectIntoBundle, null, context, configurationProvider, 2, null); o.e eVar = new o.e(context, orCreateNotificationChannelId); BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$setPublicVersionIfPresentAndSupported$2(brazeNotificationPayload), 3, (Object) null); setContentIfPresent(eVar, brazeNotificationPayload); setTitleIfPresent(eVar, brazeNotificationPayload); setSummaryTextIfPresentAndSupported(eVar, brazeNotificationPayload); setSmallIcon(configurationProvider, eVar); setAccentColorIfPresentAndSupported(eVar, brazeNotificationPayload); notificationBuilder.D(eVar.c()); } } public static final void setSetShowWhen(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); if (payload.isPushStory()) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setSetShowWhen$1.INSTANCE, 3, (Object) null); notificationBuilder.F(false); } } public static final int setSmallIcon(BrazeConfigurationProvider appConfigurationProvider, o.e notificationBuilder) { p.g(appConfigurationProvider, "appConfigurationProvider"); p.g(notificationBuilder, "notificationBuilder"); int smallNotificationIconResourceId = appConfigurationProvider.getSmallNotificationIconResourceId(); if (smallNotificationIconResourceId == 0) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setSmallIcon$1.INSTANCE, 3, (Object) null); smallNotificationIconResourceId = appConfigurationProvider.getApplicationIconResourceId(); } else { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setSmallIcon$2.INSTANCE, 3, (Object) null); } notificationBuilder.G(smallNotificationIconResourceId); return smallNotificationIconResourceId; } public static final void setSoundIfPresentAndSupported(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); String notificationSound = payload.getNotificationSound(); if (notificationSound == null) { return; } if (p.b(notificationSound, "d")) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setSoundIfPresentAndSupported$1.INSTANCE, 3, (Object) null); notificationBuilder.u(1); } else { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setSoundIfPresentAndSupported$2.INSTANCE, 3, (Object) null); notificationBuilder.H(Uri.parse(notificationSound)); } } public static final void setSummaryTextIfPresentAndSupported(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); String summaryText = payload.getSummaryText(); if (summaryText != null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setSummaryTextIfPresentAndSupported$1.INSTANCE, 3, (Object) null); notificationBuilder.J(summaryText); } else { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setSummaryTextIfPresentAndSupported$2.INSTANCE, 3, (Object) null); } } public static final void setTickerIfPresent(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setTickerIfPresent$1.INSTANCE, 3, (Object) null); String titleText = payload.getTitleText(); if (titleText == null) { return; } notificationBuilder.K(titleText); } public static final void setTitleIfPresent(o.e notificationBuilder, BrazeNotificationPayload payload) { BrazeConfigurationProvider configurationProvider; p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setTitleIfPresent$1.INSTANCE, 3, (Object) null); String titleText = payload.getTitleText(); if (titleText == null || (configurationProvider = payload.getConfigurationProvider()) == null) { return; } notificationBuilder.r(HtmlUtils.getHtmlSpannedTextIfEnabled(titleText, configurationProvider)); } public static final void setVisibilityIfPresentAndSupported(o.e notificationBuilder, BrazeNotificationPayload payload) { p.g(notificationBuilder, "notificationBuilder"); p.g(payload, "payload"); Integer notificationVisibility = payload.getNotificationVisibility(); if (notificationVisibility != null) { if (isValidNotificationVisibility(notificationVisibility.intValue())) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$setVisibilityIfPresentAndSupported$1.INSTANCE, 3, (Object) null); notificationBuilder.M(notificationVisibility.intValue()); } else { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.W, (Throwable) null, new BrazeNotificationUtils$setVisibilityIfPresentAndSupported$2(notificationVisibility), 2, (Object) null); } } } public static final boolean wakeScreenIfAppropriate(Context context, BrazeConfigurationProvider configurationProvider, Bundle bundle) { p.g(context, "context"); p.g(configurationProvider, "configurationProvider"); return wakeScreenIfAppropriate(new BrazeNotificationPayload(bundle, null, context, configurationProvider, 2, null)); } @SuppressLint({"WakelockTimeout"}) public static final boolean wakeScreenIfAppropriate(BrazeNotificationPayload payload) { BrazeConfigurationProvider configurationProvider; p.g(payload, "payload"); Context context = payload.getContext(); if (context == null || (configurationProvider = payload.getConfigurationProvider()) == null) { return false; } Bundle notificationExtras = payload.getNotificationExtras(); if (!PermissionUtils.hasPermission(context, "android.permission.WAKE_LOCK") || !configurationProvider.isPushWakeScreenForNotificationEnabled()) { return false; } try { Object systemService = context.getSystemService("uimode"); p.e(systemService, "null cannot be cast to non-null type android.app.UiModeManager"); if (((UiModeManager) systemService).getCurrentModeType() == 4) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$wakeScreenIfAppropriate$1.INSTANCE, 3, (Object) null); return false; } } catch (Exception e10) { BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e10, BrazeNotificationUtils$wakeScreenIfAppropriate$2.INSTANCE); } if (Build.VERSION.SDK_INT >= 26) { Object systemService2 = context.getSystemService("notification"); p.e(systemService2, "null cannot be cast to non-null type android.app.NotificationManager"); NotificationChannel validNotificationChannel = getValidNotificationChannel((NotificationManager) systemService2, notificationExtras); if (validNotificationChannel == null) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$wakeScreenIfAppropriate$3.INSTANCE, 3, (Object) null); return false; } if (validNotificationChannel.getImportance() == 1) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new BrazeNotificationUtils$wakeScreenIfAppropriate$4(validNotificationChannel), 3, (Object) null); return false; } } else if (getNotificationPriority(payload) == -2) { return false; } BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, BrazeNotificationUtils$wakeScreenIfAppropriate$5.INSTANCE, 3, (Object) null); Object systemService3 = context.getSystemService("power"); p.e(systemService3, "null cannot be cast to non-null type android.os.PowerManager"); PowerManager.WakeLock newWakeLock = ((PowerManager) systemService3).newWakeLock(268435482, TAG); newWakeLock.acquire(); newWakeLock.release(); return true; } private final void sendPushActionIntent(Context context, Intent intent, Bundle bundle) { BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, this, BrazeLogger.Priority.V, (Throwable) null, new BrazeNotificationUtils$sendPushActionIntent$2(intent), 2, (Object) null); if (bundle != null) { intent.putExtras(bundle); } IntentUtils.addComponentAndSendBroadcast(context, intent); } }