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

import X.8Zd;
import X.8Ze;
import X.8ec;
import X.9Ft;
import X.9Fx;
import X.9Us;
import X.9Y3;
import X.B4h;
import X.C1103Rch;
import X.C1104Rci;
import X.C1105Rcj;
import X.C1107Rcl;
import X.C1108Rcm;
import X.C1109Rcn;
import X.C1110Rco;
import X.C1111Rcp;
import X.C1112Rcq;
import X.C1150RdS;
import X.C3829SfZ;
import X.Er7;
import android.content.Context;
import android.os.HandlerThread;
import android.os.Looper;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import java.util.List;

public final class PowerModeTask implements 8Ze {
    static {
        Covode.recordClassIndex(98093);
    }

    public final boolean meetTrigger() {
        return true;
    }

    public final String prefix() {
        return "task_";
    }

    public final boolean serialExecute() {
        return false;
    }

    public final int targetProcess() {
        return 1;
    }

    public final List triggerOtherLegoComponents() {
        return null;
    }

    public final 9Ft triggerType() {
        return 8Zd.LIZ(this);
    }

    public final 9Fx scenesType() {
        return 9Fx.DEFAULT;
    }

    public final 8ec type() {
        return 8ec.BACKGROUND;
    }

    public final String key() {
        return getClass().getSimpleName();
    }

    public final void run(Context context) {
        if (context != null) {
            C1112Rcq LIZ = C1112Rcq.LIZ();
            if (!LIZ.LIZ) {
                LIZ.LIZ = true;
                HandlerThread handlerThread = new HandlerThread("power_handler");
                handlerThread.start();
                C1104Rci LIZ2 = C1104Rci.LIZ();
                LIZ2.LIZIZ = 9Y3.LIZ(9Y3.LIZ(), true, "enable_power_mode", 3);
                LIZ2.LIZJ = 9Y3.LIZ(9Y3.LIZ(), true, "enable_power_mode_always_on", 0);
                if (LIZ2.LIZJ()) {
                    B4h LIZ3 = B4h.LIZ();
                    if (LIZ3 != null && !C1104Rci.LIZLLL.contains(LIZ3)) {
                        C1104Rci.LIZLLL.add(LIZ3);
                    }
                    C1103Rch LIZ4 = C1103Rch.LIZ();
                    if (!C3829SfZ.LJIIJJI) {
                        LIZ4.LIZIZ();
                        C1104Rci.LIZ().LIZIZ();
                    }
                    C3829SfZ.LJIJ.LJI().LIZLLL(new C1105Rcj(LIZ4));
                }
                C1111Rcp LIZ5 = C1111Rcp.LIZ();
                Looper looper = handlerThread.getLooper();
                if (!LIZ5.LIZIZ) {
                    LIZ5.LIZ = new C1150RdS(looper);
                    LIZ5.LIZIZ = true;
                }
                C1108Rcm LIZ6 = C1108Rcm.LIZ();
                Looper looper2 = handlerThread.getLooper();
                if (!LIZ6.LIZ) {
                    LIZ6.LJFF = new C1109Rcn(LIZ6, looper2);
                    Er7 LIZ7 = Er7.LIZ();
                    LIZ7.LIZ = new C1110Rco(LIZ6);
                    if (!TextUtils.isEmpty(LIZ7.LIZIZ)) {
                        LIZ7.LIZ.LIZ(LIZ7.LIZIZ);
                    }
                    C3829SfZ.LJIJ.LJI().LIZLLL(new C1107Rcl(LIZ6));
                    LIZ6.LIZ = true;
                    LIZ6.LIZIZ();
                }
                C1108Rcm.LIZ().LIZ(9Us.LIZ().LIZ);
            }
        }
    }
}
