package com.seewo.ota.update.device.model.vman;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Keep;
import com.cvte.vman.entity.EntityFwSensorBox;
import com.cvte.vman.impl.FwUpgradeManager;
import com.cvte.vman.impl.SensorBoxCtrlManager;
import com.google.gson.reflect.TypeToken;
import com.seewo.ota.R;
import com.seewo.ota.util.v;
import com.seewo.ota.v.s.r.c;
import com.seewo.ota.v.s.s.i1;
import com.seewo.ota.v.s.s.q0;
import com.seewo.vcommons.data.d;
import f.e;
import f.e0.t;
import f.g;
import f.i;
import f.u.f;
import f.z.d.k;
import java.util.List;

/* JADX INFO: compiled from: SensorBoxVmanUpdateTask.kt */
/* JADX INFO: loaded from: classes.dex */
@i
@Keep
public final class SensorBoxVmanUpdateTask extends BaseVmanUpdateTask<EntityFwSensorBox> implements i1 {
    private final e usbInfoList$delegate;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public SensorBoxVmanUpdateTask(Context context, q0 q0Var) {
        super(context, new TypeToken<EntityFwSensorBox>() { // from class: com.seewo.ota.update.device.model.vman.SensorBoxVmanUpdateTask.1
        }, q0Var);
        k.e(context, "context");
        this.usbInfoList$delegate = g.a(SensorBoxVmanUpdateTask$usbInfoList$2.INSTANCE);
    }

    private final List<c> getUsbInfoList() {
        return (List) this.usbInfoList$delegate.getValue();
    }

    @Override // com.seewo.ota.update.device.model.vman.BaseVmanUpdateTask
    public void checkVersion(List<EntityFwSensorBox> list) {
        k.e(list, "waitUpgradeQueue");
        List<EntityFwSensorBox> fwSensorBoxList = SensorBoxCtrlManager.getInstance().getFwSensorBoxList();
        k.d(fwSensorBoxList, "getInstance().fwSensorBoxList");
        for (EntityFwSensorBox entityFwSensorBox : fwSensorBoxList) {
            String fwVersion = FwUpgradeManager.getInstance().getFwVersion(entityFwSensorBox.fwSensorBoxType);
            k.d(fwVersion, "getInstance().getFwVersi…ensorBox.fwSensorBoxType)");
            String string = t.d0(fwVersion).toString();
            Log.i(getName(), "checkVersion: " + entityFwSensorBox + " currentVersion: '" + string + '\'');
            if (entityFwSensorBox.isSupportOtaUpgrade && !f.g(com.seewo.ota.util.k.a(), string) && !f.g(com.seewo.ota.util.k.a(), entityFwSensorBox.otaSensorBoxBoxBasicBinVersion) && !TextUtils.equals(string, entityFwSensorBox.otaSensorBoxBoxBasicBinVersion)) {
                String str = entityFwSensorBox.otaUpgradeSensorBoxBinPath;
                k.d(str, "entityFwSensorBox.otaUpgradeSensorBoxBinPath");
                if (fileExists(str)) {
                    k.d(entityFwSensorBox, "entityFwSensorBox");
                    list.add(entityFwSensorBox);
                }
            }
        }
    }

    @Override // com.seewo.ota.update.device.model.vman.BaseVmanUpdateTask, com.seewo.ota.v.s.s.r0
    public String getBeforeUpdateTip() {
        String string = this.mContext.getString(R.string.update_sensor_box_tips);
        k.d(string, "mContext.getString(R.str…g.update_sensor_box_tips)");
        return string;
    }

    @Override // com.seewo.ota.update.device.model.vman.BaseVmanUpdateTask, com.seewo.ota.v.s.s.r0
    public String getUpdateTip() {
        String string = this.mContext.getString(R.string.update_sensor_box_message);
        k.d(string, "mContext.getString(R.str…pdate_sensor_box_message)");
        return string;
    }

    @Override // com.seewo.ota.update.device.model.vman.BaseVmanUpdateTask, com.seewo.ota.v.s.s.r0
    public /* bridge */ /* synthetic */ String isInExceptionalState() {
        return super.isInExceptionalState();
    }

    @Override // com.seewo.ota.update.device.model.vman.BaseVmanUpdateTask
    public boolean isSupportOtaUpgrade() {
        if (d.i("persist.sys.ota.disable_sensorbox_update", 0) != 1) {
            return true;
        }
        Log.i(getName(), "isSupportOtaUpgrade: disable by property.");
        return false;
    }

    @Override // com.seewo.ota.v.s.s.i1
    public String needUpdateTips() {
        String string = this.mContext.getString(R.string.update_sensor_box_tips);
        k.d(string, "mContext.getString(R.str…g.update_sensor_box_tips)");
        return string;
    }

    @Override // com.seewo.ota.v.s.s.i1
    public List<c> supportUsbInfoList() {
        return getUsbInfoList();
    }

    @Override // com.seewo.ota.update.device.model.vman.BaseVmanUpdateTask
    public /* bridge */ /* synthetic */ Object upgrade(EntityFwSensorBox entityFwSensorBox, f.w.d dVar) {
        return upgrade2(entityFwSensorBox, (f.w.d<? super Boolean>) dVar);
    }

    @Override // com.seewo.ota.update.device.model.vman.BaseVmanUpdateTask
    public boolean needReboot(EntityFwSensorBox entityFwSensorBox) {
        k.e(entityFwSensorBox, "entity");
        return entityFwSensorBox.needRebootWhenUpgraded;
    }

    /* JADX INFO: renamed from: upgrade, reason: avoid collision after fix types in other method */
    public Object upgrade2(EntityFwSensorBox entityFwSensorBox, f.w.d<? super Boolean> dVar) {
        this.mContext.sendBroadcast(new Intent("com.ifpdos.broadcast.LOCAL_UPDATE_DEVICE"));
        int i2 = entityFwSensorBox.fwSensorBoxType;
        String str = entityFwSensorBox.otaUpgradeSensorBoxBinPath;
        k.d(str, "entity.otaUpgradeSensorBoxBinPath");
        return v.a(i2, str, dVar);
    }

    public /* synthetic */ SensorBoxVmanUpdateTask(Context context, q0 q0Var, int i2, f.z.d.g gVar) {
        this(context, (i2 & 2) != 0 ? null : q0Var);
    }
}
