package com.ifpdos.autotest.lancontrol.module.other.e.y;

import android.annotation.SuppressLint;
import android.os.SystemProperties;
import d.n0.c.s;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/* JADX INFO: compiled from: RGBDataWriter1516.kt */
/* JADX INFO: loaded from: classes.dex */
@d.n
public final class h implements d {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    @SuppressLint({"SdCardPath"})
    private static final String f2165b = "/data/3dlut.bin";

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private int f2166c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private FileOutputStream f2167d = new FileOutputStream(new File(f2165b));

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

        public /* synthetic */ a(d.n0.c.l lVar) {
            this();
        }
    }

    @Override // com.ifpdos.autotest.lancontrol.module.other.e.y.d
    public boolean a(g[] gVarArr, String str) throws IOException {
        s.e(gVarArr, "rgbs");
        s.e(str, "spaceType");
        this.f2166c++;
        boolean z = false;
        int i = 0;
        int i2 = 0;
        int i3 = 0;
        for (g gVar : gVarArr) {
            int i4 = (int) gVar.f2161a;
            int i5 = (int) gVar.f2162b;
            int i6 = (int) gVar.f2163c;
            if (z) {
                int i7 = (i2 << 12) | i;
                int i8 = (i4 << 12) | i3;
                int i9 = (i6 << 12) | i5;
                this.f2167d.write(new byte[]{(byte) (i7 & 255), (byte) ((i7 >> 8) & 255), (byte) ((i7 >> 16) & 255), (byte) (i8 & 255), (byte) ((i8 >> 8) & 255), (byte) ((i8 >> 16) & 255), (byte) (i9 & 255), (byte) ((i9 >> 8) & 255), (byte) ((i9 >> 16) & 255)});
            } else {
                i3 = i6;
                i = i4;
                i2 = i5;
            }
            z = !z;
        }
        if (z) {
            int i10 = (i2 << 12) | i;
            this.f2167d.write(new byte[]{(byte) (i10 & 255), (byte) ((i10 >> 8) & 255), (byte) ((i10 >> 16) & 255), (byte) (i3 & 255), (byte) ((i3 >> 8) & 255), (byte) ((i3 >> 16) & 255), (byte) 0, (byte) 0, (byte) 0});
        }
        this.f2167d.flush();
        if (this.f2166c != 6) {
            return true;
        }
        this.f2167d.close();
        SystemProperties.set("ctl.start", "pq");
        return true;
    }
}
