package com.ifpdos.debugmenu.action;

import android.content.Context;
import android.content.Intent;
import com.ifpdos.debugmenu.action.base.ItemSwitchAction;
import com.seewo.sdk.OpenSDK;
import com.seewo.vcommons.data.UserContentResolver;
import d.i.f.c.b;
import d.i.f.c.c;
import d.i.f.e.a;

/* JADX INFO: loaded from: classes.dex */
public class FakeStandbyAction extends ItemSwitchAction {
    private static final String ACTION_FAKE_STANDBY_ALLOWED_CHANGED = "com.ifpdos.action.FAKE_STANDBY_ALLOWED";
    private static final String ACTION_POWER_MODE_CHANGED = "com.ifpdos.action.POWER_MODE_CHANGED";
    private static final String FAKE_POWER_OFF_MODE_ENABLE = "persist.sys.fpo.enable";
    private static final String KEY_ALLOWED = "allowed";
    private static final String KEY_POWER_MODE = "mode";
    private static final int POWER_MODE_FAKE = 1;
    private static final int POWER_MODE_REAL = 0;

    public FakeStandbyAction(Context context) {
        super(context);
        if (OpenSDK.getInstance().isConnected()) {
            return;
        }
        OpenSDK.getInstance().connect(context);
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSwitchAction
    public boolean isOn(Context context) {
        return a.a();
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemSwitchAction
    public void onSwitch(Context context, boolean z) {
        c.l(FAKE_POWER_OFF_MODE_ENABLE, z ? "1" : "0");
        c.l("persist.sys.etc.fpo_enable_sw", String.valueOf(z));
        Context context2 = this.mContext;
        boolean z2 = false;
        if (a.b() && (a.a() || c.g("persist.sys.etc.fpo_enable_sw", false))) {
            z2 = true;
        }
        if (z2) {
            c.l("persist.sys.etc.fpo_enable", String.valueOf(z));
            if (!z && a.a()) {
                UserContentResolver userContentResolver = b.a;
                b.h(context2.getContentResolver(), "KEY_FAKE_POWER_OFF_CHANNEL", "");
            }
            if (context2 != null) {
                context2.sendBroadcast(new Intent("com.seewo.intent.action.FAKE_POWER_OFF_ENABLE_STATE_CHANGED"));
            }
        }
        Intent intent = new Intent(ACTION_POWER_MODE_CHANGED);
        intent.putExtra(KEY_POWER_MODE, z ? 1 : 0);
        context.sendBroadcast(intent);
        Intent intent2 = new Intent(ACTION_FAKE_STANDBY_ALLOWED_CHANGED);
        intent2.putExtra(KEY_ALLOWED, z);
        context.sendBroadcast(intent2);
    }
}
