package com.firemonkeys.cloudcellapi; import android.annotation.TargetApi; import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import com.google.android.gms.drive.DriveFile; /* loaded from: classes2.dex */ public class DelayedNotificationService extends IntentService { static final String ACTION_NOTIFICATION_DISMISSED = "ACTION_NOTIFICATION_DISMISSED"; private static final String CLASSNAME = ResourceHelper.GetDelayedNotificationServiceTag(); static final String GROUP_KEY = ResourceHelper.GetGroupKey(); private static final String NOTIFICATION_KEY = ".notification."; public DelayedNotificationService() { super("DelayedNotificationService"); Logging.CC_INFO(CLASSNAME, "Constructed"); } public void NotificationDismissed() { SerialiseNotificationsHelper.ClearAll(getApplicationContext()); } @Override // android.app.IntentService @TargetApi(21) public void onHandleIntent(Intent intent) { Notification CreateBigTextNotification; String str = CLASSNAME; Logging.CC_INFO(str, "DelayedNotificationService: onHandleIntent"); if (intent.getAction() != null && intent.getAction().equals(ACTION_NOTIFICATION_DISMISSED)) { NotificationDismissed(); return; } Context applicationContext = getApplicationContext(); ApplicationInfo applicationInfo = applicationContext.getApplicationInfo(); int intExtra = intent.getIntExtra("id", -2); String string = getApplicationContext().getResources().getString(applicationInfo.labelRes); intent.getStringExtra("name"); getApplicationContext().getPackageName(); String stringExtra = intent.getStringExtra("message"); String stringExtra2 = intent.getStringExtra(LocalNotificationsCenter.EXTRA_LAUNCH_URL); NotificationManager notificationManager = (NotificationManager) getSystemService("notification"); long currentTimeMillis = System.currentTimeMillis(); int identifier = getApplicationContext().getResources().getIdentifier(ResourceHelper.GetIconID(), "drawable", applicationContext.getPackageName()); Intent launchIntentForPackage = applicationContext.getPackageManager().getLaunchIntentForPackage(applicationContext.getPackageName()); if (stringExtra2 != null && !stringExtra2.isEmpty()) { launchIntentForPackage.putExtra(LocalNotificationsCenter.EXTRA_LAUNCH_URL, stringExtra2); } Notification.Builder when = new Notification.Builder(getApplicationContext()).setContentTitle(string).setContentText(stringExtra).setSmallIcon(identifier).setContentIntent(PendingIntent.getActivity(this, 0, launchIntentForPackage, DriveFile.MODE_READ_ONLY)).setAutoCancel(true).setWhen(currentTimeMillis); when.setChannelId(intent.getStringExtra(LocalNotificationsCenter.EXTRA_CHANNEL_ID)); Intent intent2 = new Intent(this, (Class) DelayedNotificationService.class); intent2.setAction(ACTION_NOTIFICATION_DISMISSED); when.setDeleteIntent(PendingIntent.getService(this, 0, intent2, 134217728)); SerialisedNotificationInfo GetSavedInfo = SerialiseNotificationsHelper.GetSavedInfo(getApplicationContext()); int GetNotificationCount = GetSavedInfo.GetNotificationCount(); Logging.CC_INFO(str, "There are (" + GetNotificationCount + ") saved notifications"); if (GetNotificationCount > 0) { CreateBigTextNotification = CreateStackedNotification(GetSavedInfo, when, stringExtra); } else { CreateBigTextNotification = CreateBigTextNotification(when, stringExtra); } SerialiseNotificationsHelper.AddNotification(getApplicationContext(), stringExtra); Logging.CC_INFO(str, "DelayedNotificationService: showing notification id: " + intExtra + " msg: " + stringExtra); try { notificationManager.notify(0, CreateBigTextNotification); } catch (Exception e) { Logging.CC_ERROR(CLASSNAME, "DelayedNotificationService: Notification Exception: " + e.toString()); } } public Notification CreateStackedNotification(SerialisedNotificationInfo serialisedNotificationInfo, Notification.Builder builder, String str) { String str2; Notification.InboxStyle inboxStyle = new Notification.InboxStyle(builder); inboxStyle.addLine(str); int i = 0; for (int GetNotificationCount = serialisedNotificationInfo.GetNotificationCount() - 1; GetNotificationCount >= 0; GetNotificationCount--) { try { str2 = "- " + serialisedNotificationInfo.GetNotificationString(GetNotificationCount); } catch (Exception e) { Logging.CC_ERROR(CLASSNAME, "Error getting notification string: " + e.toString()); str2 = ""; } inboxStyle.addLine(str2); i++; if (i >= 4) { break; } } return inboxStyle.build(); } public Notification CreateBigTextNotification(Notification.Builder builder, String str) { return new Notification.BigTextStyle(builder).bigText(str).build(); } }