package com.benq.platform;

import com.benq.platform.events.UdiConnectionStateEvent;
import kotlin.jvm.internal.g;
import kotlin.jvm.internal.l;

/* JADX INFO: loaded from: classes.dex */
public final class UdiConnectionCoordinator {
    private final O1.c eventBus;
    private volatile boolean initStarted;
    private volatile Boolean lastState;

    /* JADX WARN: Multi-variable type inference failed */
    public UdiConnectionCoordinator() {
        this(null, 1, 0 == true ? 1 : 0);
    }

    private final void publishState(boolean z2) {
        boolean z3;
        synchronized (this) {
            if (l.a(this.lastState, Boolean.valueOf(z2))) {
                z3 = false;
            } else {
                this.lastState = Boolean.valueOf(z2);
                z3 = true;
            }
        }
        if (z3) {
            this.eventBus.r(UdiConnectionStateEvent.class);
            this.eventBus.o(new UdiConnectionStateEvent(z2));
        }
    }

    public final boolean beginInit() {
        boolean z2;
        synchronized (this) {
            if (this.initStarted) {
                z2 = false;
            } else {
                z2 = true;
                this.initStarted = true;
            }
        }
        return z2;
    }

    public final void publishConnected() {
        publishState(true);
    }

    public final void publishFailed() {
        publishState(false);
    }

    public UdiConnectionCoordinator(O1.c eventBus) {
        l.e(eventBus, "eventBus");
        this.eventBus = eventBus;
    }

    /* JADX WARN: Illegal instructions before constructor call */
    public /* synthetic */ UdiConnectionCoordinator(O1.c cVar, int i2, g gVar) {
        if ((i2 & 1) != 0) {
            cVar = O1.c.c();
            l.d(cVar, "getDefault(...)");
        }
        this(cVar);
    }
}
