正在查看: Housing v14.7.8 应用的 RichPushTimerUtilsKt.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Housing v14.7.8 应用的 RichPushTimerUtilsKt.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.moengage.richnotification.internal;
import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.RequiresApi;
import androidx.core.app.s;
import androidx.core.app.t;
import androidx.core.content.ContextCompat;
import com.facebook.react.uimanager.a;
import com.moengage.core.MoEConstants;
import com.moengage.core.internal.logger.Logger;
import com.moengage.core.internal.model.SdkInstance;
import com.moengage.core.internal.utils.CoreUtils;
import com.moengage.core.internal.utils.TimeUtilsKt;
import com.moengage.pushbase.internal.MapperKt;
import com.moengage.pushbase.internal.PushConstantsInternal;
import com.moengage.pushbase.internal.PushHelper;
import com.moengage.pushbase.internal.model.NotificationMetaData;
import com.moengage.pushbase.internal.model.TemplateTrackingMeta;
import com.moengage.richnotification.internal.models.CollapsedTemplate;
import com.moengage.richnotification.internal.models.ExpandedTemplate;
import com.moengage.richnotification.internal.models.ProgressProperties;
import com.moengage.richnotification.internal.models.Template;
import com.moengage.richnotification.internal.models.TimerProperties;
import com.moengage.richnotification.internal.models.TimerTemplate;
import kotlin.Metadata;
import kotlin.jvm.internal.r;
import org.jetbrains.annotations.NotNull;
@Metadata(d1 = {"\u0000f\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u000e\n\u0002\b\u0010\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0005\u001a\u0017\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\u0000¢\u0006\u0004\b\u0003\u0010\u0004\u001a\u001f\u0010\u0003\u001a\u00020\u00052\u0006\u0010\u0006\u001a\u00020\u00052\u0006\u0010\u0007\u001a\u00020\u0005H\u0000¢\u0006\u0004\b\u0003\u0010\b\u001a/\u0010\u0010\u001a\u00020\u000f2\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\f\u001a\u00020\u000b2\u0006\u0010\u0001\u001a\u00020\r2\u0006\u0010\u000e\u001a\u00020\u0002H\u0001¢\u0006\u0004\b\u0010\u0010\u0011\u001a7\u0010\u0014\u001a\u00020\u00132\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\u0001\u001a\u00020\u00002\u0006\u0010\f\u001a\u00020\u000b2\u0006\u0010\u000e\u001a\u00020\u00022\u0006\u0010\u0012\u001a\u00020\u0005H\u0001¢\u0006\u0004\b\u0014\u0010\u0015\u001a\u001f\u0010\u0018\u001a\u00020\u00132\u0006\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u000e\u001a\u00020\u0002H\u0000¢\u0006\u0004\b\u0018\u0010\u0019\u001a'\u0010\u001e\u001a\u00020\u00132\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\u001b\u001a\u00020\u001a2\u0006\u0010\u001d\u001a\u00020\u001cH\u0000¢\u0006\u0004\b\u001e\u0010\u001f\u001a'\u0010 \u001a\u00020\u00132\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\u001b\u001a\u00020\u001a2\u0006\u0010\u001d\u001a\u00020\u001cH\u0001¢\u0006\u0004\b \u0010\u001f\u001a'\u0010!\u001a\u00020\u00132\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\u001b\u001a\u00020\u001a2\u0006\u0010\u001d\u001a\u00020\u001cH\u0001¢\u0006\u0004\b!\u0010\u001f\u001a7\u0010&\u001a\u00020\u00132\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\"\u001a\u00020\u001a2\u0006\u0010$\u001a\u00020#2\u0006\u0010%\u001a\u00020#2\u0006\u0010\u001d\u001a\u00020\u001cH\u0000¢\u0006\u0004\b&\u0010'\u001a\u001f\u0010(\u001a\u00020\u00022\u0006\u0010\u000e\u001a\u00020\u00022\u0006\u0010\u001d\u001a\u00020\u001cH\u0000¢\u0006\u0004\b(\u0010)\u001a/\u0010*\u001a\u00020\u00132\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\u0001\u001a\u00020\u00002\u0006\u0010\f\u001a\u00020\u000b2\u0006\u0010\u000e\u001a\u00020\u0002H\u0001¢\u0006\u0004\b*\u0010+\u001a/\u0010,\u001a\u00020\u000f2\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\f\u001a\u00020\u000b2\u0006\u0010\u0001\u001a\u00020\r2\u0006\u0010\u000e\u001a\u00020\u0002H\u0001¢\u0006\u0004\b,\u0010\u0011\u001a7\u0010-\u001a\u00020\u00132\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\u0001\u001a\u00020\u00002\u0006\u0010\f\u001a\u00020\u000b2\u0006\u0010\u001d\u001a\u00020\u001c2\u0006\u0010\u000e\u001a\u00020\u0002H\u0000¢\u0006\u0004\b-\u0010.\u001a7\u0010/\u001a\u00020\u00132\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\u0001\u001a\u00020\u00002\u0006\u0010\f\u001a\u00020\u000b2\u0006\u0010\u000e\u001a\u00020\u00022\u0006\u0010\u0012\u001a\u00020\u0005H\u0003¢\u0006\u0004\b/\u0010\u0015\u001a7\u00100\u001a\u00020\u00132\u0006\u0010\n\u001a\u00020\t2\u0006\u0010\u0001\u001a\u00020\u00002\u0006\u0010\f\u001a\u00020\u000b2\u0006\u0010\u000e\u001a\u00020\u00022\u0006\u0010\u001d\u001a\u00020\u001cH\u0002¢\u0006\u0004\b0\u00101\u001a/\u00102\u001a\u00020\u00022\u0006\u0010\u000e\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u00002\u0006\u0010\f\u001a\u00020\u000b2\u0006\u0010\u001d\u001a\u00020\u001cH\u0000¢\u0006\u0004\b2\u00103\u001a\u0017\u00105\u001a\u0002042\u0006\u0010\f\u001a\u00020\u000bH\u0000¢\u0006\u0004\b5\u00106\u001a\u0017\u00107\u001a\u0002042\u0006\u0010\f\u001a\u00020\u000bH\u0000¢\u0006\u0004\b7\u00106\u001a\u0017\u00109\u001a\u0002082\u0006\u0010\n\u001a\u00020\tH\u0000¢\u0006\u0004\b9\u0010:\"\u0014\u0010;\u001a\u00020#8\u0002X\u0082T¢\u0006\u0006\n\u0004\b;\u0010<¨\u0006="}, d2 = {"Lcom/moengage/richnotification/internal/models/Template;", "template", "Lcom/moengage/richnotification/internal/models/ProgressProperties;", "getTimerEndTime", "(Lcom/moengage/richnotification/internal/models/Template;)Lcom/moengage/richnotification/internal/models/ProgressProperties;", "", RichPushConstantsKt.PROPERTY_DURATION_KEY, "endTime", "(JJ)J", "Landroid/content/Context;", "context", "Lcom/moengage/pushbase/internal/model/NotificationMetaData;", "metaData", "Lcom/moengage/richnotification/internal/models/TimerTemplate;", "progressProperties", "Landroid/app/PendingIntent;", "getTimerExpiryIntent", "(Landroid/content/Context;Lcom/moengage/pushbase/internal/model/NotificationMetaData;Lcom/moengage/richnotification/internal/models/TimerTemplate;Lcom/moengage/richnotification/internal/models/ProgressProperties;)Landroid/app/PendingIntent;", "expiryTriggerInMillis", "Lzp/j0;", "setTimerExpiryAlarm", "(Landroid/content/Context;Lcom/moengage/richnotification/internal/models/Template;Lcom/moengage/pushbase/internal/model/NotificationMetaData;Lcom/moengage/richnotification/internal/models/ProgressProperties;J)V", "Landroidx/core/app/s;", "notificationBuilder", "updateNotificationBuilderForTimerTemplate", "(Landroidx/core/app/s;Lcom/moengage/richnotification/internal/models/ProgressProperties;)V", "Landroid/os/Bundle;", "bundle", "Lcom/moengage/core/internal/model/SdkInstance;", "sdkInstance", "cancelAlarmIfAny", "(Landroid/content/Context;Landroid/os/Bundle;Lcom/moengage/core/internal/model/SdkInstance;)V", "cancelTimerAlarmIfAny", "cancelProgressAlarmIfAny", "payload", "", "templateName", "notificationTag", "dismissNotificationOnTimerExpiry", "(Landroid/content/Context;Landroid/os/Bundle;Ljava/lang/String;Ljava/lang/String;Lcom/moengage/core/internal/model/SdkInstance;)V", "setProgressUpdateProperties", "(Lcom/moengage/richnotification/internal/models/ProgressProperties;Lcom/moengage/core/internal/model/SdkInstance;)Lcom/moengage/richnotification/internal/models/ProgressProperties;", "scheduleProgressTemplateUpdateAlarm", "(Landroid/content/Context;Lcom/moengage/richnotification/internal/models/Template;Lcom/moengage/pushbase/internal/model/NotificationMetaData;Lcom/moengage/richnotification/internal/models/ProgressProperties;)V", "getProgressUpdateIntent", "setUpTimerAndProgressComponents", "(Landroid/content/Context;Lcom/moengage/richnotification/internal/models/Template;Lcom/moengage/pushbase/internal/model/NotificationMetaData;Lcom/moengage/core/internal/model/SdkInstance;Lcom/moengage/richnotification/internal/models/ProgressProperties;)V", "setUpTimerComponentsIfRequired", "setupProgressbarComponentsIfRequired", "(Landroid/content/Context;Lcom/moengage/richnotification/internal/models/Template;Lcom/moengage/pushbase/internal/model/NotificationMetaData;Lcom/moengage/richnotification/internal/models/ProgressProperties;Lcom/moengage/core/internal/model/SdkInstance;)V", "addProgressPropertiesIfRequired", "(Lcom/moengage/richnotification/internal/models/ProgressProperties;Lcom/moengage/richnotification/internal/models/Template;Lcom/moengage/pushbase/internal/model/NotificationMetaData;Lcom/moengage/core/internal/model/SdkInstance;)Lcom/moengage/richnotification/internal/models/ProgressProperties;", "", "getProgressUpdateAlarmId", "(Lcom/moengage/pushbase/internal/model/NotificationMetaData;)I", "getTimerExpiryAlarmId", "", "hasScheduleExactPermission", "(Landroid/content/Context;)Z", "tag", "Ljava/lang/String;", "rich-notification_defaultRelease"}, k = 2, mv = {1, 9, 0}, xi = 48)
public final class RichPushTimerUtilsKt {
@NotNull
private static final String tag = "RichPush_5.1.1_RichPushTimerUtils";
@NotNull
public static final ProgressProperties addProgressPropertiesIfRequired(@NotNull ProgressProperties progressProperties, @NotNull Template template, @NotNull NotificationMetaData notificationMetaData, @NotNull SdkInstance sdkInstance) {
r.k(progressProperties, "progressProperties");
r.k(template, "template");
r.k(notificationMetaData, "metaData");
r.k(sdkInstance, "sdkInstance");
if (template instanceof TimerTemplate) {
Evaluator evaluator = new Evaluator(sdkInstance.logger);
CollapsedTemplate collapsedTemplate = template.getCollapsedTemplate();
String type = collapsedTemplate != null ? collapsedTemplate.getType() : null;
ExpandedTemplate expandedTemplate = template.getExpandedTemplate();
if (evaluator.isTimerWithProgressbarTemplate$rich_notification_defaultRelease(type, expandedTemplate != null ? expandedTemplate.getType() : null) && progressProperties.getTimerEndTime() > -1) {
if (notificationMetaData.getPayload().getPayload().getBoolean(PushConstantsInternal.KEY_RE_NOTIFY) && !notificationMetaData.getPayload().getPayload().getString(PushConstantsInternal.NOTIFICATION_REPOSTING_SOURCE, "").equals(PushConstantsInternal.NOTIFICATION_REPOSTING_SOURCE_REMIND_LATER_OR_SNOOZE)) {
progressProperties.setProgressUpdateParameters(notificationMetaData.getPayload().getPayload().getInt(RichPushConstantsKt.PROGRESS_BAR_TEMPLATE_PROGRESS_UPDATE_INTERVAL), notificationMetaData.getPayload().getPayload().getInt(RichPushConstantsKt.PROGRESS_BAR_TEMPLATE_PROGRESS_INCREMENT_VALUE), notificationMetaData.getPayload().getPayload().getInt(RichPushConstantsKt.PROGRESS_BAR_TEMPLATE_CURRENT_PROGRESS_VALUE), notificationMetaData.getPayload().getPayload().getInt(RichPushConstantsKt.PROGRESS_BAR_TEMPLATE_MAX_PROGRESS_UPDATES_COUNT), notificationMetaData.getPayload().getPayload().getInt(RichPushConstantsKt.PROGRESS_BAR_TEMPLATE_CURRENT_PROGRESS_UPDATES_COUNT));
return progressProperties;
}
setProgressUpdateProperties(progressProperties, sdkInstance);
notificationMetaData.getPayload().getPayload().remove(PushConstantsInternal.NOTIFICATION_REPOSTING_SOURCE);
}
}
return progressProperties;
}
public static final void cancelAlarmIfAny(@NotNull Context context, @NotNull Bundle bundle, @NotNull SdkInstance sdkInstance) {
r.k(context, "context");
r.k(bundle, "bundle");
r.k(sdkInstance, "sdkInstance");
Logger.log$default(sdkInstance.logger, 0, null, null, RichPushTimerUtilsKt$cancelAlarmIfAny$1.INSTANCE, 7, null);
cancelTimerAlarmIfAny(context, bundle, sdkInstance);
cancelProgressAlarmIfAny(context, bundle, sdkInstance);
}
@RequiresApi(24)
public static final void cancelProgressAlarmIfAny(@NotNull Context context, @NotNull Bundle bundle, @NotNull SdkInstance sdkInstance) {
r.k(context, "context");
r.k(bundle, "bundle");
r.k(sdkInstance, "sdkInstance");
int i = bundle.getInt(RichPushConstantsKt.PROGRESS_ALARM_ID);
Logger.log$default(sdkInstance.logger, 0, null, null, new RichPushTimerUtilsKt$cancelProgressAlarmIfAny$1(i), 7, null);
Intent intent = new Intent(context, (Class<?>) MoERichPushReceiver.class);
intent.setFlags(268435456);
intent.putExtra(MoEConstants.PUSH_NOTIFICATION_CAMPAIGN_ID, bundle.getString(MoEConstants.PUSH_NOTIFICATION_CAMPAIGN_ID));
intent.putExtra(RichPushConstantsKt.TEMPLATE_NAME, bundle.getString(RichPushConstantsKt.TEMPLATE_NAME));
intent.putExtra(RichPushConstantsKt.PROGRESS_ALARM_ID, i);
intent.putExtra(MoEConstants.MOENGAGE_ACCOUNT_IDENTIFIER, bundle.getString(MoEConstants.MOENGAGE_ACCOUNT_IDENTIFIER));
intent.setAction(RichPushConstantsKt.INTENT_ACTION_PROGRESS_UPDATE);
Object systemService = context.getSystemService("alarm");
r.i(systemService, "null cannot be cast to non-null type android.app.AlarmManager");
((AlarmManager) systemService).cancel(CoreUtils.getPendingIntentBroadcast$default(context, i, intent, 0, 8, null));
}
@RequiresApi(24)
public static final void cancelTimerAlarmIfAny(@NotNull Context context, @NotNull Bundle bundle, @NotNull SdkInstance sdkInstance) {
r.k(context, "context");
r.k(bundle, "bundle");
r.k(sdkInstance, "sdkInstance");
int i = bundle.getInt(RichPushConstantsKt.TIMER_ALARM_ID);
Logger.log$default(sdkInstance.logger, 0, null, null, new RichPushTimerUtilsKt$cancelTimerAlarmIfAny$1(i), 7, null);
Intent intent = new Intent(context, (Class<?>) MoERichPushReceiver.class);
intent.setFlags(268435456);
intent.putExtra(RichPushConstantsKt.TIMER_ALARM_ID, bundle.getInt(RichPushConstantsKt.TIMER_ALARM_ID));
intent.putExtra(RichPushConstantsKt.TEMPLATE_NAME, bundle.getString(RichPushConstantsKt.TEMPLATE_NAME));
intent.putExtra(MoEConstants.PUSH_NOTIFICATION_CAMPAIGN_ID, bundle.getString(MoEConstants.PUSH_NOTIFICATION_CAMPAIGN_ID));
intent.putExtra(MoEConstants.MOENGAGE_ACCOUNT_IDENTIFIER, bundle.getString(MoEConstants.MOENGAGE_ACCOUNT_IDENTIFIER));
intent.setAction(RichPushConstantsKt.INTENT_ACTION_TIMER_ON_EXPIRY);
Object systemService = context.getSystemService("alarm");
r.i(systemService, "null cannot be cast to non-null type android.app.AlarmManager");
((AlarmManager) systemService).cancel(CoreUtils.getPendingIntentBroadcast$default(context, i, intent, 0, 8, null));
}
public static final void dismissNotificationOnTimerExpiry(@NotNull Context context, @NotNull Bundle bundle, @NotNull String str, @NotNull String str2, @NotNull SdkInstance sdkInstance) {
r.k(context, "context");
r.k(bundle, "payload");
r.k(str, "templateName");
r.k(str2, "notificationTag");
r.k(sdkInstance, "sdkInstance");
Logger.log$default(sdkInstance.logger, 0, null, null, RichPushTimerUtilsKt$dismissNotificationOnTimerExpiry$1.INSTANCE, 7, null);
bundle.putString(PushConstantsInternal.TEMPLATE_META, MapperKt.templateTrackingMetaToJsonString(new TemplateTrackingMeta(str, -1, -1)));
PushHelper.INSTANCE.getInstance().handleNotificationCancelled(context, bundle, sdkInstance);
}
public static final int getProgressUpdateAlarmId(@NotNull NotificationMetaData notificationMetaData) {
r.k(notificationMetaData, "metaData");
return notificationMetaData.getPayload().getPayload().getBoolean(PushConstantsInternal.KEY_RE_NOTIFY) ? notificationMetaData.getPayload().getPayload().getInt(RichPushConstantsKt.PROGRESS_ALARM_ID) : CoreUtils.getUniqueNumber();
}
@RequiresApi(24)
@NotNull
public static final PendingIntent getProgressUpdateIntent(@NotNull Context context, @NotNull NotificationMetaData notificationMetaData, @NotNull TimerTemplate timerTemplate, @NotNull ProgressProperties progressProperties) {
r.k(context, "context");
r.k(notificationMetaData, "metaData");
r.k(timerTemplate, "template");
r.k(progressProperties, "progressProperties");
Intent intent = new Intent(context, (Class<?>) MoERichPushReceiver.class);
Bundle payload = notificationMetaData.getPayload().getPayload();
payload.putString(RichPushConstantsKt.TEMPLATE_NAME, timerTemplate.getTemplateName());
payload.putInt(RichPushConstantsKt.PROGRESS_BAR_TEMPLATE_CURRENT_PROGRESS_VALUE, progressProperties.getProgressIncrementPercent() + progressProperties.getCurrentProgress());
payload.putInt(RichPushConstantsKt.PROGRESS_BAR_TEMPLATE_PROGRESS_INCREMENT_VALUE, progressProperties.getProgressIncrementPercent());
payload.putLong(RichPushConstantsKt.PROGRESS_BAR_TEMPLATE_PROGRESS_UPDATE_INTERVAL, progressProperties.getUpdateInterval());
payload.putInt(RichPushConstantsKt.PROGRESS_BAR_TEMPLATE_MAX_PROGRESS_UPDATES_COUNT, progressProperties.getMaxUpdatesCount());
payload.putInt(RichPushConstantsKt.PROGRESS_BAR_TEMPLATE_CURRENT_PROGRESS_UPDATES_COUNT, progressProperties.getCurrentUpdatesCount() + 1);
intent.setFlags(268435456);
intent.putExtra(MoEConstants.PUSH_NOTIFICATION_CAMPAIGN_ID, notificationMetaData.getPayload().getCampaignId());
intent.putExtra(RichPushConstantsKt.TEMPLATE_NAME, timerTemplate.getTemplateName());
intent.putExtra(RichPushConstantsKt.PROGRESS_ALARM_ID, progressProperties.getProgressAlarmId());
intent.putExtra(MoEConstants.MOENGAGE_ACCOUNT_IDENTIFIER, notificationMetaData.getPayload().getPayload().getString(MoEConstants.MOENGAGE_ACCOUNT_IDENTIFIER));
intent.setAction(RichPushConstantsKt.INTENT_ACTION_PROGRESS_UPDATE);
return CoreUtils.getPendingIntentBroadcast$default(context, progressProperties.getProgressAlarmId(), intent, 0, 8, null);
}
@NotNull
public static final ProgressProperties getTimerEndTime(@NotNull Template template) {
r.k(template, "template");
if (!(template instanceof TimerTemplate)) {
return new ProgressProperties(-1L, new TimerProperties(-1L, -1L));
}
TimerTemplate timerTemplate = (TimerTemplate) template;
return new ProgressProperties(getTimerEndTime(timerTemplate.getTimerProperties().getDuration(), timerTemplate.getTimerProperties().getExpiry()), timerTemplate.getTimerProperties());
}
public static final int getTimerExpiryAlarmId(@NotNull NotificationMetaData notificationMetaData) {
r.k(notificationMetaData, "metaData");
return notificationMetaData.getPayload().getPayload().getBoolean(PushConstantsInternal.KEY_RE_NOTIFY) ? notificationMetaData.getPayload().getPayload().getInt(RichPushConstantsKt.TIMER_ALARM_ID) : CoreUtils.getUniqueNumber();
}
@RequiresApi(24)
@NotNull
public static final PendingIntent getTimerExpiryIntent(@NotNull Context context, @NotNull NotificationMetaData notificationMetaData, @NotNull TimerTemplate timerTemplate, @NotNull ProgressProperties progressProperties) {
r.k(context, "context");
r.k(notificationMetaData, "metaData");
r.k(timerTemplate, "template");
r.k(progressProperties, "progressProperties");
Intent intent = new Intent(context, (Class<?>) MoERichPushReceiver.class);
notificationMetaData.getPayload().getPayload().putString(RichPushConstantsKt.TEMPLATE_NAME, timerTemplate.getTemplateName());
intent.setFlags(268435456);
intent.putExtra(RichPushConstantsKt.TIMER_ALARM_ID, progressProperties.getTimerAlarmId());
intent.putExtra(RichPushConstantsKt.TEMPLATE_NAME, timerTemplate.getTemplateName());
intent.putExtra(MoEConstants.PUSH_NOTIFICATION_CAMPAIGN_ID, notificationMetaData.getPayload().getCampaignId());
intent.putExtra(MoEConstants.MOENGAGE_ACCOUNT_IDENTIFIER, notificationMetaData.getPayload().getPayload().getString(MoEConstants.MOENGAGE_ACCOUNT_IDENTIFIER));
intent.setAction(RichPushConstantsKt.INTENT_ACTION_TIMER_ON_EXPIRY);
return CoreUtils.getPendingIntentBroadcast$default(context, progressProperties.getTimerAlarmId(), intent, 0, 8, null);
}
public static final boolean hasScheduleExactPermission(@NotNull Context context) {
boolean z;
r.k(context, "context");
if (Build.VERSION.SDK_INT >= 31) {
AlarmManager alarmManager = (AlarmManager) ContextCompat.getSystemService(context, AlarmManager.class);
z = alarmManager != null ? a.x(alarmManager) : false;
} else {
z = true;
}
Logger.Companion.print$default(Logger.INSTANCE, 0, null, null, new RichPushTimerUtilsKt$hasScheduleExactPermission$1(z), 7, null);
return z;
}
@RequiresApi(24)
@SuppressLint({"MissingPermission"})
public static final void scheduleProgressTemplateUpdateAlarm(@NotNull Context context, @NotNull Template template, @NotNull NotificationMetaData notificationMetaData, @NotNull ProgressProperties progressProperties) {
r.k(context, "context");
r.k(template, "template");
r.k(notificationMetaData, "metaData");
r.k(progressProperties, "progressProperties");
TimerTemplate timerTemplate = (TimerTemplate) template;
if (hasScheduleExactPermission(context)) {
PendingIntent progressUpdateIntent = getProgressUpdateIntent(context, notificationMetaData, timerTemplate, progressProperties);
Object systemService = context.getSystemService("alarm");
r.i(systemService, "null cannot be cast to non-null type android.app.AlarmManager");
((AlarmManager) systemService).setExactAndAllowWhileIdle(0, progressProperties.getUpdateInterval() + TimeUtilsKt.currentMillis(), progressUpdateIntent);
}
}
@NotNull
public static final ProgressProperties setProgressUpdateProperties(@NotNull ProgressProperties progressProperties, @NotNull SdkInstance sdkInstance) {
long j;
int i;
int i2;
r.k(progressProperties, "progressProperties");
r.k(sdkInstance, "sdkInstance");
long duration = progressProperties.getTimerProperties().getDuration();
long j2 = 1000;
long timerEndTime = duration - (progressProperties.getTimerEndTime() / j2);
if (duration >= 900 && duration <= 1800) {
i2 = 10;
j = timerEndTime;
i = 10;
} else if (duration <= 1800 || duration > 43200) {
Logger.log$default(sdkInstance.logger, 0, null, null, RichPushTimerUtilsKt$setProgressUpdateProperties$1.INSTANCE, 7, null);
j = timerEndTime;
i = -1;
i2 = -1;
} else {
i2 = 25;
i = 4;
j = timerEndTime;
}
if (i2 != -1 && i != -1) {
long j3 = duration / i2;
int i3 = (int) ((j / j3) * i);
progressProperties.setProgressUpdateParameters(j3 * j2, i, i3, i2, i3 / i2);
}
Logger.log$default(sdkInstance.logger, 0, null, null, new RichPushTimerUtilsKt$setProgressUpdateProperties$2(progressProperties), 7, null);
return progressProperties;
}
@RequiresApi(24)
@SuppressLint({"MissingPermission"})
public static final void setTimerExpiryAlarm(@NotNull Context context, @NotNull Template template, @NotNull NotificationMetaData notificationMetaData, @NotNull ProgressProperties progressProperties, long j) {
r.k(context, "context");
r.k(template, "template");
r.k(notificationMetaData, "metaData");
r.k(progressProperties, "progressProperties");
TimerTemplate timerTemplate = (TimerTemplate) template;
if (hasScheduleExactPermission(context)) {
PendingIntent timerExpiryIntent = getTimerExpiryIntent(context, notificationMetaData, timerTemplate, progressProperties);
Object systemService = context.getSystemService("alarm");
r.i(systemService, "null cannot be cast to non-null type android.app.AlarmManager");
((AlarmManager) systemService).setExactAndAllowWhileIdle(0, j, timerExpiryIntent);
Logger.Companion.print$default(Logger.INSTANCE, 0, null, null, new RichPushTimerUtilsKt$setTimerExpiryAlarm$1(progressProperties), 7, null);
}
}
public static final void setUpTimerAndProgressComponents(@NotNull Context context, @NotNull Template template, @NotNull NotificationMetaData notificationMetaData, @NotNull SdkInstance sdkInstance, @NotNull ProgressProperties progressProperties) {
r.k(context, "context");
r.k(template, "template");
r.k(notificationMetaData, "metaData");
r.k(sdkInstance, "sdkInstance");
r.k(progressProperties, "progressProperties");
updateNotificationBuilderForTimerTemplate(notificationMetaData.getNotificationBuilder(), progressProperties);
if (progressProperties.getTimerEndTime() == -1) {
Logger.log$default(sdkInstance.logger, 0, null, null, RichPushTimerUtilsKt$setUpTimerAndProgressComponents$1.INSTANCE, 7, null);
return;
}
long timerEndTime = progressProperties.getTimerEndTime() + TimeUtilsKt.currentMillis();
setUpTimerComponentsIfRequired(context, template, notificationMetaData, progressProperties, timerEndTime);
setupProgressbarComponentsIfRequired(context, template, notificationMetaData, progressProperties, sdkInstance);
PushHelper.INSTANCE.getInstance().storeRepostCampaignPayload(context, sdkInstance, notificationMetaData.getPayload(), timerEndTime);
}
@RequiresApi(24)
private static final void setUpTimerComponentsIfRequired(Context context, Template template, NotificationMetaData notificationMetaData, ProgressProperties progressProperties, long j) {
Logger.Companion.print$default(Logger.INSTANCE, 0, null, null, new RichPushTimerUtilsKt$setUpTimerComponentsIfRequired$1(progressProperties), 7, null);
if (notificationMetaData.getPayload().getPayload().getBoolean(PushConstantsInternal.KEY_RE_NOTIFY)) {
return;
}
setTimerExpiryAlarm(context, template, notificationMetaData, progressProperties, j);
}
private static final void setupProgressbarComponentsIfRequired(Context context, Template template, NotificationMetaData notificationMetaData, ProgressProperties progressProperties, SdkInstance sdkInstance) {
Evaluator evaluator = new Evaluator(sdkInstance.logger);
CollapsedTemplate collapsedTemplate = template.getCollapsedTemplate();
String type = collapsedTemplate != null ? collapsedTemplate.getType() : null;
ExpandedTemplate expandedTemplate = template.getExpandedTemplate();
if (evaluator.isTimerWithProgressbarTemplate$rich_notification_defaultRelease(type, expandedTemplate != null ? expandedTemplate.getType() : null)) {
if (progressProperties.getCurrentUpdatesCount() == progressProperties.getMaxUpdatesCount() - 1) {
progressProperties.setUpdateInterval(progressProperties.getTimerEndTime());
}
Logger.Companion.print$default(Logger.INSTANCE, 0, null, null, new RichPushTimerUtilsKt$setupProgressbarComponentsIfRequired$1(progressProperties), 7, null);
scheduleProgressTemplateUpdateAlarm(context, template, notificationMetaData, progressProperties);
}
}
public static final void updateNotificationBuilderForTimerTemplate(@NotNull s sVar, @NotNull ProgressProperties progressProperties) {
r.k(sVar, "notificationBuilder");
r.k(progressProperties, "progressProperties");
sVar.z(new t());
sVar.q((Bitmap) null);
sVar.A((CharSequence) null);
sVar.C(progressProperties.getTimerEndTime());
}
public static final long getTimerEndTime(long j, long j2) {
if (j < 900 || j > 43200) {
return -1L;
}
long j3 = 1000;
long j4 = j * j3;
long currentMillis = (j2 * j3) - TimeUtilsKt.currentMillis();
if (currentMillis <= 5000) {
return -1L;
}
return currentMillis < j4 ? currentMillis : j4;
}
}