package com.dss.ups.sp51a.ble.utils;

import kotlin.Metadata;
import kotlin.jvm.internal.o;

/* JADX INFO: loaded from: classes.dex */
@Metadata(bv = {1, 0, 3}, d1 = {"\u00000\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0010\u0005\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0012\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\t\u0018\u00002\u00020\u0001B\u000f\u0012\u0006\u0010\u0015\u001a\u00020\r¢\u0006\u0004\b\u0017\u0010\u0018J\u000f\u0010\u0003\u001a\u00020\u0002H\u0002¢\u0006\u0004\b\u0003\u0010\u0004J\r\u0010\u0005\u001a\u00020\u0002¢\u0006\u0004\b\u0005\u0010\u0004J\r\u0010\u0007\u001a\u00020\u0006¢\u0006\u0004\b\u0007\u0010\bJ\r\u0010\t\u001a\u00020\u0006¢\u0006\u0004\b\t\u0010\bJ\r\u0010\u000b\u001a\u00020\n¢\u0006\u0004\b\u000b\u0010\fJ\u000f\u0010\u000e\u001a\u0004\u0018\u00010\r¢\u0006\u0004\b\u000e\u0010\u000fJ\r\u0010\u0011\u001a\u00020\u0010¢\u0006\u0004\b\u0011\u0010\u0012R\u0016\u0010\u0013\u001a\u00020\n8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u0013\u0010\u0014R\u0016\u0010\u0015\u001a\u00020\r8\u0002@\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0015\u0010\u0016¨\u0006\u0019"}, d2 = {"Lcom/dss/ups/sp51a/ble/utils/AdvertisingParser;", "", "", "checkCurrentItemDataLen", "()Z", "isEnd", "", "getCurrentItemType", "()B", "getCurrentItemLength", "", "getCurrentItemDateFirstShort", "()I", "", "getCurrentItemDate", "()[B", "", "nextItem", "()V", "index", "I", "bytes", "[B", "<init>", "([B)V", "lib_release"}, k = 1, mv = {1, 5, 1})
public final class AdvertisingParser {
    private final byte[] bytes;
    private int index;

    public AdvertisingParser(byte[] bArr) {
        o.f(bArr, "bytes");
        this.bytes = bArr;
    }

    private final boolean checkCurrentItemDataLen() {
        return getCurrentItemLength() + this.index < this.bytes.length;
    }

    public final byte[] getCurrentItemDate() {
        if (!checkCurrentItemDataLen()) {
            return null;
        }
        int currentItemLength = getCurrentItemLength() - 1;
        byte[] bArr = new byte[currentItemLength];
        System.arraycopy(this.bytes, this.index + 2, bArr, 0, currentItemLength);
        return bArr;
    }

    public final int getCurrentItemDateFirstShort() {
        if (getCurrentItemLength() < 3 || !checkCurrentItemDataLen()) {
            return 0;
        }
        return BitUtils.INSTANCE.readU16(this.bytes, this.index + 2);
    }

    public final byte getCurrentItemLength() {
        return this.bytes[this.index];
    }

    public final byte getCurrentItemType() {
        return this.bytes[this.index + 1];
    }

    public final boolean isEnd() {
        byte currentItemLength;
        return this.index >= this.bytes.length || (currentItemLength = getCurrentItemLength()) == 0 || this.index + currentItemLength >= this.bytes.length;
    }

    public final void nextItem() {
        this.index = getCurrentItemLength() + 1 + this.index;
    }
}
