- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
339 lines
18 KiB
Java
339 lines
18 KiB
Java
package com.ea.nimble;
|
|
|
|
import android.app.AlarmManager;
|
|
import android.app.Notification;
|
|
import android.app.NotificationChannel;
|
|
import android.app.NotificationManager;
|
|
import android.app.PendingIntent;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.res.Resources;
|
|
import android.os.Bundle;
|
|
import android.service.notification.StatusBarNotification;
|
|
import androidx.core.app.NotificationCompat;
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
import com.ea.eadp.pushnotification.forwarding.FCMMessageService;
|
|
import com.ea.nimble.Error;
|
|
import com.ea.nimble.Log;
|
|
import com.ea.nimble.Persistence;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class NimbleLocalNotificationsImpl extends Component implements INimbleLocalNotifications {
|
|
private static final String BADGE_ID = "Nimble_BadgeNotification";
|
|
private static final String NOTIFICATION_TRACKING2_LOG_EVENT = "nimble.notification.tracking2.logEvent";
|
|
private static final String PERSISTENCE_ENABLED_KEY = "enabled";
|
|
private static final String PERSISTENCE_NOTIFICATION_MAP_KEY = "map";
|
|
private static INimbleBadgeProvider m_badgeProvider;
|
|
private static INimbleLocalNotificationCustomizer m_notificationCustomizer;
|
|
private boolean m_enabled = true;
|
|
private HashMap<String, Date> m_notificationMap;
|
|
|
|
@Override // com.ea.nimble.Component
|
|
public String getComponentId() {
|
|
return NimbleLocalNotifications.COMPONENT_ID;
|
|
}
|
|
|
|
@Override // com.ea.nimble.INimbleLocalNotifications
|
|
public boolean isEnabled() {
|
|
return this.m_enabled;
|
|
}
|
|
|
|
@Override // com.ea.nimble.Component
|
|
public void restore() {
|
|
String str;
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
Persistence persistenceForNimbleComponent = PersistenceService.getPersistenceForNimbleComponent(getComponentId(), Persistence.Storage.CACHE);
|
|
if (persistenceForNimbleComponent.hasKey("enabled")) {
|
|
this.m_enabled = persistenceForNimbleComponent.getBoolValue("enabled");
|
|
} else {
|
|
this.m_enabled = true;
|
|
}
|
|
if (persistenceForNimbleComponent.hasKey(PERSISTENCE_NOTIFICATION_MAP_KEY)) {
|
|
HashMap<String, Date> hashMap = (HashMap) persistenceForNimbleComponent.getValue(PERSISTENCE_NOTIFICATION_MAP_KEY);
|
|
this.m_notificationMap = hashMap;
|
|
Iterator<String> it = hashMap.keySet().iterator();
|
|
Date date = new Date();
|
|
while (it.hasNext()) {
|
|
String next = it.next();
|
|
Date date2 = this.m_notificationMap.get(next);
|
|
if (date2.before(date)) {
|
|
Log.Helper.LOGV(this, "restore(): Removed notification list key " + next + " from map because its date (" + date2 + ") is in the past!", new Object[0]);
|
|
it.remove();
|
|
}
|
|
}
|
|
saveNotificationMap();
|
|
} else {
|
|
this.m_notificationMap = new HashMap<>();
|
|
}
|
|
Context applicationContext = ApplicationEnvironment.getComponent().getApplicationContext();
|
|
NotificationManager notificationManager = (NotificationManager) applicationContext.getSystemService("notification");
|
|
if (NimbleApplicationConfiguration.configValueExists(Global.NOTIFICATION_CHANNEL_LOCAL_NOTIFICATION_ID_KEY)) {
|
|
return;
|
|
}
|
|
if (NimbleApplicationConfiguration.configValueExists(Global.NOTIFICATION_CHANNEL_DEFAULT_NAME_KEY)) {
|
|
str = applicationContext.getResources().getString(NimbleApplicationConfiguration.getConfigValueAsInt(Global.NOTIFICATION_CHANNEL_DEFAULT_NAME_KEY));
|
|
} else {
|
|
str = "Default";
|
|
}
|
|
NotificationChannel notificationChannel = new NotificationChannel(Global.NOTIFICATION_CHANNEL_DEFAULT_ID, str, 3);
|
|
if (NimbleApplicationConfiguration.configValueExists(Global.NOTIFICATION_CHANNEL_DEFAULT_DESCRIPTION_KEY)) {
|
|
notificationChannel.setDescription(applicationContext.getResources().getString(NimbleApplicationConfiguration.getConfigValueAsInt(Global.NOTIFICATION_CHANNEL_DEFAULT_DESCRIPTION_KEY)));
|
|
}
|
|
notificationManager.createNotificationChannel(notificationChannel);
|
|
}
|
|
|
|
@Override // com.ea.nimble.INimbleLocalNotifications
|
|
public Error scheduleNotification(String str, String str2, String str3, Date date) {
|
|
return scheduleNotification(str, str2, str3, date, null);
|
|
}
|
|
|
|
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
|
|
@Override // com.ea.nimble.INimbleLocalNotifications
|
|
public Error scheduleNotification(String str, String str2, String str3, Date date, Map<String, String> map) {
|
|
char c;
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
Date date2 = new Date();
|
|
if (!this.m_enabled) {
|
|
Log.Helper.LOGD(this, "scheduleNotification(): Local Notifications are not enabled!", new Object[0]);
|
|
return null;
|
|
}
|
|
Log.Helper.LOGD(this, "[scheduleNotification] Notification requested with: \n- Title : %s\n- Message : %s\n- ID : %s\n- Date : %s\n- Extras : %s", str, str2, str3, date.toString(), map.toString());
|
|
if (!Utility.validString(str)) {
|
|
Log.Helper.LOGE(this, "scheduleNotification(): Invalid title", new Object[0]);
|
|
return new Error(Error.Code.INVALID_ARGUMENT, "Invalid title");
|
|
}
|
|
if (!Utility.validString(str2)) {
|
|
Log.Helper.LOGE(this, "scheduleNotification(): Invalid message", new Object[0]);
|
|
return new Error(Error.Code.INVALID_ARGUMENT, "Invalid message");
|
|
}
|
|
if (date.before(date2)) {
|
|
Log.Helper.LOGE(this, "scheduleNotification(): Expired date", new Object[0]);
|
|
return new Error(Error.Code.INVALID_ARGUMENT, "Expired date");
|
|
}
|
|
String str4 = Utility.validString(str3) ? str3 : "auto_" + date2.getTime();
|
|
Context applicationContext = ApplicationEnvironment.getComponent().getApplicationContext();
|
|
Resources resources = ApplicationEnvironment.getComponent().getApplicationContext().getResources();
|
|
String packageName = ApplicationEnvironment.getComponent().getApplicationContext().getPackageName();
|
|
Intent intent = new Intent(applicationContext, (Class<?>) NimbleLocalNotificationReceiver.class);
|
|
for (String str5 : map.keySet()) {
|
|
str5.hashCode();
|
|
switch (str5.hashCode()) {
|
|
case -984292776:
|
|
if (str5.equals(FCMMessageService.PushIntentExtraKeys.PN_TYPE)) {
|
|
c = 0;
|
|
break;
|
|
}
|
|
c = 65535;
|
|
break;
|
|
case -976922155:
|
|
if (str5.equals(FCMMessageService.PushIntentExtraKeys.PUSH_ID)) {
|
|
c = 1;
|
|
break;
|
|
}
|
|
c = 65535;
|
|
break;
|
|
case 595233003:
|
|
if (str5.equals("notification")) {
|
|
c = 2;
|
|
break;
|
|
}
|
|
c = 65535;
|
|
break;
|
|
default:
|
|
c = 65535;
|
|
break;
|
|
}
|
|
switch (c) {
|
|
case 0:
|
|
case 1:
|
|
case 2:
|
|
Log.Helper.LOGE(this, "scheduleNotification(): Cannot use extra with key : " + str5, new Object[0]);
|
|
break;
|
|
}
|
|
intent.putExtra(str5, map.get(str5));
|
|
}
|
|
Notification.Builder autoCancel = new Notification.Builder(applicationContext, NimbleApplicationConfiguration.configValueExists(Global.NOTIFICATION_CHANNEL_LOCAL_NOTIFICATION_ID_KEY) ? NimbleApplicationConfiguration.getConfigValueAsString(Global.NOTIFICATION_CHANNEL_LOCAL_NOTIFICATION_ID_KEY) : Global.NOTIFICATION_CHANNEL_DEFAULT_ID).setContentTitle(str).setContentText(str2).setStyle(new Notification.BigTextStyle().bigText(str2)).setAutoCancel(true);
|
|
try {
|
|
autoCancel.setSmallIcon(resources.getIdentifier("pn_icon", "drawable", packageName));
|
|
INimbleLocalNotificationCustomizer iNimbleLocalNotificationCustomizer = m_notificationCustomizer;
|
|
if (iNimbleLocalNotificationCustomizer != null) {
|
|
iNimbleLocalNotificationCustomizer.customizeLocalNotification(autoCancel, intent.getExtras());
|
|
}
|
|
Notification build = autoCancel.build();
|
|
this.m_notificationMap.put(str4, date);
|
|
saveNotificationMap();
|
|
intent.putExtra("notification", build);
|
|
intent.putExtra(FCMMessageService.PushIntentExtraKeys.PUSH_ID, str4);
|
|
intent.putExtra(FCMMessageService.PushIntentExtraKeys.PN_TYPE, "local");
|
|
((AlarmManager) applicationContext.getSystemService(NotificationCompat.CATEGORY_ALARM)).set(0, System.currentTimeMillis() + (date.getTime() - date2.getTime()), PendingIntent.getBroadcast(applicationContext, str4 != null ? str4.hashCode() : 0, intent, 201326592));
|
|
HashMap hashMap = new HashMap();
|
|
hashMap.put("en", "message");
|
|
Bundle bundle = new Bundle();
|
|
bundle.putSerializable("core", hashMap);
|
|
bundle.putString("msg_id", str4);
|
|
bundle.putString("type", "pn");
|
|
bundle.putString(NotificationCompat.CATEGORY_SERVICE, "local");
|
|
bundle.putString("status", "started");
|
|
bundle.putString("format", "pn");
|
|
Intent intent2 = new Intent();
|
|
intent2.setAction(NOTIFICATION_TRACKING2_LOG_EVENT);
|
|
intent2.putExtras(bundle);
|
|
LocalBroadcastManager.getInstance(ApplicationEnvironment.getComponent().getApplicationContext()).sendBroadcast(intent2);
|
|
return null;
|
|
} catch (Exception e) {
|
|
Log.Helper.LOGE(this, "scheduleNotification(): Not scheduled. Unable to set application icon due to exception: " + e, new Object[0]);
|
|
return new Error(Error.Code.SYSTEM_UNEXPECTED, "Unable to get pn_icon");
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.INimbleLocalNotifications
|
|
public void cancelAllNotifications() {
|
|
Iterator it = ((HashMap) this.m_notificationMap.clone()).keySet().iterator();
|
|
while (it.hasNext()) {
|
|
cancelNotification((String) it.next());
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.INimbleLocalNotifications
|
|
public void cancelNotification(String str) {
|
|
Context applicationContext = ApplicationEnvironment.getComponent().getApplicationContext();
|
|
PendingIntent broadcast = PendingIntent.getBroadcast(applicationContext, str.hashCode(), new Intent(applicationContext, (Class<?>) NimbleLocalNotificationReceiver.class), 603979776);
|
|
if (broadcast != null) {
|
|
broadcast.cancel();
|
|
((AlarmManager) applicationContext.getSystemService(NotificationCompat.CATEGORY_ALARM)).cancel(broadcast);
|
|
this.m_notificationMap.remove(str);
|
|
saveNotificationMap();
|
|
Log.Helper.LOGD(this, "cancelNotification(%s): Successfully canceled", str);
|
|
HashMap hashMap = new HashMap();
|
|
hashMap.put("en", "message");
|
|
Bundle bundle = new Bundle();
|
|
bundle.putSerializable("core", hashMap);
|
|
bundle.putString("msg_id", str);
|
|
bundle.putString("type", "pn");
|
|
bundle.putString(NotificationCompat.CATEGORY_SERVICE, "local");
|
|
bundle.putString("status", "canceled");
|
|
bundle.putString("format", "pn");
|
|
Intent intent = new Intent();
|
|
intent.setAction(NOTIFICATION_TRACKING2_LOG_EVENT);
|
|
intent.putExtras(bundle);
|
|
LocalBroadcastManager.getInstance(ApplicationEnvironment.getComponent().getApplicationContext()).sendBroadcast(intent);
|
|
return;
|
|
}
|
|
Log.Helper.LOGD(this, "cancelNotification(%s): Not found", str);
|
|
}
|
|
|
|
@Override // com.ea.nimble.INimbleLocalNotifications
|
|
public void setEnabled(boolean z) {
|
|
if (this.m_enabled != z) {
|
|
this.m_enabled = z;
|
|
Persistence persistenceForNimbleComponent = PersistenceService.getPersistenceForNimbleComponent(getComponentId(), Persistence.Storage.CACHE);
|
|
persistenceForNimbleComponent.setValue("enabled", Boolean.valueOf(this.m_enabled));
|
|
persistenceForNimbleComponent.lambda$new$0();
|
|
cancelAllNotifications();
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.INimbleLocalNotifications
|
|
public void setCustomizer(INimbleLocalNotificationCustomizer iNimbleLocalNotificationCustomizer) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
m_notificationCustomizer = iNimbleLocalNotificationCustomizer;
|
|
}
|
|
|
|
@Override // com.ea.nimble.INimbleLocalNotifications
|
|
public void setBadgeProvider(INimbleBadgeProvider iNimbleBadgeProvider) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
m_badgeProvider = iNimbleBadgeProvider;
|
|
}
|
|
|
|
@Override // com.ea.nimble.INimbleLocalNotifications
|
|
public Error setBadgeCount(int i, String str, String str2) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
if (!this.m_enabled) {
|
|
Log.Helper.LOGE(this, "setBadgeCount(): Local notifications are disabled, unable to set badge count", new Object[0]);
|
|
return new Error(Error.Code.NOT_AVAILABLE, "setBadgeCount(): Local notifications are disabled, unable to set badge count");
|
|
}
|
|
INimbleBadgeProvider iNimbleBadgeProvider = m_badgeProvider;
|
|
if (iNimbleBadgeProvider != null) {
|
|
return iNimbleBadgeProvider.setBadgeCount(i, str, str2);
|
|
}
|
|
Context applicationContext = ApplicationEnvironment.getComponent().getApplicationContext();
|
|
NotificationManager notificationManager = (NotificationManager) applicationContext.getSystemService("notification");
|
|
Resources resources = ApplicationEnvironment.getComponent().getApplicationContext().getResources();
|
|
String packageName = ApplicationEnvironment.getComponent().getApplicationContext().getPackageName();
|
|
if (i == 0) {
|
|
notificationManager.cancel(-1544873096);
|
|
return null;
|
|
}
|
|
if (i < 0 || i > 999999) {
|
|
String str3 = "setBadgeCount(): Badge count " + i + "outside [0-999999] range";
|
|
Log.Helper.LOGE(this, str3, new Object[0]);
|
|
return new Error(Error.Code.INVALID_ARGUMENT, str3);
|
|
}
|
|
if (!Utility.validString(str)) {
|
|
Log.Helper.LOGE(this, "setBadgeCount(): Invalid title", new Object[0]);
|
|
return new Error(Error.Code.INVALID_ARGUMENT, "Invalid title");
|
|
}
|
|
if (!Utility.validString(str2)) {
|
|
Log.Helper.LOGE(this, "setBadgeCount(): Invalid message", new Object[0]);
|
|
return new Error(Error.Code.INVALID_ARGUMENT, "Invalid message");
|
|
}
|
|
Notification.Builder visibility = new Notification.Builder(applicationContext, NimbleApplicationConfiguration.configValueExists(Global.NOTIFICATION_CHANNEL_LOCAL_NOTIFICATION_ID_KEY) ? NimbleApplicationConfiguration.getConfigValueAsString(Global.NOTIFICATION_CHANNEL_LOCAL_NOTIFICATION_ID_KEY) : Global.NOTIFICATION_CHANNEL_DEFAULT_ID).setContentTitle(str).setContentText(str2).setAutoCancel(true).setNumber(i).setVisibility(-1);
|
|
try {
|
|
visibility.setSmallIcon(resources.getIdentifier("pn_icon", "drawable", packageName));
|
|
Notification build = visibility.build();
|
|
Context applicationContext2 = applicationContext.getApplicationContext();
|
|
String className = applicationContext2.getPackageManager().getLaunchIntentForPackage(applicationContext2.getPackageName()).resolveActivity(applicationContext2.getPackageManager()).getClassName();
|
|
try {
|
|
Intent intent = new Intent(applicationContext, Class.forName(className));
|
|
intent.putExtra(FCMMessageService.PushIntentExtraKeys.PUSH_ID, BADGE_ID);
|
|
intent.putExtra(FCMMessageService.PushIntentExtraKeys.PN_TYPE, "local");
|
|
intent.setFlags(603979776);
|
|
PendingIntent activity = PendingIntent.getActivity(applicationContext, 0, intent, 1140850688);
|
|
if (build == null) {
|
|
Log.Helper.LOGE(this, "setBadgeCount(): Unable to create Local Notification", new Object[0]);
|
|
return new Error(Error.Code.NOT_AVAILABLE, "setBadgeCount(): Unable to create Local Notification");
|
|
}
|
|
if (activity != null) {
|
|
build.contentIntent = activity;
|
|
notificationManager.notify(-1544873096, build);
|
|
return null;
|
|
}
|
|
Log.Helper.LOGE(this, "setBadgeCount(): Unable to create PendingIntent", new Object[0]);
|
|
return new Error(Error.Code.NOT_AVAILABLE, "setBadgeCount(): Unable to create PendingIntent");
|
|
} catch (ClassNotFoundException e) {
|
|
String format = String.format("setBadgeCount(): Could not launch target activity: %s, exception: %s", className, e);
|
|
Log.Helper.LOGE(this, format, new Object[0]);
|
|
return new Error(Error.Code.SYSTEM_UNEXPECTED, format);
|
|
}
|
|
} catch (Exception e2) {
|
|
Log.Helper.LOGE(this, "setBadgeCount(): Unable to set application icon due to exception: " + e2, new Object[0]);
|
|
return new Error(Error.Code.SYSTEM_UNEXPECTED, "Unable to get pn_icon");
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.INimbleLocalNotifications
|
|
public int getBadgeCount() {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
INimbleBadgeProvider iNimbleBadgeProvider = m_badgeProvider;
|
|
if (iNimbleBadgeProvider != null) {
|
|
return iNimbleBadgeProvider.getBadgeCount();
|
|
}
|
|
for (StatusBarNotification statusBarNotification : ((NotificationManager) ApplicationEnvironment.getComponent().getApplicationContext().getSystemService("notification")).getActiveNotifications()) {
|
|
if (statusBarNotification.getId() == -1544873096) {
|
|
return statusBarNotification.getNotification().number;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
private void saveNotificationMap() {
|
|
Persistence persistenceForNimbleComponent = PersistenceService.getPersistenceForNimbleComponent(getComponentId(), Persistence.Storage.CACHE);
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_NOTIFICATION_MAP_KEY, this.m_notificationMap);
|
|
persistenceForNimbleComponent.lambda$new$0();
|
|
}
|
|
}
|