package com.ea.nimble.pushtng; import android.app.PendingIntent; import android.content.ComponentName; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; import android.os.Bundle; import androidx.core.app.NotificationCompat; import com.ea.eadp.http.services.HttpService; import com.ea.eadp.pushnotification.forwarding.FCMMessageService; import com.ea.nimble.ApplicationEnvironment; import com.ea.nimble.Log; import com.ea.nimble.tracking.Tracking; import com.facebook.internal.NativeProtocol; import java.io.File; import java.util.HashMap; import java.util.Iterator; import java.util.Vector; /* loaded from: classes2.dex */ public class NimblePushTNGIntentService extends FCMMessageService { private static final String DO_NOT_COLLAPSE = "do_not_collapse"; public static final String EXTRA_IS_DELETE_INTENT = "IsDeleteIntent"; private static final String KEY_PUSH_COUNT = "push_count"; private static final String KEY_PUSH_TEXT_LIST = "push_text_list"; @Override // com.ea.eadp.pushnotification.forwarding.FCMMessageService public void onHandleMessage(Intent intent) { Log.Helper.LOGFUNC(this); Bundle extras = intent.getExtras(); if (extras == null) { Log.Helper.LOGE(this, "NimblePushTNGIntentService onHandleMessage failed! Extras from intent were null, unable to process message.", new Object[0]); return; } String string = extras.getString(FCMMessageService.PushIntentExtraKeys.PUSH_ID); String string2 = extras.getString(FCMMessageService.PushIntentExtraKeys.PN_TYPE); if (string != null && string2 != null) { HashMap hashMap = new HashMap(); hashMap.put(PushNotification.KEY_TRACKING_TYPE, Tracking.EVENT_PN_RECEIVED); hashMap.put("NIMBLESTANDARD::KEY_PN_MESSAGE_ID", string); hashMap.put(Tracking.KEY_PN_MESSAGE_TYPE, string2); PushNotificationImpl.persistTrackingData(getApplicationContext(), hashMap, string + "_" + Tracking.EVENT_PN_RECEIVED); } intent.putExtra("PushNotification", "true"); super.onHandleMessage(intent); } @Override // com.ea.eadp.pushnotification.forwarding.FCMMessageService public void customizeNotification(NotificationCompat.Builder builder, Bundle bundle) { Log.Helper.LOGFUNC(this); super.customizeNotification(builder, bundle); String string = bundle.getString(FCMMessageService.PushIntentExtraKeys.COLLAPSE_KEY); if (string == null || string.equalsIgnoreCase(DO_NOT_COLLAPSE)) { return; } String replace = string.replace(File.pathSeparator, "-").replace(File.separator, "_"); SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences("PushTNGStacking_" + replace, 0); int i = sharedPreferences.getInt(KEY_PUSH_COUNT, 0); Vector vector = new Vector(); for (int i2 = 0; i2 < i; i2++) { String string2 = sharedPreferences.getString(KEY_PUSH_TEXT_LIST + i2, null); if (string2 != null) { vector.add(string2); } } int i3 = i + 1; vector.add(bundle.getString(FCMMessageService.PushIntentExtraKeys.ALERT)); if (i3 > 1) { Resources resources = getApplicationContext().getResources(); String packageName = getApplicationContext().getPackageName(); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); Iterator it = vector.iterator(); while (it.hasNext()) { inboxStyle.addLine((CharSequence) it.next()); } CharSequence charSequence = getApplicationContext().getResources().getString(resources.getIdentifier(NativeProtocol.BRIDGE_ARG_APP_NAME_STRING, "string", packageName)) + "(" + i3 + ")"; inboxStyle.setBigContentTitle(charSequence); builder.setContentTitle(charSequence); builder.setStyle(inboxStyle); } ComponentName broadcastForwarderComponent = getBroadcastForwarderComponent(); if (broadcastForwarderComponent != null) { Intent intent = new Intent(); intent.setComponent(broadcastForwarderComponent); intent.putExtra(EXTRA_IS_DELETE_INTENT, true); intent.putExtra(FCMMessageService.PushIntentExtraKeys.COLLAPSE_KEY, replace); builder.setDeleteIntent(PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 335544320)); } else { Log.Helper.LOGW(this, "Broadcast listener for action 'com.ea.eadp.pushnotification.FORWARD_AS_ORDERED_BROADCAST' was not found. Skipping setting DeleteIntent in Notification.", new Object[0]); } SharedPreferences.Editor edit = sharedPreferences.edit(); for (int i4 = 0; i4 < vector.size(); i4++) { edit.putString(KEY_PUSH_TEXT_LIST + i4, (String) vector.elementAt(i4)); } edit.putInt(KEY_PUSH_COUNT, i3); edit.apply(); } @Override // com.ea.eadp.pushnotification.forwarding.FCMMessageService public boolean isInForeground() { Log.Helper.LOGFUNC(this); return ApplicationEnvironment.isMainApplicationActive(); } @Override // com.ea.eadp.pushnotification.forwarding.FCMMessageService public HttpService getHttpService() { Log.Helper.LOGFUNC(this); return new NimbleAndroidHttpService(); } }