- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
442 lines
19 KiB
Java
442 lines
19 KiB
Java
package com.ea.nimble;
|
|
|
|
import android.content.Intent;
|
|
import android.content.pm.Signature;
|
|
import android.content.pm.SigningInfo;
|
|
import android.os.Build;
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import com.ea.nimble.IApplicationLifecycle;
|
|
import com.ea.nimble.Log;
|
|
import com.ea.nimble.bridge.NimbleCppApplicationLifeCycle;
|
|
import com.ea.nimble.bridge.NimbleCppComponentRegistrar;
|
|
import com.unity3d.ads.core.data.datasource.AndroidStaticDeviceInfoDataSource;
|
|
import com.unity3d.services.ads.gmascar.bridges.mobileads.MobileAdsBridgeBase;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import java.security.cert.CertificateException;
|
|
import java.security.cert.CertificateFactory;
|
|
import java.security.cert.X509Certificate;
|
|
import java.util.Map;
|
|
import javax.security.auth.x500.X500Principal;
|
|
|
|
/* loaded from: classes2.dex */
|
|
class BaseCore implements IApplicationLifecycle.ApplicationLifecycleCallbacks {
|
|
public static final String NIMBLE_LOG_SETTING = "setting::log";
|
|
public static final String NIMBLE_SERVER_CONFIG = "com.ea.nimble.configuration";
|
|
protected ApplicationEnvironmentImpl m_applicationEnvironment;
|
|
protected IApplicationLifecycle m_applicationLifecycle;
|
|
protected ComponentManager m_componentManager;
|
|
protected NimbleConfiguration m_configuration;
|
|
protected LogImpl m_log;
|
|
protected PersistenceServiceImpl m_persistenceService;
|
|
protected State m_state;
|
|
public static final String[] NIMBLE_COMPONENTS = {"com.ea.nimble.tracking.Tracking", "com.ea.nimble.tracking.NimbleTrackingSynergyComponent", "com.ea.nimble.tracking.TrackingEventWrangler", "com.ea.nimble.identity.NimbleIdentityImpl", "com.ea.nimble.identity.AuthenticatorOrigin", "com.ea.nimble.identity.AuthenticatorFacebook", "com.ea.nimble.identity.AuthenticatorAnonymous", "com.ea.nimble.friends.NimbleFriendsImpl", "com.ea.nimble.friends.NimbleOriginFriendsServiceImpl", "com.ea.nimble.origin.Origin", "com.ea.nimble.Facebook", "com.ea.nimble.NimbleAndroidFacebook", "com.ea.nimble.NimbleAndroidGoogleServiceImpl", "com.ea.nimble.mtx.googleplay.GooglePlay", "com.ea.nimble.mtx.amazon.AmazonStore", "com.ea.nimble.pushtng.PushNotification", NimbleCppApplicationLifeCycle.COMPONENT_ID, NimbleCppComponentRegistrar.COMPONENT_ID};
|
|
protected static BaseCore s_core = null;
|
|
protected static boolean s_coreDestroyed = false;
|
|
|
|
public enum State {
|
|
INACTIVE,
|
|
AUTO_SETUP,
|
|
MANUAL_SETUP,
|
|
MANUAL_TEARDOWN,
|
|
QUITTING,
|
|
DESTROY,
|
|
FAKE_DESTROY
|
|
}
|
|
|
|
public IApplicationEnvironment getApplicationEnvironment() {
|
|
return this.m_applicationEnvironment;
|
|
}
|
|
|
|
public IApplicationLifecycle getApplicationLifecycle() {
|
|
return this.m_applicationLifecycle;
|
|
}
|
|
|
|
public ComponentManager getComponentManager() {
|
|
return this.m_componentManager;
|
|
}
|
|
|
|
public NimbleConfiguration getConfiguration() {
|
|
return this.m_configuration;
|
|
}
|
|
|
|
public ILog getLog() {
|
|
return this.m_log;
|
|
}
|
|
|
|
public IPersistenceService getPersistenceService() {
|
|
return this.m_persistenceService;
|
|
}
|
|
|
|
private void initialize() {
|
|
this.m_state = State.INACTIVE;
|
|
loadConfiguration();
|
|
this.m_componentManager = new ComponentManager();
|
|
this.m_applicationLifecycle = new ApplicationLifecycleImpl(this);
|
|
this.m_applicationEnvironment = new ApplicationEnvironmentImpl(this);
|
|
LogImpl logImpl = (LogImpl) Log.getComponent();
|
|
this.m_log = logImpl;
|
|
logImpl.connectToCore(this);
|
|
this.m_persistenceService = new PersistenceServiceImpl();
|
|
NetworkImpl networkImpl = new NetworkImpl();
|
|
SynergyEnvironmentImpl synergyEnvironmentImpl = new SynergyEnvironmentImpl(this);
|
|
SynergyNetworkImpl synergyNetworkImpl = new SynergyNetworkImpl();
|
|
SynergyIdManagerImpl synergyIdManagerImpl = new SynergyIdManagerImpl();
|
|
OperationalTelemetryDispatchImpl operationalTelemetryDispatchImpl = new OperationalTelemetryDispatchImpl();
|
|
NimbleLocalNotificationsImpl nimbleLocalNotificationsImpl = new NimbleLocalNotificationsImpl();
|
|
this.m_componentManager.registerComponent(this.m_applicationEnvironment, ApplicationEnvironment.COMPONENT_ID);
|
|
this.m_componentManager.registerComponent(this.m_log, Log.COMPONENT_ID);
|
|
this.m_componentManager.registerComponent(this.m_persistenceService, PersistenceService.COMPONENT_ID);
|
|
this.m_componentManager.registerComponent(networkImpl, "com.ea.nimble.network");
|
|
this.m_componentManager.registerComponent(synergyIdManagerImpl, SynergyIdManager.COMPONENT_ID);
|
|
this.m_componentManager.registerComponent(synergyEnvironmentImpl, SynergyEnvironment.COMPONENT_ID);
|
|
this.m_componentManager.registerComponent(synergyNetworkImpl, SynergyNetwork.COMPONENT_ID);
|
|
this.m_componentManager.registerComponent(operationalTelemetryDispatchImpl, OperationalTelemetryDispatch.COMPONENT_ID);
|
|
this.m_componentManager.registerComponent(nimbleLocalNotificationsImpl, NimbleLocalNotifications.COMPONENT_ID);
|
|
for (String str : NIMBLE_COMPONENTS) {
|
|
try {
|
|
Method declaredMethod = Class.forName(str).getDeclaredMethod(MobileAdsBridgeBase.initializeMethodName, new Class[0]);
|
|
declaredMethod.setAccessible(true);
|
|
declaredMethod.invoke(null, new Object[0]);
|
|
} catch (ClassNotFoundException unused) {
|
|
Log.Helper.LOGD(this, "Component " + str + " not found", new Object[0]);
|
|
} catch (IllegalAccessException unused2) {
|
|
Log.Helper.LOGE(this, "Method " + str + ".initialize() is not accessible", new Object[0]);
|
|
} catch (IllegalArgumentException unused3) {
|
|
Log.Helper.LOGE(this, "Method " + str + ".initialize() should take no arguments", new Object[0]);
|
|
} catch (NoSuchMethodException unused4) {
|
|
Log.Helper.LOGE(this, "No method " + str + ".initialize()", new Object[0]);
|
|
} catch (NullPointerException unused5) {
|
|
Log.Helper.LOGE(this, "Method " + str + ".initialize() should be static", new Object[0]);
|
|
} catch (InvocationTargetException e) {
|
|
Log.Helper.LOGE(this, "Method " + str + ".initialize() threw an exception", new Object[0]);
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
if (isAppSigned()) {
|
|
return;
|
|
}
|
|
android.util.Log.e(Global.NIMBLE_ID, "This application is NOT signed with a valid certificate. MTX may not work correctly with this application");
|
|
}
|
|
|
|
public Map<String, String> getSettings(String str) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
if (!str.equals(NIMBLE_LOG_SETTING)) {
|
|
return null;
|
|
}
|
|
int identifier = ApplicationEnvironment.getComponent().getApplicationContext().getResources().getIdentifier("nimble_log", "xml", ApplicationEnvironment.getCurrentActivity().getPackageName());
|
|
if (identifier == 0) {
|
|
return null;
|
|
}
|
|
return Utility.parseXmlFile(identifier);
|
|
}
|
|
|
|
public static synchronized BaseCore getInstance() {
|
|
BaseCore baseCore;
|
|
synchronized (BaseCore.class) {
|
|
try {
|
|
if (s_core == null) {
|
|
if (s_coreDestroyed) {
|
|
throw new AssertionError("Cannot revive destroyed BaseCore, please utilizesetupNimble() and tearDownNimble() explicitly to extend longevity to match your expectation.");
|
|
}
|
|
String.format("NIMBLE VERSION %s (Build %s)", Global.NIMBLE_RELEASE_VERSION, Global.NIMBLE_SDK_VERSION);
|
|
BaseCore baseCore2 = new BaseCore();
|
|
s_core = baseCore2;
|
|
baseCore2.initialize();
|
|
}
|
|
baseCore = s_core;
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
return baseCore;
|
|
}
|
|
|
|
/* renamed from: com.ea.nimble.BaseCore$2, reason: invalid class name */
|
|
public static /* synthetic */ class AnonymousClass2 {
|
|
static final /* synthetic */ int[] $SwitchMap$com$ea$nimble$BaseCore$State;
|
|
|
|
static {
|
|
int[] iArr = new int[State.values().length];
|
|
$SwitchMap$com$ea$nimble$BaseCore$State = iArr;
|
|
try {
|
|
iArr[State.INACTIVE.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$ea$nimble$BaseCore$State[State.MANUAL_TEARDOWN.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$ea$nimble$BaseCore$State[State.DESTROY.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$ea$nimble$BaseCore$State[State.AUTO_SETUP.ordinal()] = 4;
|
|
} catch (NoSuchFieldError unused4) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$ea$nimble$BaseCore$State[State.MANUAL_SETUP.ordinal()] = 5;
|
|
} catch (NoSuchFieldError unused5) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$ea$nimble$BaseCore$State[State.QUITTING.ordinal()] = 6;
|
|
} catch (NoSuchFieldError unused6) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$ea$nimble$BaseCore$State[State.FAKE_DESTROY.ordinal()] = 7;
|
|
} catch (NoSuchFieldError unused7) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public BaseCore activeValidate() {
|
|
Log.Helper.LOGFUNC(this);
|
|
int i = AnonymousClass2.$SwitchMap$com$ea$nimble$BaseCore$State[this.m_state.ordinal()];
|
|
if (i == 1) {
|
|
Log.Helper.LOGF(this, "Access NimbleBaseCore before setup, call setupNimble() explicitly to activate it.", new Object[0]);
|
|
return null;
|
|
}
|
|
if (i == 2) {
|
|
Log.Helper.LOGF(this, "Access NimbleBaseCore after clean up, call setupNimble() explicitly again to activate it.", new Object[0]);
|
|
return null;
|
|
}
|
|
if (i != 3) {
|
|
return this;
|
|
}
|
|
Log.Helper.LOGF(this, "Accessing component after destroy, only static components are available right now.", new Object[0]);
|
|
return null;
|
|
}
|
|
|
|
public void setup() {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
switch (AnonymousClass2.$SwitchMap$com$ea$nimble$BaseCore$State[this.m_state.ordinal()]) {
|
|
case 1:
|
|
case 2:
|
|
this.m_componentManager.setup();
|
|
this.m_state = State.MANUAL_SETUP;
|
|
Utility.sendBroadcast(Global.NOTIFICATION_COMPONENT_INDEPENDENT_SETUP_FINISHED);
|
|
this.m_componentManager.restore();
|
|
break;
|
|
case 3:
|
|
case 5:
|
|
case 6:
|
|
case 7:
|
|
Log.Helper.LOGF(this, "Multiple setupNimble() calls without teardownNimble().", new Object[0]);
|
|
break;
|
|
case 4:
|
|
this.m_state = State.MANUAL_SETUP;
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void teardown() {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
switch (AnonymousClass2.$SwitchMap$com$ea$nimble$BaseCore$State[this.m_state.ordinal()]) {
|
|
case 1:
|
|
case 4:
|
|
Log.Helper.LOGF(this, "Cannot teardownNimble() before setupNimble().", new Object[0]);
|
|
break;
|
|
case 2:
|
|
case 3:
|
|
Log.Helper.LOGF(this, "Multiple teardownNimble() calls without setupNibmle().", new Object[0]);
|
|
break;
|
|
case 5:
|
|
this.m_componentManager.cleanup();
|
|
this.m_state = State.MANUAL_TEARDOWN;
|
|
this.m_componentManager.teardown();
|
|
break;
|
|
case 6:
|
|
case 7:
|
|
this.m_componentManager.cleanup();
|
|
this.m_state = State.MANUAL_TEARDOWN;
|
|
this.m_componentManager.teardown();
|
|
destroy();
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void restartWithConfiguration(final NimbleConfiguration nimbleConfiguration) {
|
|
Log.Helper.LOGPUBLICFUNC(this);
|
|
Log.Helper.LOGE(this, ">>>>>>>>>>>>>>>>>>>>>>", new Object[0]);
|
|
Log.Helper.LOGE(this, "restartWithConfiguration should not be used in an integration. This function is for QA testing purposes.", new Object[0]);
|
|
Log.Helper.LOGE(this, ">>>>>>>>>>>>>>>>>>>>>>", new Object[0]);
|
|
if (nimbleConfiguration == NimbleConfiguration.UNKNOWN) {
|
|
Log.Helper.LOGE(this, "Cannot restart nimble with unknown configuration", new Object[0]);
|
|
} else {
|
|
new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.ea.nimble.BaseCore.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
switch (AnonymousClass2.$SwitchMap$com$ea$nimble$BaseCore$State[BaseCore.this.m_state.ordinal()]) {
|
|
case 1:
|
|
case 2:
|
|
case 3:
|
|
Log.Helper.LOGF(this, "Should not happen, getInstance should ensure active instance", new Object[0]);
|
|
break;
|
|
case 4:
|
|
case 5:
|
|
BaseCore.this.m_componentManager.cleanup();
|
|
BaseCore.this.m_componentManager.teardown();
|
|
BaseCore baseCore = BaseCore.this;
|
|
baseCore.m_configuration = nimbleConfiguration;
|
|
baseCore.m_componentManager.setup();
|
|
Utility.sendBroadcast(Global.NOTIFICATION_COMPONENT_INDEPENDENT_SETUP_FINISHED);
|
|
BaseCore.this.m_componentManager.restore();
|
|
break;
|
|
case 6:
|
|
case 7:
|
|
Log.Helper.LOGF(this, "Cannot restart Nimble when app is quiting", new Object[0]);
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.IApplicationLifecycle.ApplicationLifecycleCallbacks
|
|
public void onApplicationLaunch(Intent intent) {
|
|
State state = this.m_state;
|
|
if (state == State.INACTIVE || state == State.DESTROY) {
|
|
this.m_componentManager.setup();
|
|
Utility.sendBroadcast(Global.NOTIFICATION_COMPONENT_INDEPENDENT_SETUP_FINISHED);
|
|
this.m_state = State.AUTO_SETUP;
|
|
try {
|
|
this.m_componentManager.restore();
|
|
return;
|
|
} catch (AssertionError e) {
|
|
this.m_state = State.INACTIVE;
|
|
throw e;
|
|
}
|
|
}
|
|
if (state == State.FAKE_DESTROY) {
|
|
this.m_componentManager.resume();
|
|
this.m_state = State.AUTO_SETUP;
|
|
} else if (state == State.QUITTING) {
|
|
this.m_componentManager.resume();
|
|
this.m_state = State.MANUAL_SETUP;
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.IApplicationLifecycle.ApplicationLifecycleCallbacks
|
|
public void onApplicationSuspend() {
|
|
State state = this.m_state;
|
|
if (state == State.MANUAL_SETUP || state == State.AUTO_SETUP) {
|
|
this.m_componentManager.suspend();
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.IApplicationLifecycle.ApplicationLifecycleCallbacks
|
|
public void onApplicationResume() {
|
|
State state = this.m_state;
|
|
if (state == State.MANUAL_SETUP || state == State.AUTO_SETUP) {
|
|
this.m_componentManager.resume();
|
|
}
|
|
}
|
|
|
|
@Override // com.ea.nimble.IApplicationLifecycle.ApplicationLifecycleCallbacks
|
|
public void onApplicationQuit() {
|
|
int i = AnonymousClass2.$SwitchMap$com$ea$nimble$BaseCore$State[this.m_state.ordinal()];
|
|
if (i == 1) {
|
|
Log.Helper.LOGF(this, "No app start before app quit, something must be wrong.", new Object[0]);
|
|
return;
|
|
}
|
|
if (i != 3) {
|
|
if (i == 4) {
|
|
this.m_componentManager.suspend();
|
|
this.m_state = State.FAKE_DESTROY;
|
|
return;
|
|
} else if (i == 5) {
|
|
this.m_componentManager.suspend();
|
|
this.m_state = State.QUITTING;
|
|
return;
|
|
} else if (i != 6) {
|
|
return;
|
|
}
|
|
}
|
|
Log.Helper.LOGF(this, "Double app quit, something must be wrong.", new Object[0]);
|
|
}
|
|
|
|
public static void injectMock(BaseCore baseCore) {
|
|
Log.Helper.LOGFUNCS("BaseCore");
|
|
if (baseCore == null) {
|
|
s_core = null;
|
|
s_coreDestroyed = false;
|
|
} else {
|
|
s_core = baseCore;
|
|
s_coreDestroyed = false;
|
|
}
|
|
}
|
|
|
|
private void destroy() {
|
|
Log.Helper.LOGD(this, "NIMBLE DESTROY for Android will keep Core and Static components alive", new Object[0]);
|
|
}
|
|
|
|
private void loadConfiguration() {
|
|
Log.Helper.LOGFUNCS("BaseCore");
|
|
String configValueAsString = NimbleApplicationConfiguration.getConfigValueAsString(NIMBLE_SERVER_CONFIG);
|
|
if (Utility.validString(configValueAsString)) {
|
|
NimbleConfiguration fromName = NimbleConfiguration.fromName(configValueAsString);
|
|
this.m_configuration = fromName;
|
|
if (fromName != NimbleConfiguration.UNKNOWN && fromName != NimbleConfiguration.CUSTOMIZED) {
|
|
return;
|
|
}
|
|
}
|
|
android.util.Log.e(Global.NIMBLE_ID, "WARNING! Cannot find valid NimbleConfiguration from AndroidManifest.xml");
|
|
this.m_configuration = NimbleConfiguration.LIVE;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
private boolean isAppSigned() {
|
|
boolean z;
|
|
Signature[] signatureArr;
|
|
SigningInfo signingInfo;
|
|
X500Principal x500Principal = new X500Principal("CN=Android Debug,O=Android,C=US");
|
|
int i = 0;
|
|
try {
|
|
if (Build.VERSION.SDK_INT >= 33) {
|
|
signingInfo = Utility.getPackageInfo(134217728).signingInfo;
|
|
signatureArr = signingInfo.getApkContentsSigners();
|
|
} else {
|
|
signatureArr = Utility.getPackageInfo(64).signatures;
|
|
}
|
|
int length = signatureArr.length;
|
|
z = 0;
|
|
while (i < length) {
|
|
try {
|
|
z = ((X509Certificate) CertificateFactory.getInstance(AndroidStaticDeviceInfoDataSource.CERTIFICATE_TYPE_X509).generateCertificate(new ByteArrayInputStream(signatureArr[i].toByteArray()))).getSubjectX500Principal().equals(x500Principal);
|
|
if (z != 0) {
|
|
break;
|
|
}
|
|
i++;
|
|
z = z;
|
|
} catch (CertificateException e) {
|
|
e = e;
|
|
i = z ? 1 : 0;
|
|
e.printStackTrace();
|
|
z = i;
|
|
return !z;
|
|
} catch (Exception e2) {
|
|
e = e2;
|
|
i = z ? 1 : 0;
|
|
e.printStackTrace();
|
|
z = i;
|
|
return !z;
|
|
}
|
|
}
|
|
} catch (CertificateException e3) {
|
|
e = e3;
|
|
} catch (Exception e4) {
|
|
e = e4;
|
|
}
|
|
return !z;
|
|
}
|
|
|
|
public boolean isActive() {
|
|
Log.Helper.LOGPUBLICFUNCS("BaseCore");
|
|
State state = this.m_state;
|
|
return state == State.AUTO_SETUP || state == State.MANUAL_SETUP;
|
|
}
|
|
}
|