- 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
815 lines
37 KiB
Java
815 lines
37 KiB
Java
package com.ea.nimble.tracking;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import com.ea.nimble.ApplicationEnvironment;
|
|
import com.ea.nimble.Component;
|
|
import com.ea.nimble.Global;
|
|
import com.ea.nimble.Log;
|
|
import com.ea.nimble.LogSource;
|
|
import com.ea.nimble.Network;
|
|
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.mtx.catalog.synergy.SynergyCatalog;
|
|
import com.ea.nimble.tracking.Tracking;
|
|
import com.ironsource.mediationsdk.metadata.a;
|
|
import java.io.Serializable;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.concurrent.ScheduledFuture;
|
|
|
|
/* loaded from: classes2.dex */
|
|
abstract class NimbleTrackingImplBase extends Component implements ITracking, LogSource {
|
|
private static final int DATA_VERSION_CURRENT = 3;
|
|
private static final int DEFAULT_MAX_QUEUE_LENGTH = 3;
|
|
protected static final double DEFAULT_POST_INTERVAL = 1.0d;
|
|
protected static final double DEFAULT_REPOST_MULTIPLIER = 2.0d;
|
|
protected static final double DEFAULT_RETRY_DELAY = 1.0d;
|
|
protected static final double MAX_POST_RETRY_DELAY = 300.0d;
|
|
private static final int MAX_QUEUED_EVENTS = 50;
|
|
private static final int MAX_QUEUED_SESSIONS = 50;
|
|
public static final String NIMBLE_TRACKING_DEFAULT_POST_ENABLE = "NimbleDefaultTrackingPostFlag";
|
|
protected static final double NOW_POST_INTERVAL = 0.0d;
|
|
private static final String ORIGIN_LOGIN_STATUS_STRING_AUTO_LOGGING_IN = "autoLogin";
|
|
private static final String ORIGIN_LOGIN_STATUS_STRING_LIVE_USER = "live";
|
|
private static final String ORIGIN_NOTIFICATION_LOGIN_STATUS_UPDATE_KEY_STATUS = "STATUS";
|
|
private static final String PERSISTENCE_CURRENT_SESSION_ID = "currentSessionObject";
|
|
private static final String PERSISTENCE_ENABLE_FLAG = "trackingEnabledFlag";
|
|
private static final String PERSISTENCE_EVENT_QUEUE_ID = "eventQueue";
|
|
private static final String PERSISTENCE_FIRST_SESSION_ID_NUMBER = "firstSessionIDNumber";
|
|
private static final String PERSISTENCE_LAST_SESSION_ID_NUMBER = "lastSessionIDNumber";
|
|
private static final String PERSISTENCE_LOGGED_IN_TO_ORIGIN_ID = "loggedInToOrigin";
|
|
private static final String PERSISTENCE_POST_ENABLE_FLAG = "trackingPostEnabledFlag";
|
|
private static final String PERSISTENCE_QUEUED_SESSIONS_ID = "queuedSessionObjects";
|
|
private static final String PERSISTENCE_SAVED_SESSION_ID_NUMBER = "savedSession";
|
|
private static final String PERSISTENCE_SESSION_DATA_ID = "sessionData";
|
|
private static final String PERSISTENCE_TOTAL_SESSION_COUNT = "totalSessionCount";
|
|
private static final String PERSISTENCE_TRACKING_ATTRIBUTES = "trackingAttributes";
|
|
private static final String PERSISTENCE_VERSION_ID = "dataVersion";
|
|
private static final String SESSION_FILE_FORMAT = "%sSession%d";
|
|
protected double m_postRetryDelay;
|
|
private ScheduledFuture<?> m_postTimer;
|
|
protected NimbleTrackingThreadManager m_threadManager;
|
|
protected ArrayList<TrackingBaseSessionObject> m_sessionsToPost = new ArrayList<>();
|
|
private boolean m_enable = true;
|
|
private boolean m_isFeatureDisabledFromServer = false;
|
|
protected ArrayList<SessionData> m_customSessionData = new ArrayList<>();
|
|
private StartupRequestsFinishedReceiver m_receiver = null;
|
|
private BroadcastReceiver m_networkStatusChangedReceiver = null;
|
|
protected boolean m_loggedInToOrigin = false;
|
|
private OriginLoginStatusChangedReceiver m_originLoginStatusChangedReceiver = null;
|
|
protected TrackingBaseSessionObject m_currentSessionObject = new TrackingBaseSessionObject();
|
|
protected double m_postInterval = 1.0d;
|
|
private boolean m_isPostPending = false;
|
|
protected boolean m_isRequestInProgress = false;
|
|
private long m_lastSessionIDNumber = -1;
|
|
private long m_firstSessionIDNumber = 0;
|
|
private long m_totalSessions = 0;
|
|
protected HashMap<String, String> m_trackingAttributes = new HashMap<>();
|
|
private boolean m_postEnable = true;
|
|
private final int m_maxQueueLength = 3;
|
|
|
|
public static class SessionData implements Serializable {
|
|
private static final long serialVersionUID = 465486;
|
|
String key;
|
|
String value;
|
|
}
|
|
|
|
public abstract List<Map<String, String>> convertEvent(Tracking.Event event);
|
|
|
|
public abstract String getFeatureTag();
|
|
|
|
@Override // com.ea.nimble.LogSource
|
|
public String getLogSourceTitle() {
|
|
return "TrackingBase";
|
|
}
|
|
|
|
public abstract String getPersistenceIdentifier();
|
|
|
|
public abstract void packageCurrentSession();
|
|
|
|
public abstract void postPendingEvents(boolean z);
|
|
|
|
public class PostTask implements Runnable {
|
|
private boolean m_packageEventsOnExpiry;
|
|
|
|
public PostTask(boolean z) {
|
|
this.m_packageEventsOnExpiry = false;
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
this.m_packageEventsOnExpiry = z;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
NimbleTrackingImplBase.this.postIntervalTimerExpired(this.m_packageEventsOnExpiry);
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.tracking.ITracking
|
|
public boolean getEnable() {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
return this.m_enable;
|
|
}
|
|
|
|
@Override // com.ea.nimble.tracking.ITracking
|
|
public void setEnable(boolean z) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
Object[] objArr = new Object[1];
|
|
objArr[0] = z ? "ENABLED" : "DISABLED";
|
|
Log.Helper.LOGI(this, "setEnable called. enable = %s", objArr);
|
|
if (this.m_enable == z) {
|
|
return;
|
|
}
|
|
if (!z) {
|
|
HashMap hashMap = new HashMap();
|
|
hashMap.put("eventType", Tracking.EVENT_USER_TRACKING_OPTOUT);
|
|
logEvent(Tracking.EVENT_USER_TRACKING_OPTOUT, hashMap);
|
|
packageCurrentSession();
|
|
postPendingEvents(false);
|
|
if (this.m_currentSessionObject.countOfEvents() > 0) {
|
|
Log.Helper.LOGI(this, "Removing %d remaining events that couldn't be sent from queue.", Integer.valueOf(this.m_currentSessionObject.countOfEvents()));
|
|
}
|
|
this.m_currentSessionObject = new TrackingBaseSessionObject();
|
|
ArrayList<TrackingBaseSessionObject> arrayList = this.m_sessionsToPost;
|
|
if (arrayList != null && arrayList.size() > 0) {
|
|
Log.Helper.LOGI(this, "Removing unposted sessions.", new Object[0]);
|
|
this.m_sessionsToPost.clear();
|
|
}
|
|
killPostTimer();
|
|
} else {
|
|
resetPostTimer();
|
|
}
|
|
this.m_enable = z;
|
|
saveToPersistence();
|
|
}
|
|
|
|
private void logEvent(Tracking.Event event, boolean z) {
|
|
ScheduledFuture<?> scheduledFuture;
|
|
Log.Helper.LOGFUNC(this);
|
|
List<Map<String, String>> convertEvent = convertEvent(event);
|
|
if (convertEvent != null && !convertEvent.isEmpty()) {
|
|
for (Map<String, String> map : convertEvent) {
|
|
this.m_currentSessionObject.events.add(map);
|
|
Log.Helper.LOGD(this, "Logged event, %s: \n", map);
|
|
}
|
|
saveToPersistence();
|
|
if (!z && (((scheduledFuture = this.m_postTimer) == null || (scheduledFuture.isDone() && !this.m_isRequestInProgress)) && isAbleToPostEvent(false))) {
|
|
resetPostTimer();
|
|
}
|
|
}
|
|
if (this.m_currentSessionObject.events.size() >= 50) {
|
|
Log.Helper.LOGD(this, "Current number of events (%d) has reached maximum (%d). Posting event queue now.", Integer.valueOf(this.m_currentSessionObject.events.size()), 50);
|
|
} else if (!z) {
|
|
return;
|
|
}
|
|
killPostTimer();
|
|
packageCurrentSession();
|
|
postPendingEvents(z);
|
|
}
|
|
|
|
@Override // com.ea.nimble.tracking.ITracking
|
|
public void logEvent(String str, Map<String, String> map) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
if (!this.m_enable || this.m_isFeatureDisabledFromServer) {
|
|
return;
|
|
}
|
|
boolean z = false;
|
|
if (str.equals(Tracking.EVENT_SESSION_END)) {
|
|
Log.Helper.LOGD(this, "Logging session end event, " + str + ". Posting event queue now.", new Object[0]);
|
|
z = true;
|
|
}
|
|
Tracking.Event event = new Tracking.Event();
|
|
event.type = str;
|
|
event.parameters = map;
|
|
event.timestamp = new Date();
|
|
logEvent(event, z);
|
|
}
|
|
|
|
public void resetPostTimer() {
|
|
Log.Helper.LOGFUNC(this);
|
|
resetPostTimer(this.m_postInterval);
|
|
}
|
|
|
|
public void resetPostTimer(double d) {
|
|
Log.Helper.LOGFUNC(this);
|
|
resetPostTimer(d, true);
|
|
}
|
|
|
|
public void resetPostTimer(double d, boolean z) {
|
|
Log.Helper.LOGFUNC(this);
|
|
double d2 = NOW_POST_INTERVAL;
|
|
if (d < NOW_POST_INTERVAL) {
|
|
Log.Helper.LOGE(this, "resetPostTimer called with an invalid period: period < 0.0. Timer reset with period 0.0 instead", new Object[0]);
|
|
} else {
|
|
d2 = d;
|
|
}
|
|
Log.Helper.LOGI(this, "Resetting event post timer for %s seconds.", Double.valueOf(d));
|
|
killPostTimer();
|
|
this.m_postTimer = this.m_threadManager.createTimer(d2, new PostTask(z));
|
|
}
|
|
|
|
private void killPostTimer() {
|
|
Log.Helper.LOGFUNC(this);
|
|
ScheduledFuture<?> scheduledFuture = this.m_postTimer;
|
|
if (scheduledFuture != null) {
|
|
scheduledFuture.cancel(false);
|
|
this.m_postTimer = null;
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.Component
|
|
public void setup() {
|
|
Log.Helper.LOGFUNC(this);
|
|
this.m_postRetryDelay = 1.0d;
|
|
this.m_threadManager = NimbleTrackingThreadManager.acquireInstance();
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:78:0x019f */
|
|
/* JADX WARN: Removed duplicated region for block: B:79:0x01a7 */
|
|
/* JADX WARN: Removed duplicated region for block: B:82:0x01ba */
|
|
@Override // com.ea.nimble.Component
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public void restore() {
|
|
/*
|
|
Method dump skipped, instructions count: 576
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.ea.nimble.tracking.NimbleTrackingImplBase.restore():void");
|
|
}
|
|
|
|
@Override // com.ea.nimble.Component
|
|
public void suspend() {
|
|
Log.Helper.LOGFUNC(this);
|
|
BroadcastReceiver broadcastReceiver = this.m_networkStatusChangedReceiver;
|
|
if (broadcastReceiver != null) {
|
|
Utility.unregisterReceiver(broadcastReceiver);
|
|
this.m_networkStatusChangedReceiver = null;
|
|
}
|
|
OriginLoginStatusChangedReceiver originLoginStatusChangedReceiver = this.m_originLoginStatusChangedReceiver;
|
|
if (originLoginStatusChangedReceiver != null) {
|
|
Utility.unregisterReceiver(originLoginStatusChangedReceiver);
|
|
this.m_originLoginStatusChangedReceiver = null;
|
|
}
|
|
killPostTimer();
|
|
saveToPersistence();
|
|
}
|
|
|
|
@Override // com.ea.nimble.Component
|
|
public void resume() {
|
|
Log.Helper.LOGFUNC(this);
|
|
updateFeatureDisableState();
|
|
if (getEnable()) {
|
|
resetPostTimer();
|
|
}
|
|
if (this.m_originLoginStatusChangedReceiver == null) {
|
|
OriginLoginStatusChangedReceiver originLoginStatusChangedReceiver = new OriginLoginStatusChangedReceiver();
|
|
this.m_originLoginStatusChangedReceiver = originLoginStatusChangedReceiver;
|
|
Utility.registerReceiver(Global.NOTIFICATION_LOGIN_STATUS_CHANGE, originLoginStatusChangedReceiver);
|
|
}
|
|
this.m_postRetryDelay = 1.0d;
|
|
}
|
|
|
|
@Override // com.ea.nimble.Component
|
|
public void cleanup() {
|
|
Log.Helper.LOGFUNC(this);
|
|
killPostTimer();
|
|
}
|
|
|
|
@Override // com.ea.nimble.Component
|
|
public void teardown() {
|
|
Log.Helper.LOGFUNC(this);
|
|
NimbleTrackingThreadManager.releaseInstance();
|
|
this.m_threadManager = null;
|
|
}
|
|
|
|
private void saveToPersistence() {
|
|
Log.Helper.LOGFUNC(this);
|
|
Persistence persistenceForNimbleComponent = PersistenceService.getPersistenceForNimbleComponent(getComponentId(), Persistence.Storage.CACHE);
|
|
Log.Helper.LOGD(this, "Saving event queue to persistence (cache storage).", new Object[0]);
|
|
try {
|
|
try {
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_VERSION_ID, String.valueOf(3));
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_CURRENT_SESSION_ID, this.m_currentSessionObject);
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_SESSION_DATA_ID, this.m_customSessionData);
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_LOGGED_IN_TO_ORIGIN_ID, Boolean.valueOf(this.m_loggedInToOrigin));
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_FIRST_SESSION_ID_NUMBER, Long.valueOf(this.m_firstSessionIDNumber));
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_LAST_SESSION_ID_NUMBER, Long.valueOf(this.m_lastSessionIDNumber));
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_TOTAL_SESSION_COUNT, Long.valueOf(this.m_totalSessions));
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_QUEUED_SESSIONS_ID, this.m_sessionsToPost);
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_TRACKING_ATTRIBUTES, this.m_trackingAttributes);
|
|
} catch (OutOfMemoryError e) {
|
|
Log.Helper.LOGE(this, "OutOfMemoryError in saving m_sessionsToPost to persistence! MaxQueueLength is %s. Exception: %s", Integer.valueOf(this.m_maxQueueLength), e.getLocalizedMessage());
|
|
}
|
|
persistenceForNimbleComponent.lambda$new$0();
|
|
Persistence persistenceForNimbleComponent2 = PersistenceService.getPersistenceForNimbleComponent(getComponentId(), Persistence.Storage.DOCUMENT);
|
|
Log.Helper.LOGD(this, "Saving tracking enable/disable flag to persistence (document storage).", new Object[0]);
|
|
if (!persistenceForNimbleComponent2.getBackUp()) {
|
|
persistenceForNimbleComponent2.setBackUp(true);
|
|
}
|
|
persistenceForNimbleComponent2.setValue(PERSISTENCE_ENABLE_FLAG, Boolean.valueOf(this.m_enable));
|
|
persistenceForNimbleComponent2.lambda$new$0();
|
|
} catch (Throwable th) {
|
|
Log.Helper.LOGE(this, "Caught generic throwable while saving to persistence! Discarding attempt to save. Exception: %s", th.getLocalizedMessage());
|
|
}
|
|
}
|
|
|
|
private void configureTrackingOnFirstInstall() {
|
|
Log.Helper.LOGFUNC(this);
|
|
Log.Helper.LOGD(this, "First Install. Look for App Settings to enable/disable tracking", new Object[0]);
|
|
String configValueAsString = NimbleApplicationConfiguration.getConfigValueAsString(Tracking.NIMBLE_TRACKING_DEFAULTENABLE);
|
|
if (Utility.validString(configValueAsString)) {
|
|
if (configValueAsString.equalsIgnoreCase(a.j)) {
|
|
Log.Helper.LOGD(this, "Default App Setting : Enable Tracking", new Object[0]);
|
|
this.m_enable = true;
|
|
return;
|
|
} else {
|
|
if (configValueAsString.equalsIgnoreCase("disable")) {
|
|
Log.Helper.LOGD(this, "Default App Setting : Disable Tracking", new Object[0]);
|
|
this.m_enable = false;
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
android.util.Log.e(Global.NIMBLE_ID, "WARNING! Cannot find valid TrackingEnable from AndroidManifest.xml");
|
|
}
|
|
|
|
public void addObserverForSynergyEnvironmentUpdateFinished() {
|
|
Log.Helper.LOGFUNC(this);
|
|
if (this.m_receiver == null) {
|
|
StartupRequestsFinishedReceiver startupRequestsFinishedReceiver = new StartupRequestsFinishedReceiver();
|
|
this.m_receiver = startupRequestsFinishedReceiver;
|
|
Utility.registerReceiver(SynergyEnvironment.NOTIFICATION_STARTUP_REQUESTS_FINISHED, startupRequestsFinishedReceiver);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void onStartupRequestsFinished(Intent intent) {
|
|
Map<String, Object> map;
|
|
Log.Helper.LOGFUNC(this);
|
|
if (intent.getExtras() == null || !intent.getExtras().getString("result").equals("1")) {
|
|
return;
|
|
}
|
|
int trackingPostInterval = SynergyEnvironment.getComponent().getTrackingPostInterval();
|
|
if (trackingPostInterval < 0 || trackingPostInterval == -1) {
|
|
this.m_postInterval = 1.0d;
|
|
} else {
|
|
this.m_postInterval = trackingPostInterval;
|
|
}
|
|
ArrayList<TrackingBaseSessionObject> arrayList = this.m_sessionsToPost;
|
|
if (arrayList != null) {
|
|
Iterator<TrackingBaseSessionObject> it = arrayList.iterator();
|
|
while (it.hasNext()) {
|
|
TrackingBaseSessionObject next = it.next();
|
|
if (next != null && (map = next.sessionData) != null) {
|
|
Object obj = map.get(SynergyCatalog.MTX_INFO_KEY_SELLID);
|
|
if (obj instanceof String) {
|
|
String str = (String) obj;
|
|
if (Utility.validString(str) && !str.equals("0")) {
|
|
String sellId = SynergyEnvironment.getComponent().getSellId();
|
|
next.sessionData.put(SynergyCatalog.MTX_INFO_KEY_SELLID, Utility.safeString(sellId));
|
|
if (sellId == null || sellId.equals("") || sellId.equals("0")) {
|
|
Log.Helper.LOGE(this, "Sell Id was still null after synergy update", new Object[0]);
|
|
}
|
|
}
|
|
}
|
|
Object obj2 = next.sessionData.get("hwId");
|
|
if ((obj2 instanceof String) && Utility.validString((String) obj2)) {
|
|
String eAHardwareId = SynergyEnvironment.getComponent().getEAHardwareId();
|
|
next.sessionData.put("hwId", Utility.safeString(eAHardwareId));
|
|
if (eAHardwareId == null || eAHardwareId.equals("")) {
|
|
Log.Helper.LOGE(this, "Hardware Id was still null after synergy update", new Object[0]);
|
|
}
|
|
}
|
|
Object obj3 = next.sessionData.get("deviceId");
|
|
if (obj3 instanceof String) {
|
|
String str2 = (String) obj3;
|
|
if (Utility.validString(str2) && !str2.equals("0")) {
|
|
String eADeviceId = SynergyEnvironment.getComponent().getEADeviceId();
|
|
next.sessionData.put("deviceId", Utility.safeString(eADeviceId));
|
|
if (eADeviceId == null || eADeviceId.equals("") || eADeviceId.equals("0")) {
|
|
Log.Helper.LOGE(this, "Device Id was still null after synergy update", new Object[0]);
|
|
}
|
|
}
|
|
}
|
|
Object obj4 = next.sessionData.get("synergyId");
|
|
if (obj4 instanceof String) {
|
|
String str3 = (String) obj4;
|
|
if (Utility.validString(str3) && !str3.equals("0")) {
|
|
String synergyId = SynergyEnvironment.getComponent().getSynergyId();
|
|
next.sessionData.put("synergyId", Utility.safeString(synergyId));
|
|
if (synergyId == null || synergyId.equals("") || synergyId.equals("0")) {
|
|
Log.Helper.LOGE(this, "Synergy Id was still null after synergy update", new Object[0]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Log.Helper.LOGI(this, "Synergy environment update successful. Removing observer and re-attempting event post.", new Object[0]);
|
|
StartupRequestsFinishedReceiver startupRequestsFinishedReceiver = this.m_receiver;
|
|
if (startupRequestsFinishedReceiver != null) {
|
|
Utility.unregisterReceiver(startupRequestsFinishedReceiver);
|
|
this.m_receiver = null;
|
|
}
|
|
if (this.m_isPostPending) {
|
|
this.m_isPostPending = false;
|
|
resetPostTimer(NOW_POST_INTERVAL);
|
|
}
|
|
}
|
|
|
|
public class StartupRequestsFinishedReceiver extends BroadcastReceiver {
|
|
private StartupRequestsFinishedReceiver() {
|
|
}
|
|
|
|
@Override // android.content.BroadcastReceiver
|
|
public void onReceive(Context context, final Intent intent) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
if (intent.getAction().equals(SynergyEnvironment.NOTIFICATION_STARTUP_REQUESTS_FINISHED)) {
|
|
NimbleTrackingImplBase.this.updateFeatureDisableState();
|
|
NimbleTrackingImplBase.this.m_threadManager.runInWorkerThread(new Runnable() { // from class: com.ea.nimble.tracking.NimbleTrackingImplBase.StartupRequestsFinishedReceiver.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
NimbleTrackingImplBase.this.onStartupRequestsFinished(intent);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void onOriginLoginStatusChanged(Intent intent) {
|
|
Log.Helper.LOGFUNC(this);
|
|
if (intent.getExtras() != null) {
|
|
String string = intent.getExtras().getString(ORIGIN_NOTIFICATION_LOGIN_STATUS_UPDATE_KEY_STATUS);
|
|
if (string.equals(ORIGIN_LOGIN_STATUS_STRING_LIVE_USER) || string.equals(ORIGIN_LOGIN_STATUS_STRING_AUTO_LOGGING_IN)) {
|
|
Log.Helper.LOGI(this, "Login status update, TRUE", new Object[0]);
|
|
this.m_loggedInToOrigin = true;
|
|
return;
|
|
} else {
|
|
Log.Helper.LOGI(this, "Login status update, FALSE", new Object[0]);
|
|
this.m_loggedInToOrigin = false;
|
|
return;
|
|
}
|
|
}
|
|
Log.Helper.LOGI(this, "Login status updated event received without extras bundle. Marking NOT logged in to Origin.", new Object[0]);
|
|
this.m_loggedInToOrigin = false;
|
|
}
|
|
|
|
public class OriginLoginStatusChangedReceiver extends BroadcastReceiver {
|
|
private OriginLoginStatusChangedReceiver() {
|
|
}
|
|
|
|
@Override // android.content.BroadcastReceiver
|
|
public void onReceive(Context context, final Intent intent) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
if (intent.getAction().equals(Global.NOTIFICATION_LOGIN_STATUS_CHANGE)) {
|
|
NimbleTrackingImplBase.this.m_threadManager.runInWorkerThread(new Runnable() { // from class: com.ea.nimble.tracking.NimbleTrackingImplBase.OriginLoginStatusChangedReceiver.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
NimbleTrackingImplBase.this.onOriginLoginStatusChanged(intent);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.tracking.ITracking
|
|
public void addCustomSessionData(String str, String str2) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
if (Utility.validString(str) && Utility.validString(str2)) {
|
|
SessionData sessionData = new SessionData();
|
|
sessionData.key = str;
|
|
sessionData.value = str2;
|
|
this.m_customSessionData.add(sessionData);
|
|
saveSessionDataToPersistent();
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.tracking.ITracking
|
|
public void removeCustomSessionData(String str) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
if (Utility.validString(str)) {
|
|
Iterator<SessionData> it = this.m_customSessionData.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
SessionData next = it.next();
|
|
if (next.key.equals(str)) {
|
|
this.m_customSessionData.remove(next);
|
|
break;
|
|
}
|
|
}
|
|
saveSessionDataToPersistent();
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.tracking.ITracking
|
|
public void clearCustomSessionData() {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
}
|
|
|
|
@Override // com.ea.nimble.tracking.ITracking
|
|
public String getSessionId() {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
return "";
|
|
}
|
|
|
|
private void saveSessionDataToPersistent() {
|
|
Log.Helper.LOGFUNC(this);
|
|
Persistence persistenceForNimbleComponent = PersistenceService.getPersistenceForNimbleComponent(getComponentId(), Persistence.Storage.CACHE);
|
|
Log.Helper.LOGI(this, "Saving event queue to persistence.", new Object[0]);
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_SESSION_DATA_ID, this.m_customSessionData);
|
|
persistenceForNimbleComponent.lambda$new$0();
|
|
}
|
|
|
|
public boolean isAbleToPostEvent(boolean z) {
|
|
Log.Helper.LOGFUNC(this);
|
|
if (!this.m_enable || this.m_isFeatureDisabledFromServer || !this.m_postEnable) {
|
|
return false;
|
|
}
|
|
if (!z && !ApplicationEnvironment.isMainApplicationActive()) {
|
|
Log.Helper.LOGD(this, "isAbleToPostEvent - return because the app is in background", new Object[0]);
|
|
return false;
|
|
}
|
|
if (Network.getComponent().getStatus() == Network.Status.OK) {
|
|
if (SynergyEnvironment.getComponent().isDataAvailable()) {
|
|
return true;
|
|
}
|
|
this.m_isPostPending = true;
|
|
addObserverForSynergyEnvironmentUpdateFinished();
|
|
return false;
|
|
}
|
|
if (this.m_networkStatusChangedReceiver == null) {
|
|
Log.Helper.LOGD(this, "Network status not OK for event post. Adding receiver for network status change.", new Object[0]);
|
|
killPostTimer();
|
|
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { // from class: com.ea.nimble.tracking.NimbleTrackingImplBase.1
|
|
@Override // android.content.BroadcastReceiver
|
|
public void onReceive(Context context, Intent intent) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
if (intent.getAction().equals(Global.NOTIFICATION_NETWORK_STATUS_CHANGE)) {
|
|
NimbleTrackingImplBase.this.m_threadManager.runInWorkerThread(new Runnable() { // from class: com.ea.nimble.tracking.NimbleTrackingImplBase.1.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
NimbleTrackingImplBase.this.onNetworkStatusChange();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
this.m_networkStatusChangedReceiver = broadcastReceiver;
|
|
Utility.registerReceiver(Global.NOTIFICATION_NETWORK_STATUS_CHANGE, broadcastReceiver);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // com.ea.nimble.tracking.ITracking
|
|
public void setPostEnable(boolean z) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
if (this.m_postEnable != z) {
|
|
this.m_postEnable = z;
|
|
Persistence persistenceForNimbleComponent = PersistenceService.getPersistenceForNimbleComponent(getComponentId(), Persistence.Storage.DOCUMENT);
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_POST_ENABLE_FLAG, Boolean.valueOf(this.m_postEnable));
|
|
persistenceForNimbleComponent.lambda$new$0();
|
|
if (isAbleToPostEvent(false)) {
|
|
resetPostTimer();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.tracking.ITracking
|
|
public boolean getPostEnable() {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
return this.m_postEnable;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void onNetworkStatusChange() {
|
|
Log.Helper.LOGFUNC(this);
|
|
if (Network.getComponent().getStatus() == Network.Status.OK) {
|
|
Log.Helper.LOGD(this, "Network status restored, kicking off event post.", new Object[0]);
|
|
Utility.unregisterReceiver(this.m_networkStatusChangedReceiver);
|
|
this.m_networkStatusChangedReceiver = null;
|
|
resetPostTimer(NOW_POST_INTERVAL);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void postIntervalTimerExpired(boolean z) {
|
|
Log.Helper.LOGFUNC(this);
|
|
if (z) {
|
|
packageCurrentSession();
|
|
}
|
|
postPendingEvents(false);
|
|
}
|
|
|
|
@Override // com.ea.nimble.tracking.ITracking
|
|
public void setTrackingAttribute(String str, String str2) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
if (Utility.validString(str) && Utility.validString(str2)) {
|
|
this.m_trackingAttributes.put(str, str2);
|
|
}
|
|
}
|
|
|
|
public void queueCurrentEventsForPost() {
|
|
Log.Helper.LOGFUNC(this);
|
|
Log.Helper.LOGI(this, "queueCurrentEventsForPost called. Starting queue size: %d", Integer.valueOf(this.m_sessionsToPost.size()));
|
|
if (this.m_sessionsToPost == null) {
|
|
this.m_sessionsToPost = new ArrayList<>();
|
|
}
|
|
TrackingBaseSessionObject trackingBaseSessionObject = this.m_currentSessionObject;
|
|
if (trackingBaseSessionObject == null) {
|
|
Log.Helper.LOGE(this, "Unexpected state, currentSessionObject is null.", new Object[0]);
|
|
} else if (trackingBaseSessionObject.countOfEvents() == 0) {
|
|
Log.Helper.LOGE(this, "Unexpected state, currentSessionObject events list is null or empty.", new Object[0]);
|
|
} else {
|
|
addCurrentSessionObjectToBackOfQueue();
|
|
dropExtraSessions();
|
|
}
|
|
this.m_currentSessionObject = new TrackingBaseSessionObject(new HashMap(this.m_currentSessionObject.sessionData));
|
|
saveToPersistence();
|
|
}
|
|
|
|
private void saveSessionToFile(TrackingBaseSessionObject trackingBaseSessionObject, long j) {
|
|
Log.Helper.LOGFUNC(this);
|
|
String filenameForSessionID = getFilenameForSessionID(j);
|
|
Persistence persistenceForNimbleComponent = PersistenceService.getPersistenceForNimbleComponent(filenameForSessionID, Persistence.Storage.DOCUMENT);
|
|
if (persistenceForNimbleComponent.getBackUp()) {
|
|
persistenceForNimbleComponent.setBackUp(false);
|
|
}
|
|
try {
|
|
persistenceForNimbleComponent.setValue(PERSISTENCE_SAVED_SESSION_ID_NUMBER, trackingBaseSessionObject);
|
|
} catch (OutOfMemoryError e) {
|
|
Log.Helper.LOGE(this, "OutOfMemoryError occurred while saving a session object to file. Exception: %s", e.getLocalizedMessage());
|
|
}
|
|
persistenceForNimbleComponent.lambda$new$0();
|
|
PersistenceService.cleanReferenceToPersistence(filenameForSessionID, Persistence.Storage.DOCUMENT);
|
|
}
|
|
|
|
private TrackingBaseSessionObject loadSessionFromFile(long j) {
|
|
Serializable value;
|
|
Log.Helper.LOGFUNC(this);
|
|
Persistence persistenceForNimbleComponent = PersistenceService.getPersistenceForNimbleComponent(getFilenameForSessionID(j), Persistence.Storage.DOCUMENT);
|
|
if (persistenceForNimbleComponent == null || (value = persistenceForNimbleComponent.getValue(PERSISTENCE_SAVED_SESSION_ID_NUMBER)) == null || value.getClass() != TrackingBaseSessionObject.class) {
|
|
return null;
|
|
}
|
|
return (TrackingBaseSessionObject) value;
|
|
}
|
|
|
|
private String getFilenameForSessionID(long j) {
|
|
Log.Helper.LOGFUNC(this);
|
|
if (j < 0) {
|
|
Log.Helper.LOGE(this, "Trying to find the filename for an invalid sessionID!", new Object[0]);
|
|
return null;
|
|
}
|
|
return String.format(Locale.US, SESSION_FILE_FORMAT, getComponentId(), Long.valueOf(j));
|
|
}
|
|
|
|
public void removeSessionAndFillQueue(TrackingBaseSessionObject trackingBaseSessionObject) {
|
|
Log.Helper.LOGFUNC(this);
|
|
this.m_sessionsToPost.remove(trackingBaseSessionObject);
|
|
this.m_firstSessionIDNumber++;
|
|
this.m_totalSessions--;
|
|
fillSessionsToPost();
|
|
saveToPersistence();
|
|
}
|
|
|
|
private void addCurrentSessionObjectToBackOfQueue() {
|
|
Log.Helper.LOGFUNC(this);
|
|
this.m_lastSessionIDNumber++;
|
|
this.m_totalSessions++;
|
|
if (this.m_sessionsToPost.size() >= this.m_maxQueueLength) {
|
|
saveSessionToFile(this.m_currentSessionObject, this.m_lastSessionIDNumber);
|
|
} else {
|
|
this.m_sessionsToPost.add(this.m_currentSessionObject);
|
|
}
|
|
saveToPersistence();
|
|
}
|
|
|
|
private void fillSessionsToPost() {
|
|
Log.Helper.LOGFUNC(this);
|
|
for (int size = this.m_sessionsToPost.size(); size < this.m_maxQueueLength; size++) {
|
|
long j = this.m_firstSessionIDNumber + size;
|
|
if (j > this.m_lastSessionIDNumber) {
|
|
return;
|
|
}
|
|
TrackingBaseSessionObject loadSessionFromFile = loadSessionFromFile(j);
|
|
if (loadSessionFromFile != null) {
|
|
this.m_sessionsToPost.add(loadSessionFromFile);
|
|
PersistenceService.removePersistenceForNimbleComponent(getFilenameForSessionID(j), Persistence.Storage.DOCUMENT);
|
|
} else {
|
|
this.m_firstSessionIDNumber++;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void dropExtraSessions() {
|
|
Log.Helper.LOGFUNC(this);
|
|
if (dropExtraSessions(true)) {
|
|
return;
|
|
}
|
|
Log.Helper.LOGD(this, "Failed to drop enough sessions. Dropping sessions without checking canDropSession.", new Object[0]);
|
|
if (dropExtraSessions(false)) {
|
|
return;
|
|
}
|
|
Log.Helper.LOGE(this, "Still unable to drop enough sessions. Remaining number: " + ((this.m_lastSessionIDNumber - this.m_firstSessionIDNumber) + 1), new Object[0]);
|
|
}
|
|
|
|
private void dropSessions(ArrayList<TrackingBaseSessionObject> arrayList, long j) {
|
|
Log.Helper.LOGFUNC(this);
|
|
for (int i = 0; i < arrayList.size(); i++) {
|
|
this.m_sessionsToPost.remove(arrayList.get(i));
|
|
PersistenceService.removePersistenceForNimbleComponent(getFilenameForSessionID(j - i), Persistence.Storage.DOCUMENT);
|
|
}
|
|
long size = (j - arrayList.size()) + 1;
|
|
long j2 = this.m_firstSessionIDNumber;
|
|
if (size == j2) {
|
|
this.m_firstSessionIDNumber = j2 + arrayList.size();
|
|
}
|
|
this.m_totalSessions -= arrayList.size();
|
|
saveToPersistence();
|
|
}
|
|
|
|
private boolean dropExtraSessions(boolean z) {
|
|
TrackingBaseSessionObject loadSessionFromFile;
|
|
Log.Helper.LOGFUNC(this);
|
|
long j = this.m_totalSessions;
|
|
if (j < 50) {
|
|
return true;
|
|
}
|
|
Log.Helper.LOGD(this, "Current number of sessions (%d) has reached maximum (%d). Removing old sessions.", Long.valueOf(j), 50);
|
|
ArrayList<TrackingBaseSessionObject> arrayList = new ArrayList<>();
|
|
long j2 = this.m_firstSessionIDNumber;
|
|
while (j2 <= this.m_lastSessionIDNumber) {
|
|
long j3 = j2 - this.m_firstSessionIDNumber;
|
|
if (j3 < this.m_sessionsToPost.size()) {
|
|
loadSessionFromFile = this.m_sessionsToPost.get((int) j3);
|
|
} else {
|
|
loadSessionFromFile = loadSessionFromFile(j2);
|
|
if (loadSessionFromFile == null) {
|
|
continue;
|
|
j2++;
|
|
}
|
|
}
|
|
if (arrayList.size() == 0 || isSameSession(arrayList.get(arrayList.size() - 1), loadSessionFromFile)) {
|
|
arrayList.add(loadSessionFromFile);
|
|
} else {
|
|
if (!z || canDropSession(arrayList)) {
|
|
dropSessions(arrayList, j2 - 1);
|
|
}
|
|
arrayList.clear();
|
|
if (this.m_totalSessions < 50) {
|
|
fillSessionsToPost();
|
|
return true;
|
|
}
|
|
arrayList.add(loadSessionFromFile);
|
|
}
|
|
j2++;
|
|
}
|
|
if (arrayList.size() > 0 && (!z || canDropSession(arrayList))) {
|
|
dropSessions(arrayList, j2 - 1);
|
|
}
|
|
fillSessionsToPost();
|
|
return this.m_totalSessions < 50;
|
|
}
|
|
|
|
public boolean isSameSession(TrackingBaseSessionObject trackingBaseSessionObject, TrackingBaseSessionObject trackingBaseSessionObject2) {
|
|
Log.Helper.LOGFUNC(this);
|
|
return false;
|
|
}
|
|
|
|
public boolean canDropSession(List<TrackingBaseSessionObject> list) {
|
|
Log.Helper.LOGFUNC(this);
|
|
return true;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void updateFeatureDisableState() {
|
|
Log.Helper.LOGFUNC(this);
|
|
if (SynergyEnvironment.getComponent().isDataAvailable()) {
|
|
boolean isFeatureDisabled = SynergyEnvironment.getComponent().isFeatureDisabled(getFeatureTag());
|
|
this.m_isFeatureDisabledFromServer = isFeatureDisabled;
|
|
if (isFeatureDisabled) {
|
|
Log.Helper.LOGI(this, "*** FEATURE DISABLED FROM SERVER ***", new Object[0]);
|
|
}
|
|
}
|
|
}
|
|
}
|