package com.ss.android.ugc.aweme.setting.page.datasave;

import X.1hK;
import X.46i;
import X.49h;
import X.7he;
import X.C5115OJa;
import X.C5116OJb;
import X.C5131OJq;
import X.Crj;
import X.LeS;
import X.Lnj;
import X.LwM;
import X.M12;
import X.OJQ;
import X.OJW;
import X.OJX;
import X.OJY;
import X.OJZ;
import android.app.Activity;
import android.content.SharedPreferences;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.common.applog.AppLog;
import com.ss.android.ugc.aweme.IAccountUserService;
import com.ss.android.ugc.aweme.setting.services.ISpeedModeSetting;
import com.ss.android.ugc.aweme.utils.ActivityStack;
import java.util.List;
import kotlin.h.b.n;

public final class SpeedModeSettingImpl implements ISpeedModeSetting {
    public final String LIZ = "MultiNetworkDialog";
    public long LIZIZ = 3000;
    public final int LIZJ = 10001;
    public final String LIZLLL = "to_cellular_toast_show";
    public final String LJ = "network_status";
    public final String LJFF = "to_cellular_toast_accept";
    public final String LJI = "to_cellular_toast_refuse";
    public final String LJII = "duration";
    public final String LJIIIIZZ = "IMultiChannelStorage";
    public long LJIIIZ = 600000;
    public final List<String> LJIIJ = LeS.LIZIZ(new String[]{"LiveBgBroadcastActivity", "LivePlayActivity", "StartLiveActivity", "LiveBroadcastSigningActivity", "GiftAdActivity", "LiveSettingActivity", "LiveContainerActivity", "LiveBroadcastActivity"});
    public final String LJIIJJI = "KEY_ENABLE_MULTI_NETWORK_SWITCH";
    public final Crj LJIIL = 7he.LIZ(new C5115OJa(this));
    public final Crj LJIILIIL = 7he.LIZ(new LwM(this));

    static {
        Covode.recordClassIndex(105975);
    }

    private final C5116OJb LJ() {
        return (C5116OJb) this.LJIIL.getValue();
    }

    private final SharedPreferences LJFF() {
        return (SharedPreferences) this.LJIILIIL.getValue();
    }

    public final void LIZ() {
        LJ().removeMessages(this.LIZJ);
    }

    public final OJY LIZJ() {
        int i = LJFF().getInt(LJI(), 0);
        if (i == -1) {
            return OJY.NOT_ALLOW;
        }
        if (i != 1) {
            return OJY.NONE;
        }
        return OJY.ALLOW;
    }

    private final String LJI() {
        String serverDeviceId = AppLog.getServerDeviceId();
        IAccountUserService LJFF2 = 46i.LJFF();
        n.LIZIZ(LJFF2, "");
        String curUserId = LJFF2.getCurUserId();
        return this.LJIIJJI + '_' + serverDeviceId + '_' + curUserId;
    }

    public final void LIZIZ() {
        Activity topActivity = ActivityStack.getTopActivity();
        if (topActivity == null) {
            return;
        }
        if (topActivity.isFinishing()) {
            Boolean.valueOf(topActivity.isFinishing());
        } else if (!this.LJIIJ.contains(topActivity.getClass().getSimpleName())) {
            LJ().post(new OJX(this, topActivity));
            LJ().sendEmptyMessageDelayed(this.LIZJ, this.LJIIIZ);
        }
    }

    public static ISpeedModeSetting LIZLLL() {
        MethodCollector.i(4620);
        ISpeedModeSetting iSpeedModeSetting = (ISpeedModeSetting) Lnj.LIZ(ISpeedModeSetting.class, false);
        if (iSpeedModeSetting != null) {
            MethodCollector.o(4620);
            return iSpeedModeSetting;
        }
        Object LIZIZ2 = Lnj.LIZIZ(ISpeedModeSetting.class, false);
        if (LIZIZ2 != null) {
            ISpeedModeSetting iSpeedModeSetting2 = (ISpeedModeSetting) LIZIZ2;
            MethodCollector.o(4620);
            return iSpeedModeSetting2;
        }
        if (Lnj.aQ == null) {
            synchronized (ISpeedModeSetting.class) {
                try {
                    if (Lnj.aQ == null) {
                        Lnj.aQ = new SpeedModeSettingImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(4620);
                    throw th;
                }
            }
        }
        SpeedModeSettingImpl speedModeSettingImpl = (SpeedModeSettingImpl) Lnj.aQ;
        MethodCollector.o(4620);
        return speedModeSettingImpl;
    }

    public final void LIZ(OJY ojy) {
        M12.LIZ(ojy);
        int i = OJZ.LIZ[ojy.ordinal()];
        if (i == 1) {
            LJFF().edit().putInt(LJI(), 1).apply();
        } else if (i != 2) {
            LJFF().edit().putInt(LJI(), 0).apply();
        } else {
            LJFF().edit().putInt(LJI(), -1).apply();
        }
    }

    public final void LIZ(OJW ojw, long j) {
        49h topActivity = ActivityStack.getTopActivity();
        if (topActivity != null && !topActivity.isFinishing() && (topActivity instanceof 1hK) && (topActivity instanceof 49h) && topActivity.isMainTabVisible()) {
            C5131OJq.LIZIZ(new OJQ(this, topActivity, ojw, j), "BoltsUtils");
        }
    }
}
