package com.ifpdos.factorytest;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import com.cvte.vman.VmanMiddleWare;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public class AlgorithmBox extends TestItem {
    private final String TAG;

    public AlgorithmBox(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.TAG = "AlgorithmBox";
        checkAlgorithmBoxStatus();
    }

    @Override // com.ifpdos.factorytest.TestItem
    boolean doTest() {
        checkAlgorithmBoxStatus();
        return false;
    }

    private void checkAlgorithmBoxStatus() {
        if (!getPlugState()) {
            testDone(false, this.mContext.getResources().getString(R.string.test_no_algorith_box_plug));
            return;
        }
        if (!getNetworkState()) {
            testDone(false, this.mContext.getResources().getString(R.string.test_algorith_box_net_error));
        } else if (!getReserveGPIOState()) {
            testDone(false, this.mContext.getResources().getString(R.string.test_algorith_box_io_error));
        } else {
            testDone(true, this.mContext.getResources().getString(R.string.test_algorith_box_pass));
        }
    }

    private boolean getPlugState() {
        boolean plugState;
        try {
            plugState = VmanMiddleWare.getInstance().getDF15Ctrl().getPlugState();
        } catch (Exception e) {
            Log.e("AlgorithmBox", "checkAlgorithmBoxStatus: error", e);
            plugState = false;
        }
        Log.d("AlgorithmBox", "getPlugState: " + plugState);
        return plugState;
    }

    private boolean getNetworkState() {
        boolean networkState;
        try {
            networkState = VmanMiddleWare.getInstance().getDF15Ctrl().getNetworkState();
        } catch (Exception e) {
            Log.e("AlgorithmBox", "getNetworkState: error", e);
            networkState = false;
        }
        Log.d("AlgorithmBox", "getNetworkState: " + networkState);
        return networkState;
    }

    private boolean getReserveGPIOState() {
        List<Boolean> arrayList = new ArrayList<>();
        try {
            arrayList = VmanMiddleWare.getInstance().getDF15Ctrl().getReserveGPIOState();
        } catch (Exception e) {
            Log.e("AlgorithmBox", "getReserveGPIOStateList: error", e);
        }
        if (arrayList.size() == 0) {
            Log.d("AlgorithmBox", "getReserveGPIOStateList: listSize = " + arrayList.size());
            return false;
        }
        Iterator<Boolean> it = arrayList.iterator();
        while (it.hasNext()) {
            if (!it.next().booleanValue()) {
                Log.d("AlgorithmBox", "getReserveGPIOState: false");
                return false;
            }
        }
        return true;
    }
}
