package com.ifpdos.debugmenu.action;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import c.n.a;
import com.cvte.vman.VmanMiddleWare;
import com.ifpdos.debugmenu.R;
import com.ifpdos.debugmenu.action.base.ItemButtonAction;
import com.trello.rxlifecycle3.android.ActivityEvent;
import com.trello.rxlifecycle3.components.support.RxAppCompatActivity;
import d.f.a.c1;
import d.f.a.p2.p0;
import d.f.a.p2.t0;
import d.f.a.r2.t2;
import d.f.a.s1.e;
import d.f.a.s1.f;
import f.a.k;
import f.a.w.e.d.c;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public class ClearMACAction extends ItemButtonAction implements c1 {
    private static final String TAG = "ClearMACAction";
    private e mActionFinishCallback;
    private p0 upgradeHandler;

    public ClearMACAction(Context context) {
        super(context);
        this.upgradeHandler = t0.a;
        this.mContext = context;
    }

    private void showConfirmDialog() {
        a.V(R.string.str_debug_clear_mac, R.string.str_debug_clear_mac_hint, new e() { // from class: d.f.a.p1.r1
            @Override // d.f.a.s1.e
            public final void call() {
                this.a.j();
            }
        });
    }

    private void showInputDialog() {
        a.X(R.string.str_debug_clear_mac, R.string.str_debug_clear_confirm, new f() { // from class: d.f.a.p1.t1
            @Override // d.f.a.s1.f
            public final void a(String str) {
                this.a.k(str);
            }
        });
    }

    @SuppressLint({"CheckResult"})
    private void upgrade() {
        t2.e();
        a.a0(R.string.str_debug_clear_mac);
        Objects.requireNonNull((t0) this.upgradeHandler);
        new c(new k() { // from class: d.f.a.p2.p
            @Override // f.a.k
            public final void subscribe(f.a.j jVar) {
                t0 t0Var = t0.a;
                c.a aVar = (c.a) jVar;
                aVar.d(Boolean.valueOf(VmanMiddleWare.getInstance().getAtCfgControl().setMac(new String(new byte[6], 0, 6).getBytes())));
            }
        }).w(f.a.z.a.f4044c).g(((RxAppCompatActivity) this.mContext).bindUntilEvent(ActivityEvent.DESTROY)).u(new f.a.v.c() { // from class: d.f.a.p1.p1
            @Override // f.a.v.c
            public final void accept(Object obj) {
                c.n.a.f0(R.string.str_debug_clear_mac, ((Boolean) obj).booleanValue());
            }
        }, new f.a.v.c() { // from class: d.f.a.p1.u1
            @Override // f.a.v.c
            public final void accept(Object obj) {
                c.n.a.f0(R.string.str_debug_clear_mac, false);
            }
        }, f.a.w.b.a.f3725b, f.a.w.b.a.f3726c);
    }

    public /* synthetic */ void h() {
        a.o();
        upgrade();
    }

    public /* synthetic */ void i(DialogInterface dialogInterface) {
        e eVar = this.mActionFinishCallback;
        if (eVar != null) {
            eVar.call();
        }
    }

    public /* synthetic */ void j() {
        a.o();
        upgrade();
    }

    public /* synthetic */ void k(String str) {
        if (!str.equals("1234")) {
            d.b.a.a.a.I(R.string.str_wrong_password, 1, k.c.a.c.c());
        } else {
            a.o();
            showConfirmDialog();
        }
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemButtonAction, d.f.a.j2.e.e.a
    public void onClick(Context context, d.f.a.j2.e.e eVar) {
        showInputDialog();
    }

    @Override // com.ifpdos.debugmenu.action.base.ItemButtonAction, d.f.a.j2.e.e.a
    public void onLongClick(Context context, d.f.a.j2.e.e eVar) {
    }

    @Override // d.f.a.c1
    public void quickAction(e eVar) {
        this.mActionFinishCallback = eVar;
        a.U(R.string.str_debug_clear_mac, R.string.str_debug_clear_mac_hint, new e() { // from class: d.f.a.p1.s1
            @Override // d.f.a.s1.e
            public final void call() {
                this.a.h();
            }
        }, new DialogInterface.OnCancelListener() { // from class: d.f.a.p1.q1
            @Override // android.content.DialogInterface.OnCancelListener
            public final void onCancel(DialogInterface dialogInterface) {
                this.f2894b.i(dialogInterface);
            }
        });
    }
}
