package com.ifpdos.autotest.lancontrol.module.other.impls.gamma;

import android.util.Log;
import com.seewo.libmcuservice.aidl.model.McuEnum;
import com.seewo.sdk.model.SDKKeyboardCode;
import d.n;
import d.n0.c.l;
import d.n0.c.s;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: compiled from: GammaInfo.kt */
/* JADX INFO: loaded from: classes.dex */
@n
public final class b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final a f2206a = new a(null);

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final ByteBuffer f2207b = ByteBuffer.allocate(1544);

    /* JADX INFO: compiled from: GammaInfo.kt */
    @n
    public static final class a {
        private a() {
        }

        public /* synthetic */ a(l lVar) {
            this();
        }
    }

    private final boolean a(List<Integer> list, List<Integer> list2, List<Integer> list3) {
        return list != null && list2 != null && list3 != null && list.size() == 257 && list2.size() == 257 && list3.size() == 257;
    }

    private final void c(List<Integer> list, List<Integer> list2, List<Integer> list3) {
        this.f2207b.clear();
        Iterator<Integer> it = list.iterator();
        while (it.hasNext()) {
            int iIntValue = it.next().intValue();
            this.f2207b.put((byte) (iIntValue & 255));
            this.f2207b.put((byte) ((iIntValue >> 8) & 255));
        }
        Iterator<Integer> it2 = list2.iterator();
        while (it2.hasNext()) {
            int iIntValue2 = it2.next().intValue();
            this.f2207b.put((byte) (iIntValue2 & 255));
            this.f2207b.put((byte) ((iIntValue2 >> 8) & 255));
        }
        Iterator<Integer> it3 = list3.iterator();
        while (it3.hasNext()) {
            int iIntValue3 = it3.next().intValue();
            this.f2207b.put((byte) (iIntValue3 & 255));
            this.f2207b.put((byte) ((iIntValue3 >> 8) & 255));
        }
        this.f2207b.put(SDKKeyboardCode.FUNCTION_KEY_BOARD_MINUS);
        this.f2207b.put(SDKKeyboardCode.FUNCTION_KEY_BOARD_I);
    }

    public final byte[] b() {
        byte[] bArrArray = this.f2207b.array();
        s.d(bArrArray, "buffer.array()");
        return bArrArray;
    }

    public final void d(byte[] bArr) {
        s.e(bArr, McuEnum.KEY_DATA);
        if (bArr.length < 1544) {
            Log.e("GammaInfo", "Error", new Exception("data is too short!"));
        } else {
            this.f2207b.put(bArr, 0, 1544);
        }
    }

    public final boolean e(List<Integer> list, List<Integer> list2, List<Integer> list3) {
        s.e(list, "r");
        s.e(list2, "g");
        s.e(list3, "b");
        if (!a(list, list2, list3)) {
            return false;
        }
        try {
            c(list, list2, list3);
            return true;
        } catch (Exception e2) {
            b.c.c.l.b.b("GammaInfo", e2);
            return false;
        }
    }
}
