package com.seewo.ota.data;

import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import com.cvte.vman.impl.FwUpgradeManager;
import com.seewo.ota.R;
import com.seewo.ota.util.h;
import com.seewo.ota.util.j;
import com.seewo.ota.v.s.s.k0;
import com.seewo.vcommons.data.d;
import d.e.h.e.f;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;
import org.xmlpull.v1.XmlPullParserException;

/* JADX INFO: compiled from: UpdateConfig.java */
/* JADX INFO: loaded from: classes.dex */
public class b {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private static volatile b f2116f;
    private Context a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private String f2117b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private String f2118c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private SimpleDateFormat f2119d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private List<k0> f2120e;

    public static b i() {
        if (f2116f == null) {
            synchronized (b.class) {
                if (f2116f == null) {
                    f2116f = new b();
                }
            }
        }
        return f2116f;
    }

    public Context a() {
        return this.a;
    }

    public SimpleDateFormat b() {
        if (this.f2119d == null) {
            this.f2119d = new SimpleDateFormat("yyyyMMdd", Locale.ENGLISH);
        }
        return this.f2119d;
    }

    public String c() {
        return d().replace(".bin", ".md5");
    }

    public String d() {
        String mcuBinNameToUp = d.e.h.e.b.g() ? FwUpgradeManager.getInstance().getMcuBinNameToUp() : "";
        if (TextUtils.isEmpty(mcuBinNameToUp)) {
            mcuBinNameToUp = d.k("persist.ctm.mcubin");
        }
        Log.d("DeviceUpdateManager", "getDeviceUpdateMcuPath: mcuUpdateFileName from prop:" + mcuBinNameToUp);
        if (mcuBinNameToUp.isEmpty()) {
            return this.a.getResources().getString(R.string.mcu_update_path);
        }
        StringBuilder sb = new StringBuilder();
        sb.append(Build.VERSION.SDK_INT >= 33 ? "/vendor/etc/firmware/mcu/" : "/system/etc/firmwares/mcu/");
        sb.append(mcuBinNameToUp);
        return sb.toString();
    }

    public String e() {
        return this.a.getResources().getString(R.string.usb_hub_update_md5_path);
    }

    public String f() {
        return this.a.getResources().getString(R.string.usb_hub_update_path);
    }

    public String g() {
        String str = f.a("cat /sys/devices/virtual/aw9523/aw9523/aw9523_info").f3605b;
        if (TextUtils.isEmpty(str)) {
            return "/system/etc/firmwares/small_board/upgrade_b.xml";
        }
        String strTrim = str.trim();
        Log.d("DeviceUpdateManager", "getDeviceUpdateXML:" + strTrim + "!");
        return strTrim.startsWith("B") ? "/system/etc/firmwares/small_board/upgrade_b.xml" : "/system/etc/firmwares/small_board/upgrade.xml";
    }

    public String h() {
        return this.a.getResources().getString(R.string.mcu_update_manifest_path);
    }

    public String j() {
        if (this.f2117b == null) {
            if (Build.VERSION.SDK_INT >= 31) {
                this.f2117b = j.a.a() + File.separator + "update.zip";
            } else {
                StringBuilder sb = new StringBuilder();
                sb.append((d.e.h.e.b.f() || d.e.h.a.a.h(10) || Build.VERSION.SDK_INT == 29) ? j.a.a() : this.a.getResources().getString(R.string.folder_update_path));
                sb.append(File.separator);
                sb.append("update.zip");
                this.f2117b = sb.toString();
            }
        }
        return this.f2117b;
    }

    public String k() {
        if (this.f2118c == null) {
            this.f2118c = this.a.getResources().getString(R.string.folder_update_path) + File.separator + "SlotUpdate.zip";
        }
        return this.f2118c;
    }

    public List<k0> l() throws XmlPullParserException, IOException {
        List<k0> list = this.f2120e;
        if (list == null || list.isEmpty()) {
            String strG = g();
            Log.d("DeviceUpdateManager", "getUpgradeDeviceModel: " + strG);
            this.f2120e = com.seewo.ota.v.s.r.a.a(strG);
        }
        return this.f2120e;
    }

    public void m(Context context) {
        this.a = context;
    }

    public boolean n() {
        return this.a.getResources().getBoolean(R.bool.is_CN);
    }

    public boolean o() {
        return this.a.getResources().getBoolean(R.bool.support_mcu_manifest_check) || d.e.h.a.a.h(8) || Build.VERSION.SDK_INT >= 33;
    }

    public boolean p() {
        return this.a.getResources().getBoolean(R.bool.support_mcu_update) || d.e.h.a.a.h(8);
    }

    public boolean q() {
        return this.a.getResources().getBoolean(R.bool.support_platform_ota);
    }

    public boolean r() {
        return q() && h.a();
    }

    public boolean s() {
        return this.a.getResources().getBoolean(R.bool.support_slot_ota);
    }

    public boolean t() {
        return this.a.getResources().getBoolean(R.bool.support_speechi_ota);
    }

    public boolean u() {
        return this.a.getResources().getBoolean(R.bool.support_third_update);
    }

    public boolean v() {
        return this.a.getResources().getBoolean(R.bool.support_update_touch);
    }

    public boolean w() {
        return this.a.getResources().getBoolean(R.bool.support_type_c_update);
    }

    public boolean x() {
        return this.a.getResources().getBoolean(R.bool.support_usb_hub_update);
    }

    public boolean y() {
        return this.a.getResources().getBoolean(R.bool.use_device_upgrade_v2);
    }
}
