package com.vinfast.companion.map.manager;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
@kotlin.Metadata(d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\u0018\u00002\u00020\u0001B\u001f\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004\u0012\u0006\u0010\u0006\u001a\u00020\u0004¢\u0006\u0004\b\u0007\u0010\bJ\u000f\u0010\n\u001a\u00020\tH\u0002¢\u0006\u0004\b\n\u0010\u000bJ\u000f\u0010\f\u001a\u00020\tH\u0002¢\u0006\u0004\b\f\u0010\u000bJ\u000f\u0010\r\u001a\u00020\tH\u0002¢\u0006\u0004\b\r\u0010\u000bJ\u000f\u0010\u000e\u001a\u00020\tH\u0016¢\u0006\u0004\b\u000e\u0010\u000bR\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u000f\u0010\u0010R\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u000e\u0010\u0011R\u0014\u0010\u0006\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0012\u0010\u0011R\u0016\u0010\u0015\u001a\u0004\u0018\u00010\u00138VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u0012\u0010\u0014R\u0016\u0010\u0018\u001a\u0004\u0018\u00010\u00168VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u000f\u0010\u0017¨\u0006\u0019"}, d2 = {"Lcom/vinfast/companion/map/manager/HereManagerImpl;", "Lcom/vinfast/companion/map/manager/HEREManager;", "Landroid/content/Context;", "context", "", "accessKeyID", "accessKeySecret", "<init>", "(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V", "", "g", "()V", "f", "e", "b", "a", "Landroid/content/Context;", "Ljava/lang/String;", "c", "Lcom/here/sdk/search/SearchEngine;", "()Lcom/here/sdk/search/SearchEngine;", "searchEngine", "Lcom/here/sdk/routing/RoutingEngine;", "()Lcom/here/sdk/routing/RoutingEngine;", "routingEngine", "hereSdk_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
public final class HereManagerImpl implements com.vinfast.companion.map.manager.HEREManager {

    /* JADX INFO: renamed from: a, reason: from kotlin metadata */
    private final android.content.Context context;

    /* JADX INFO: renamed from: b, reason: from kotlin metadata */
    private final java.lang.String accessKeyID;

    /* JADX INFO: renamed from: c, reason: from kotlin metadata */
    private final java.lang.String accessKeySecret;

    public HereManagerImpl(android.content.Context context, java.lang.String str, java.lang.String str2) {
        kotlin.jvm.internal.Intrinsics.l(context, "context");
        kotlin.jvm.internal.Intrinsics.l(str, "accessKeyID");
        kotlin.jvm.internal.Intrinsics.l(str2, "accessKeySecret");
        this.context = context;
        this.accessKeyID = str;
        this.accessKeySecret = str2;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void e() {
        timber.log.Timber.a.a("[HERE_LOGGER] ===> dispose here sdk", new java.lang.Object[0]);
        com.here.sdk.core.engine.SDKNativeEngine sharedInstance = com.here.sdk.core.engine.SDKNativeEngine.getSharedInstance();
        if (sharedInstance != null) {
            sharedInstance.dispose();
        }
        com.here.sdk.core.engine.SDKNativeEngine.setSharedInstance((com.here.sdk.core.engine.SDKNativeEngine) null);
    }

    private final void f() {
        try {
            try {
                com.here.sdk.core.engine.AuthenticationMode authenticationModeWithKeySecret = com.here.sdk.core.engine.AuthenticationMode.withKeySecret(this.accessKeyID, this.accessKeySecret);
                kotlin.jvm.internal.Intrinsics.k(authenticationModeWithKeySecret, "withKeySecret(...)");
                com.here.sdk.core.engine.SDKOptions sDKOptions = new com.here.sdk.core.engine.SDKOptions(authenticationModeWithKeySecret);
                sDKOptions.politicalView = "VNM";
                com.here.sdk.mapview.MapView.setPrimaryLanguage(com.here.sdk.core.LanguageCode.VI_VN);
                com.here.sdk.core.engine.SDKNativeEngine.makeSharedInstance(this.context, sDKOptions);
                timber.log.Timber.a.a("[HERE_LOGGER] Initialized", new java.lang.Object[0]);
            } catch (com.here.sdk.core.errors.InstantiationErrorException e) {
                timber.log.Timber.Forest forest = timber.log.Timber.a;
                forest.a("[HERE_LOGGER] Initialization of HERE SDK failed: %s", new java.lang.Object[]{e.error.name()});
                forest.a("[HERE_LOGGER] Initialized", new java.lang.Object[0]);
            }
        } catch (java.lang.Throwable th) {
            timber.log.Timber.a.a("[HERE_LOGGER] Initialized", new java.lang.Object[0]);
            throw th;
        }
    }

    private final void g() {
        androidx.lifecycle.ProcessLifecycleOwner.i.a().getLifecycle().a(new androidx.lifecycle.DefaultLifecycleObserver() { // from class: com.vinfast.companion.map.manager.HereManagerImpl$observeAppLifecycle$1
            public /* bridge */ void E0(androidx.lifecycle.LifecycleOwner lifecycleOwner) {
                super.E0(lifecycleOwner);
            }

            public void onDestroy(androidx.lifecycle.LifecycleOwner owner) {
                kotlin.jvm.internal.Intrinsics.l(owner, "owner");
                super.onDestroy(owner);
                timber.log.Timber.a.j("💀 App is about to terminate.", new java.lang.Object[0]);
                this.a.e();
            }

            public /* bridge */ void onPause(androidx.lifecycle.LifecycleOwner lifecycleOwner) {
                super.onPause(lifecycleOwner);
            }

            public /* bridge */ void onResume(androidx.lifecycle.LifecycleOwner lifecycleOwner) {
                super.onResume(lifecycleOwner);
            }

            public /* bridge */ void onStart(androidx.lifecycle.LifecycleOwner lifecycleOwner) {
                super.onStart(lifecycleOwner);
            }

            public /* bridge */ void onStop(androidx.lifecycle.LifecycleOwner lifecycleOwner) {
                super.onStop(lifecycleOwner);
            }
        });
    }

    @Override // com.vinfast.companion.map.manager.HEREManager
    public com.here.sdk.routing.RoutingEngine a() {
        try {
            return new com.here.sdk.routing.RoutingEngine();
        } catch (com.here.sdk.core.errors.InstantiationErrorException e) {
            timber.log.Timber.a.c("[HERE_LOGGER] Initialization of `RouteEngine` failed: " + e.error.name(), new java.lang.Object[0]);
            return null;
        } catch (java.lang.Throwable th) {
            timber.log.Timber.a.c("[HERE_LOGGER] Initialization of `RouteEngine` failed: " + th.getLocalizedMessage(), new java.lang.Object[0]);
            return null;
        }
    }

    @Override // com.vinfast.companion.map.manager.HEREManager
    public void b() {
        g();
        f();
    }

    @Override // com.vinfast.companion.map.manager.HEREManager
    public com.here.sdk.search.SearchEngine c() {
        try {
            return new com.here.sdk.search.SearchEngine();
        } catch (com.here.sdk.core.errors.InstantiationErrorException e) {
            timber.log.Timber.a.c("[HERE_LOGGER] Initialization of `SearchEngine` failed: " + e.error.name(), new java.lang.Object[0]);
            return null;
        } catch (java.lang.Throwable th) {
            timber.log.Timber.a.c("[HERE_LOGGER] Initialization of `SearchEngine` failed: " + th.getLocalizedMessage(), new java.lang.Object[0]);
            return null;
        }
    }
}
