package com.seewo.factoryaging.human;

import android.content.Context;
import android.os.Build;
import android.util.Log;
import android.view.View;
import androidx.lifecycle.e;
import androidx.lifecycle.f;
import com.cvte.vman.R;
import com.seewo.factoryaging.s0.j;
import com.seewo.factoryaging.u;
import j.k0.j0;
import j.n;
import j.p0.d.r;
import j.v;

/* JADX INFO: compiled from: HumanTestModelView.kt */
/* JADX INFO: loaded from: classes.dex */
@n
public final class HumanTestModelView implements j, f {
    private final Context a;
    private Boolean b;

    public HumanTestModelView(Context context) {
        r.f(context, "context");
        this.a = context;
    }

    @Override // com.seewo.factoryaging.s0.j
    public boolean a() {
        return true;
    }

    @Override // com.seewo.factoryaging.s0.j
    public boolean e() {
        if (Build.VERSION.SDK_INT > 28 && com.seewo.factoryaging.e1.f.a.o()) {
            Log.d("HumanTestModelView", "hasSensorBox show human test view");
            return true;
        }
        if (!this.a.getResources().getBoolean(R.bool.showHumanFragment)) {
            return false;
        }
        if (!this.a.getResources().getBoolean(R.bool.enableCheckDevice)) {
            return true;
        }
        boolean zO = com.seewo.factoryaging.e1.f.a.o();
        Log.d("HumanTestModelView", "hasPIRSensor ? " + zO);
        return zO;
    }

    @Override // com.seewo.factoryaging.s0.j
    public View i() {
        View viewInflate = View.inflate(this.a, R.layout.view_human_fragment, null);
        r.e(viewInflate, "inflate(mContext, R.layo…iew_human_fragment, null)");
        return viewInflate;
    }

    @Override // com.seewo.factoryaging.s0.j
    public float j() {
        return 1.0f;
    }

    @androidx.lifecycle.n(e.a.ON_START)
    public final void onStart() {
        Log.d("HumanTestModelView", "onStart");
        if (e()) {
            u uVar = (u) com.seewo.factoryaging.d1.b.a.f("/v1/device/ultrasonic/detection/human/enable", u.class);
            this.b = uVar != null ? Boolean.valueOf(uVar.a()) : null;
            Log.d("HumanTestModelView", "mPirEnableRestore = " + this.b);
            if (this.b != null) {
                com.seewo.factoryaging.d1.b.k(com.seewo.factoryaging.d1.b.a, "/v1/device/ultrasonic/detection/human/enable", j0.c(v.a("enable", Boolean.TRUE)), null, 4, null);
            }
        }
    }

    @androidx.lifecycle.n(e.a.ON_STOP)
    public final void onStop() {
        Log.d("HumanTestModelView", "onStop");
        Boolean bool = this.b;
        if (bool != null) {
            boolean zBooleanValue = bool.booleanValue();
            Log.d("HumanTestModelView", "restore PirEnable = " + zBooleanValue);
            com.seewo.factoryaging.d1.b.k(com.seewo.factoryaging.d1.b.a, "/v1/device/ultrasonic/detection/human/enable", j0.c(v.a("enable", Boolean.valueOf(zBooleanValue))), null, 4, null);
        }
    }
}
