Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
package com.ea.eadp.pushnotification.forwarding;
import android.content.ComponentName;
import android.content.Intent;
import com.ea.nimble.ApplicationEnvironment;
import com.ea.nimble.pushtng.PushNotification;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
/* loaded from: classes2.dex */
public class FCMMessageReceiver extends FirebaseMessagingService {
@Override // com.google.firebase.messaging.FirebaseMessagingService
public final void onMessageReceived(RemoteMessage remoteMessage) {
ComponentName componentName = new ComponentName(getApplicationContext().getPackageName(), getIntentServiceName());
Intent intent = remoteMessage.toIntent();
intent.setComponent(componentName);
FCMMessageService.enqueueWork(getApplicationContext(), getIntentServiceName(), intent);
}
@Override // com.google.firebase.messaging.FirebaseMessagingService
public final void onNewToken(String str) {
if (ApplicationEnvironment.isMainApplicationActive()) {
PushNotification.getComponent().updateToken(str);
}
}
public String getIntentServiceName() {
return FCMMessageService.class.getName();
}
}

View File

@@ -0,0 +1,5 @@
package com.ea.eadp.pushnotification.forwarding;
/* loaded from: classes2.dex */
public abstract /* synthetic */ class FCMMessageService$$ExternalSyntheticApiModelOutline0 {
}

View File

@@ -0,0 +1,5 @@
package com.ea.eadp.pushnotification.forwarding;
/* loaded from: classes2.dex */
public abstract /* synthetic */ class FCMMessageService$$ExternalSyntheticApiModelOutline1 {
}

View File

@@ -0,0 +1,248 @@
package com.ea.eadp.pushnotification.forwarding;
import android.annotation.SuppressLint;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import androidx.core.app.NotificationCompat;
import com.ea.eadp.http.services.HttpService;
import com.ea.eadp.pushnotification.lifecycles.PushLifecycleCallbacks;
import com.ea.eadp.pushnotification.services.IPushService;
import com.ea.nimble.Global;
import com.ea.nimble.Log;
import com.ea.nimble.Utility;
import com.facebook.internal.NativeProtocol;
import java.util.List;
/* loaded from: classes2.dex */
public class FCMMessageService extends JobIntentService {
protected static final int JOB_ID = 5566;
private static final String LOG_TAG = "FCMMessageService";
private IPushService pushManager;
public interface EnsEventFlags {
public static final int ALL_DISABLED = 0;
public static final int ALL_ENABLED = 3;
public static final int CLICK_ENABLED = 1;
public static final int RECEIVED_ENABLED = 2;
}
public interface PushIntentExtraKeys {
public static final String ALERT = "alert";
public static final String COLLAPSE_KEY = "collapse_key";
public static final String DEEP_LINK_URL = "deepLinkUrl";
public static final String ENS_EVENTS = "ensEvents";
public static final String PN_TYPE = "pnType";
public static final String PUSH_ID = "pushId";
}
public boolean displayNotification(Bundle bundle) {
return true;
}
public HttpService getHttpService() {
return null;
}
public static void enqueueWork(Context context, String str, Intent intent) {
try {
JobIntentService.enqueueWork(context, Class.forName(str), JOB_ID, intent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
@Override // androidx.core.app.JobIntentService
public void onHandleWork(@NonNull Intent intent) {
if (intent.getExtras() == null) {
Log.Helper.LOGE(this, "Skipping Push Notification: Incomplete Intent. Missing expected extras bundle.", new Object[0]);
} else {
onHandleMessage(intent);
}
}
/* JADX WARN: Removed duplicated region for block: B:14:0x0051 */
/* JADX WARN: Removed duplicated region for block: B:27:? A[RETURN, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public void onHandleMessage(android.content.Intent r5) {
/*
r4 = this;
android.os.Bundle r5 = r5.getExtras()
r0 = 0
if (r5 != 0) goto Lf
java.lang.String r5 = "Skipping Push Notification: Incomplete Intent. Missing expected extras bundle."
java.lang.Object[] r0 = new java.lang.Object[r0]
com.ea.nimble.Log.Helper.LOGE(r4, r5, r0)
return
Lf:
java.lang.StringBuilder r1 = new java.lang.StringBuilder
r1.<init>()
java.lang.String r2 = "Message received: "
r1.append(r2)
r1.append(r5)
java.lang.String r1 = r1.toString()
java.lang.Object[] r2 = new java.lang.Object[r0]
java.lang.String r3 = "FCMMessageService"
com.ea.nimble.Log.Helper.LOGIS(r3, r1, r2)
boolean r1 = r4.displayNotification(r5)
if (r1 == 0) goto L34
android.content.Context r1 = r4.getApplicationContext()
r4.postNotification(r1, r5)
L34:
java.lang.String r1 = "ensEvents"
java.lang.String r1 = r5.getString(r1)
if (r1 == 0) goto L48
int r0 = java.lang.Integer.parseInt(r1) // Catch: java.lang.NumberFormatException -> L41
goto L49
L41:
java.lang.String r1 = "ensEvents flag found but not parseable as integer"
java.lang.Object[] r0 = new java.lang.Object[r0]
com.ea.nimble.Log.Helper.LOGWS(r3, r1, r0)
L48:
r0 = 3
L49:
java.lang.String r1 = "pushId"
boolean r2 = r5.containsKey(r1)
if (r2 == 0) goto L8e
r2 = 2
if (r0 >= r2) goto L56
if (r0 >= 0) goto L8e
L56:
com.ea.eadp.pushnotification.services.IPushService r0 = r4.pushManager
if (r0 != 0) goto L69
com.ea.eadp.pushnotification.services.AndroidPushService r0 = new com.ea.eadp.pushnotification.services.AndroidPushService
android.content.Context r2 = r4.getApplicationContext()
com.ea.eadp.http.services.HttpService r3 = r4.getHttpService()
r0.<init>(r2, r3)
r4.pushManager = r0
L69:
boolean r0 = com.ea.nimble.ApplicationEnvironment.isMainApplicationRunning()
java.lang.String r2 = "NOTIFICATION_RECEIVED"
java.lang.String r3 = "pnType"
if (r0 == 0) goto L81
com.ea.eadp.pushnotification.services.IPushService r0 = r4.pushManager
java.lang.String r1 = r5.getString(r1)
java.lang.String r5 = r5.getString(r3)
r0.sendTrackingEvent(r1, r5, r2)
goto L8e
L81:
com.ea.eadp.pushnotification.services.IPushService r0 = r4.pushManager
java.lang.String r1 = r5.getString(r1)
java.lang.String r5 = r5.getString(r3)
r0.persistTrackingEvent(r1, r5, r2)
L8e:
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.ea.eadp.pushnotification.forwarding.FCMMessageService.onHandleMessage(android.content.Intent):void");
}
@SuppressLint({"InlinedApi"})
private void postNotification(Context context, Bundle bundle) {
Intent intent = new Intent();
intent.addFlags(32);
intent.putExtras(bundle);
intent.setPackage(context.getPackageName());
ComponentName broadcastForwarderComponent = getBroadcastForwarderComponent();
if (isInForeground()) {
if (broadcastForwarderComponent != null) {
intent.setComponent(broadcastForwarderComponent);
sendBroadcast(intent);
return;
} else {
Log.Helper.LOGW(this, "Broadcast listener for action 'com.ea.eadp.pushnotification.FORWARD_AS_ORDERED_BROADCAST' was not found. Not sending broadcast", new Object[0]);
return;
}
}
String string = bundle.getString(PushIntentExtraKeys.PUSH_ID);
int hashCode = string != null ? string.hashCode() : 0;
ApplicationInfo applicationInfo = Utility.getApplicationInfo(128);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, (applicationInfo == null || !applicationInfo.metaData.containsKey(Global.NOTIFICATION_CHANNEL_PUSHTNG_ID_KEY)) ? Global.NOTIFICATION_CHANNEL_DEFAULT_ID : applicationInfo.metaData.getString(Global.NOTIFICATION_CHANNEL_PUSHTNG_ID_KEY));
if (broadcastForwarderComponent != null) {
String string2 = bundle.getString(PushIntentExtraKeys.COLLAPSE_KEY);
if (string2 != null && !string2.equalsIgnoreCase("do_not_collapse")) {
intent.putExtra(PushIntentExtraKeys.COLLAPSE_KEY, string2);
}
intent.setComponent(broadcastForwarderComponent);
customizeNotification(builder, bundle);
intent.putExtra("notification", builder.build());
PendingIntent broadcast = PendingIntent.getBroadcast(context, hashCode, intent, 201326592);
if (broadcast != null) {
builder.setContentIntent(broadcast);
try {
broadcast.send();
return;
} catch (PendingIntent.CanceledException e) {
Log.Helper.LOGE(LOG_TAG, "[CanceledException] Could not launch PendingIntent for PN " + e, new Object[0]);
return;
}
}
Log.Helper.LOGE(LOG_TAG, "Unable to query PendingIntent", new Object[0]);
return;
}
Log.Helper.LOGW(this, "Broadcast listener for action 'com.ea.eadp.pushnotification.FORWARD_AS_ORDERED_BROADCAST' was not found. Not setting ContentIntent", new Object[0]);
customizeNotification(builder, bundle);
NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
if (notificationManager != null) {
String string3 = bundle.getString(PushIntentExtraKeys.COLLAPSE_KEY);
if (string3 != null && !string3.equalsIgnoreCase("do_not_collapse")) {
notificationManager.notify(string3, 0, builder.build());
return;
} else {
notificationManager.notify(hashCode, builder.build());
return;
}
}
Log.Helper.LOGE(this, "Notification Manager is not available or is inaccessible. Skipping Notification formatting.", new Object[0]);
}
public boolean isInForeground() {
return PushLifecycleCallbacks.inForeground;
}
public void customizeNotification(NotificationCompat.Builder builder, Bundle bundle) {
String string = bundle.getString(PushIntentExtraKeys.ALERT);
Resources resources = getApplicationContext().getResources();
String packageName = getApplicationContext().getPackageName();
String string2 = getApplicationContext().getResources().getString(resources.getIdentifier(NativeProtocol.BRIDGE_ARG_APP_NAME_STRING, "string", packageName));
try {
builder.setSmallIcon(resources.getIdentifier("pn_icon", "drawable", packageName));
} catch (Exception e) {
Log.Helper.LOGE(LOG_TAG, "PN NOT DISPLAYED: Unable to set application icon due to exception: " + e, new Object[0]);
}
builder.setContentTitle(string2).setStyle(new NotificationCompat.BigTextStyle().bigText(string)).setContentText(string).setAutoCancel(true).setDefaults(getApplicationContext().checkCallingOrSelfPermission("android.permission.VIBRATE") == 0 ? 7 : 5);
}
public ComponentName getBroadcastForwarderComponent() {
List<ResolveInfo> queryBroadcastReceivers;
PackageManager.ResolveInfoFlags of;
Log.Helper.LOGFUNC(this);
PackageManager packageManager = getApplicationContext().getPackageManager();
Intent intent = new Intent("com.ea.eadp.pushnotification.FORWARD_AS_ORDERED_BROADCAST");
intent.setPackage(getApplicationContext().getPackageName());
if (Build.VERSION.SDK_INT >= 33) {
of = PackageManager.ResolveInfoFlags.of(0L);
queryBroadcastReceivers = packageManager.queryBroadcastReceivers(intent, of);
} else {
queryBroadcastReceivers = packageManager.queryBroadcastReceivers(intent, 0);
}
if (queryBroadcastReceivers.isEmpty()) {
return null;
}
ActivityInfo activityInfo = queryBroadcastReceivers.get(0).activityInfo;
return new ComponentName(activityInfo.packageName, activityInfo.name);
}
}

View File

@@ -0,0 +1,5 @@
package com.ea.eadp.pushnotification.forwarding;
/* loaded from: classes2.dex */
public abstract /* synthetic */ class PushBroadcastForwarder$$ExternalSyntheticApiModelOutline0 {
}

View File

@@ -0,0 +1,161 @@
package com.ea.eadp.pushnotification.forwarding;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import com.ea.eadp.http.services.HttpService;
import com.ea.eadp.pushnotification.forwarding.FCMMessageService;
import com.ea.eadp.pushnotification.services.IPushService;
import com.ea.nimble.Log;
/* loaded from: classes2.dex */
public class PushBroadcastForwarder extends BroadcastReceiver {
private static final String LOG_TAG = "PushBroadcastForwarder";
private IPushService pushManager;
public HttpService getHttpService() {
return null;
}
/* JADX WARN: Removed duplicated region for block: B:17:0x003a */
/* JADX WARN: Removed duplicated region for block: B:20:0x0053 */
/* JADX WARN: Removed duplicated region for block: B:21:0x0061 */
@Override // android.content.BroadcastReceiver
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public final void onReceive(android.content.Context r5, android.content.Intent r6) {
/*
r4 = this;
android.os.Bundle r6 = r6.getExtras()
r0 = 0
if (r6 != 0) goto Lf
java.lang.String r5 = "Unable to get extras from Intent"
java.lang.Object[] r6 = new java.lang.Object[r0]
com.ea.nimble.Log.Helper.LOGE(r4, r5, r6)
return
Lf:
java.lang.String r1 = "ensEvents"
java.lang.String r1 = r6.getString(r1)
r2 = 3
if (r1 == 0) goto L26
int r0 = java.lang.Integer.parseInt(r1) // Catch: java.lang.NumberFormatException -> L1d
goto L27
L1d:
java.lang.String r1 = "ensEvents flag found but not parseable as integer"
java.lang.Object[] r0 = new java.lang.Object[r0]
java.lang.String r3 = "PushBroadcastForwarder"
com.ea.nimble.Log.Helper.LOGWS(r3, r1, r0)
L26:
r0 = r2
L27:
java.lang.String r1 = "pushId"
boolean r3 = r6.containsKey(r1)
if (r3 == 0) goto L6e
if (r0 >= r2) goto L36
r2 = 1
if (r0 == r2) goto L36
if (r0 >= 0) goto L6e
L36:
com.ea.eadp.pushnotification.services.IPushService r0 = r4.pushManager
if (r0 != 0) goto L49
com.ea.eadp.pushnotification.services.AndroidPushService r0 = new com.ea.eadp.pushnotification.services.AndroidPushService
android.content.Context r2 = r5.getApplicationContext()
com.ea.eadp.http.services.HttpService r3 = r4.getHttpService()
r0.<init>(r2, r3)
r4.pushManager = r0
L49:
boolean r0 = com.ea.nimble.ApplicationEnvironment.isMainApplicationRunning()
java.lang.String r2 = "NOTIFICATION_OPENED"
java.lang.String r3 = "pnType"
if (r0 == 0) goto L61
com.ea.eadp.pushnotification.services.IPushService r0 = r4.pushManager
java.lang.String r1 = r6.getString(r1)
java.lang.String r3 = r6.getString(r3)
r0.sendTrackingEvent(r1, r3, r2)
goto L6e
L61:
com.ea.eadp.pushnotification.services.IPushService r0 = r4.pushManager
java.lang.String r1 = r6.getString(r1)
java.lang.String r3 = r6.getString(r3)
r0.persistTrackingEvent(r1, r3, r2)
L6e:
r4.handleNewPushNotification(r5, r6)
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.ea.eadp.pushnotification.forwarding.PushBroadcastForwarder.onReceive(android.content.Context, android.content.Intent):void");
}
public void handleNewPushNotification(Context context, Bundle bundle) {
Intent intent;
Notification notification;
Object parcelable;
String string = bundle.getString("deepLinkUrl");
if (string != null) {
intent = new Intent("android.intent.action.VIEW", Uri.parse(string));
Log.Helper.LOGIS(LOG_TAG, "Push notification clicked with URL: " + string, new Object[0]);
} else {
String pushTargetActivity = getPushTargetActivity(context);
Log.Helper.LOGIS(LOG_TAG, "Push notification clicked with target activity: " + pushTargetActivity, new Object[0]);
try {
intent = new Intent(context, Class.forName(pushTargetActivity));
} catch (ClassNotFoundException e) {
Log.Helper.LOGES(LOG_TAG, String.format("Could not launch target activity: %s, exception: %s", pushTargetActivity, e), new Object[0]);
return;
}
}
intent.putExtras(bundle);
intent.setFlags(603979776);
if (Build.VERSION.SDK_INT >= 33) {
parcelable = bundle.getParcelable("notification", Notification.class);
notification = (Notification) parcelable;
} else {
notification = (Notification) bundle.getParcelable("notification");
}
String string2 = bundle.getString(FCMMessageService.PushIntentExtraKeys.PUSH_ID);
int hashCode = string2 != null ? string2.hashCode() : 0;
PendingIntent activity = PendingIntent.getActivity(context, 0, intent, 1140850688);
if (notification == null) {
Log.Helper.LOGE(this, "Unable to create Push Notification", new Object[0]);
return;
}
if (activity != null) {
notification.contentIntent = activity;
NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
if (notificationManager != null) {
String string3 = bundle.getString(FCMMessageService.PushIntentExtraKeys.COLLAPSE_KEY);
if (string3 != null && !string3.equalsIgnoreCase("do_not_collapse")) {
notificationManager.notify(string3, 0, notification);
return;
} else {
notificationManager.notify(hashCode, notification);
return;
}
}
Log.Helper.LOGE(this, "Notification Manager is not available or is inaccessible. Skipping Notification formatting.", new Object[0]);
return;
}
Log.Helper.LOGE(this, "Unable to create PendingIntent", new Object[0]);
}
public String getPushTargetActivity(Context context) {
Intent launchIntentForPackage;
ComponentName resolveActivity;
Context applicationContext = context.getApplicationContext();
PackageManager packageManager = applicationContext.getPackageManager();
if (packageManager != null && (launchIntentForPackage = packageManager.getLaunchIntentForPackage(applicationContext.getPackageName())) != null && (resolveActivity = launchIntentForPackage.resolveActivity(applicationContext.getPackageManager())) != null) {
return resolveActivity.getClassName();
}
Log.Helper.LOGE(this, "PackageManager service is unable or is inaccessible. Unable to get PushTargetActivity.", new Object[0]);
return "";
}
}

View File

@@ -0,0 +1,44 @@
package com.ea.eadp.pushnotification.lifecycles;
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
/* loaded from: classes2.dex */
public class PushLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {
public static boolean inForeground = false;
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityCreated(Activity activity, Bundle bundle) {
inForeground = true;
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityDestroyed(Activity activity) {
inForeground = false;
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityPaused(Activity activity) {
inForeground = false;
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityResumed(Activity activity) {
inForeground = true;
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityStarted(Activity activity) {
inForeground = true;
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityStopped(Activity activity) {
inForeground = false;
}
}

View File

@@ -0,0 +1,12 @@
package com.ea.eadp.pushnotification.listeners;
/* loaded from: classes2.dex */
public interface IPushListener {
void onConnectionError(int i, String str);
void onGetInAppSuccess(int i, String str);
void onRegistrationSuccess(int i, String str);
void onTrackingSuccess(int i, String str);
}

View File

@@ -0,0 +1,162 @@
package com.ea.eadp.pushnotification.models;
import android.os.Build;
import java.util.Locale;
import java.util.TimeZone;
/* loaded from: classes2.dex */
public class PushNotificationConfig {
private String appId;
private String appVersion;
private String country;
private String dateOfBirth;
private String deviceIdentifier;
private boolean disabled;
private String disabledReason;
private String registrationIdentifier;
private Integer silentIntervalEnd;
private Integer silentIntervalStart;
private String userAlias;
private String manufacturer = Build.MANUFACTURER;
private String operatingSystem = Build.VERSION.RELEASE;
private String model = Build.MODEL;
private String deviceType = "android";
private String locale = Locale.getDefault().toString();
private TimeZone timezone = TimeZone.getDefault();
public String getAppId() {
return this.appId;
}
public String getAppVersion() {
return this.appVersion;
}
public String getCountry() {
return this.country;
}
public String getDateOfBirth() {
return this.dateOfBirth;
}
public String getDeviceIdentifier() {
return this.deviceIdentifier;
}
public String getDeviceType() {
return this.deviceType;
}
public String getDisabledReason() {
return this.disabledReason;
}
public String getLocale() {
return this.locale;
}
public String getManufacturer() {
return this.manufacturer;
}
public String getModel() {
return this.model;
}
public String getOperatingSystem() {
return this.operatingSystem;
}
public String getRegistrationIdentifier() {
return this.registrationIdentifier;
}
public Integer getSilentIntervalEnd() {
return this.silentIntervalEnd;
}
public Integer getSilentIntervalStart() {
return this.silentIntervalStart;
}
public TimeZone getTimezone() {
return this.timezone;
}
public String getUserAlias() {
return this.userAlias;
}
public boolean isDisabled() {
return this.disabled;
}
public void setAppId(String str) {
this.appId = str;
}
public void setAppVersion(String str) {
this.appVersion = str;
}
public void setCountry(String str) {
this.country = str;
}
public void setDateOfBirth(String str) {
this.dateOfBirth = str;
}
public void setDeviceIdentifier(String str) {
this.deviceIdentifier = str;
}
public void setDeviceType(String str) {
this.deviceType = str;
}
public void setDisabled(boolean z) {
this.disabled = z;
}
public void setDisabledReason(String str) {
this.disabledReason = str;
}
public void setLocale(String str) {
this.locale = str;
}
public void setManufacturer(String str) {
this.manufacturer = str;
}
public void setModel(String str) {
this.model = str;
}
public void setOperatingSystem(String str) {
this.operatingSystem = str;
}
public void setRegistrationIdentifier(String str) {
this.registrationIdentifier = str;
}
public void setSilentIntervalEnd(Integer num) {
this.silentIntervalEnd = num;
}
public void setSilentIntervalStart(Integer num) {
this.silentIntervalStart = num;
}
public void setTimezone(TimeZone timeZone) {
this.timezone = timeZone;
}
public void setUserAlias(String str) {
this.userAlias = str;
}
}

View File

@@ -0,0 +1,451 @@
package com.ea.eadp.pushnotification.services;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Base64;
import androidx.annotation.NonNull;
import com.ea.eadp.deviceid.DeviceIdService;
import com.ea.eadp.http.models.HttpRequest;
import com.ea.eadp.http.models.HttpRequestListener;
import com.ea.eadp.http.models.HttpResponse;
import com.ea.eadp.http.services.HttpService;
import com.ea.eadp.pushnotification.forwarding.FCMMessageService;
import com.ea.eadp.pushnotification.lifecycles.PushLifecycleCallbacks;
import com.ea.eadp.pushnotification.listeners.IPushListener;
import com.ea.eadp.pushnotification.models.PushNotificationConfig;
import com.ea.nimble.Log;
import com.ea.nimble.pushtng.PushNotification;
import com.google.android.gms.common.GoogleApiAvailabilityLight;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.messaging.FirebaseMessaging;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.Timer;
import java.util.TimerTask;
/* loaded from: classes2.dex */
public final class AndroidPushService implements IPushService {
private static final String API_KEY_KEY = "apiKey";
private static final String API_SECRET_KEY = "apiSecret";
public static final String AUTHORIZATION = "Authorization";
private static final String DEVICE_ID_KEY = "deviceId";
private static final String EVENT_LIST_KEY = "eventListKey";
private static final String GAME_ID_KEY = "gameId";
private static final String LOG_TAG = "PushManager";
private static final String PUSH_SERVER_URL_KEY = "pushNotificationServerUrl";
private static final String SHARED_PREFS_FILENAME = "PushManagerConfigurationData";
private static final String TRACKING_PREFS_FILENAME = "PushManagerTrackingData";
private static final String TRACKING_STATE_KEY = "state";
private final String apiKey;
private final String apiSecret;
private String appId;
private final Context context;
private PushNotificationConfig currentConfig;
private DeviceIdService deviceIdService;
private final String gameId;
private final HttpService httpService;
private long inAppNotificationInterval;
private Timer inAppTimer;
private IPushListener pushListener;
private final String pushNotificationServerUrl;
private String startClientToken;
private PushNotificationConfig startConfig;
@Override // com.ea.eadp.pushnotification.services.IPushService
public IPushListener getPushListener() {
return this.pushListener;
}
@Override // com.ea.eadp.pushnotification.services.IPushService
public void setPushListener(IPushListener iPushListener) {
this.pushListener = iPushListener;
}
public AndroidPushService(HttpService httpService, DeviceIdService deviceIdService, Context context, IPushListener iPushListener, String str, String str2, String str3, String str4, String str5, int i) {
Log.Helper.LOGIS(LOG_TAG, "Instantiating new push mgr", new Object[0]);
this.httpService = httpService;
this.deviceIdService = deviceIdService;
this.context = context;
this.pushListener = iPushListener;
this.pushNotificationServerUrl = str;
this.gameId = str2;
this.appId = str3;
this.apiKey = str4;
this.apiSecret = str5;
this.inAppNotificationInterval = i * 1000;
}
public AndroidPushService(Context context, HttpService httpService) {
this.context = context;
this.httpService = httpService;
this.pushNotificationServerUrl = loadConfigData(PUSH_SERVER_URL_KEY);
this.gameId = loadConfigData("gameId");
this.apiKey = loadConfigData(API_KEY_KEY);
this.apiSecret = loadConfigData(API_SECRET_KEY);
}
@Override // com.ea.eadp.pushnotification.services.IPushService
public void startWithConfig(final PushNotificationConfig pushNotificationConfig, final String str) {
Log.Helper.LOGPUBLICFUNC(this);
if (pushNotificationConfig == null) {
Log.Helper.LOGES(LOG_TAG, "Error: Config data is null.", new Object[0]);
IPushListener iPushListener = this.pushListener;
if (iPushListener != null) {
iPushListener.onConnectionError(0, "Config data is null");
return;
}
return;
}
if (this.inAppNotificationInterval > 0) {
Timer timer = new Timer();
this.inAppTimer = timer;
TimerTask timerTask = new TimerTask() { // from class: com.ea.eadp.pushnotification.services.AndroidPushService.1
@Override // java.util.TimerTask, java.lang.Runnable
public void run() {
AndroidPushService.this.getInAppNotifications(pushNotificationConfig.getUserAlias(), str);
}
};
long j = this.inAppNotificationInterval;
timer.schedule(timerTask, j, j);
}
if (pushNotificationConfig.isDisabled()) {
registerDevice(pushNotificationConfig);
} else {
new Thread(new Runnable() { // from class: com.ea.eadp.pushnotification.services.AndroidPushService.2
@Override // java.lang.Runnable
public void run() {
if (AndroidPushService.this.checkPlayServices()) {
Log.Helper.LOGIS(AndroidPushService.LOG_TAG, "Attempt to register device with FCM", new Object[0]);
try {
FirebaseMessaging.getInstance().getToken().addOnCompleteListener(new OnCompleteListener<String>() { // from class: com.ea.eadp.pushnotification.services.AndroidPushService.2.1
@Override // com.google.android.gms.tasks.OnCompleteListener
public void onComplete(@NonNull Task<String> task) {
if (!task.isSuccessful()) {
Log.Helper.LOGES(AndroidPushService.LOG_TAG, "Failed to get firebase instance id: %s", task.getException().getLocalizedMessage());
pushNotificationConfig.setDisabled(true);
pushNotificationConfig.setDisabledReason(PushNotification.DISABLED_REASON_REGISTER_FAILURE);
} else {
String result = task.getResult();
pushNotificationConfig.setRegistrationIdentifier(result);
pushNotificationConfig.setDisabled(false);
pushNotificationConfig.setDisabledReason(null);
Log.Helper.LOGIS(AndroidPushService.LOG_TAG, String.format("Device registered on FCM. Registration id: %s", result), new Object[0]);
try {
((Application) AndroidPushService.this.context.getApplicationContext()).registerActivityLifecycleCallbacks(new PushLifecycleCallbacks());
} catch (Exception e) {
Log.Helper.LOGES(AndroidPushService.LOG_TAG, "Failed to register activity lifecycle callbacks: %s", e.getLocalizedMessage());
}
}
AnonymousClass2 anonymousClass2 = AnonymousClass2.this;
AndroidPushService.this.registerDevice(pushNotificationConfig);
}
});
return;
} catch (Exception e) {
Log.Helper.LOGES(AndroidPushService.LOG_TAG, "Failed to get registration ID from FCM: %s", e.getLocalizedMessage());
pushNotificationConfig.setDisabled(true);
pushNotificationConfig.setDisabledReason(PushNotification.DISABLED_REASON_REGISTER_FAILURE);
AndroidPushService.this.registerDevice(pushNotificationConfig);
return;
}
}
Log.Helper.LOGES(AndroidPushService.LOG_TAG, "Failed to find appropriate Google Play Service SDK on device.", new Object[0]);
pushNotificationConfig.setDisabled(true);
pushNotificationConfig.setDisabledReason(PushNotification.DISABLED_REASON_REGISTER_FAILURE);
AndroidPushService.this.registerDevice(pushNotificationConfig);
}
}, "startWithConfig thread").start();
}
}
@Override // com.ea.eadp.pushnotification.services.IPushService
public void updateToken(String str) {
PushNotificationConfig pushNotificationConfig = this.currentConfig;
if (pushNotificationConfig != null) {
pushNotificationConfig.setRegistrationIdentifier(str);
registerDevice(this.currentConfig);
}
}
@Override // com.ea.eadp.pushnotification.services.IPushService
public void registerDevice(final PushNotificationConfig pushNotificationConfig) {
this.currentConfig = pushNotificationConfig;
if (pushNotificationConfig == null) {
Log.Helper.LOGES(LOG_TAG, "Error: Config data is null.", new Object[0]);
IPushListener iPushListener = this.pushListener;
if (iPushListener != null) {
iPushListener.onConnectionError(0, "Config data is null");
return;
}
return;
}
if (pushNotificationConfig.getDeviceIdentifier() == null) {
pushNotificationConfig.setDeviceIdentifier(this.deviceIdService.getDeviceId());
}
Log.Helper.LOGIS(LOG_TAG, "Attempt to register device with EADP push notification service", new Object[0]);
try {
try {
HttpRequest resource = this.httpService.getResource(String.format("%s/games/%s/devices", this.pushNotificationServerUrl, this.gameId));
resource.setHeader("Authorization", createAuthorizationHeader());
pushNotificationConfig.setAppId(this.appId);
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(TimeZone.class, new TimeZoneSerializer());
resource.setJsonBody(gsonBuilder.create().toJson(pushNotificationConfig));
resource.postAsync(new HttpRequestListener() { // from class: com.ea.eadp.pushnotification.services.AndroidPushService.3
@Override // com.ea.eadp.http.models.HttpRequestListener
public void onComplete(HttpResponse httpResponse) {
int code = httpResponse.getCode();
String body = httpResponse.getBody();
if (code >= 200 && code < 300) {
Log.Helper.LOGIS(AndroidPushService.LOG_TAG, "Registration request successful!", new Object[0]);
Log.Helper.LOGDS(AndroidPushService.LOG_TAG, String.format("response: %s", body), new Object[0]);
Log.Helper.LOGIS(AndroidPushService.LOG_TAG, String.format("Device registration with server complete. Registered id: %s", pushNotificationConfig.getRegistrationIdentifier()), new Object[0]);
if (AndroidPushService.this.pushListener != null) {
AndroidPushService.this.pushListener.onRegistrationSuccess(code, body);
return;
}
return;
}
String format = String.format("Registration request failed! Status: %s, Message: %s", Integer.valueOf(code), httpResponse.getMessage());
Log.Helper.LOGES(AndroidPushService.LOG_TAG, format, new Object[0]);
Log.Helper.LOGDS(AndroidPushService.LOG_TAG, String.format("response: %s", body), new Object[0]);
if (AndroidPushService.this.pushListener != null) {
AndroidPushService.this.pushListener.onConnectionError(code, format);
}
}
});
} catch (Exception e) {
String format = String.format("Failed to register device with Exception: %s", e.getLocalizedMessage());
Log.Helper.LOGES(LOG_TAG, format, new Object[0]);
IPushListener iPushListener2 = this.pushListener;
if (iPushListener2 != null) {
iPushListener2.onConnectionError(0, format);
}
}
} finally {
saveConfigData(pushNotificationConfig);
}
}
@Override // com.ea.eadp.pushnotification.services.IPushService
public void sendTrackingEvent(String str, String str2, String str3) {
try {
HttpRequest resource = this.httpService.getResource(String.format("%s/games/%s/events", this.pushNotificationServerUrl, this.gameId));
TrackingEvent trackingEvent = new TrackingEvent(str, str2, str3, loadConfigData(DEVICE_ID_KEY));
resource.setHeader("Authorization", createAuthorizationHeader());
resource.setJsonBody(new Gson().toJson(trackingEvent));
resource.postAsync(new HttpRequestListener() { // from class: com.ea.eadp.pushnotification.services.AndroidPushService.4
@Override // com.ea.eadp.http.models.HttpRequestListener
public void onComplete(HttpResponse httpResponse) {
int code = httpResponse.getCode();
if (code >= 200 && code < 300) {
Log.Helper.LOGIS(AndroidPushService.LOG_TAG, "Tracking request successful!", new Object[0]);
Log.Helper.LOGDS(AndroidPushService.LOG_TAG, String.format("response: %s", httpResponse.getBody()), new Object[0]);
if (AndroidPushService.this.pushListener != null) {
AndroidPushService.this.pushListener.onTrackingSuccess(code, httpResponse.getBody());
return;
}
return;
}
String format = String.format("Tracking request failed! Status: %s, Message: %s", Integer.valueOf(httpResponse.getCode()), httpResponse.getMessage());
Log.Helper.LOGES(AndroidPushService.LOG_TAG, format, new Object[0]);
Log.Helper.LOGDS(AndroidPushService.LOG_TAG, String.format("response: %s", httpResponse.getBody()), new Object[0]);
if (AndroidPushService.this.pushListener != null) {
AndroidPushService.this.pushListener.onConnectionError(code, format);
}
}
});
} catch (Exception e) {
String format = String.format("Tracking request failed with Exception: %s", e.getMessage());
Log.Helper.LOGES(LOG_TAG, format, new Object[0]);
IPushListener iPushListener = this.pushListener;
if (iPushListener != null) {
iPushListener.onConnectionError(0, format);
}
}
}
@Override // com.ea.eadp.pushnotification.services.IPushService
public void persistTrackingEvent(String str, String str2, String str3) {
List arrayList;
SharedPreferences sharedPreferences = this.context.getApplicationContext().getSharedPreferences(TRACKING_PREFS_FILENAME, 0);
String string = sharedPreferences.getString(EVENT_LIST_KEY, null);
if (string != null) {
arrayList = (List) new Gson().fromJson(string, List.class);
} else {
arrayList = new ArrayList();
}
HashMap hashMap = new HashMap();
hashMap.put(FCMMessageService.PushIntentExtraKeys.PUSH_ID, str);
hashMap.put(FCMMessageService.PushIntentExtraKeys.PN_TYPE, str2);
hashMap.put("state", str3);
if (arrayList == null) {
Log.Helper.LOGE(this, "Unexpected Event List. Skipping Tracking event persistence.", new Object[0]);
return;
}
arrayList.add(hashMap);
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString(EVENT_LIST_KEY, new Gson().toJson(arrayList));
edit.apply();
}
@Override // com.ea.eadp.pushnotification.services.IPushService
public void sendPendingTrackingRequests() {
Gson gson = new Gson();
SharedPreferences sharedPreferences = this.context.getSharedPreferences(TRACKING_PREFS_FILENAME, 0);
String string = sharedPreferences.getString(EVENT_LIST_KEY, null);
if (string != null) {
List<Map> list = (List) gson.fromJson(string, List.class);
if (list == null) {
Log.Helper.LOGE(this, "Event List from Json is null!", new Object[0]);
return;
}
for (Map map : list) {
if (map != null && !map.isEmpty()) {
sendTrackingEvent((String) map.get(FCMMessageService.PushIntentExtraKeys.PUSH_ID), (String) map.get(FCMMessageService.PushIntentExtraKeys.PN_TYPE), (String) map.get("state"));
}
}
}
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.clear();
edit.apply();
}
@Override // com.ea.eadp.pushnotification.services.IPushService
public void getInAppNotifications(final String str, final String str2) {
if (str != null) {
new Thread(new Runnable() { // from class: com.ea.eadp.pushnotification.services.AndroidPushService.5
@Override // java.lang.Runnable
public void run() {
int i;
HttpResponse httpResponse;
try {
HttpRequest resource = AndroidPushService.this.httpService.getResource(String.format("%s/games/%s/users/%s/inapp", AndroidPushService.this.pushNotificationServerUrl, AndroidPushService.this.gameId, str));
if (str2 != null) {
resource.setHeader("Authorization", "Bearer " + str2);
}
httpResponse = resource.get();
i = httpResponse.getCode();
} catch (Exception e) {
e = e;
i = 0;
}
try {
if (i >= 200 && i < 300) {
Log.Helper.LOGIS(AndroidPushService.LOG_TAG, "Get In-App Notification request successful!", new Object[0]);
Log.Helper.LOGDS(AndroidPushService.LOG_TAG, "response: " + httpResponse.getBody(), new Object[0]);
if (AndroidPushService.this.pushListener != null) {
AndroidPushService.this.pushListener.onGetInAppSuccess(i, httpResponse.getBody());
}
} else {
String format = String.format("Get In-App Notification request failed! Status: %s, Message: %s", Integer.valueOf(httpResponse.getCode()), httpResponse.getMessage());
Log.Helper.LOGES(AndroidPushService.LOG_TAG, format, new Object[0]);
Log.Helper.LOGDS(AndroidPushService.LOG_TAG, String.format("response: %s", httpResponse.getBody()), new Object[0]);
if (AndroidPushService.this.pushListener != null) {
AndroidPushService.this.pushListener.onConnectionError(i, format);
}
}
} catch (Exception e2) {
e = e2;
String format2 = String.format("In-App Notification request failed with Exception: %s", e.getMessage());
Log.Helper.LOGES(AndroidPushService.LOG_TAG, format2, new Object[0]);
if (AndroidPushService.this.pushListener != null) {
AndroidPushService.this.pushListener.onConnectionError(i, format2);
}
}
}
}, "getInAppNotifications thread").start();
return;
}
IPushListener iPushListener = this.pushListener;
if (iPushListener != null) {
iPushListener.onConnectionError(0, "UserAlias is null");
}
}
@Override // com.ea.eadp.pushnotification.services.IPushService
public void onRestart() {
if (this.inAppTimer == null || this.inAppNotificationInterval <= 0) {
return;
}
Timer timer = new Timer();
this.inAppTimer = timer;
TimerTask timerTask = new TimerTask() { // from class: com.ea.eadp.pushnotification.services.AndroidPushService.6
@Override // java.util.TimerTask, java.lang.Runnable
public void run() {
AndroidPushService androidPushService = AndroidPushService.this;
androidPushService.getInAppNotifications(androidPushService.startConfig.getUserAlias(), AndroidPushService.this.startClientToken);
}
};
long j = this.inAppNotificationInterval;
timer.schedule(timerTask, j, j);
}
@Override // com.ea.eadp.pushnotification.services.IPushService
public void onStop() {
Timer timer = this.inAppTimer;
if (timer != null) {
timer.cancel();
}
}
/* JADX INFO: Access modifiers changed from: private */
public boolean checkPlayServices() {
return GoogleApiAvailabilityLight.getInstance().isGooglePlayServicesAvailable(this.context) == 0;
}
private void saveConfigData(PushNotificationConfig pushNotificationConfig) {
SharedPreferences.Editor edit = this.context.getApplicationContext().getSharedPreferences(SHARED_PREFS_FILENAME, 0).edit();
if (pushNotificationConfig.getDeviceIdentifier() != null && !pushNotificationConfig.getDeviceIdentifier().equals("")) {
edit.putString(DEVICE_ID_KEY, pushNotificationConfig.getDeviceIdentifier());
}
String str = this.pushNotificationServerUrl;
if (str != null && !str.equals("")) {
edit.putString(PUSH_SERVER_URL_KEY, this.pushNotificationServerUrl);
}
String str2 = this.gameId;
if (str2 != null && !str2.equals("")) {
edit.putString("gameId", this.gameId);
}
String str3 = this.apiKey;
if (str3 != null && !str3.equals("")) {
edit.putString(API_KEY_KEY, this.apiKey);
}
String str4 = this.apiSecret;
if (str4 != null && !str4.equals("")) {
edit.putString(API_SECRET_KEY, this.apiSecret);
}
edit.apply();
}
private String loadConfigData(String str) {
return this.context.getApplicationContext().getSharedPreferences(SHARED_PREFS_FILENAME, 0).getString(str, null);
}
private String createAuthorizationHeader() {
return String.format("Basic %s", Base64.encodeToString((this.apiKey + ':' + this.apiSecret).getBytes(StandardCharsets.UTF_8), 10));
}
public static class TimeZoneSerializer implements JsonSerializer<TimeZone> {
private TimeZoneSerializer() {
}
@Override // com.google.gson.JsonSerializer
public JsonElement serialize(TimeZone timeZone, Type type, JsonSerializationContext jsonSerializationContext) {
return new JsonPrimitive(timeZone.getID());
}
}
}

View File

@@ -0,0 +1,32 @@
package com.ea.eadp.pushnotification.services;
import com.ea.eadp.pushnotification.listeners.IPushListener;
import com.ea.eadp.pushnotification.models.PushNotificationConfig;
/* loaded from: classes2.dex */
public interface IPushService {
public static final String NOTIFICATION_TYPE_OPENED = "NOTIFICATION_OPENED";
public static final String NOTIFICATION_TYPE_RECEIVED = "NOTIFICATION_RECEIVED";
void getInAppNotifications(String str, String str2);
IPushListener getPushListener();
void onRestart();
void onStop();
void persistTrackingEvent(String str, String str2, String str3);
void registerDevice(PushNotificationConfig pushNotificationConfig);
void sendPendingTrackingRequests();
void sendTrackingEvent(String str, String str2, String str3);
void setPushListener(IPushListener iPushListener);
void startWithConfig(PushNotificationConfig pushNotificationConfig, String str);
void updateToken(String str);
}

View File

@@ -0,0 +1,29 @@
package com.ea.eadp.pushnotification.services;
import com.ea.eadp.pushnotification.forwarding.FCMMessageService;
import com.google.gson.annotations.Expose;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes2.dex */
class TrackingEvent {
@Expose
private final String name;
@Expose
private final Map<String, String> parameters;
public TrackingEvent(String str, String str2, String str3, String str4) {
this.name = str3;
HashMap hashMap = new HashMap();
this.parameters = hashMap;
hashMap.put(FCMMessageService.PushIntentExtraKeys.PUSH_ID, str);
hashMap.put(FCMMessageService.PushIntentExtraKeys.PN_TYPE, str2);
hashMap.put("deviceType", "android");
hashMap.put("deviceIdentifier", str4);
hashMap.put("timestamp", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()));
}
}