package com.ifpdos.debugmenu.action;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.SystemProperties;
import com.ifpdos.debugmenu.R;
import com.ifpdos.debugmenu.action.base.ItemSelectAction;
import com.seewo.sdk.SDKConfigureHelper;
import d.f.a.r2.y2;
import java.util.Arrays;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public class NoSignalPowerOffAction extends ItemSelectAction {
    private static final String CHANGE_CHANNEL_BROADCAST = "com.ifpdos.memory_last_source_changed";
    private static final int RETURN_FIVE_MIN_INDEX = 2;
    private static final int RETURN_GO_TO_PREVIOUS_CHANNEL_INDEX = 0;
    private static final int SHOW = 1;
    private static final String SHOW_GO_TO_PREVIOUS_CHANNEL = "persist.previous.channel.enable";
    public int[] values;

    public NoSignalPowerOffAction(Context context) {
        super(context);
        this.values = this.mContext.getResources().getIntArray(hasChangeChannel() ? R.array.power_off_timeout_value_change_channel : R.array.power_off_timeout_value);
    }

    private void changePreviousChannel(boolean z) {
        String str = y2.a;
        SystemProperties.set("persist.sys.memory_last_source", String.valueOf(z));
        sendBroadcast();
    }

    private boolean hasChangeChannel() {
        return y2.a.equals("i3") || showChangeChannel();
    }

    private void sendBroadcast() {
        Intent intent = new Intent();
        intent.setAction(CHANGE_CHANNEL_BROADCAST);
        this.mContext.sendBroadcast(intent);
    }

    private boolean showChangeChannel() {
        return SystemProperties.getInt(SHOW_GO_TO_PREVIOUS_CHANNEL, 0) == 1;
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSelectAction
    public List<String> getEntryList(Context context) {
        boolean zHasChangeChannel = hasChangeChannel();
        Resources resources = context.getResources();
        return zHasChangeChannel ? Arrays.asList(resources.getStringArray(R.array.power_off_timeout_or_change_channel)) : Arrays.asList(resources.getStringArray(R.array.power_off_timeout));
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSelectAction
    public int getSelectIndex(Context context) {
        int noSignalSleepTime = SDKConfigureHelper.I.getNoSignalSleepTime() / 60;
        int i2 = 0;
        while (true) {
            int[] iArr = this.values;
            if (i2 >= iArr.length) {
                return 2;
            }
            if (iArr[i2] == noSignalSleepTime) {
                return i2;
            }
            i2++;
        }
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSelectAction
    public void onSelect(Context context, int i2) {
        int selectIndex = getSelectIndex(context);
        SDKConfigureHelper.I.setNoSignalSleepTime(this.values[i2] * 60);
        if (hasChangeChannel()) {
            if (i2 == 0) {
                changePreviousChannel(true);
            } else if (selectIndex == 0) {
                changePreviousChannel(false);
            }
        }
    }
}
