package com.seewo.vcommons.helper;

import android.content.Context;
import android.content.Intent;
import android.os.SystemProperties;
import android.text.format.Time;
import com.seewo.vcommons.constants.SeewoConstants;
import com.seewo.vcommons.constants.SeewoIntent;
import com.seewo.vcommons.data.PropertiesUtils;
import com.seewo.vcommons.utils.ShellCommandUtils;

/* JADX INFO: loaded from: classes.dex */
public class VStatusHelper {
    private static final String DATA_COMMAND_HEAD = "date -s ";
    private static final String DATA_COMMAND_HEAD_BY_SECONDS = "date -s +%s ";
    private static final String REBOOT_COMMAND = "reboot\n";

    public static boolean isIRLocked() {
        return (SystemProperties.getInt(SeewoConstants.SYSTEM_PROPERTY_KEYS_VS_LOCK_STATE, 0) & 4) == 4;
    }

    public static void sendKeyPad(Context context, int i2) {
        if (i2 > 0) {
            Intent intent = new Intent(SeewoIntent.ACTION_KEY_CLICK);
            intent.putExtra("key_code", i2);
            context.sendBroadcast(intent);
        }
    }

    public static void setBackLightState(Context context, boolean z) {
        Intent intent = new Intent("com.cvte.newmcuto901.ACTION_BROADCAST_BACKLIGHT_CONTROL");
        intent.putExtra("KEY_BACKLIGHT_CONTROL", z);
        context.sendBroadcast(intent);
    }

    public static void setIRLocked(Context context, boolean z, boolean z2) {
        Intent intent = new Intent(SeewoIntent.ACTION_IN_VS_LOCK_STATE_CHANGED);
        intent.putExtra(SeewoIntent.KEY_VS_LOCK_TYPE, 4);
        intent.putExtra(SeewoIntent.KEY_VS_LOCK_STATE, z);
        intent.putExtra("showui", z2);
        context.sendBroadcast(intent);
        if (z && PropertiesUtils.isKeyLocked()) {
            setKeyLocked(context, false, false);
        }
    }

    public static void setKeyLocked(Context context, boolean z, boolean z2) {
        Intent intent = new Intent(SeewoIntent.ACTION_IN_CHILD_KEYPAD_LOCK_STATE);
        intent.putExtra(SeewoIntent.KEYPAD_LOCK_STATE, z);
        intent.putExtra("showui", z2);
        context.sendBroadcast(intent);
        if (z && PropertiesUtils.isIRLocked()) {
            setIRLocked(context, false, false);
        }
    }

    public Time getSystemRTCTime() {
        Time time = new Time();
        time.setToNow();
        return time;
    }

    public void rebootMachine() {
        ShellCommandUtils.executeCommand(REBOOT_COMMAND);
    }

    public void setSysteRTCBySeconds(String str) {
        ShellCommandUtils.executeCommand(DATA_COMMAND_HEAD_BY_SECONDS + str + "; \n");
    }

    public void setSystemRTCTime(String str) {
        ShellCommandUtils.executeCommand(DATA_COMMAND_HEAD + str);
    }

    public void shutdownScreen(Context context) {
        setBackLightState(context, false);
    }

    public void wakeupScreen(Context context) {
        setBackLightState(context, true);
    }
}
