package com.ifpdos.debugmenu.action;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import com.ifpdos.debugmenu.R;
import com.ifpdos.debugmenu.action.base.ItemSelectAction;
import com.ifpdos.debugmenu.event.ViewEvent;
import com.ifpdos.mcusdk.McuCommonCommand;
import com.ifpdos.mcusdk.McuCommonResponse;
import com.seewo.sdk.model.SDKIrNotifyState;
import com.seewo.sdk.model.SDKKeyboardCode;
import d.f.a.i2.a;
import d.f.a.j2.e.i;
import d.f.a.r2.a3;
import d.f.a.r2.r2;
import d.f.c.b;
import d.i.f.c.b;
import java.util.List;
import k.c.a.c;
import k.c.a.j;
import org.greenrobot.eventbus.ThreadMode;

/* JADX INFO: loaded from: classes.dex */
public class IRCustomerCodeAction extends ItemSelectAction {
    public static final int ACTION_IN_CLEAR_KEYPAD_LOCK = 2;
    public static final int ACTION_IN_GET_REMOTE_CONTROL_STATE = 5;
    public static final int ACTION_IN_SET_CHILD_LOCK_STATE = 3;
    public static final int ACTION_IN_SET_KEYPAD_LOCK = 1;
    public static final int ACTION_IN_SET_REMOTE_CONTROL_STATE = 4;
    public static final int ACTION_OUT_GET_REMOTE_CONTROL_STATE = 2;
    public static final int ACTION_OUT_SET_KEYPAD_LOCK = 1;
    public static final String KEY_GET_REMOTE_CONTROL = "KEY_GET_REMOTE_CONTROL";
    public static final String KEY_SET_CHILD_LOCK = "KEY_SET_CHILD_LOCK";
    public static final String KEY_SET_REMOTE_CONTROL = "KEY_SET_REMOTE_CONTROL";
    public static final int REMOTE_CONTROL_DISABLE = 0;
    public static final int REMOTE_CONTROL_ENABLE = 1;
    public static final int REMOTE_CONTROL_PASS_THROUGH = 2;
    private static final String TAG = "IRCustomerCodeAction";
    private static final byte VALUE_GET_REMOTE_CONTROL_STATE_ACT_DISABLE = 0;
    private static final byte VALUE_GET_REMOTE_CONTROL_STATE_ACT_ENABLE = 1;
    private static final byte VALUE_GET_REMOTE_CONTROL_STATE_ACT_PASS_THROUGH = 2;

    /* JADX INFO: renamed from: com.ifpdos.debugmenu.action.IRCustomerCodeAction$2, reason: invalid class name */
    public static /* synthetic */ class AnonymousClass2 {
        public static final /* synthetic */ int[] $SwitchMap$com$seewo$sdk$model$SDKIrNotifyState;

        static {
            SDKIrNotifyState.values();
            int[] iArr = new int[3];
            $SwitchMap$com$seewo$sdk$model$SDKIrNotifyState = iArr;
            try {
                iArr[SDKIrNotifyState.DISABLE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$com$seewo$sdk$model$SDKIrNotifyState[SDKIrNotifyState.ENABLE.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                $SwitchMap$com$seewo$sdk$model$SDKIrNotifyState[SDKIrNotifyState.PASS_THROUGH.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    public IRCustomerCodeAction(Context context) {
        super(context);
        a.a().f2585b.add(this);
        c.c().k(this);
    }

    private SDKIrNotifyState get551RemoteControlState() {
        byte b2 = 0;
        if (b.b(this.mContext, "pass_through", false)) {
            b2 = 2;
        } else {
            if (!((d.i.f.c.c.c("persist.sys.keys.vs.locks", 0) & 4) != 0)) {
                b2 = 1;
            }
        }
        Bundle bundle = new Bundle();
        processRemoteControlState(SDKKeyboardCode.FUNCTION_KEY_BOARD_U, b2);
        return getRemoteControlState(b2, bundle);
    }

    private SDKIrNotifyState getRemoteControlState(byte b2, Bundle bundle) {
        if (b2 == 0) {
            b.g(this.mContext, "pass_through", false);
            bundle.putInt(KEY_GET_REMOTE_CONTROL, 0);
            return SDKIrNotifyState.DISABLE;
        }
        if (b2 == 1) {
            b.g(this.mContext, "pass_through", false);
            bundle.putInt(KEY_GET_REMOTE_CONTROL, 1);
            return SDKIrNotifyState.ENABLE;
        }
        if (b2 != 2) {
            return null;
        }
        b.g(this.mContext, "pass_through", true);
        bundle.putInt(KEY_GET_REMOTE_CONTROL, 2);
        return SDKIrNotifyState.PASS_THROUGH;
    }

    private SDKIrNotifyState getRemoteControlValue(int i2) {
        return i2 != 0 ? i2 != 1 ? i2 != 2 ? SDKIrNotifyState.ENABLE : SDKIrNotifyState.PASS_THROUGH : SDKIrNotifyState.ENABLE : SDKIrNotifyState.DISABLE;
    }

    private void processRemoteControlState(byte b2, byte b3) {
        Bundle bundle = new Bundle();
        if (b2 == 11) {
            b.g(this.mContext, "pass_through", false);
            bundle.putInt(KEY_GET_REMOTE_CONTROL, 0);
        } else if (b2 == 13) {
            b.g(this.mContext, "pass_through", false);
            bundle.putInt(KEY_GET_REMOTE_CONTROL, 1);
        } else if (b2 == 22) {
            b.g(this.mContext, "pass_through", true);
            bundle.putInt(KEY_GET_REMOTE_CONTROL, 2);
        } else if (b2 == 24) {
            getRemoteControlState(b3, bundle);
        }
        b.d.a.b(new McuCommonCommand(Byte.valueOf(SDKKeyboardCode.FUNCTION_KEY_BOARD_W), Byte.valueOf(b2), (byte) 0), new d.f.c.e.c() { // from class: com.ifpdos.debugmenu.action.IRCustomerCodeAction.1
            @Override // d.f.c.e.c
            public void onCall(McuCommonResponse mcuCommonResponse) {
                StringBuilder sbB = d.b.a.a.a.B("NewServer McuCommonResponse ");
                sbB.append(mcuCommonResponse.toString());
                Log.i(IRCustomerCodeAction.TAG, sbB.toString());
                StringBuilder sb = new StringBuilder();
                sb.append("NewServer McuCommonResponse ");
                d.b.a.a.a.U(sb, mcuCommonResponse.f2027i, IRCustomerCodeAction.TAG);
            }
        });
    }

    private void set551RemoteControlState(SDKIrNotifyState sDKIrNotifyState) {
        int iOrdinal = sDKIrNotifyState.ordinal();
        byte b2 = SDKKeyboardCode.FUNCTION_KEY_BOARD_J;
        if (iOrdinal == 0) {
            d.i.f.c.b.g(this.mContext, "pass_through", false);
            d.i.c.a.H(this.mContext, true, true);
            b2 = SDKKeyboardCode.FUNCTION_KEY_BOARD_H;
        } else if (iOrdinal == 1) {
            d.i.f.c.b.g(this.mContext, "pass_through", false);
            d.i.c.a.H(this.mContext, false, true);
        } else if (iOrdinal == 2) {
            d.i.c.a.H(this.mContext, true, true);
            d.i.f.c.b.g(this.mContext, "pass_through", true);
            b2 = SDKKeyboardCode.FUNCTION_KEY_BOARD_S;
        }
        processRemoteControlState(b2, (byte) 0);
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSelectAction
    public List<String> getEntryList(Context context) {
        return d.b.a.a.a.G(context, R.array.ir_customer_code);
    }

    public SDKIrNotifyState getIrNotifyState() {
        return get551RemoteControlState();
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSelectAction
    public int getSelectIndex(Context context) {
        return getIrNotifyState().ordinal();
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSelectAction
    public boolean isEnable() {
        return ((Boolean) a3.b(this.mContext).a("hospitality_mode_status", Boolean.FALSE)).booleanValue();
    }

    /* JADX WARN: Multi-variable type inference failed */
    @j(threadMode = ThreadMode.MAIN)
    public void onEvent(ViewEvent.UpdateViewEnable updateViewEnable) {
        int i2 = updateViewEnable.viewId;
        if (i2 == -1) {
            Log.e(getClass().getSimpleName(), "UpdateViewEnable for NO_ID view is forbidden");
            return;
        }
        r2 r2Var = r2.IR_CUSTOMER_CODE;
        if (i2 == r2Var.ordinal()) {
            setEnable((i) this.mViewModel, updateViewEnable.isEnabled);
        }
        if (r2Var.ordinal() == r2.COMMON_SOURCE.ordinal()) {
            setEnable((i) this.mViewModel, updateViewEnable.isEnabled);
        }
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSelectAction
    public void onSelect(Context context, int i2) {
        set551RemoteControlState(SDKIrNotifyState.values()[i2]);
    }

    public void processCommand(int i2, Bundle bundle) {
        if (i2 == 1) {
            setTouchKeyPadLock(true);
            return;
        }
        if (i2 == 2) {
            setTouchKeyPadLock(false);
            return;
        }
        if (i2 == 3) {
            setChildLockState(bundle.getBoolean(KEY_SET_CHILD_LOCK, false));
        } else if (i2 == 4) {
            setIrNotifyState(getRemoteControlValue(bundle.getInt(KEY_SET_REMOTE_CONTROL, 1)));
        } else {
            if (i2 != 5) {
                return;
            }
            getIrNotifyState();
        }
    }

    public void setChildLockState(boolean z) {
        d.f.c.b bVar = b.d.a;
        bVar.d(new McuCommonCommand(Byte.valueOf(SDKKeyboardCode.FUNCTION_KEY_BOARD_Q), Byte.valueOf(z ? (byte) 4 : (byte) 6), (byte) 0));
        bVar.d(new McuCommonCommand(Byte.valueOf(SDKKeyboardCode.FUNCTION_KEY_BOARD_R), (byte) 0, (byte) 0));
    }

    public void setIrNotifyState(SDKIrNotifyState sDKIrNotifyState) {
        set551RemoteControlState(sDKIrNotifyState);
    }

    public void setTouchKeyPadLock(boolean z) {
        Log.v(TAG, "setTouchKeyPadLock setTouchEnabled: " + z);
        String str = d.i.f.c.c.a;
        d.i.f.c.c.l(d.i.f.a.b.a, Boolean.toString(z));
        d.f.c.b bVar = b.d.a;
        bVar.d(new McuCommonCommand(Byte.valueOf(SDKKeyboardCode.FUNCTION_KEY_BOARD_Q), Byte.valueOf(z ? (byte) 1 : (byte) 0), (byte) 0));
        bVar.d(new McuCommonCommand(Byte.valueOf(SDKKeyboardCode.FUNCTION_KEY_BOARD_R), (byte) 0, (byte) 0));
    }
}
