MD5 校验值:328357c6f846d37b47ed4cc8f5415f3d
FlutterLocalNotificationsPlugin.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.dexterous.flutterlocalnotifications; import android.app.Activity; import android.app.AlarmManager; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationChannelGroup; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.res.AssetFileDescriptor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.media.AudioAttributes; import android.media.RingtoneManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.service.notification.StatusBarNotification; import android.text.Html; import android.text.SpannableString; import android.text.Spanned; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; import androidx.annotation.Keep; import androidx.core.app.l; import androidx.core.app.o; import androidx.core.app.p; import androidx.core.app.r; import androidx.core.graphics.drawable.IconCompat; import com.dexterous.flutterlocalnotifications.models.BitmapSource; import com.dexterous.flutterlocalnotifications.models.DateTimeComponents; import com.dexterous.flutterlocalnotifications.models.IconSource; import com.dexterous.flutterlocalnotifications.models.MessageDetails; import com.dexterous.flutterlocalnotifications.models.NotificationAction; import com.dexterous.flutterlocalnotifications.models.NotificationChannelAction; import com.dexterous.flutterlocalnotifications.models.NotificationChannelDetails; import com.dexterous.flutterlocalnotifications.models.NotificationChannelGroupDetails; import com.dexterous.flutterlocalnotifications.models.NotificationDetails; import com.dexterous.flutterlocalnotifications.models.PersonDetails; import com.dexterous.flutterlocalnotifications.models.ScheduledNotificationRepeatFrequency; import com.dexterous.flutterlocalnotifications.models.SoundSource; import com.dexterous.flutterlocalnotifications.models.styles.BigPictureStyleInformation; import com.dexterous.flutterlocalnotifications.models.styles.BigTextStyleInformation; import com.dexterous.flutterlocalnotifications.models.styles.DefaultStyleInformation; import com.dexterous.flutterlocalnotifications.models.styles.InboxStyleInformation; import com.dexterous.flutterlocalnotifications.models.styles.MessagingStyleInformation; import com.dexterous.flutterlocalnotifications.models.styles.StyleInformation; import com.dexterous.flutterlocalnotifications.utils.BooleanUtils; import com.dexterous.flutterlocalnotifications.utils.StringUtils; import d.f.c.e; import d.f.c.f; import h.a.d.a.j; import h.a.d.a.k; import h.a.d.a.n; import h.a.d.a.p; import io.flutter.embedding.engine.i.a; import j$.time.LocalDateTime; import j$.time.ZoneId; import j$.time.ZonedDateTime; import j$.time.format.DateTimeFormatter; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @Keep public class FlutterLocalNotificationsPlugin implements k.c, n, p, io.flutter.embedding.engine.i.a, io.flutter.embedding.engine.i.c.a { static final boolean $assertionsDisabled = false; private static final String ACTION_ID = "actionId"; private static final String ARE_NOTIFICATIONS_ENABLED_METHOD = "areNotificationsEnabled"; private static final String CALLBACK_HANDLE = "callback_handle"; private static final String CANCEL_ALL_METHOD = "cancelAll"; private static final String CANCEL_ID = "id"; private static final String CANCEL_METHOD = "cancel"; static final String CANCEL_NOTIFICATION = "cancelNotification"; private static final String CANCEL_TAG = "tag"; private static final String CREATE_NOTIFICATION_CHANNEL_GROUP_METHOD = "createNotificationChannelGroup"; private static final String CREATE_NOTIFICATION_CHANNEL_METHOD = "createNotificationChannel"; private static final String DEFAULT_ICON = "defaultIcon"; private static final String DELETE_NOTIFICATION_CHANNEL_GROUP_METHOD = "deleteNotificationChannelGroup"; private static final String DELETE_NOTIFICATION_CHANNEL_METHOD = "deleteNotificationChannel"; private static final String DISPATCHER_HANDLE = "dispatcher_handle"; private static final String DRAWABLE = "drawable"; private static final String GET_ACTIVE_NOTIFICATIONS_ERROR_MESSAGE = "Android version must be 6.0 or newer to use getActiveNotifications"; private static final String GET_ACTIVE_NOTIFICATIONS_METHOD = "getActiveNotifications"; private static final String GET_ACTIVE_NOTIFICATION_MESSAGING_STYLE_ERROR_CODE = "getActiveNotificationMessagingStyleError"; private static final String GET_ACTIVE_NOTIFICATION_MESSAGING_STYLE_METHOD = "getActiveNotificationMessagingStyle"; private static final String GET_CALLBACK_HANDLE_METHOD = "getCallbackHandle"; private static final String GET_NOTIFICATION_APP_LAUNCH_DETAILS_METHOD = "getNotificationAppLaunchDetails"; private static final String GET_NOTIFICATION_CHANNELS_ERROR_CODE = "getNotificationChannelsError"; private static final String GET_NOTIFICATION_CHANNELS_METHOD = "getNotificationChannels"; private static final String INITIALIZE_METHOD = "initialize"; private static final String INPUT = "input"; private static final String INPUT_RESULT = "FlutterLocalNotificationsPluginInputResult"; private static final String INVALID_BIG_PICTURE_ERROR_CODE = "invalid_big_picture"; private static final String INVALID_DRAWABLE_RESOURCE_ERROR_MESSAGE = "The resource %s could not be found. Please make sure it has been added as a drawable resource to your Android head project."; private static final String INVALID_ICON_ERROR_CODE = "invalid_icon"; private static final String INVALID_LARGE_ICON_ERROR_CODE = "invalid_large_icon"; private static final String INVALID_LED_DETAILS_ERROR_CODE = "invalid_led_details"; private static final String INVALID_LED_DETAILS_ERROR_MESSAGE = "Must specify both ledOnMs and ledOffMs to configure the blink cycle on older versions of Android before Oreo"; private static final String INVALID_RAW_RESOURCE_ERROR_MESSAGE = "The resource %s could not be found. Please make sure it has been added as a raw resource to your Android head project."; private static final String INVALID_SOUND_ERROR_CODE = "invalid_sound"; private static final String METHOD_CHANNEL = "dexterous.com/flutter/local_notifications"; static String NOTIFICATION_DETAILS = "notificationDetails"; static final String NOTIFICATION_ID = "notificationId"; private static final String NOTIFICATION_LAUNCHED_APP = "notificationLaunchedApp"; static final int NOTIFICATION_PERMISSION_REQUEST_CODE = 1; private static final String NOTIFICATION_RESPONSE_TYPE = "notificationResponseType"; static final String PAYLOAD = "payload"; private static final String PENDING_NOTIFICATION_REQUESTS_METHOD = "pendingNotificationRequests"; private static final String PERIODICALLY_SHOW_METHOD = "periodicallyShow"; private static final String PERMISSION_REQUEST_IN_PROGRESS_ERROR_CODE = "permissionRequestInProgress"; private static final String PERMISSION_REQUEST_IN_PROGRESS_ERROR_MESSAGE = "Another permission request is already in progress"; private static final String REQUEST_PERMISSION_METHOD = "requestPermission"; private static final String SCHEDULED_NOTIFICATIONS = "scheduled_notifications"; private static final String SCHEDULE_METHOD = "schedule"; private static final String SELECT_FOREGROUND_NOTIFICATION_ACTION = "SELECT_FOREGROUND_NOTIFICATION"; private static final String SELECT_NOTIFICATION = "SELECT_NOTIFICATION"; private static final String SHARED_PREFERENCES_KEY = "notification_plugin_cache"; private static final String SHOW_DAILY_AT_TIME_METHOD = "showDailyAtTime"; private static final String SHOW_METHOD = "show"; private static final String SHOW_WEEKLY_AT_DAY_AND_TIME_METHOD = "showWeeklyAtDayAndTime"; private static final String START_FOREGROUND_SERVICE = "startForegroundService"; private static final String STOP_FOREGROUND_SERVICE = "stopForegroundService"; private static final String UNSUPPORTED_OS_VERSION_ERROR_CODE = "unsupported_os_version"; private static final String ZONED_SCHEDULE_METHOD = "zonedSchedule"; static e gson; private Context applicationContext; private com.dexterous.flutterlocalnotifications.c callback; private k channel; private Activity mainActivity; private boolean permissionRequestInProgress = false; public class a extends d.f.c.a0.a<ArrayList<NotificationDetails>> { a() { } } class b implements com.dexterous.flutterlocalnotifications.c { final k.d a; b(k.d dVar) { this.a = dVar; } @Override public void a(String str) { this.a.error(FlutterLocalNotificationsPlugin.PERMISSION_REQUEST_IN_PROGRESS_ERROR_CODE, str, null); } @Override public void b(boolean z) { this.a.success(Boolean.valueOf(z)); } } public static class c { static final int[] a; static final int[] f1697b; static final int[] f1698c; static { int[] iArr = new int[NotificationStyle.values().length]; f1698c = iArr; try { iArr[NotificationStyle.BigPicture.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { f1698c[NotificationStyle.BigText.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { f1698c[NotificationStyle.Inbox.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } try { f1698c[NotificationStyle.Messaging.ordinal()] = 4; } catch (NoSuchFieldError unused4) { } try { f1698c[NotificationStyle.Media.ordinal()] = 5; } catch (NoSuchFieldError unused5) { } int[] iArr2 = new int[IconSource.values().length]; f1697b = iArr2; try { iArr2[IconSource.DrawableResource.ordinal()] = 1; } catch (NoSuchFieldError unused6) { } try { f1697b[IconSource.BitmapFilePath.ordinal()] = 2; } catch (NoSuchFieldError unused7) { } try { f1697b[IconSource.ContentUri.ordinal()] = 3; } catch (NoSuchFieldError unused8) { } try { f1697b[IconSource.FlutterBitmapAsset.ordinal()] = 4; } catch (NoSuchFieldError unused9) { } try { f1697b[IconSource.ByteArray.ordinal()] = 5; } catch (NoSuchFieldError unused10) { } int[] iArr3 = new int[RepeatInterval.values().length]; a = iArr3; try { iArr3[RepeatInterval.EveryMinute.ordinal()] = 1; } catch (NoSuchFieldError unused11) { } try { a[RepeatInterval.Hourly.ordinal()] = 2; } catch (NoSuchFieldError unused12) { } try { a[RepeatInterval.Daily.ordinal()] = 3; } catch (NoSuchFieldError unused13) { } try { a[RepeatInterval.Weekly.ordinal()] = 4; } catch (NoSuchFieldError unused14) { } } } private static void applyGrouping(NotificationDetails notificationDetails, l.e eVar) { boolean z; if (StringUtils.isNullOrEmpty(notificationDetails.groupKey).booleanValue()) { z = false; } else { eVar.y(notificationDetails.groupKey); z = true; } if (z) { if (BooleanUtils.getValue(notificationDetails.setAsGroupSummary)) { eVar.A(true); } eVar.z(notificationDetails.groupAlertBehavior.intValue()); } } private void areNotificationsEnabled(k.d dVar) { dVar.success(Boolean.valueOf(getNotificationManager(this.applicationContext).a())); } public static e buildGson() { if (gson == null) { gson = new f().c(RuntimeTypeAdapterFactory.of(StyleInformation.class).registerSubtype(DefaultStyleInformation.class).registerSubtype(BigTextStyleInformation.class).registerSubtype(BigPictureStyleInformation.class).registerSubtype(InboxStyleInformation.class).registerSubtype(MessagingStyleInformation.class)).b(); } return gson; } private static androidx.core.app.p buildPerson(Context context, PersonDetails personDetails) { IconSource iconSource; if (personDetails == null) { return null; } p.b bVar = new p.b(); bVar.b(BooleanUtils.getValue(personDetails.bot)); Object obj = personDetails.icon; if (obj != null && (iconSource = personDetails.iconBitmapSource) != null) { bVar.c(getIconFromSource(context, obj, iconSource)); } bVar.d(BooleanUtils.getValue(personDetails.important)); String str = personDetails.key; if (str != null) { bVar.e(str); } String str2 = personDetails.name; if (str2 != null) { bVar.f(str2); } String str3 = personDetails.uri; if (str3 != null) { bVar.g(str3); } return bVar.a(); } private static long calculateNextNotificationTrigger(long j2, long j3) { while (j2 < System.currentTimeMillis()) { j2 += j3; } return j2; } private static long calculateRepeatIntervalMilliseconds(NotificationDetails notificationDetails) { int i2 = c.a[notificationDetails.repeatInterval.ordinal()]; if (i2 == 1) { return 60000L; } if (i2 == 2) { return 3600000L; } if (i2 != 3) { return i2 != 4 ? 0L : 604800000L; } return 86400000L; } private static Boolean canCreateNotificationChannel(Context context, NotificationChannelDetails notificationChannelDetails) { NotificationChannelAction notificationChannelAction; if (Build.VERSION.SDK_INT < 26) { return Boolean.FALSE; } NotificationChannel notificationChannel = ((NotificationManager) context.getSystemService("notification")).getNotificationChannel(notificationChannelDetails.f1705id); return Boolean.valueOf((notificationChannel == null && ((notificationChannelAction = notificationChannelDetails.channelAction) == null || notificationChannelAction == NotificationChannelAction.CreateIfNotExists)) || (notificationChannel != null && notificationChannelDetails.channelAction == NotificationChannelAction.Update)); } private void cancel(j jVar, k.d dVar) { Map map = (Map) jVar.b(); cancelNotification((Integer) map.get(CANCEL_ID), (String) map.get(CANCEL_TAG)); dVar.success(null); } private void cancelAllNotifications(k.d dVar) { getNotificationManager(this.applicationContext).d(); ArrayList<NotificationDetails> loadScheduledNotifications = loadScheduledNotifications(this.applicationContext); if (loadScheduledNotifications == null || loadScheduledNotifications.isEmpty()) { dVar.success(null); return; } Intent intent = new Intent(this.applicationContext, (Class<?>) ScheduledNotificationReceiver.class); Iterator<NotificationDetails> it = loadScheduledNotifications.iterator(); while (it.hasNext()) { getAlarmManager(this.applicationContext).cancel(getBroadcastPendingIntent(this.applicationContext, it.next().f1707id.intValue(), intent)); } saveScheduledNotifications(this.applicationContext, new ArrayList()); dVar.success(null); } private void cancelNotification(Integer num, String str) { getAlarmManager(this.applicationContext).cancel(getBroadcastPendingIntent(this.applicationContext, num.intValue(), new Intent(this.applicationContext, (Class<?>) ScheduledNotificationReceiver.class))); o notificationManager = getNotificationManager(this.applicationContext); if (str == null) { notificationManager.b(num.intValue()); } else { notificationManager.c(str, num.intValue()); } removeNotificationFromCache(this.applicationContext, num); } private static byte[] castObjectToByteArray(Object obj) { if (!(obj instanceof ArrayList)) { return (byte[]) obj; } ArrayList arrayList = (ArrayList) obj; byte[] bArr = new byte[arrayList.size()]; for (int i2 = 0; i2 < arrayList.size(); i2++) { bArr[i2] = (byte) ((Double) arrayList.get(i2)).intValue(); } return bArr; } private static l.h.a createMessage(Context context, MessageDetails messageDetails) { String str; l.h.a aVar = new l.h.a(messageDetails.text, messageDetails.timestamp.longValue(), buildPerson(context, messageDetails.person)); String str2 = messageDetails.dataUri; if (str2 != null && (str = messageDetails.dataMimeType) != null) { aVar.j(str, Uri.parse(str2)); } return aVar; } public static Notification createNotification(Context context, NotificationDetails notificationDetails) { Intent intent; String str; int i2; int i3; PendingIntent broadcast; IconSource iconSource; NotificationChannelDetails fromNotificationDetails = NotificationChannelDetails.fromNotificationDetails(notificationDetails); if (canCreateNotificationChannel(context, fromNotificationDetails).booleanValue()) { setupNotificationChannel(context, fromNotificationDetails); } Intent launchIntent = getLaunchIntent(context); launchIntent.setAction(SELECT_NOTIFICATION); launchIntent.putExtra(NOTIFICATION_ID, notificationDetails.f1707id); launchIntent.putExtra(PAYLOAD, notificationDetails.payload); int i4 = 23; PendingIntent activity = PendingIntent.getActivity(context, notificationDetails.f1707id.intValue(), launchIntent, Build.VERSION.SDK_INT >= 23 ? 201326592 : 134217728); DefaultStyleInformation defaultStyleInformation = (DefaultStyleInformation) notificationDetails.styleInformation; l.e G = new l.e(context, notificationDetails.channelId).t(defaultStyleInformation.htmlFormatTitle.booleanValue() ? fromHtml(notificationDetails.title) : notificationDetails.title).s(defaultStyleInformation.htmlFormatBody.booleanValue() ? fromHtml(notificationDetails.body) : notificationDetails.body).P(notificationDetails.ticker).m(BooleanUtils.getValue(notificationDetails.autoCancel)).r(activity).H(notificationDetails.priority.intValue()).F(BooleanUtils.getValue(notificationDetails.ongoing)).G(BooleanUtils.getValue(notificationDetails.onlyAlertOnce)); if (notificationDetails.actions != null) { int intValue = notificationDetails.f1707id.intValue() * 16; for (NotificationAction notificationAction : notificationDetails.actions) { IconCompat iconCompat = null; if (!TextUtils.isEmpty(notificationAction.icon) && (iconSource = notificationAction.iconSource) != null) { iconCompat = getIconFromSource(context, notificationAction.icon, iconSource); } Boolean bool = notificationAction.showsUserInterface; if (bool == null || !bool.booleanValue()) { intent = new Intent(context, (Class<?>) ActionBroadcastReceiver.class); str = "com.dexterous.flutterlocalnotifications.ActionBroadcastReceiver.ACTION_TAPPED"; } else { intent = getLaunchIntent(context); str = SELECT_FOREGROUND_NOTIFICATION_ACTION; } intent.setAction(str); intent.putExtra(NOTIFICATION_ID, notificationDetails.f1707id).putExtra(ACTION_ID, notificationAction.f1704id).putExtra(CANCEL_NOTIFICATION, notificationAction.cancelNotification).putExtra(PAYLOAD, notificationDetails.payload); List<NotificationAction.a> list = notificationAction.actionInputs; if (list == null || list.isEmpty()) { if (Build.VERSION.SDK_INT >= i4) { i2 = 201326592; } i2 = 134217728; } else { if (Build.VERSION.SDK_INT >= 31) { i2 = 167772160; } i2 = 134217728; } Boolean bool2 = notificationAction.showsUserInterface; if (bool2 == null || !bool2.booleanValue()) { i3 = intValue + 1; broadcast = PendingIntent.getBroadcast(context, intValue, intent, i2); } else { i3 = intValue + 1; broadcast = PendingIntent.getActivity(context, intValue, intent, i2); } intValue = i3; SpannableString spannableString = new SpannableString(notificationAction.title); if (notificationAction.titleColor != null) { spannableString.setSpan(new ForegroundColorSpan(notificationAction.titleColor.intValue()), 0, spannableString.length(), 0); } l.a.C0014a c0014a = new l.a.C0014a(iconCompat, spannableString, broadcast); Boolean bool3 = notificationAction.contextual; if (bool3 != null) { c0014a.e(bool3.booleanValue()); } Boolean bool4 = notificationAction.showsUserInterface; if (bool4 != null) { c0014a.f(bool4.booleanValue()); } Boolean bool5 = notificationAction.allowGeneratedReplies; if (bool5 != null) { c0014a.d(bool5.booleanValue()); } List<NotificationAction.a> list2 = notificationAction.actionInputs; if (list2 != null) { for (NotificationAction.a aVar : list2) { r.e e2 = new r.e(INPUT_RESULT).e(aVar.r); Boolean bool6 = aVar.q; if (bool6 != null) { e2.c(bool6.booleanValue()); } List<String> list3 = aVar.s; if (list3 != null) { Iterator<String> it = list3.iterator(); while (it.hasNext()) { e2.b(it.next(), true); } } List<String> list4 = aVar.p; if (list4 != null) { e2.d((CharSequence[]) list4.toArray(new CharSequence[0])); } c0014a.a(e2.a()); } } G.b(c0014a.b()); i4 = 23; } } setSmallIcon(context, notificationDetails, G); G.B(getBitmapFromSource(context, notificationDetails.largeIcon, notificationDetails.largeIconBitmapSource)); Integer num = notificationDetails.color; if (num != null) { G.p(num.intValue()); } Boolean bool7 = notificationDetails.colorized; if (bool7 != null) { G.q(bool7.booleanValue()); } Boolean bool8 = notificationDetails.showWhen; if (bool8 != null) { G.K(BooleanUtils.getValue(bool8)); } Long l2 = notificationDetails.when; if (l2 != null) { G.U(l2.longValue()); } Boolean bool9 = notificationDetails.usesChronometer; if (bool9 != null) { G.R(bool9.booleanValue()); } if (BooleanUtils.getValue(notificationDetails.fullScreenIntent)) { G.x(activity, true); } if (!StringUtils.isNullOrEmpty(notificationDetails.shortcutId).booleanValue()) { G.J(notificationDetails.shortcutId); } if (!StringUtils.isNullOrEmpty(notificationDetails.subText).booleanValue()) { G.O(notificationDetails.subText); } Integer num2 = notificationDetails.number; if (num2 != null) { G.E(num2.intValue()); } setVisibility(notificationDetails, G); applyGrouping(notificationDetails, G); setSound(context, notificationDetails, G); setVibrationPattern(notificationDetails, G); setLights(notificationDetails, G); setStyle(context, notificationDetails, G); setProgress(notificationDetails, G); setCategory(notificationDetails, G); setTimeoutAfter(notificationDetails, G); Notification c2 = G.c(); int[] iArr = notificationDetails.additionalFlags; if (iArr != null && iArr.length > 0) { for (int i5 : iArr) { c2.flags = i5 | c2.flags; } } return c2; } private void createNotificationChannel(j jVar, k.d dVar) { setupNotificationChannel(this.applicationContext, NotificationChannelDetails.from((Map) jVar.b())); dVar.success(null); } private void createNotificationChannelGroup(j jVar, k.d dVar) { int i2 = Build.VERSION.SDK_INT; if (i2 >= 26) { NotificationChannelGroupDetails from = NotificationChannelGroupDetails.from((Map) jVar.b()); NotificationManager notificationManager = (NotificationManager) this.applicationContext.getSystemService("notification"); NotificationChannelGroup notificationChannelGroup = new NotificationChannelGroup(from.f1706id, from.name); if (i2 >= 28) { notificationChannelGroup.setDescription(from.description); } notificationManager.createNotificationChannelGroup(notificationChannelGroup); } dVar.success(null); } private void deleteNotificationChannel(j jVar, k.d dVar) { if (Build.VERSION.SDK_INT >= 26) { ((NotificationManager) this.applicationContext.getSystemService("notification")).deleteNotificationChannel((String) jVar.b()); } dVar.success(null); } private void deleteNotificationChannelGroup(j jVar, k.d dVar) { if (Build.VERSION.SDK_INT >= 26) { ((NotificationManager) this.applicationContext.getSystemService("notification")).deleteNotificationChannelGroup((String) jVar.b()); } dVar.success(null); } private Map<String, Object> describeIcon(IconCompat iconCompat) { IconSource iconSource; String resourceEntryName; if (iconCompat == null) { return null; } int u = iconCompat.u(); if (u == 2) { iconSource = IconSource.DrawableResource; resourceEntryName = this.applicationContext.getResources().getResourceEntryName(iconCompat.r()); } else { if (u != 4) { return null; } iconSource = IconSource.ContentUri; resourceEntryName = iconCompat.v().toString(); } HashMap hashMap = new HashMap(); hashMap.put("source", Integer.valueOf(iconSource.ordinal())); hashMap.put("data", resourceEntryName); return hashMap; } private Map<String, Object> describePerson(androidx.core.app.p pVar) { if (pVar == null) { return null; } HashMap hashMap = new HashMap(); hashMap.put("key", pVar.d()); hashMap.put("name", pVar.e()); hashMap.put("uri", pVar.f()); hashMap.put("bot", Boolean.valueOf(pVar.g())); hashMap.put("important", Boolean.valueOf(pVar.h())); hashMap.put("icon", describeIcon(pVar.c())); return hashMap; } private NotificationDetails extractNotificationDetails(k.d dVar, Map<String, Object> map) { NotificationDetails from = NotificationDetails.from(map); if (hasInvalidIcon(dVar, from.icon) || hasInvalidLargeIcon(dVar, from.largeIcon, from.largeIconBitmapSource) || hasInvalidBigPictureResources(dVar, from) || hasInvalidRawSoundResource(dVar, from) || hasInvalidLedDetails(dVar, from)) { return null; } return from; } public static Map<String, Object> extractNotificationResponseMap(Intent intent) { int intExtra = intent.getIntExtra(NOTIFICATION_ID, 0); HashMap hashMap = new HashMap(); hashMap.put(NOTIFICATION_ID, Integer.valueOf(intExtra)); hashMap.put(ACTION_ID, intent.getStringExtra(ACTION_ID)); hashMap.put(PAYLOAD, intent.getStringExtra(PAYLOAD)); Bundle k2 = r.k(intent); if (k2 != null) { hashMap.put(INPUT, k2.getString(INPUT_RESULT)); } if (SELECT_NOTIFICATION.equals(intent.getAction())) { hashMap.put(NOTIFICATION_RESPONSE_TYPE, 0); } if (SELECT_FOREGROUND_NOTIFICATION_ACTION.equals(intent.getAction())) { hashMap.put(NOTIFICATION_RESPONSE_TYPE, 1); } return hashMap; } private static Spanned fromHtml(String str) { if (str == null) { return null; } return Build.VERSION.SDK_INT >= 24 ? Html.fromHtml(str, 0) : Html.fromHtml(str); } private void getActiveNotificationMessagingStyle(j jVar, k.d dVar) { Notification notification; if (Build.VERSION.SDK_INT < 23) { dVar.error(UNSUPPORTED_OS_VERSION_ERROR_CODE, "Android version must be 6.0 or newer to use getActiveNotificationMessagingStyle", null); return; } NotificationManager notificationManager = (NotificationManager) this.applicationContext.getSystemService("notification"); try { Map map = (Map) jVar.b(); int intValue = ((Integer) map.get(CANCEL_ID)).intValue(); String str = (String) map.get(CANCEL_TAG); for (StatusBarNotification statusBarNotification : notificationManager.getActiveNotifications()) { if (statusBarNotification.getId() == intValue && (str == null || str.equals(statusBarNotification.getTag()))) { notification = statusBarNotification.getNotification(); break; } } notification = null; if (notification == null) { dVar.success(null); return; } l.h y = l.h.y(notification); if (y == null) { dVar.success(null); return; } HashMap hashMap = new HashMap(); hashMap.put("groupConversation", Boolean.valueOf(y.E())); hashMap.put("person", describePerson(y.C())); hashMap.put("conversationTitle", y.A()); ArrayList arrayList = new ArrayList(); for (l.h.a aVar : y.B()) { HashMap hashMap2 = new HashMap(); hashMap2.put("text", aVar.h()); hashMap2.put("timestamp", Long.valueOf(aVar.i())); hashMap2.put("person", describePerson(aVar.g())); arrayList.add(hashMap2); } hashMap.put("messages", arrayList); dVar.success(hashMap); } catch (Throwable th) { dVar.error(GET_ACTIVE_NOTIFICATION_MESSAGING_STYLE_ERROR_CODE, th.getMessage(), th.getStackTrace()); } } private void getActiveNotifications(k.d dVar) { if (Build.VERSION.SDK_INT < 23) { dVar.error(UNSUPPORTED_OS_VERSION_ERROR_CODE, GET_ACTIVE_NOTIFICATIONS_ERROR_MESSAGE, null); return; } try { StatusBarNotification[] activeNotifications = ((NotificationManager) this.applicationContext.getSystemService("notification")).getActiveNotifications(); ArrayList arrayList = new ArrayList(); for (StatusBarNotification statusBarNotification : activeNotifications) { HashMap hashMap = new HashMap(); hashMap.put(CANCEL_ID, Integer.valueOf(statusBarNotification.getId())); Notification notification = statusBarNotification.getNotification(); if (Build.VERSION.SDK_INT >= 26) { hashMap.put("channelId", notification.getChannelId()); } hashMap.put(CANCEL_TAG, statusBarNotification.getTag()); hashMap.put("groupKey", notification.getGroup()); hashMap.put("title", notification.extras.getCharSequence("android.title")); hashMap.put("body", notification.extras.getCharSequence("android.text")); arrayList.add(hashMap); } dVar.success(arrayList); } catch (Throwable th) { dVar.error(UNSUPPORTED_OS_VERSION_ERROR_CODE, th.getMessage(), th.getStackTrace()); } } private static AlarmManager getAlarmManager(Context context) { return (AlarmManager) context.getSystemService("alarm"); } private static Bitmap getBitmapFromSource(Context context, Object obj, BitmapSource bitmapSource) { if (bitmapSource == BitmapSource.DrawableResource) { return BitmapFactory.decodeResource(context.getResources(), getDrawableResourceId(context, (String) obj)); } if (bitmapSource == BitmapSource.FilePath) { return BitmapFactory.decodeFile((String) obj); } if (bitmapSource != BitmapSource.ByteArray) { return null; } byte[] castObjectToByteArray = castObjectToByteArray(obj); return BitmapFactory.decodeByteArray(castObjectToByteArray, 0, castObjectToByteArray.length); } private static PendingIntent getBroadcastPendingIntent(Context context, int i2, Intent intent) { return PendingIntent.getBroadcast(context, i2, intent, Build.VERSION.SDK_INT >= 23 ? 201326592 : 134217728); } private void getCallbackHandle(k.d dVar) { dVar.success(new com.dexterous.flutterlocalnotifications.d.a(this.applicationContext).c()); } private static int getDrawableResourceId(Context context, String str) { return context.getResources().getIdentifier(str, DRAWABLE, context.getPackageName()); } private static IconCompat getIconFromSource(Context context, Object obj, IconSource iconSource) { int i2 = c.f1697b[iconSource.ordinal()]; if (i2 == 1) { return IconCompat.o(context, getDrawableResourceId(context, (String) obj)); } if (i2 == 2) { return IconCompat.k(BitmapFactory.decodeFile((String) obj)); } if (i2 == 3) { return IconCompat.m((String) obj); } if (i2 != 4) { if (i2 != 5) { return null; } byte[] castObjectToByteArray = castObjectToByteArray(obj); return IconCompat.n(castObjectToByteArray, 0, castObjectToByteArray.length); } try { AssetFileDescriptor openFd = context.getAssets().openFd(h.a.a.e().c().i((String) obj)); FileInputStream createInputStream = openFd.createInputStream(); IconCompat k2 = IconCompat.k(BitmapFactory.decodeStream(createInputStream)); createInputStream.close(); openFd.close(); return k2; } catch (IOException e2) { throw new RuntimeException(e2); } } private static Intent getLaunchIntent(Context context) { return context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); } private HashMap<String, Object> getMappedNotificationChannel(NotificationChannel notificationChannel) { String uri; HashMap<String, Object> hashMap = new HashMap<>(); if (Build.VERSION.SDK_INT >= 26) { hashMap.put(CANCEL_ID, notificationChannel.getId()); hashMap.put("name", notificationChannel.getName()); hashMap.put("description", notificationChannel.getDescription()); hashMap.put("groupId", notificationChannel.getGroup()); hashMap.put("showBadge", Boolean.valueOf(notificationChannel.canShowBadge())); hashMap.put("importance", Integer.valueOf(notificationChannel.getImportance())); Uri sound = notificationChannel.getSound(); if (sound == null) { hashMap.put("sound", null); hashMap.put("playSound", Boolean.FALSE); } else { hashMap.put("playSound", Boolean.TRUE); List asList = Arrays.asList(SoundSource.values()); if (sound.getScheme().equals("android.resource")) { uri = sound.toString().split("/")[r1.length - 1]; Integer tryParseInt = tryParseInt(uri); if (tryParseInt == null || (uri = this.applicationContext.getResources().getResourceEntryName(tryParseInt.intValue())) != null) { hashMap.put("soundSource", Integer.valueOf(asList.indexOf(SoundSource.RawResource))); } } else { hashMap.put("soundSource", Integer.valueOf(asList.indexOf(SoundSource.Uri))); uri = sound.toString(); } hashMap.put("sound", uri); } hashMap.put("enableVibration", Boolean.valueOf(notificationChannel.shouldVibrate())); hashMap.put("vibrationPattern", notificationChannel.getVibrationPattern()); hashMap.put("enableLights", Boolean.valueOf(notificationChannel.shouldShowLights())); hashMap.put("ledColor", Integer.valueOf(notificationChannel.getLightColor())); } return hashMap; } static String getNextFireDate(NotificationDetails notificationDetails) { LocalDateTime plusWeeks; ScheduledNotificationRepeatFrequency scheduledNotificationRepeatFrequency = notificationDetails.scheduledNotificationRepeatFrequency; if (scheduledNotificationRepeatFrequency == ScheduledNotificationRepeatFrequency.Daily) { plusWeeks = LocalDateTime.parse(notificationDetails.scheduledDateTime).plusDays(1L); } else { if (scheduledNotificationRepeatFrequency != ScheduledNotificationRepeatFrequency.Weekly) { return null; } plusWeeks = LocalDateTime.parse(notificationDetails.scheduledDateTime).plusWeeks(1L); } return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(plusWeeks); } static String getNextFireDateMatchingDateTimeComponents(NotificationDetails notificationDetails) { ZoneId of = ZoneId.of(notificationDetails.timeZoneName); ZonedDateTime of2 = ZonedDateTime.of(LocalDateTime.parse(notificationDetails.scheduledDateTime), of); ZonedDateTime now = ZonedDateTime.now(of); ZonedDateTime of3 = ZonedDateTime.of(now.getYear(), now.getMonthValue(), now.getDayOfMonth(), of2.getHour(), of2.getMinute(), of2.getSecond(), of2.getNano(), of); while (of3.isBefore(now)) { of3 = of3.plusDays(1L); } DateTimeComponents dateTimeComponents = notificationDetails.matchDateTimeComponents; if (dateTimeComponents != DateTimeComponents.Time) { if (dateTimeComponents == DateTimeComponents.DayOfWeekAndTime) { while (of3.getDayOfWeek() != of2.getDayOfWeek()) { of3 = of3.plusDays(1L); } } else if (dateTimeComponents == DateTimeComponents.DayOfMonthAndTime) { while (of3.getDayOfMonth() != of2.getDayOfMonth()) { of3 = of3.plusDays(1L); } } else { if (dateTimeComponents != DateTimeComponents.DateAndTime) { return null; } while (true) { if (of3.getMonthValue() == of2.getMonthValue() && of3.getDayOfMonth() == of2.getDayOfMonth()) { break; } of3 = of3.plusDays(1L); } } } return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(of3); } private void getNotificationAppLaunchDetails(k.d dVar) { HashMap hashMap = new HashMap(); Boolean bool = Boolean.FALSE; Activity activity = this.mainActivity; if (activity != null) { Intent intent = activity.getIntent(); Boolean valueOf = Boolean.valueOf(intent != null && (SELECT_NOTIFICATION.equals(intent.getAction()) || SELECT_FOREGROUND_NOTIFICATION_ACTION.equals(intent.getAction())) && !launchedActivityFromHistory(intent)); if (valueOf.booleanValue()) { hashMap.put("notificationResponse", extractNotificationResponseMap(intent)); } bool = valueOf; } hashMap.put(NOTIFICATION_LAUNCHED_APP, bool); dVar.success(hashMap); } private void getNotificationChannels(k.d dVar) { try { List<NotificationChannel> g2 = getNotificationManager(this.applicationContext).g(); ArrayList arrayList = new ArrayList(); Iterator<NotificationChannel> it = g2.iterator(); while (it.hasNext()) { arrayList.add(getMappedNotificationChannel(it.next())); } dVar.success(arrayList); } catch (Throwable th) { dVar.error(GET_NOTIFICATION_CHANNELS_ERROR_CODE, th.getMessage(), th.getStackTrace()); } } private static o getNotificationManager(Context context) { return o.e(context); } private boolean hasInvalidBigPictureResources(k.d dVar, NotificationDetails notificationDetails) { if (notificationDetails.style != NotificationStyle.BigPicture) { return false; } BigPictureStyleInformation bigPictureStyleInformation = (BigPictureStyleInformation) notificationDetails.styleInformation; if (hasInvalidLargeIcon(dVar, bigPictureStyleInformation.largeIcon, bigPictureStyleInformation.largeIconBitmapSource)) { return true; } BitmapSource bitmapSource = bigPictureStyleInformation.bigPictureBitmapSource; if (bitmapSource == BitmapSource.DrawableResource) { String str = (String) bigPictureStyleInformation.bigPicture; return StringUtils.isNullOrEmpty(str).booleanValue() && !isValidDrawableResource(this.applicationContext, str, dVar, INVALID_BIG_PICTURE_ERROR_CODE); } if (bitmapSource == BitmapSource.FilePath) { return StringUtils.isNullOrEmpty((String) bigPictureStyleInformation.bigPicture).booleanValue(); } if (bitmapSource != BitmapSource.ByteArray) { return false; } byte[] bArr = (byte[]) bigPictureStyleInformation.bigPicture; return bArr == null || bArr.length == 0; } private boolean hasInvalidIcon(k.d dVar, String str) { return (StringUtils.isNullOrEmpty(str).booleanValue() || isValidDrawableResource(this.applicationContext, str, dVar, INVALID_ICON_ERROR_CODE)) ? false : true; } private boolean hasInvalidLargeIcon(k.d dVar, Object obj, BitmapSource bitmapSource) { BitmapSource bitmapSource2 = BitmapSource.DrawableResource; if (bitmapSource != bitmapSource2 && bitmapSource != BitmapSource.FilePath) { return bitmapSource == BitmapSource.ByteArray && ((byte[]) obj).length == 0; } String str = (String) obj; return (StringUtils.isNullOrEmpty(str).booleanValue() || bitmapSource != bitmapSource2 || isValidDrawableResource(this.applicationContext, str, dVar, INVALID_LARGE_ICON_ERROR_CODE)) ? false : true; } private boolean hasInvalidLedDetails(k.d dVar, NotificationDetails notificationDetails) { if (notificationDetails.ledColor == null) { return false; } if (notificationDetails.ledOnMs != null && notificationDetails.ledOffMs != null) { return false; } dVar.error(INVALID_LED_DETAILS_ERROR_CODE, INVALID_LED_DETAILS_ERROR_MESSAGE, null); return true; } private boolean hasInvalidRawSoundResource(k.d dVar, NotificationDetails notificationDetails) { SoundSource soundSource; if (StringUtils.isNullOrEmpty(notificationDetails.sound).booleanValue() || !(((soundSource = notificationDetails.soundSource) == null || soundSource == SoundSource.RawResource) && this.applicationContext.getResources().getIdentifier(notificationDetails.sound, "raw", this.applicationContext.getPackageName()) == 0)) { return false; } dVar.error(INVALID_SOUND_ERROR_CODE, String.format(INVALID_RAW_RESOURCE_ERROR_MESSAGE, notificationDetails.sound), null); return true; } private void initialize(j jVar, k.d dVar) { String str = (String) ((Map) jVar.b()).get(DEFAULT_ICON); if (isValidDrawableResource(this.applicationContext, str, dVar, INVALID_ICON_ERROR_CODE)) { Long l2 = (Long) jVar.a(DISPATCHER_HANDLE); Long l3 = (Long) jVar.a(CALLBACK_HANDLE); if (l2 != null && l3 != null) { new com.dexterous.flutterlocalnotifications.d.a(this.applicationContext).e(l2, l3); } this.applicationContext.getSharedPreferences(SHARED_PREFERENCES_KEY, 0).edit().putString(DEFAULT_ICON, str).apply(); dVar.success(Boolean.TRUE); } } private static boolean isValidDrawableResource(Context context, String str, k.d dVar, String str2) { if (context.getResources().getIdentifier(str, DRAWABLE, context.getPackageName()) != 0) { return true; } dVar.error(str2, String.format(INVALID_DRAWABLE_RESOURCE_ERROR_MESSAGE, str), null); return false; } private static boolean launchedActivityFromHistory(Intent intent) { return intent != null && (intent.getFlags() & 1048576) == 1048576; } private static ArrayList<NotificationDetails> loadScheduledNotifications(Context context) { ArrayList<NotificationDetails> arrayList = new ArrayList<>(); String string = context.getSharedPreferences(SCHEDULED_NOTIFICATIONS, 0).getString(SCHEDULED_NOTIFICATIONS, null); return string != null ? (ArrayList) buildGson().i(string, new a().e()) : arrayList; } private void pendingNotificationRequests(k.d dVar) { ArrayList<NotificationDetails> loadScheduledNotifications = loadScheduledNotifications(this.applicationContext); ArrayList arrayList = new ArrayList(); Iterator<NotificationDetails> it = loadScheduledNotifications.iterator(); while (it.hasNext()) { NotificationDetails next = it.next(); HashMap hashMap = new HashMap(); hashMap.put(CANCEL_ID, next.f1707id); hashMap.put("title", next.title); hashMap.put("body", next.body); hashMap.put(PAYLOAD, next.payload); arrayList.add(hashMap); } dVar.success(arrayList); } public static void removeNotificationFromCache(Context context, Integer num) { ArrayList<NotificationDetails> loadScheduledNotifications = loadScheduledNotifications(context); Iterator<NotificationDetails> it = loadScheduledNotifications.iterator(); while (true) { if (!it.hasNext()) { break; } else if (it.next().f1707id.equals(num)) { it.remove(); break; } } saveScheduledNotifications(context, loadScheduledNotifications); } private void repeat(j jVar, k.d dVar) { NotificationDetails extractNotificationDetails = extractNotificationDetails(dVar, (Map) jVar.b()); if (extractNotificationDetails != null) { repeatNotification(this.applicationContext, extractNotificationDetails, Boolean.TRUE); dVar.success(null); } } private static void repeatNotification(Context context, NotificationDetails notificationDetails, Boolean bool) { long calculateRepeatIntervalMilliseconds = calculateRepeatIntervalMilliseconds(notificationDetails); long longValue = notificationDetails.calledAt.longValue(); if (notificationDetails.repeatTime != null) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(11, notificationDetails.repeatTime.hour.intValue()); calendar.set(12, notificationDetails.repeatTime.minute.intValue()); calendar.set(13, notificationDetails.repeatTime.second.intValue()); Integer num = notificationDetails.day; if (num != null) { calendar.set(7, num.intValue()); } longValue = calendar.getTimeInMillis(); } long calculateNextNotificationTrigger = calculateNextNotificationTrigger(longValue, calculateRepeatIntervalMilliseconds); String q = buildGson().q(notificationDetails); Intent intent = new Intent(context, (Class<?>) ScheduledNotificationReceiver.class); intent.putExtra(NOTIFICATION_DETAILS, q); PendingIntent broadcastPendingIntent = getBroadcastPendingIntent(context, notificationDetails.f1707id.intValue(), intent); AlarmManager alarmManager = getAlarmManager(context); if (BooleanUtils.getValue(notificationDetails.allowWhileIdle)) { androidx.core.app.e.b(alarmManager, 0, calculateNextNotificationTrigger, broadcastPendingIntent); } else { alarmManager.setInexactRepeating(0, calculateNextNotificationTrigger, calculateRepeatIntervalMilliseconds, broadcastPendingIntent); } if (bool.booleanValue()) { saveScheduledNotification(context, notificationDetails); } } public static void rescheduleNotifications(Context context) { Iterator<NotificationDetails> it = loadScheduledNotifications(context).iterator(); while (it.hasNext()) { NotificationDetails next = it.next(); if (next.repeatInterval != null) { repeatNotification(context, next, Boolean.FALSE); } else if (next.timeZoneName == null) { scheduleNotification(context, next, Boolean.FALSE); } else { zonedScheduleNotification(context, next, Boolean.FALSE); } } } private static Uri retrieveSoundResourceUri(Context context, String str, SoundSource soundSource) { if (StringUtils.isNullOrEmpty(str).booleanValue()) { return RingtoneManager.getDefaultUri(2); } if (soundSource != null && soundSource != SoundSource.RawResource) { if (soundSource == SoundSource.Uri) { return Uri.parse(str); } return null; } return Uri.parse("android.resource://" + context.getPackageName() + "/raw/" + str); } private static void saveScheduledNotification(Context context, NotificationDetails notificationDetails) { ArrayList<NotificationDetails> loadScheduledNotifications = loadScheduledNotifications(context); ArrayList arrayList = new ArrayList(); Iterator<NotificationDetails> it = loadScheduledNotifications.iterator(); while (it.hasNext()) { NotificationDetails next = it.next(); if (!next.f1707id.equals(notificationDetails.f1707id)) { arrayList.add(next); } } arrayList.add(notificationDetails); saveScheduledNotifications(context, arrayList); } private static void saveScheduledNotifications(Context context, ArrayList<NotificationDetails> arrayList) { context.getSharedPreferences(SCHEDULED_NOTIFICATIONS, 0).edit().putString(SCHEDULED_NOTIFICATIONS, buildGson().q(arrayList)).apply(); } private void schedule(j jVar, k.d dVar) { NotificationDetails extractNotificationDetails = extractNotificationDetails(dVar, (Map) jVar.b()); if (extractNotificationDetails != null) { scheduleNotification(this.applicationContext, extractNotificationDetails, Boolean.TRUE); dVar.success(null); } } public static void scheduleNextRepeatingNotification(Context context, NotificationDetails notificationDetails) { long calculateNextNotificationTrigger = calculateNextNotificationTrigger(notificationDetails.calledAt.longValue(), calculateRepeatIntervalMilliseconds(notificationDetails)); String q = buildGson().q(notificationDetails); Intent intent = new Intent(context, (Class<?>) ScheduledNotificationReceiver.class); intent.putExtra(NOTIFICATION_DETAILS, q); androidx.core.app.e.b(getAlarmManager(context), 0, calculateNextNotificationTrigger, getBroadcastPendingIntent(context, notificationDetails.f1707id.intValue(), intent)); saveScheduledNotification(context, notificationDetails); } private static void scheduleNotification(Context context, NotificationDetails notificationDetails, Boolean bool) { String q = buildGson().q(notificationDetails); Intent intent = new Intent(context, (Class<?>) ScheduledNotificationReceiver.class); intent.putExtra(NOTIFICATION_DETAILS, q); PendingIntent broadcastPendingIntent = getBroadcastPendingIntent(context, notificationDetails.f1707id.intValue(), intent); AlarmManager alarmManager = getAlarmManager(context); if (BooleanUtils.getValue(notificationDetails.allowWhileIdle)) { androidx.core.app.e.b(alarmManager, 0, notificationDetails.millisecondsSinceEpoch.longValue(), broadcastPendingIntent); } else { androidx.core.app.e.a(alarmManager, 0, notificationDetails.millisecondsSinceEpoch.longValue(), broadcastPendingIntent); } if (bool.booleanValue()) { saveScheduledNotification(context, notificationDetails); } } private Boolean sendNotificationPayloadMessage(Intent intent) { if (!SELECT_NOTIFICATION.equals(intent.getAction()) && !SELECT_FOREGROUND_NOTIFICATION_ACTION.equals(intent.getAction())) { return Boolean.FALSE; } Map<String, Object> extractNotificationResponseMap = extractNotificationResponseMap(intent); if (SELECT_FOREGROUND_NOTIFICATION_ACTION.equals(intent.getAction()) && intent.getBooleanExtra(CANCEL_NOTIFICATION, false)) { o.e(this.applicationContext).b(((Integer) extractNotificationResponseMap.get(NOTIFICATION_ID)).intValue()); } this.channel.c("didReceiveNotificationResponse", extractNotificationResponseMap); return Boolean.TRUE; } private void setActivity(Activity activity) { this.mainActivity = activity; } private static void setBigPictureStyle(Context context, NotificationDetails notificationDetails, l.e eVar) { Bitmap bitmapFromSource; BigPictureStyleInformation bigPictureStyleInformation = (BigPictureStyleInformation) notificationDetails.styleInformation; l.b bVar = new l.b(); if (bigPictureStyleInformation.contentTitle != null) { bVar.A(bigPictureStyleInformation.htmlFormatContentTitle.booleanValue() ? fromHtml(bigPictureStyleInformation.contentTitle) : bigPictureStyleInformation.contentTitle); } if (bigPictureStyleInformation.summaryText != null) { bVar.B(bigPictureStyleInformation.htmlFormatSummaryText.booleanValue() ? fromHtml(bigPictureStyleInformation.summaryText) : bigPictureStyleInformation.summaryText); } if (!bigPictureStyleInformation.hideExpandedLargeIcon.booleanValue()) { Object obj = bigPictureStyleInformation.largeIcon; bitmapFromSource = obj != null ? getBitmapFromSource(context, obj, bigPictureStyleInformation.largeIconBitmapSource) : null; bVar.z(getBitmapFromSource(context, bigPictureStyleInformation.bigPicture, bigPictureStyleInformation.bigPictureBitmapSource)); eVar.N(bVar); } bVar.y(bitmapFromSource); bVar.z(getBitmapFromSource(context, bigPictureStyleInformation.bigPicture, bigPictureStyleInformation.bigPictureBitmapSource)); eVar.N(bVar); } private static void setBigTextStyle(NotificationDetails notificationDetails, l.e eVar) { BigTextStyleInformation bigTextStyleInformation = (BigTextStyleInformation) notificationDetails.styleInformation; l.c cVar = new l.c(); if (bigTextStyleInformation.bigText != null) { cVar.x(bigTextStyleInformation.htmlFormatBigText.booleanValue() ? fromHtml(bigTextStyleInformation.bigText) : bigTextStyleInformation.bigText); } if (bigTextStyleInformation.contentTitle != null) { cVar.y(bigTextStyleInformation.htmlFormatContentTitle.booleanValue() ? fromHtml(bigTextStyleInformation.contentTitle) : bigTextStyleInformation.contentTitle); } if (bigTextStyleInformation.summaryText != null) { boolean booleanValue = bigTextStyleInformation.htmlFormatSummaryText.booleanValue(); String str = bigTextStyleInformation.summaryText; CharSequence charSequence = str; if (booleanValue) { charSequence = fromHtml(str); } cVar.z(charSequence); } eVar.N(cVar); } private static void setCategory(NotificationDetails notificationDetails, l.e eVar) { String str = notificationDetails.category; if (str == null) { return; } eVar.n(str); } private static void setInboxStyle(NotificationDetails notificationDetails, l.e eVar) { InboxStyleInformation inboxStyleInformation = (InboxStyleInformation) notificationDetails.styleInformation; ?? gVar = new l.g(); if (inboxStyleInformation.contentTitle != null) { gVar.y(inboxStyleInformation.htmlFormatContentTitle.booleanValue() ? fromHtml(inboxStyleInformation.contentTitle) : inboxStyleInformation.contentTitle); } if (inboxStyleInformation.summaryText != null) { gVar.z(inboxStyleInformation.htmlFormatSummaryText.booleanValue() ? fromHtml(inboxStyleInformation.summaryText) : inboxStyleInformation.summaryText); } ArrayList<String> arrayList = inboxStyleInformation.lines; if (arrayList != null) { Iterator<String> it = arrayList.iterator(); while (it.hasNext()) { String next = it.next(); if (inboxStyleInformation.htmlFormatLines.booleanValue()) { next = fromHtml(next); } gVar.x(next); } } eVar.N(gVar); } private static void setLights(NotificationDetails notificationDetails, l.e eVar) { if (!BooleanUtils.getValue(notificationDetails.enableLights) || notificationDetails.ledOnMs == null || notificationDetails.ledOffMs == null) { return; } eVar.C(notificationDetails.ledColor.intValue(), notificationDetails.ledOnMs.intValue(), notificationDetails.ledOffMs.intValue()); } private static void setMediaStyle(l.e eVar) { eVar.N(new androidx.media.g.c()); } private static void setMessagingStyle(Context context, NotificationDetails notificationDetails, l.e eVar) { MessagingStyleInformation messagingStyleInformation = (MessagingStyleInformation) notificationDetails.styleInformation; l.h hVar = new l.h(buildPerson(context, messagingStyleInformation.person)); hVar.I(BooleanUtils.getValue(messagingStyleInformation.groupConversation)); String str = messagingStyleInformation.conversationTitle; if (str != null) { hVar.H(str); } ArrayList<MessageDetails> arrayList = messagingStyleInformation.messages; if (arrayList != null && !arrayList.isEmpty()) { Iterator<MessageDetails> it = messagingStyleInformation.messages.iterator(); while (it.hasNext()) { hVar.x(createMessage(context, it.next())); } } eVar.N(hVar); } private static void setProgress(NotificationDetails notificationDetails, l.e eVar) { if (BooleanUtils.getValue(notificationDetails.showProgress)) { eVar.I(notificationDetails.maxProgress.intValue(), notificationDetails.progress.intValue(), notificationDetails.indeterminate.booleanValue()); } } private static void setSmallIcon(Context context, NotificationDetails notificationDetails, l.e eVar) { int intValue; if (StringUtils.isNullOrEmpty(notificationDetails.icon).booleanValue()) { String string = context.getSharedPreferences(SHARED_PREFERENCES_KEY, 0).getString(DEFAULT_ICON, null); intValue = StringUtils.isNullOrEmpty(string).booleanValue() ? notificationDetails.iconResourceId.intValue() : getDrawableResourceId(context, string); } else { intValue = getDrawableResourceId(context, notificationDetails.icon); } eVar.L(intValue); } private static void setSound(Context context, NotificationDetails notificationDetails, l.e eVar) { eVar.M(BooleanUtils.getValue(notificationDetails.playSound) ? retrieveSoundResourceUri(context, notificationDetails.sound, notificationDetails.soundSource) : null); } private static void setStyle(Context context, NotificationDetails notificationDetails, l.e eVar) { int i2 = c.f1698c[notificationDetails.style.ordinal()]; if (i2 == 1) { setBigPictureStyle(context, notificationDetails, eVar); return; } if (i2 == 2) { setBigTextStyle(notificationDetails, eVar); return; } if (i2 == 3) { setInboxStyle(notificationDetails, eVar); } else if (i2 == 4) { setMessagingStyle(context, notificationDetails, eVar); } else { if (i2 != 5) { return; } setMediaStyle(eVar); } } private static void setTimeoutAfter(NotificationDetails notificationDetails, l.e eVar) { Long l2 = notificationDetails.timeoutAfter; if (l2 == null) { return; } eVar.Q(l2.longValue()); } private static void setVibrationPattern(NotificationDetails notificationDetails, l.e eVar) { if (!BooleanUtils.getValue(notificationDetails.enableVibration)) { eVar.S(new long[]{0}); return; } long[] jArr = notificationDetails.vibrationPattern; if (jArr == null || jArr.length <= 0) { return; } eVar.S(jArr); } private static void setVisibility(NotificationDetails notificationDetails, l.e eVar) { Integer num = notificationDetails.visibility; if (num == null) { return; } int intValue = num.intValue(); int i2 = 1; if (intValue == 0) { i2 = 0; } else if (intValue != 1) { if (intValue != 2) { throw new IllegalArgumentException("Unknown index: " + notificationDetails.visibility); } i2 = -1; } eVar.T(i2); } private static void setupNotificationChannel(Context context, NotificationChannelDetails notificationChannelDetails) { Integer num; if (Build.VERSION.SDK_INT >= 26) { NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification"); NotificationChannel notificationChannel = new NotificationChannel(notificationChannelDetails.f1705id, notificationChannelDetails.name, notificationChannelDetails.importance.intValue()); notificationChannel.setDescription(notificationChannelDetails.description); notificationChannel.setGroup(notificationChannelDetails.groupId); if (notificationChannelDetails.playSound.booleanValue()) { Integer num2 = notificationChannelDetails.audioAttributesUsage; notificationChannel.setSound(retrieveSoundResourceUri(context, notificationChannelDetails.sound, notificationChannelDetails.soundSource), new AudioAttributes.Builder().setUsage(Integer.valueOf(num2 != null ? num2.intValue() : 5).intValue()).build()); } else { notificationChannel.setSound(null, null); } notificationChannel.enableVibration(BooleanUtils.getValue(notificationChannelDetails.enableVibration)); long[] jArr = notificationChannelDetails.vibrationPattern; if (jArr != null && jArr.length > 0) { notificationChannel.setVibrationPattern(jArr); } boolean value = BooleanUtils.getValue(notificationChannelDetails.enableLights); notificationChannel.enableLights(value); if (value && (num = notificationChannelDetails.ledColor) != null) { notificationChannel.setLightColor(num.intValue()); } notificationChannel.setShowBadge(BooleanUtils.getValue(notificationChannelDetails.showBadge)); notificationManager.createNotificationChannel(notificationChannel); } } private void show(j jVar, k.d dVar) { NotificationDetails extractNotificationDetails = extractNotificationDetails(dVar, (Map) jVar.b()); if (extractNotificationDetails != null) { showNotification(this.applicationContext, extractNotificationDetails); dVar.success(null); } } public static void showNotification(Context context, NotificationDetails notificationDetails) { Notification createNotification = createNotification(context, notificationDetails); o notificationManager = getNotificationManager(context); String str = notificationDetails.tag; int intValue = notificationDetails.f1707id.intValue(); if (str != null) { notificationManager.i(str, intValue, createNotification); } else { notificationManager.h(intValue, createNotification); } } private void startForegroundService(j jVar, k.d dVar) { String str; Map<String, Object> map = (Map) jVar.a("notificationData"); Integer num = (Integer) jVar.a("startType"); ArrayList arrayList = (ArrayList) jVar.a("foregroundServiceTypes"); if (arrayList != null && arrayList.size() == 0) { str = "If foregroundServiceTypes is non-null it must not be empty!"; } else if (map == null || num == null) { str = "An argument passed to startForegroundService was null!"; } else { NotificationDetails extractNotificationDetails = extractNotificationDetails(dVar, map); if (extractNotificationDetails == null) { return; } if (extractNotificationDetails.f1707id.intValue() != 0) { com.dexterous.flutterlocalnotifications.b bVar = new com.dexterous.flutterlocalnotifications.b(extractNotificationDetails, num.intValue(), arrayList); Intent intent = new Intent(this.applicationContext, (Class<?>) com.dexterous.flutterlocalnotifications.a.class); intent.putExtra("com.dexterous.flutterlocalnotifications.ForegroundServiceStartParameter", bVar); c.e.j.a.m(this.applicationContext, intent); dVar.success(null); return; } str = "The id of the notification for a foreground service must not be 0!"; } dVar.error("ARGUMENT_ERROR", str, null); } private void stopForegroundService(k.d dVar) { this.applicationContext.stopService(new Intent(this.applicationContext, (Class<?>) com.dexterous.flutterlocalnotifications.a.class)); dVar.success(null); } private Integer tryParseInt(String str) { try { return Integer.valueOf(Integer.parseInt(str)); } catch (NumberFormatException unused) { return null; } } private void zonedSchedule(j jVar, k.d dVar) { NotificationDetails extractNotificationDetails = extractNotificationDetails(dVar, (Map) jVar.b()); if (extractNotificationDetails != null) { if (extractNotificationDetails.matchDateTimeComponents != null) { extractNotificationDetails.scheduledDateTime = getNextFireDateMatchingDateTimeComponents(extractNotificationDetails); } zonedScheduleNotification(this.applicationContext, extractNotificationDetails, Boolean.TRUE); dVar.success(null); } } public static void zonedScheduleNextNotification(Context context, NotificationDetails notificationDetails) { String nextFireDate = getNextFireDate(notificationDetails); if (nextFireDate == null) { return; } notificationDetails.scheduledDateTime = nextFireDate; zonedScheduleNotification(context, notificationDetails, Boolean.TRUE); } public static void zonedScheduleNextNotificationMatchingDateComponents(Context context, NotificationDetails notificationDetails) { String nextFireDateMatchingDateTimeComponents = getNextFireDateMatchingDateTimeComponents(notificationDetails); if (nextFireDateMatchingDateTimeComponents == null) { return; } notificationDetails.scheduledDateTime = nextFireDateMatchingDateTimeComponents; zonedScheduleNotification(context, notificationDetails, Boolean.TRUE); } private static void zonedScheduleNotification(Context context, NotificationDetails notificationDetails, Boolean bool) { String q = buildGson().q(notificationDetails); Intent intent = new Intent(context, (Class<?>) ScheduledNotificationReceiver.class); intent.putExtra(NOTIFICATION_DETAILS, q); PendingIntent broadcastPendingIntent = getBroadcastPendingIntent(context, notificationDetails.f1707id.intValue(), intent); AlarmManager alarmManager = getAlarmManager(context); long epochMilli = ZonedDateTime.of(LocalDateTime.parse(notificationDetails.scheduledDateTime), ZoneId.of(notificationDetails.timeZoneName)).toInstant().toEpochMilli(); if (BooleanUtils.getValue(notificationDetails.allowWhileIdle)) { androidx.core.app.e.b(alarmManager, 0, epochMilli, broadcastPendingIntent); } else { androidx.core.app.e.a(alarmManager, 0, epochMilli, broadcastPendingIntent); } if (bool.booleanValue()) { saveScheduledNotification(context, notificationDetails); } } @Override public void onAttachedToActivity(io.flutter.embedding.engine.i.c.c cVar) { cVar.c(this); cVar.b(this); this.mainActivity = cVar.getActivity(); } @Override public void onAttachedToEngine(a.b bVar) { this.applicationContext = bVar.a(); k kVar = new k(bVar.b(), METHOD_CHANNEL); this.channel = kVar; kVar.e(this); } @Override public void onDetachedFromActivity() { this.mainActivity = null; } @Override public void onDetachedFromActivityForConfigChanges() { this.mainActivity = null; } @Override public void onDetachedFromEngine(a.b bVar) { this.channel.e(null); this.channel = null; this.applicationContext = null; } @Override public void onMethodCall(j jVar, k.d dVar) { String str = jVar.a; str.hashCode(); char c2 = 65535; switch (str.hashCode()) { case -2096263152: if (str.equals(STOP_FOREGROUND_SERVICE)) { c2 = 0; break; } break; case -2041662895: if (str.equals(GET_NOTIFICATION_CHANNELS_METHOD)) { c2 = 1; break; } break; case -1889739879: if (str.equals(SHOW_WEEKLY_AT_DAY_AND_TIME_METHOD)) { c2 = 2; break; } break; case -1873731438: if (str.equals(DELETE_NOTIFICATION_CHANNEL_GROUP_METHOD)) { c2 = 3; break; } break; case -1367724422: if (str.equals(CANCEL_METHOD)) { c2 = 4; break; } break; case -799130106: if (str.equals(PENDING_NOTIFICATION_REQUESTS_METHOD)) { c2 = 5; break; } break; case -697920873: if (str.equals(SCHEDULE_METHOD)) { c2 = 6; break; } break; case -208611345: if (str.equals(GET_NOTIFICATION_APP_LAUNCH_DETAILS_METHOD)) { c2 = 7; break; } break; case 3529469: if (str.equals(SHOW_METHOD)) { c2 = '\b'; break; } break; case 6625712: if (str.equals(PERIODICALLY_SHOW_METHOD)) { c2 = '\t'; break; } break; case 116003316: if (str.equals(GET_ACTIVE_NOTIFICATION_MESSAGING_STYLE_METHOD)) { c2 = '\n'; break; } break; case 476547271: if (str.equals(CANCEL_ALL_METHOD)) { c2 = 11; break; } break; case 548573423: if (str.equals(ZONED_SCHEDULE_METHOD)) { c2 = '\f'; break; } break; case 746581438: if (str.equals(REQUEST_PERMISSION_METHOD)) { c2 = '\r'; break; } break; case 767006947: if (str.equals(CREATE_NOTIFICATION_CHANNEL_GROUP_METHOD)) { c2 = 14; break; } break; case 825311171: if (str.equals(GET_CALLBACK_HANDLE_METHOD)) { c2 = 15; break; } break; case 871091088: if (str.equals(INITIALIZE_METHOD)) { c2 = 16; break; } break; case 891942317: if (str.equals(ARE_NOTIFICATIONS_ENABLED_METHOD)) { c2 = 17; break; } break; case 1008472557: if (str.equals(DELETE_NOTIFICATION_CHANNEL_METHOD)) { c2 = 18; break; } break; case 1207771056: if (str.equals(START_FOREGROUND_SERVICE)) { c2 = 19; break; } break; case 1408864732: if (str.equals(SHOW_DAILY_AT_TIME_METHOD)) { c2 = 20; break; } break; case 1594833996: if (str.equals(GET_ACTIVE_NOTIFICATIONS_METHOD)) { c2 = 21; break; } break; case 1653467900: if (str.equals(CREATE_NOTIFICATION_CHANNEL_METHOD)) { c2 = 22; break; } break; } switch (c2) { case 0: stopForegroundService(dVar); return; case 1: getNotificationChannels(dVar); return; case 2: case '\t': case 20: repeat(jVar, dVar); return; case 3: deleteNotificationChannelGroup(jVar, dVar); return; case 4: cancel(jVar, dVar); return; case 5: pendingNotificationRequests(dVar); return; case 6: schedule(jVar, dVar); return; case 7: getNotificationAppLaunchDetails(dVar); return; case '\b': show(jVar, dVar); return; case '\n': getActiveNotificationMessagingStyle(jVar, dVar); return; case 11: cancelAllNotifications(dVar); return; case '\f': zonedSchedule(jVar, dVar); return; case '\r': requestPermission(new b(dVar)); return; case 14: createNotificationChannelGroup(jVar, dVar); return; case 15: getCallbackHandle(dVar); return; case 16: initialize(jVar, dVar); return; case 17: areNotificationsEnabled(dVar); return; case 18: deleteNotificationChannel(jVar, dVar); return; case 19: startForegroundService(jVar, dVar); return; case 21: getActiveNotifications(dVar); return; case 22: createNotificationChannel(jVar, dVar); return; default: dVar.notImplemented(); return; } } @Override public boolean onNewIntent(Intent intent) { Activity activity; boolean booleanValue = sendNotificationPayloadMessage(intent).booleanValue(); if (booleanValue && (activity = this.mainActivity) != null) { activity.setIntent(intent); } return booleanValue; } @Override public void onReattachedToActivityForConfigChanges(io.flutter.embedding.engine.i.c.c cVar) { cVar.c(this); cVar.b(this); this.mainActivity = cVar.getActivity(); } @Override public boolean onRequestPermissionsResult(int i2, String[] strArr, int[] iArr) { if (this.permissionRequestInProgress) { if (i2 == 1) { boolean z = iArr.length > 0 && iArr[0] == 0; this.callback.b(z); this.permissionRequestInProgress = false; return z; } } return false; } public void requestPermission(com.dexterous.flutterlocalnotifications.c cVar) { if (this.permissionRequestInProgress) { cVar.a(PERMISSION_REQUEST_IN_PROGRESS_ERROR_MESSAGE); return; } this.callback = cVar; if (Build.VERSION.SDK_INT < 33) { this.callback.b(o.e(this.mainActivity).a()); return; } if (c.e.j.a.a(this.mainActivity, "android.permission.POST_NOTIFICATIONS") == 0) { this.callback.b(true); this.permissionRequestInProgress = false; } else { this.permissionRequestInProgress = true; androidx.core.app.b.s(this.mainActivity, new String[]{"android.permission.POST_NOTIFICATIONS"}, 1); } } }