Files
rr3-apk/decompiled-community/sources/com/ea/nimble/pushtng/PushNotificationImpl.java
Daniel Elliott c080f0d97f Add Discord community version (64-bit only)
- 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
2026-02-18 15:48:36 -08:00

402 lines
20 KiB
Java

package com.ea.nimble.pushtng;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.core.app.NotificationCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.ea.eadp.pushnotification.listeners.IPushListener;
import com.ea.eadp.pushnotification.models.PushNotificationConfig;
import com.ea.eadp.pushnotification.services.AndroidPushService;
import com.ea.eadp.pushnotification.services.IPushService;
import com.ea.nimble.ApplicationEnvironment;
import com.ea.nimble.ApplicationLifecycle;
import com.ea.nimble.Base;
import com.ea.nimble.Component;
import com.ea.nimble.Global;
import com.ea.nimble.IApplicationLifecycle;
import com.ea.nimble.ISynergyEnvironment;
import com.ea.nimble.Log;
import com.ea.nimble.LogSource;
import com.ea.nimble.NimbleApplicationConfiguration;
import com.ea.nimble.Persistence;
import com.ea.nimble.PersistenceService;
import com.ea.nimble.SynergyEnvironment;
import com.ea.nimble.Utility;
import com.ea.nimble.tracking.ITracking;
import com.ea.nimble.tracking.Tracking;
import com.google.firebase.FirebaseApp;
import com.google.gson.Gson;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.TimeZone;
/* loaded from: classes2.dex */
public class PushNotificationImpl extends Component implements IPushNotification, LogSource, IApplicationLifecycle.ActivityLifecycleCallbacks {
private static final String NOTIFICATION_TRACKING2_LOG_EVENT = "nimble.notification.tracking2.logEvent";
private static final String PERSISTENCE_DISABLED_KEY = "disabled";
private String disableCheck;
private Boolean disabled;
private long dobFromAgeCompliance = -2147483648L;
private BroadcastReceiver m_ageListener;
private IPushService pushService;
private boolean statusCheck;
@Override // com.ea.nimble.Component
public String getComponentId() {
return PushNotification.COMPONENT_ID;
}
@Override // com.ea.nimble.LogSource
public String getLogSourceTitle() {
return "PushTNG";
}
@Override // com.ea.nimble.IApplicationLifecycle.ActivityLifecycleCallbacks
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override // com.ea.nimble.IApplicationLifecycle.ActivityLifecycleCallbacks
public void onActivityDestroyed(Activity activity) {
}
@Override // com.ea.nimble.IApplicationLifecycle.ActivityLifecycleCallbacks
public void onActivityPaused(Activity activity) {
}
@Override // com.ea.nimble.IApplicationLifecycle.ActivityLifecycleCallbacks
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override // com.ea.nimble.IApplicationLifecycle.ActivityLifecycleCallbacks
public void onActivityStarted(Activity activity) {
}
@Override // com.ea.nimble.IApplicationLifecycle.ActivityLifecycleCallbacks
public void onActivityStopped(Activity activity) {
}
@Override // com.ea.nimble.Component
public void setup() {
Log.Helper.LOGPUBLICFUNC(this);
if (FirebaseApp.initializeApp(ApplicationEnvironment.getCurrentActivity().getApplicationContext()) == null) {
Log.Helper.LOGE(this, "PushTNG failed to initialize FireBaseApp. Probably configuration is missing.", new Object[0]);
} else {
Log.Helper.LOGV(this, "PushTNG initialized FireBase app.", new Object[0]);
}
if (this.m_ageListener == null) {
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { // from class: com.ea.nimble.pushtng.PushNotificationImpl.1
@Override // android.content.BroadcastReceiver
public void onReceive(Context context, Intent intent) {
if (intent != null) {
Bundle extras = intent.getExtras();
PushNotificationImpl.this.dobFromAgeCompliance = extras.getLong("dob", -2147483648L);
if (PushNotificationImpl.this.dobFromAgeCompliance != -2147483648L) {
Log.Helper.LOGV(this, "PushTNG received AgeCompliance birthday update", new Object[0]);
}
}
}
};
this.m_ageListener = broadcastReceiver;
Utility.registerReceiver(Global.NIMBLE_NOTIFICATION_AGE_COMPLIANCE_DOB_UPDATE, broadcastReceiver);
}
}
@Override // com.ea.nimble.Component
public void restore() {
Log.Helper.LOGPUBLICFUNC(this);
sendPendingTrackingRequests();
Persistence persistenceForNimbleComponent = PersistenceService.getPersistenceForNimbleComponent(getComponentId(), Persistence.Storage.CACHE);
if (persistenceForNimbleComponent != null) {
this.disabled = (Boolean) persistenceForNimbleComponent.getValue("disabled");
}
ISynergyEnvironment component = SynergyEnvironment.getComponent();
if (component.getProductId() != null && component.getSellId() != null && component.getServerUrlWithKey(SynergyEnvironment.SERVER_URL_KEY_ENS) != null) {
onComponentSetupCompleted();
} else {
Utility.registerReceiver(SynergyEnvironment.NOTIFICATION_STARTUP_REQUESTS_FINISHED, new BroadcastReceiver() { // from class: com.ea.nimble.pushtng.PushNotificationImpl.2
@Override // android.content.BroadcastReceiver
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras == null || !extras.getString("result").equals("1")) {
return;
}
PushNotificationImpl.this.onComponentSetupCompleted();
}
});
}
ApplicationLifecycle.getComponent().registerActivityLifecycleCallbacks(this);
}
@Override // com.ea.nimble.Component
public void cleanup() {
Log.Helper.LOGFUNC(this);
Utility.unregisterReceiver(this.m_ageListener);
this.m_ageListener = null;
ApplicationLifecycle.getComponent().unregisterActivityLifecycleCallbacks(this);
}
@Override // com.ea.nimble.IApplicationLifecycle.ActivityLifecycleCallbacks
public void onActivityResumed(Activity activity) {
sendPendingTrackingRequests();
}
/* JADX INFO: Access modifiers changed from: private */
@TargetApi(26)
public void onComponentSetupCompleted() {
String str;
Log.Helper.LOGFUNC(this);
ISynergyEnvironment component = SynergyEnvironment.getComponent();
if (component == null) {
Log.Helper.LOGE(this, "Synergy environment is null! Unable to complete component setup for PushTNG.", new Object[0]);
return;
}
String serverUrlWithKey = component.getServerUrlWithKey(SynergyEnvironment.SERVER_URL_KEY_ENS);
String productId = component.getProductId();
String sellId = component.getSellId();
if (serverUrlWithKey == null || productId == null || sellId == null) {
Log.Helper.LOGW(this, "Synergy environment startup requests finished, but data is not available", new Object[0]);
return;
}
Context applicationContext = ApplicationEnvironment.getComponent().getApplicationContext();
NimbleAndroidHttpService nimbleAndroidHttpService = new NimbleAndroidHttpService();
NimbleDeviceIdService nimbleDeviceIdService = new NimbleDeviceIdService();
NotificationManager notificationManager = (NotificationManager) applicationContext.getSystemService("notification");
if (!NimbleApplicationConfiguration.configValueExists(Global.NOTIFICATION_CHANNEL_PUSHTNG_ID_KEY)) {
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);
}
int configValueAsInt = NimbleApplicationConfiguration.getConfigValueAsInt("com.ea.nimble.pushtng.auth.api.key");
int configValueAsInt2 = NimbleApplicationConfiguration.getConfigValueAsInt("com.ea.nimble.pushtng.auth.api.secret");
if (configValueAsInt != 0 && configValueAsInt2 != 0) {
this.pushService = new AndroidPushService(nimbleAndroidHttpService, nimbleDeviceIdService, applicationContext, null, serverUrlWithKey, productId, sellId, applicationContext.getResources().getString(configValueAsInt), applicationContext.getResources().getString(configValueAsInt2), 0);
Utility.sendBroadcast(PushNotification.NOTIFICATION_PUSHTNG_COMPONENT_SETUP_COMPLETE);
this.pushService.sendPendingTrackingRequests();
return;
}
Log.Helper.LOGW(this, "Configuration data not loaded. Push component not initialized.", new Object[0]);
}
@Override // com.ea.nimble.pushtng.IPushNotification
public void startWithDefaults(String str, Date date, IPushListener iPushListener) {
Log.Helper.LOGPUBLICFUNC(this);
if (this.pushService == null) {
Log.Helper.LOGW(this, "Nimble Component has not yet been initialized.", new Object[0]);
if (iPushListener != null) {
iPushListener.onConnectionError(0, "Nimble Component has not yet been initialized.");
return;
}
return;
}
PushNotificationConfig pushNotificationConfig = new PushNotificationConfig();
pushNotificationConfig.setUserAlias(str);
pushNotificationConfig.setDateOfBirth(new SimpleDateFormat("yyyy-MM").format(getValidDOB(date)));
startWithConfig(pushNotificationConfig, iPushListener);
}
@Override // com.ea.nimble.pushtng.IPushNotification
public void startAsDisabled(String str, Date date, String str2, IPushListener iPushListener) {
Log.Helper.LOGPUBLICFUNC(this);
if (this.pushService == null) {
if (iPushListener != null) {
iPushListener.onConnectionError(0, "Nimble Component has not yet been initialized.");
}
} else {
PushNotificationConfig pushNotificationConfig = new PushNotificationConfig();
pushNotificationConfig.setUserAlias(str);
pushNotificationConfig.setDateOfBirth(new SimpleDateFormat("yyyy-MM").format(getValidDOB(date)));
pushNotificationConfig.setDisabled(true);
pushNotificationConfig.setDisabledReason(str2);
startWithConfig(pushNotificationConfig, iPushListener);
}
}
private void startWithConfig(final PushNotificationConfig pushNotificationConfig, final IPushListener iPushListener) {
Log.Helper.LOGFUNC(this);
final Context applicationContext = ApplicationEnvironment.getComponent().getApplicationContext();
this.pushService.setPushListener(new IPushListener() { // from class: com.ea.nimble.pushtng.PushNotificationImpl.3
@Override // com.ea.eadp.pushnotification.listeners.IPushListener
public void onTrackingSuccess(int i, String str) {
IPushListener iPushListener2 = iPushListener;
if (iPushListener2 != null) {
iPushListener2.onTrackingSuccess(i, str);
}
}
@Override // com.ea.eadp.pushnotification.listeners.IPushListener
public void onRegistrationSuccess(int i, String str) {
boolean z = false;
Log.Helper.LOGD(this, "onRegistrationSuccess: " + str, new Object[0]);
HashMap hashMap = new HashMap();
hashMap.put(Tracking.KEY_PN_DATE_OF_BIRTH, pushNotificationConfig.getDateOfBirth());
hashMap.put(Tracking.KEY_PN_DISABLED_FLAG, pushNotificationConfig.isDisabled() ? "true" : "false");
hashMap.put(PushNotification.KEY_TRACKING_TYPE, Tracking.EVENT_PN_DEVICE_REGISTERED);
PushNotificationImpl.this.disableCheck = pushNotificationConfig.isDisabled() ? pushNotificationConfig.getDisabledReason() : null;
PushNotificationImpl pushNotificationImpl = PushNotificationImpl.this;
if (i >= 200 && i < 300) {
z = true;
}
pushNotificationImpl.statusCheck = z;
PushNotificationImpl.persistTrackingData(applicationContext, hashMap, str);
if (ApplicationEnvironment.isMainApplicationRunning()) {
PushNotificationImpl.this.sendPendingTrackingRequests();
}
IPushListener iPushListener2 = iPushListener;
if (iPushListener2 != null) {
iPushListener2.onRegistrationSuccess(i, str);
}
}
@Override // com.ea.eadp.pushnotification.listeners.IPushListener
public void onGetInAppSuccess(int i, String str) {
IPushListener iPushListener2 = iPushListener;
if (iPushListener2 != null) {
iPushListener2.onGetInAppSuccess(i, str);
}
}
@Override // com.ea.eadp.pushnotification.listeners.IPushListener
public void onConnectionError(int i, String str) {
Log.Helper.LOGW(this, "onConnectionError: " + str, new Object[0]);
IPushListener iPushListener2 = iPushListener;
if (iPushListener2 != null) {
iPushListener2.onConnectionError(i, str);
}
PushNotificationImpl.this.statusCheck = false;
}
});
this.pushService.startWithConfig(pushNotificationConfig, null);
boolean isDisabled = pushNotificationConfig.isDisabled();
if ((!isDisabled || pushNotificationConfig.getDisabledReason().equals(PushNotification.DISABLED_REASON_OPT_OUT)) && !Boolean.valueOf(isDisabled).equals(this.disabled)) {
this.disabled = Boolean.valueOf(isDisabled);
HashMap hashMap = new HashMap();
hashMap.put("en", "settings");
Bundle bundle = new Bundle();
bundle.putSerializable("core", hashMap);
bundle.putString("type", "opt_in_pn");
bundle.putString("status", isDisabled ? "declined" : "accepted");
Intent intent = new Intent();
intent.setAction(NOTIFICATION_TRACKING2_LOG_EVENT);
intent.putExtras(bundle);
LocalBroadcastManager.getInstance(ApplicationEnvironment.getComponent().getApplicationContext()).sendBroadcast(intent);
Persistence persistenceForNimbleComponent = PersistenceService.getPersistenceForNimbleComponent(getComponentId(), Persistence.Storage.CACHE);
if (persistenceForNimbleComponent != null) {
persistenceForNimbleComponent.setValue("disabled", this.disabled);
}
}
}
@Override // com.ea.nimble.pushtng.IPushNotification
public void updateToken(String str) {
Log.Helper.LOGPUBLICFUNC(this);
IPushService iPushService = this.pushService;
if (iPushService != null) {
iPushService.updateToken(str);
}
}
@Override // com.ea.nimble.pushtng.IPushNotification
public boolean getRegistrationStatus() {
Log.Helper.LOGPUBLICFUNC(this);
return this.statusCheck;
}
@Override // com.ea.nimble.pushtng.IPushNotification
public String getDisableStatus() {
Log.Helper.LOGPUBLICFUNC(this);
return this.disableCheck;
}
@Override // com.ea.nimble.pushtng.IPushNotification
public void sendPendingTrackingRequests() {
Map map;
Log.Helper.LOGPUBLICFUNC(this);
SharedPreferences sharedPreferences = ApplicationEnvironment.getComponent().getApplicationContext().getSharedPreferences("PushTNGTracking", 0);
Gson gson = new Gson();
ArrayList<Map> arrayList = new ArrayList();
Iterator<String> it = sharedPreferences.getAll().keySet().iterator();
while (it.hasNext()) {
String string = sharedPreferences.getString(it.next(), null);
if (string != null && (map = (Map) gson.fromJson(string, HashMap.class)) != null && !map.isEmpty()) {
arrayList.add(map);
}
}
Object component = Base.getComponent(Tracking.COMPONENT_ID);
if (component != null) {
ITracking iTracking = (ITracking) component;
Iterator it2 = arrayList.iterator();
while (it2.hasNext()) {
HashMap hashMap = new HashMap((Map) it2.next());
String remove = hashMap.remove(PushNotification.KEY_TRACKING_TYPE);
hashMap.put(Tracking.KEY_PN_DEVICE_ID, SynergyEnvironment.getComponent().getEADeviceId());
iTracking.logEvent(remove, hashMap);
}
}
for (Map map2 : arrayList) {
String str = (String) map2.get(PushNotification.KEY_TRACKING_TYPE);
if (str.equals(Tracking.EVENT_PN_RECEIVED) || str.equals(Tracking.EVENT_PN_SHOWN_TO_USER)) {
String str2 = str.equals(Tracking.EVENT_PN_RECEIVED) ? "received" : "impression";
HashMap hashMap2 = new HashMap();
hashMap2.put("en", "message");
Bundle bundle = new Bundle();
bundle.putSerializable("core", hashMap2);
bundle.putString("type", "pn");
bundle.putString(NotificationCompat.CATEGORY_SERVICE, "aruba");
bundle.putString("status", str2);
bundle.putString("format", "pn");
bundle.putString("msg_id", (String) map2.get("NIMBLESTANDARD::KEY_PN_MESSAGE_ID"));
bundle.putString("media", (String) map2.get(Tracking.KEY_PN_MESSAGE_TYPE));
Intent intent = new Intent();
intent.setAction(NOTIFICATION_TRACKING2_LOG_EVENT);
intent.putExtras(bundle);
LocalBroadcastManager.getInstance(ApplicationEnvironment.getComponent().getApplicationContext()).sendBroadcast(intent);
}
}
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.clear();
edit.apply();
}
public static void persistTrackingData(Context context, Map<String, String> map, String str) {
Log.Helper.LOGPUBLICFUNCS("PushNotificationImpl");
SharedPreferences.Editor edit = context.getApplicationContext().getSharedPreferences("PushTNGTracking", 0).edit();
edit.putString(str, new Gson().toJson(map));
edit.apply();
}
private Date getValidDOB(Date date) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
if (date != null && date.getTime() != 0) {
Log.Helper.LOGV(this, "getValidDOB(): Using valid DOB from PushTNG: " + simpleDateFormat.format(date), new Object[0]);
return date;
}
if (this.dobFromAgeCompliance != -2147483648L) {
Date date2 = new Date(this.dobFromAgeCompliance * 1000);
Log.Helper.LOGV(this, "getValidDOB(): Got DOB from AgeCompliance: " + simpleDateFormat.format(date2), new Object[0]);
return date2;
}
Date date3 = new Date(0L);
Log.Helper.LOGV(this, "getValidDOB(): Default DOB to 1/1/1970: " + simpleDateFormat.format(date3), new Object[0]);
return date3;
}
}