package com.ss.android.ugc.aweme.compliance.business.serviceimpl;

import X.0Gf;
import X.0Gp;
import X.3i8;
import X.3uW;
import X.3uX;
import X.AnonymousClass8AI;
import X.AnonymousClass8AJ;
import X.AnonymousClass9I2;
import X.C04537he;
import X.C12337yS;
import X.C12347yT;
import X.C12357yU;
import X.C12367yV;
import X.C43939Jw;
import X.C48369aN;
import X.C49989cz;
import X.C49999d0;
import X.C50019d2;
import X.C50049d5;
import X.C50369db;
import X.Crj;
import X.ESC;
import X.LeY;
import X.Lnj;
import X.M12;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.keva.Keva;
import com.ss.android.ugc.aweme.compliance.api.a;
import com.ss.android.ugc.aweme.compliance.api.services.child.IChildModeService;
import com.ss.android.ugc.aweme.utils.ActivityStack;
import java.util.List;
import kotlin.h.b.n;

public final class ChildModeServiceImpl implements IChildModeService {
    public Boolean LIZ;
    public final Crj LIZIZ = C04537he.LIZ(C48369aN.LIZ);

    static {
        Covode.recordClassIndex(61138);
    }

    public final boolean LIZ() {
        return C12337yS.LIZLLL.LIZJ();
    }

    public final List<String> LIZLLL() {
        return 3uW.LJI.LJIILLIIL();
    }

    public final /* synthetic */ AnonymousClass9I2 LJFF() {
        return new C49999d0();
    }

    public final /* synthetic */ AnonymousClass9I2 LJI() {
        return new C50049d5();
    }

    public final /* synthetic */ AnonymousClass9I2 LJII() {
        return new C50369db();
    }

    public final C49989cz LJIIIIZZ() {
        return C49999d0.LIZJ.LIZ();
    }

    public final AnonymousClass9I2 LJ() {
        return (AnonymousClass9I2) this.LIZIZ.getValue();
    }

    public final void LIZJ() {
        boolean z;
        3uX r1 = 3uW.LIZ;
        Boolean bool = true;
        r1.LIZLLL = bool;
        Keva keva = r1.LIZ;
        if (bool != null) {
            z = bool.booleanValue();
        } else {
            z = false;
        }
        keva.storeBoolean("have_updated_and_checked", z);
    }

    public final boolean LIZIZ() {
        Boolean valueOf;
        3uX r1 = 3uW.LIZ;
        if (r1.LIZLLL != null) {
            valueOf = r1.LIZLLL;
        } else {
            valueOf = Boolean.valueOf(r1.LIZ.getBoolean("have_updated_and_checked", false));
        }
        if (valueOf != null) {
            return valueOf.booleanValue();
        }
        return false;
    }

    public final boolean LJIIIZ() {
        if (this.LIZ == null) {
            this.LIZ = Boolean.valueOf(Keva.getRepo("compliance_setting").getBoolean("update_and_check_new_kids_mode", false));
        }
        Boolean bool = this.LIZ;
        if (bool != null) {
            return bool.booleanValue();
        }
        return false;
    }

    public static IChildModeService LJIIJ() {
        MethodCollector.i(3460);
        IChildModeService iChildModeService = (IChildModeService) Lnj.LIZ(IChildModeService.class, false);
        if (iChildModeService != null) {
            MethodCollector.o(3460);
            return iChildModeService;
        }
        Object LIZIZ2 = Lnj.LIZIZ(IChildModeService.class, false);
        if (LIZIZ2 != null) {
            IChildModeService iChildModeService2 = (IChildModeService) LIZIZ2;
            MethodCollector.o(3460);
            return iChildModeService2;
        }
        if (Lnj.LLFII == null) {
            synchronized (IChildModeService.class) {
                try {
                    if (Lnj.LLFII == null) {
                        Lnj.LLFII = new ChildModeServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(3460);
                    throw th;
                }
            }
        }
        ChildModeServiceImpl childModeServiceImpl = (ChildModeServiceImpl) Lnj.LLFII;
        MethodCollector.o(3460);
        return childModeServiceImpl;
    }

    public final void LIZ(C12347yT r2) {
        M12.LIZ(r2);
        M12.LIZ(r2);
        C12337yS.LIZJ.add(r2);
    }

    public final void LIZ(C50019d2 r2) {
        M12.LIZ(r2);
        C49999d0.LIZJ.LIZ(r2);
    }

    public final void LIZIZ(Context context) {
        M12.LIZ(context);
        0Gp.LIZ(C12357yU.LIZ).LIZ(new AnonymousClass8AI(this, context), 0Gp.LIZIZ, (0Gf) null);
    }

    public final void LIZ(Context context) {
        M12.LIZ(context);
        0Gp.LIZ(C12367yV.LIZ).LIZ(new AnonymousClass8AJ(this, context), 0Gp.LIZIZ, (0Gf) null);
    }

    public final void LIZJ(Context context) {
        Boolean valueOf;
        if (context != null) {
            3uX r1 = 3uW.LIZ;
            boolean z = false;
            if (r1.LIZJ != null) {
                valueOf = r1.LIZJ;
            } else {
                valueOf = Boolean.valueOf(r1.LIZ.getBoolean("update_and_check_new_kids_mode", false));
            }
            if (valueOf == null || !valueOf.booleanValue()) {
                3uX r2 = 3uW.LIZ;
                Boolean bool = true;
                r2.LIZJ = bool;
                Keva keva = r2.LIZ;
                if (bool != null) {
                    z = bool.booleanValue();
                }
                keva.storeBoolean("update_and_check_new_kids_mode", z);
                if (ESC.LIZLLL()) {
                    a.LJIILLIIL().LIZ(context);
                }
            }
        }
    }

    public final void LIZLLL(Context context) {
        M12.LIZ(context);
        String packageName = context.getPackageName();
        n.LIZIZ(packageName, "");
        Intent launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(packageName);
        if (launchIntentForPackage != null) {
            launchIntentForPackage.addFlags(268468224);
            3i8.LIZ(launchIntentForPackage, context);
            context.startActivity(launchIntentForPackage);
            Activity[] activityStack = ActivityStack.getActivityStack();
            n.LIZIZ(activityStack, "");
            for (Activity activity : LeY.LJI(activityStack)) {
                n.LIZIZ(activity, "");
                if (!activity.isFinishing()) {
                    activity.finish();
                }
            }
            Runtime.getRuntime().exit(0);
        }
    }

    public final void LIZ(boolean z, Runnable runnable) {
        0Gp.LIZ(new C43939Jw(z, runnable));
    }

    public final boolean LIZ(C49989cz r2, String str) {
        return C49999d0.LIZJ.LIZ(r2, str);
    }
}
