package com.ss.android.ugc.aweme.splash;

import X.070;
import X.0HH;
import X.1hK;
import X.2HX;
import X.2OR;
import X.2kf;
import X.2nK;
import X.3i8;
import X.4Ek;
import X.4U3;
import X.AnonymousClass8B3;
import X.AnonymousClass92R;
import X.AnonymousClass9BJ;
import X.AnonymousClass9K3;
import X.AnonymousClass9ZU;
import X.C03917eu;
import X.C43789Jh;
import X.C48019Zo;
import X.C48029Zp;
import X.Ept;
import X.FKe;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import com.bytedance.common.utility.collection.WeakHandler;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.common.MobClick;
import com.ss.android.ugc.aweme.initializer.AVServiceProxyImpl;
import com.ss.android.ugc.aweme.launcher.serviceimpl.crashsdk.CrashSdkImpl;
import com.ss.android.ugc.aweme.legoImp.task.UploadInstallEventTask;
import com.ss.android.ugc.aweme.legoImp.task.UploadSysStatusTask;

public class SplashActivity extends 1hK implements WeakHandler.IHandler {
    public static C03917eu sConfirmWelcomeType = C03917eu.FULL_SCREEN_WELCOME;
    public static boolean sShowWelcomeCheckBox;
    public boolean isFirstShow;
    public volatile boolean mAlive = true;
    public boolean mAllowAd = true;
    public Dialog mDialog = null;
    public boolean mDirectlyGoMain;
    public boolean mFirstResume = true;
    public final Handler mHandler = new WeakHandler(this);
    public boolean mInited;
    public boolean mJumped;
    public C48029Zp mSubmitPreloadHelper = new C48029Zp();
    public boolean mTrackSession;

    private void submitPreload() {
    }

    public void doInit() {
    }

    public boolean isSplashShowing() {
        return true;
    }

    public void onBackPressed() {
    }

    public void onDialogShowOrDismiss(DialogInterface dialogInterface, boolean z) {
    }

    public void onStop() {
        com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_aweme_lancet_ActivityEnterTransitionCoordinatorLancet_onStop(this);
    }

    public boolean quickLaunch() {
        return false;
    }

    public void com_ss_android_ugc_aweme_splash_SplashActivity__onStop$___twin___() {
        SplashActivity.super.onStop();
    }

    public void onStart() {
        SplashActivity.super.onStart();
    }

    public void tryShowAdAndGoNext() {
        goMainActivity();
    }

    public void goMainActivity() {
        goMainActivity((Bundle) null);
    }

    static {
        Covode.recordClassIndex(115504);
    }

    public static boolean enableSplashLaunchFix() {
        try {
            return 2OR.LIZ.LIZIZ.getEnableSplashLaunchFix().booleanValue();
        } catch (4Ek unused) {
            return true;
        }
    }

    private void hotStartIntercept() {
        if (isHotStart()) {
            AnonymousClass9ZU.LIZIZ.LIZ();
        }
    }

    public void tryInit() {
        if (!this.mInited) {
            doInit();
            this.mInited = true;
        }
    }

    public void onDestroy() {
        Dialog dialog = this.mDialog;
        if (dialog != null) {
            dialog.dismiss();
        }
        this.mHandler.removeMessages(100);
        this.mAlive = false;
        SplashActivity.super.onDestroy();
    }

    public void tryShowShortCutDlg() {
        2HX.LIZ.LIZ("method_splash_try_show_ad_duration", false);
        tryShowAdAndGoNext();
        2HX.LIZ.LIZIZ("method_splash_try_show_ad_duration", false);
    }

    private boolean isHotStart() {
        Intent intent = getIntent();
        if (!isTaskRoot() || intent == null || !intent.hasCategory("android.intent.category.LAUNCHER") || !"android.intent.action.MAIN".equals(intent.getAction())) {
            return false;
        }
        return true;
    }

    private void reportLaunchTime() {
        boolean z;
        long currentTimeMillis = System.currentTimeMillis() - 2HX.LIZ.LJFF;
        int LIZ = AnonymousClass9K3.LIZ();
        int LIZIZ = C43789Jh.LIZ().LIZIZ();
        if (LIZ != LIZIZ) {
            z = true;
        } else {
            z = false;
        }
        if (C48019Zo.LIZ().LIZ) {
            4U3 r1 = new 4U3();
            r1.LIZ(Ept.LIZ.getMobLaunchEventTask(z, currentTimeMillis));
            r1.LIZ();
        }
        if (LIZ == 0) {
            AnonymousClass9K3.LIZ(LIZIZ);
        }
    }

    /* JADX WARNING: type inference failed for: r3v0, types: [android.content.Context, com.ss.android.ugc.aweme.splash.SplashActivity] */
    public Intent getMainIntent() {
        Intent intent = getIntent();
        Intent intent2 = new Intent(this, AVServiceProxyImpl.createIAVServiceProxybyMonsterPlugin(false).getApplicationService().LIZLLL());
        intent2.setFlags(335544320);
        if (intent != null) {
            intent2.setAction(intent.getAction());
        }
        AnonymousClass92R.LIZ(intent, intent2);
        if (!(intent == null || INVOKEVIRTUAL_com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_aweme_lancet_IntentLancet_getExtras(intent) == null)) {
            intent2.putExtras(INVOKEVIRTUAL_com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_aweme_lancet_IntentLancet_getExtras(intent));
        }
        return intent2;
    }

    private void mobLaunchMob() {
        String str = "";
        try {
            Intent intent = getIntent();
            if (intent != null) {
                Uri data = intent.getData();
                boolean booleanExtra = getIntent().getBooleanExtra("from_notification", false);
                if (data != null) {
                    str = data.getQueryParameter("gd_label");
                }
                if (booleanExtra || str != null) {
                    C48019Zo.LIZ().LIZIZ = false;
                    return;
                }
            }
            MobClick obtain = MobClick.obtain();
            obtain.setEventName("launch_app");
            obtain.setLabelName("enter_launch");
            2nK.onEvent(obtain);
            C48019Zo.LIZ().LIZIZ = false;
        } catch (Exception e) {
            0HH.LIZ(e);
        }
    }

    /* JADX WARNING: type inference failed for: r3v0, types: [android.content.Context, com.ss.android.ugc.aweme.splash.SplashActivity, X.1hK] */
    public void onResume() {
        Bundle INVOKEVIRTUAL_com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_aweme_lancet_IntentLancet_getExtras;
        2HX.LIZ.LIZ = false;
        SplashActivity.super.onResume();
        if (this.mDirectlyGoMain) {
            goMainActivity();
            return;
        }
        Intent intent = getIntent();
        if (this.mFirstResume && !this.mJumped) {
            this.mFirstResume = false;
            if (!(intent == null || (INVOKEVIRTUAL_com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_aweme_lancet_IntentLancet_getExtras = INVOKEVIRTUAL_com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_aweme_lancet_IntentLancet_getExtras(intent)) == null || !INVOKEVIRTUAL_com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_aweme_lancet_IntentLancet_getExtras.getBoolean("from_notification"))) {
                AnonymousClass9BJ.LIZ(this, "more_tab", "notify_click");
                AnonymousClass9BJ.LIZ(this, "apn", "recall");
            }
            if (quickLaunch()) {
                goMainActivity();
            }
        }
    }

    public static Bundle INVOKEVIRTUAL_com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_aweme_lancet_IntentLancet_getExtras(Intent intent) {
        try {
            return intent.getExtras();
        } catch (Exception unused) {
            return null;
        }
    }

    public void attachBaseContext(Context context) {
        AnonymousClass8B3.LJIILIIL.LJIIIIZZ();
        SplashActivity.super.attachBaseContext(context);
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [com.ss.android.ugc.aweme.splash.SplashActivity, android.app.Activity] */
    /* JADX WARNING: Unknown variable types count: 1 */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static void com_ss_android_ugc_aweme_splash_SplashActivity_com_bytedance_sysoptimizer_EnterTransitionLancet_onStop(com.ss.android.ugc.aweme.splash.SplashActivity r1) {
        /*
            r1.com_ss_android_ugc_aweme_splash_SplashActivity__onStop$___twin___()
            android.content.Context r0 = com.bytedance.sysoptimizer.EnterTransitionCrashOptimizer.getContext()
            if (r0 == 0) goto L_0x0018
            android.view.Window r0 = r1.getWindow()     // Catch:{ all -> 0x0018 }
            android.view.View r0 = r0.getDecorView()     // Catch:{ all -> 0x0018 }
            android.view.ViewTreeObserver r0 = r0.getViewTreeObserver()     // Catch:{ all -> 0x0018 }
            r0.dispatchOnPreDraw()     // Catch:{ all -> 0x0018 }
        L_0x0018:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.splash.SplashActivity.com_ss_android_ugc_aweme_splash_SplashActivity_com_bytedance_sysoptimizer_EnterTransitionLancet_onStop(com.ss.android.ugc.aweme.splash.SplashActivity):void");
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [com.ss.android.ugc.aweme.splash.SplashActivity, android.app.Activity] */
    /* JADX WARNING: Unknown variable types count: 1 */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static void com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_aweme_lancet_ActivityEnterTransitionCoordinatorLancet_onStop(com.ss.android.ugc.aweme.splash.SplashActivity r0) {
        /*
            com_ss_android_ugc_aweme_splash_SplashActivity_com_bytedance_sysoptimizer_EnterTransitionLancet_onStop(r0)
            android.view.Window r0 = r0.getWindow()     // Catch:{ all -> 0x0012 }
            android.view.View r0 = r0.getDecorView()     // Catch:{ all -> 0x0012 }
            android.view.ViewTreeObserver r0 = r0.getViewTreeObserver()     // Catch:{ all -> 0x0012 }
            r0.dispatchOnPreDraw()     // Catch:{ all -> 0x0012 }
        L_0x0012:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.splash.SplashActivity.com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_aweme_lancet_ActivityEnterTransitionCoordinatorLancet_onStop(com.ss.android.ugc.aweme.splash.SplashActivity):void");
    }

    public void handleMsg(Message message) {
        if (this.mAlive && message.what == 100) {
            goMainActivity(message.getData());
        }
    }

    public void goMainActivity(Bundle bundle) {
        submitPreload();
        this.mHandler.removeMessages(100);
        if (!this.mJumped) {
            this.mJumped = true;
            if (this.mAlive) {
                Intent mainIntent = getMainIntent();
                if (bundle != null) {
                    mainIntent.putExtra("extra_splash_data", bundle);
                }
                INVOKEVIRTUAL_com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_tiktok_security_lancet_ContextLancet_startActivity(this, mainIntent);
                if (!isFinishing()) {
                    finish();
                }
            }
        }
    }

    /* JADX WARNING: type inference failed for: r7v0, types: [android.content.Context, com.ss.android.ugc.aweme.splash.SplashActivity, X.1hK] */
    public void onCreate(Bundle bundle) {
        2HX.LIZ.LIZIZ("cold_boot_application_to_splash", true);
        2HX.LIZ.LIZ("cold_boot_splash_duration", true);
        CrashSdkImpl.LJ().LIZ((Context) this);
        2HX.LIZ.LIZ("method_splash_super_duration", false);
        getWindow().setBackgroundDrawable(new ColorDrawable(070.LIZJ(this, 2131099667)));
        SplashActivity.super.onCreate(bundle);
        2HX.LIZ.LIZIZ("method_splash_super_duration", false);
        if (getIntent() != null && TextUtils.equals(getIntent().getAction(), "android.intent.action.MAIN") && getIntent().getCategories() != null && getIntent().getCategories().size() > 0 && getIntent().getCategories().contains("android.intent.category.LAUNCHER") && !isTaskRoot() && FKe.LIZ().LIZ.LIZ() && enableSplashLaunchFix()) {
            2kf.LIZIZ(4, "SplashActivity", "finish SplashActivity directly");
            finish();
        } else if (!isTaskRoot()) {
            goMainActivity();
        } else {
            this.mAlive = true;
            this.mFirstResume = true;
            this.mJumped = false;
            reportLaunchTime();
            mobLaunchMob();
            C48019Zo.LIZ().LIZ = false;
            4U3 r1 = new 4U3();
            r1.LIZ(new UploadInstallEventTask());
            r1.LIZ();
            if (sConfirmWelcomeType == C03917eu.NO_WELCOME) {
                this.mTrackSession = true;
                tryInit();
            }
            hotStartIntercept();
            if (!this.mJumped) {
                tryInit();
                if (!quickLaunch()) {
                    tryShowShortCutDlg();
                }
            }
            4U3 r12 = new 4U3();
            r12.LIZ(Ept.LIZ.getAntispamApiUploadTask());
            r12.LIZ();
            4U3 r13 = new 4U3();
            r13.LIZ(new UploadSysStatusTask());
            r13.LIZ();
            2HX.LIZ.LIZIZ("cold_boot_splash_duration", true);
            2HX.LIZ.LIZ("cold_boot_splash_to_main", true);
        }
    }

    public static void INVOKEVIRTUAL_com_ss_android_ugc_aweme_splash_SplashActivity_com_ss_android_ugc_tiktok_security_lancet_ContextLancet_startActivity(SplashActivity splashActivity, Intent intent) {
        3i8.LIZ(intent, splashActivity);
        splashActivity.startActivity(intent);
    }
}
