package com.adobe.marketing.mobile;

import android.app.Activity;
import android.app.Application;
import com.adobe.marketing.mobile.Event;
import com.adobe.marketing.mobile.internal.configuration.ConfigurationExtension;
import com.google.firebase.remoteconfig.RemoteConfigConstants;
import dn.l;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import qg.a;
import rm.n0;
import wg.i0;
import wg.t;

/* loaded from: classes4.dex */
public final class MobileCore {

    /* renamed from: a, reason: collision with root package name */
    static AtomicBoolean f12191a = new AtomicBoolean(false);

    /* renamed from: com.adobe.marketing.mobile.MobileCore$1, reason: invalid class name */
    /* loaded from: classes4.dex */
    class AnonymousClass1 implements AdobeCallbackWithError<Event> {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ AdobeCallback f12192a;

        AnonymousClass1(AdobeCallback adobeCallback) {
            this.f12192a = adobeCallback;
        }

        @Override // com.adobe.marketing.mobile.AdobeCallbackWithError
        public void b(AdobeError adobeError) {
            AdobeCallback adobeCallback = this.f12192a;
            if (adobeCallback instanceof AdobeCallbackWithError) {
                ((AdobeCallbackWithError) adobeCallback).b(AdobeError.f12147s);
            } else {
                adobeCallback.a(null);
            }
        }

        @Override // com.adobe.marketing.mobile.AdobeCallback
        /* renamed from: c, reason: merged with bridge method [inline-methods] */
        public void a(Event event) {
            this.f12192a.a(MobilePrivacyStatus.fromString(ch.b.k(event.o(), "global.privacy", null)));
        }
    }

    /* renamed from: com.adobe.marketing.mobile.MobileCore$2, reason: invalid class name */
    /* loaded from: classes4.dex */
    class AnonymousClass2 implements AdobeCallbackWithError<Event> {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ AdobeCallback f12193a;

        AnonymousClass2(AdobeCallback adobeCallback) {
            this.f12193a = adobeCallback;
        }

        @Override // com.adobe.marketing.mobile.AdobeCallbackWithError
        public void b(AdobeError adobeError) {
            AdobeCallback adobeCallback = this.f12193a;
            if (adobeCallback instanceof AdobeCallbackWithError) {
                ((AdobeCallbackWithError) adobeCallback).b(AdobeError.f12147s);
            } else {
                adobeCallback.a("{}");
            }
        }

        @Override // com.adobe.marketing.mobile.AdobeCallback
        /* renamed from: c, reason: merged with bridge method [inline-methods] */
        public void a(Event event) {
            this.f12193a.a(ch.b.k(event.o(), "config.allIdentifiers", "{}"));
        }
    }

    /* renamed from: com.adobe.marketing.mobile.MobileCore$3, reason: invalid class name */
    /* loaded from: classes4.dex */
    class AnonymousClass3 implements AdobeCallbackWithError<Event> {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ AdobeCallback f12194a;

        AnonymousClass3(AdobeCallback adobeCallback) {
            this.f12194a = adobeCallback;
        }

        @Override // com.adobe.marketing.mobile.AdobeCallbackWithError
        public void b(AdobeError adobeError) {
            AdobeCallback adobeCallback = this.f12194a;
            if (adobeCallback instanceof AdobeCallbackWithError) {
                ((AdobeCallbackWithError) adobeCallback).b(AdobeError.f12147s);
            } else {
                adobeCallback.a(null);
            }
        }

        @Override // com.adobe.marketing.mobile.AdobeCallback
        /* renamed from: c, reason: merged with bridge method [inline-methods] */
        public void a(Event event) {
            this.f12194a.a(event);
        }
    }

    /* renamed from: com.adobe.marketing.mobile.MobileCore$4, reason: invalid class name */
    /* loaded from: classes4.dex */
    static /* synthetic */ class AnonymousClass4 {

        /* renamed from: a, reason: collision with root package name */
        static final /* synthetic */ int[] f12195a;

        static {
            int[] iArr = new int[LoggingMode.values().length];
            f12195a = iArr;
            try {
                iArr[LoggingMode.ERROR.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f12195a[LoggingMode.WARNING.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f12195a[LoggingMode.DEBUG.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                f12195a[LoggingMode.VERBOSE.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
        }
    }

    private MobileCore() {
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static void c(Activity activity) {
        DataMarshaller dataMarshaller = new DataMarshaller();
        dataMarshaller.d(activity);
        Map c10 = dataMarshaller.c();
        if (c10 == null || c10.isEmpty()) {
            t.a("MobileCore", "MobileCore", "collectData: Could not dispatch generic data event, data is null or empty.", new Object[0]);
        } else {
            f(new Event.Builder("CollectData", "com.adobe.eventType.generic.data", "com.adobe.eventSource.os").d(c10).a());
        }
    }

    public static void d(Map map) {
        if (map == null || map.isEmpty()) {
            t.b("MobileCore", "MobileCore", "collectData: Could not dispatch generic data event, data is null or empty.", new Object[0]);
        } else {
            f(new Event.Builder("CollectData", "com.adobe.eventType.generic.data", "com.adobe.eventSource.os").d(map).a());
        }
    }

    public static void e(String str) {
        if (str == null) {
            t.b("MobileCore", "MobileCore", "configureWithAppID failed - appId is null.", new Object[0]);
            return;
        }
        HashMap hashMap = new HashMap();
        hashMap.put("config.appId", str);
        f(new Event.Builder("Configure with AppID", "com.adobe.eventType.configuration", "com.adobe.eventSource.requestContent").d(hashMap).a());
    }

    public static void f(Event event) {
        if (event == null) {
            t.b("MobileCore", "MobileCore", "Failed to dispatchEvent - event is null", new Object[0]);
        } else {
            qg.a.f33690q.a().y(event);
        }
    }

    public static String g() {
        WrapperType L = qg.a.f33690q.a().L();
        if (L == WrapperType.NONE) {
            return "2.2.2";
        }
        return "2.2.2-" + L.getWrapperTag();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static /* synthetic */ n0 h(ExtensionErrorCallback extensionErrorCallback, qg.c cVar) {
        if (cVar == qg.c.None) {
            return null;
        }
        ExtensionError extensionError = cVar == qg.c.InvalidExtensionName ? ExtensionError.f12178w : cVar == qg.c.DuplicateExtensionName ? ExtensionError.f12179x : ExtensionError.f12177v;
        if (extensionErrorCallback != null) {
            extensionErrorCallback.a(extensionError);
        }
        return null;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static /* synthetic */ n0 i(AdobeCallback adobeCallback) {
        if (adobeCallback != null) {
            adobeCallback.a(null);
        }
        return null;
    }

    public static void j() {
        HashMap hashMap = new HashMap();
        hashMap.put("action", "pause");
        f(new Event.Builder("LifecyclePause", "com.adobe.eventType.generic.lifecycle", "com.adobe.eventSource.requestContent").d(hashMap).a());
    }

    public static void k(Map map) {
        HashMap hashMap = new HashMap();
        hashMap.put("action", "start");
        hashMap.put("additionalcontextdata", map);
        f(new Event.Builder("LifecycleResume", "com.adobe.eventType.generic.lifecycle", "com.adobe.eventSource.requestContent").d(hashMap).a());
    }

    public static boolean l(Class cls, final ExtensionErrorCallback extensionErrorCallback) {
        if (!f12191a.get()) {
            t.b("MobileCore", "MobileCore", "Failed to registerExtension - setApplication not called", new Object[0]);
            return false;
        }
        if (cls == null) {
            t.b("MobileCore", "MobileCore", "Failed to registerExtension - extensionClass is null", new Object[0]);
            return false;
        }
        qg.a.f33690q.a().P(cls, new l() { // from class: com.adobe.marketing.mobile.f
            @Override // dn.l
            public final Object invoke(Object obj) {
                n0 h10;
                h10 = MobileCore.h(ExtensionErrorCallback.this, (qg.c) obj);
                return h10;
            }
        });
        return true;
    }

    public static void m(Application application) {
        if (application == null) {
            t.b("MobileCore", "MobileCore", "setApplication failed - application is null", new Object[0]);
            return;
        }
        if (f12191a.getAndSet(true)) {
            t.a("MobileCore", "MobileCore", "Ignoring as setApplication was already called.", new Object[0]);
            return;
        }
        try {
            new Date().toString();
        } catch (AssertionError | Exception unused) {
        }
        i0.f().a().d(application);
        zg.a.f53467v.g(new zg.b() { // from class: com.adobe.marketing.mobile.e
            @Override // zg.b
            public final void a(Object obj) {
                MobileCore.c((Activity) obj);
            }
        });
        try {
            new V4ToV5Migration().f();
        } catch (Exception e10) {
            t.b("MobileCore", "MobileCore", "V4 to V5 migration failed - " + e10.getLocalizedMessage(), new Object[0]);
        }
        a.C0782a c0782a = qg.a.f33690q;
        c0782a.a().M();
        c0782a.a().O(ConfigurationExtension.class);
    }

    public static void n(LoggingMode loggingMode) {
        if (loggingMode == null) {
            t.b("MobileCore", "MobileCore", "setLogLevel failed - mode is null", new Object[0]);
        } else {
            t.d(loggingMode);
        }
    }

    public static void o(final AdobeCallback adobeCallback) {
        t.f("MobileCore", "MobileCore", "Use 'MobileCore.registerExtensions' method to initialize AEP SDK. Refer install instructions in Tags mobile property corresponding to this application.", new Object[0]);
        if (f12191a.get()) {
            qg.a.f33690q.a().U(new dn.a() { // from class: com.adobe.marketing.mobile.d
                @Override // dn.a
                public final Object invoke() {
                    n0 i10;
                    i10 = MobileCore.i(AdobeCallback.this);
                    return i10;
                }
            });
        } else {
            t.b("MobileCore", "MobileCore", "Failed to registerExtension - setApplication not called", new Object[0]);
        }
    }

    public static void p(String str, Map map) {
        HashMap hashMap = new HashMap();
        if (str == null) {
            str = "";
        }
        hashMap.put("action", str);
        if (map == null) {
            map = new HashMap();
        }
        hashMap.put("contextdata", map);
        f(new Event.Builder("Analytics Track", "com.adobe.eventType.generic.track", "com.adobe.eventSource.requestContent").d(hashMap).a());
    }

    public static void q(String str, Map map) {
        HashMap hashMap = new HashMap();
        if (str == null) {
            str = "";
        }
        hashMap.put(RemoteConfigConstants.ResponseFieldKey.STATE, str);
        if (map == null) {
            map = new HashMap();
        }
        hashMap.put("contextdata", map);
        f(new Event.Builder("Analytics Track", "com.adobe.eventType.generic.track", "com.adobe.eventSource.requestContent").d(hashMap).a());
    }
}
