Files
rr3-apk/decompiled-community/sources/com/ea/nimble/OperationalTelemetryDispatchImpl.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

248 lines
10 KiB
Java

package com.ea.nimble;
import com.ea.nimble.Log;
import csdk.gluads.Consts;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;
/* loaded from: classes2.dex */
class OperationalTelemetryDispatchImpl extends Component implements IOperationalTelemetryDispatch, LogSource {
private Map<String, Integer> m_maxEventQueueSizeDict;
private List<OperationalTelemetryEvent> m_networkMetricsArray = new ArrayList();
private List<OperationalTelemetryEvent> m_networkPayloadsArray = new ArrayList();
@Override // com.ea.nimble.Component
public void cleanup() {
}
@Override // com.ea.nimble.Component
public String getComponentId() {
return OperationalTelemetryDispatch.COMPONENT_ID;
}
@Override // com.ea.nimble.LogSource
public String getLogSourceTitle() {
return OperationalTelemetryDispatch.LOG_TAG;
}
@Override // com.ea.nimble.Component
public void restore() {
}
@Override // com.ea.nimble.Component
public void resume() {
}
@Override // com.ea.nimble.Component
public void suspend() {
}
public OperationalTelemetryDispatchImpl() {
HashMap hashMap = new HashMap();
this.m_maxEventQueueSizeDict = hashMap;
hashMap.put("com.ea.nimble.network", 100);
this.m_maxEventQueueSizeDict.put(IOperationalTelemetryDispatch.EVENTTYPE_TRACKING_SYNERGY_PAYLOADS, 100);
}
@Override // com.ea.nimble.IOperationalTelemetryDispatch
public void logEvent(String str, String str2) {
boolean z;
Log.Helper.LOGPUBLICFUNC(this);
if (!Utility.validString(str)) {
Log.Helper.LOGE(this, "logEvent called with null or empty eventType.", new Object[0]);
return;
}
try {
JSONObject jSONObject = new JSONObject(str2);
if (jSONObject.length() == 0) {
Log.Helper.LOGE(this, "logEvent called with null or empty eventDictionary.", new Object[0]);
return;
}
OperationalTelemetryEventImpl operationalTelemetryEventImpl = new OperationalTelemetryEventImpl(str, jSONObject, new Date());
synchronized (this) {
try {
z = true;
if (str.equals("com.ea.nimble.network")) {
if (!canLogEvent(str)) {
trimEventQueue(str);
}
if (canLogEvent(str)) {
this.m_networkMetricsArray.add(operationalTelemetryEventImpl);
}
} else if (str.equals(IOperationalTelemetryDispatch.EVENTTYPE_TRACKING_SYNERGY_PAYLOADS)) {
if (!canLogEvent(str)) {
trimEventQueue(str);
}
if (canLogEvent(str)) {
this.m_networkPayloadsArray.add(operationalTelemetryEventImpl);
}
} else {
z = false;
}
} catch (Throwable th) {
throw th;
}
}
if (!z) {
Log.Helper.LOGE(this, "logEvent, unsupported OT eventType, " + str + Consts.STRING_PERIOD, new Object[0]);
}
updateEventThresholdListeners();
} catch (Exception unused) {
Log.Helper.LOGE(this, "logEvent could not build JSONObject from payload: " + str2, new Object[0]);
}
}
@Override // com.ea.nimble.IOperationalTelemetryDispatch
public List<OperationalTelemetryEvent> getEvents(String str) {
List<OperationalTelemetryEvent> list;
Log.Helper.LOGPUBLICFUNC(this);
if (!Utility.validString(str)) {
Log.Helper.LOGE(this, "getEvents called with null or empty eventType.", new Object[0]);
return null;
}
synchronized (this) {
try {
if (str.equals("com.ea.nimble.network")) {
list = this.m_networkMetricsArray;
this.m_networkMetricsArray = new ArrayList();
} else if (str.equals(IOperationalTelemetryDispatch.EVENTTYPE_TRACKING_SYNERGY_PAYLOADS)) {
list = this.m_networkPayloadsArray;
this.m_networkPayloadsArray = new ArrayList();
} else {
list = null;
}
} catch (Throwable th) {
throw th;
}
}
if (list == null) {
Log.Helper.LOGE(this, "getEvents, unsupported OT eventType, " + str + Consts.STRING_PERIOD, new Object[0]);
return null;
}
return Collections.unmodifiableList(list);
}
@Override // com.ea.nimble.IOperationalTelemetryDispatch
public void setMaxEventCount(String str, int i) {
Log.Helper.LOGPUBLICFUNC(this);
if (!Utility.validString(str)) {
Log.Helper.LOGE(this, "setMaxEventCount called with null or empty eventType.", new Object[0]);
} else {
this.m_maxEventQueueSizeDict.put(str, Integer.valueOf(i));
trimEventQueue(str);
}
}
@Override // com.ea.nimble.IOperationalTelemetryDispatch
public int getMaxEventCount(String str) {
Log.Helper.LOGPUBLICFUNC(this);
if (!Utility.validString(str)) {
Log.Helper.LOGE(this, "getMaxEventCount called with null or empty eventType.", new Object[0]);
return 100;
}
Integer num = this.m_maxEventQueueSizeDict.get(str);
if (num == null) {
return 100;
}
return num.intValue();
}
private boolean canLogEvent(String str) {
List<OperationalTelemetryEvent> list;
Log.Helper.LOGFUNC(this);
int maxEventCount = getMaxEventCount(str);
if (str.equals("com.ea.nimble.network")) {
list = this.m_networkMetricsArray;
} else {
if (!str.equals(IOperationalTelemetryDispatch.EVENTTYPE_TRACKING_SYNERGY_PAYLOADS)) {
Log.Helper.LOGE(this, "canLogEvent, unsupported OT eventType, " + str + Consts.STRING_PERIOD, new Object[0]);
return false;
}
list = this.m_networkPayloadsArray;
}
return ((list.size() < maxEventCount) || (maxEventCount < 0)) && !(maxEventCount == 0);
}
private void updateEventThresholdListeners() {
Log.Helper.LOGFUNC(this);
int maxEventCount = getMaxEventCount("com.ea.nimble.network");
if (maxEventCount > 0) {
if (this.m_networkMetricsArray.size() >= ((int) (maxEventCount * 0.75d))) {
HashMap hashMap = new HashMap();
hashMap.put("eventType", "com.ea.nimble.network");
Utility.sendBroadcast(IOperationalTelemetryDispatch.NOTIFICATION_OT_EVENT_THRESHOLD_WARNING, hashMap);
Log.Helper.LOGV(this, "updateEventThresholdListeners, notifying listeners event queue is approaching threshold.", new Object[0]);
}
}
int maxEventCount2 = getMaxEventCount(IOperationalTelemetryDispatch.EVENTTYPE_TRACKING_SYNERGY_PAYLOADS);
if (maxEventCount2 > 0) {
if (this.m_networkPayloadsArray.size() >= ((int) (maxEventCount2 * 0.75d))) {
HashMap hashMap2 = new HashMap();
hashMap2.put("eventType", IOperationalTelemetryDispatch.EVENTTYPE_TRACKING_SYNERGY_PAYLOADS);
Utility.sendBroadcast(IOperationalTelemetryDispatch.NOTIFICATION_OT_EVENT_THRESHOLD_WARNING, hashMap2);
Log.Helper.LOGV(this, "updateEventThresholdListeners, notifying listeners event queue is approaching threshold.", new Object[0]);
}
}
}
private void trimEventQueue(String str) {
List<OperationalTelemetryEvent> list;
Log.Helper.LOGFUNC(this);
int maxEventCount = getMaxEventCount(str);
if (str.equals("com.ea.nimble.network")) {
list = this.m_networkMetricsArray;
} else {
if (!str.equals(IOperationalTelemetryDispatch.EVENTTYPE_TRACKING_SYNERGY_PAYLOADS)) {
Log.Helper.LOGE(this, "trimEventQueue, unsupported OT eventType, " + str + Consts.STRING_PERIOD, new Object[0]);
return;
}
list = this.m_networkPayloadsArray;
}
if (maxEventCount >= 0 && list.size() != 0 && list.size() - maxEventCount >= 0) {
synchronized (this) {
try {
if (maxEventCount == 0) {
list.clear();
} else {
int i = maxEventCount / 2;
Log.Helper.LOGI(this, "trimEventQueues, queue threshold surprassed, purging " + i + " older events ", new Object[0]);
for (int i2 = 0; i2 < i; i2++) {
purgeOldestEvent(list);
}
}
} catch (Throwable th) {
throw th;
}
}
}
}
private void purgeOldestEvent(List<OperationalTelemetryEvent> list) {
Log.Helper.LOGFUNC(this);
synchronized (this) {
try {
if (list.size() == 0) {
Log.Helper.LOGD(this, "purgeOldestEvent called with empty event array.", new Object[0]);
return;
}
OperationalTelemetryEvent operationalTelemetryEvent = null;
for (OperationalTelemetryEvent operationalTelemetryEvent2 : list) {
if (operationalTelemetryEvent == null || operationalTelemetryEvent2.getLoggedTime().before(operationalTelemetryEvent.getLoggedTime())) {
operationalTelemetryEvent = operationalTelemetryEvent2;
}
}
if (operationalTelemetryEvent != null) {
list.remove(operationalTelemetryEvent);
}
} catch (Throwable th) {
throw th;
}
}
}
}