package d.f.a.q1.n;

import android.content.Context;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Pair;
import com.seewo.sdk.util.RLog;
import com.seewo.vcommons.data.UserContentResolver;
import d.f.a.r2.w2;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import jxl.Workbook;
import jxl.write.WritableCellFormat;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

/* JADX INFO: compiled from: ValueRecorder.java */
/* JADX INFO: loaded from: classes.dex */
public class b {
    public static final SimpleDateFormat a = new SimpleDateFormat("yyyyMMdd_HHmmss");

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Context f3101b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public ArrayList f3102c = new ArrayList();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public File f3103d;

    public b(Context context) {
        String strD;
        this.f3101b = context;
        Context context2 = d.i.f.d.b.this.f3652c;
        if (context2 == null) {
            strD = d.i.f.d.b.a;
        } else {
            UserContentResolver userContentResolver = d.i.f.c.b.a;
            strD = d.i.f.c.b.d(context2.getContentResolver(), "root_path");
            if (TextUtils.isEmpty(strD.trim())) {
                strD = Environment.getExternalStorageDirectory().getPath();
            }
        }
        File file = new File(strD, "DebugMenu");
        if (!file.exists()) {
            file.mkdirs();
        }
        this.f3103d = new File(file, a.format(Long.valueOf(System.currentTimeMillis())) + ".xls");
    }

    public void a() {
        Pair pair;
        w2 w2Var = new w2();
        File file = this.f3103d;
        ArrayList arrayList = this.f3102c;
        if (file.exists()) {
            file.delete();
        }
        try {
            file.createNewFile();
            WritableWorkbook writableWorkbookCreateWorkbook = Workbook.createWorkbook(file);
            pair = new Pair(writableWorkbookCreateWorkbook, writableWorkbookCreateWorkbook.createSheet("sheet1", 0));
        } catch (IOException e2) {
            RLog.e("JxlUtil", e2);
            pair = null;
        }
        try {
            WritableCellFormat writableCellFormatC = w2Var.c((WritableSheet) pair.second);
            w2Var.a((WritableSheet) pair.second, writableCellFormatC);
            w2Var.b(arrayList, (WritableSheet) pair.second, writableCellFormatC);
            ((WritableWorkbook) pair.first).write();
            ((WritableWorkbook) pair.first).close();
        } catch (Exception e3) {
            RLog.e("JxlUtil", e3);
        }
    }
}
