package d.f.a;

import android.util.Log;
import com.ifpdos.debugmenu.R;
import com.ifpdos.debugmenu.event.ActivityEvent;
import com.ifpdos.debugmenu.event.ViewEvent;
import d.f.a.e0;
import d.f.a.r2.u2;
import d.f.a.r2.v2;
import java.io.File;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

/* JADX INFO: compiled from: DebugMainActivity.java */
/* JADX INFO: loaded from: classes.dex */
public class f0 implements v2.a {
    public final /* synthetic */ e0 a;

    public f0(e0 e0Var) {
        this.a = e0Var;
    }

    @Override // d.f.a.r2.v2.a
    public void onFail() {
        k.c.a.c.c().g(new ViewEvent.TextAndColor(this.a.o.getString(R.string.str_not_found_udisk), -65536));
        d.b.a.a.a.Y(false, k.c.a.c.c());
        e0 e0Var = this.a;
        e0.e(e0Var, e0Var.getString(R.string.str_not_found_udisk));
    }

    @Override // d.f.a.r2.v2.a
    public void onSuccess() {
        f.a.t.a aVar = this.a.u;
        TimeUnit timeUnit = TimeUnit.SECONDS;
        f.a.i<Long> iVarX = f.a.i.l(1L, timeUnit).x(f.a.i.B(30L, timeUnit));
        f.a.o oVar = f.a.z.a.f4044c;
        aVar.b(iVarX.n(oVar).w(oVar).u(new f.a.v.c() { // from class: d.f.a.b
            @Override // f.a.v.c
            public final void accept(Object obj) {
                f0 f0Var = this.f2558b;
                d.i.a.a.a aVarJ = f0Var.a.j();
                e0 e0Var = f0Var.a;
                Objects.requireNonNull(e0Var);
                ViewEvent.TextAndColor textAndColor = new ViewEvent.TextAndColor();
                if (aVarJ == null) {
                    e0Var.w = true;
                    textAndColor.setText("文件信息为空");
                    textAndColor.setColor(-65536);
                } else {
                    File fileG = u2.g("software_information");
                    if (fileG == null) {
                        e0Var.w = true;
                        d.b.a.a.a.K(e0Var.o, R.string.str_not_found_udisk, textAndColor, -65536);
                    } else {
                        StringBuilder sbB = d.b.a.a.a.B("softWareInfo=");
                        sbB.append(aVarJ.toString());
                        Log.i("DebugMainActivity", sbB.toString());
                        if (aVarJ.toString().indexOf(e0Var.o.getString(R.string.device_loading)) > 0) {
                            e0Var.w = false;
                            d.b.a.a.a.K(e0Var.o, R.string.str_fail_loading_exporting, textAndColor, -65536);
                        } else if (u2.b(fileG)) {
                            e0Var.w = true;
                            Log.e("DebugMainActivity", "exportSoftwareInformation: 文件检查失败");
                            d.b.a.a.a.K(e0Var.o, R.string.str_fail_exporting, textAndColor, -65536);
                        } else if (aVarJ.e(fileG)) {
                            e0Var.w = true;
                            Log.e("DebugMainActivity", "exportSoftwareInformation: 文件写入成功");
                            String string = e0Var.o.getString(R.string.restart_this_page_after_export);
                            int color = e0Var.o.getColor(R.color.orange);
                            textAndColor.setText(string);
                            textAndColor.setColor(color);
                        } else {
                            e0Var.w = true;
                            Log.e("DebugMainActivity", "exportSoftwareInformation: 文件写入失败");
                            d.b.a.a.a.K(e0Var.o, R.string.str_fail_exporting, textAndColor, -65536);
                        }
                    }
                }
                StringBuilder sbB2 = d.b.a.a.a.B("exportSoftwareInfo textAndColor:");
                sbB2.append(textAndColor.getText().toString());
                Log.i("DebugMainActivity", sbB2.toString());
                d.i.c.a.c("sync;sync;", false);
                k.c.a.c.c().g(new ViewEvent.TextAndColor(textAndColor.getText(), textAndColor.getColor()));
                StringBuilder sb = new StringBuilder();
                sb.append("exportSoftwareInfo mIsExit:");
                sb.append(f0Var.a.w);
                sb.append(", mIsExportExit = ");
                d.b.a.a.a.V(sb, f0Var.a.q, "DebugMainActivity");
                if (f0Var.a.w) {
                    throw new e0.b(textAndColor.getColor() == -65536 ? textAndColor.getText() : f0Var.a.getString(R.string.str_finish_exporting));
                }
            }
        }, new f.a.v.c() { // from class: d.f.a.c
            @Override // f.a.v.c
            public final void accept(Object obj) {
                f0 f0Var = this.f2560b;
                Throwable th = (Throwable) obj;
                Objects.requireNonNull(f0Var);
                Log.e("DebugMainActivity", "exportSoftwareInfo fail", th);
                d.b.a.a.a.Y(false, k.c.a.c.c());
                if (th instanceof e0.b) {
                    e0.e(f0Var.a, th.getMessage());
                } else {
                    e0 e0Var = f0Var.a;
                    e0.e(e0Var, e0Var.getString(R.string.str_fail_exporting));
                }
            }
        }, new f.a.v.a() { // from class: d.f.a.a
            @Override // f.a.v.a
            public final void run() {
                f0 f0Var = this.a;
                Objects.requireNonNull(f0Var);
                k.c.a.c.c().g(new ActivityEvent.ShowProgressDialog(false));
                Log.e("DebugMainActivity", "exportSoftwareInfo onComplete");
                e0 e0Var = f0Var.a;
                e0.e(e0Var, e0Var.getString(R.string.str_fail_exporting));
            }
        }, f.a.w.b.a.f3726c));
    }
}
