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

import android.content.Context;
import android.content.Intent;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.Log;
import com.cvte.vman.VmanMiddleWare;
import com.ifpdos.autotest.api.IWB;
import com.ifpdos.autotest.h0;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;

/* JADX INFO: compiled from: WBMultiTempImpl.java */
/* JADX INFO: loaded from: classes.dex */
public class x implements IWB {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private static final Map<String, Integer> f2150a = new a();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private static final Map<com.seewo.sdk.interfaces.g, Integer> f2151b = new b();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private static final Map<Integer, com.seewo.sdk.interfaces.g> f2152c = new c();
    private final Context h;
    private final int i;
    private final String j;
    private final VmanMiddleWare k;
    private boolean m;
    private boolean n;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private boolean f2153d = true;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private boolean f2154e = false;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private boolean f2155f = false;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private final Map<com.seewo.sdk.interfaces.g, Integer> f2156g = new HashMap();
    private boolean l = false;

    /* JADX INFO: compiled from: WBMultiTempImpl.java */
    class a extends HashMap<String, Integer> {
        a() {
            put("COLOR_SPACE_OPTION_SRGB", 0);
            put("COLOR_SPACE_OPTION_ADOBE_RGB", 1);
            put("COLOR_SPACE_OPTION_DISPLAY_P3", 2);
            put("COLOR_SPACE_OPTION_DCI_P3", 3);
            put("COLOR_SPACE_OPTION_HDR_BT2020", 4);
            put("COLOR_SPACE_OPTION_STANDARD", 5);
        }
    }

    /* JADX INFO: compiled from: WBMultiTempImpl.java */
    class b extends HashMap<com.seewo.sdk.interfaces.g, Integer> {
        b() {
            put(com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_0, 0);
            put(com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_1, 1);
            put(com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_2, 2);
            put(com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_3, 3);
            put(com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_4, 4);
            put(com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_5, 5);
            put(com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_6, 6);
            put(com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_7, 7);
            put(com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_8, 8);
            put(com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_9, 9);
        }
    }

    /* JADX INFO: compiled from: WBMultiTempImpl.java */
    class c extends HashMap<Integer, com.seewo.sdk.interfaces.g> {
        c() {
            put(0, com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_0);
            put(1, com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_1);
            put(2, com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_2);
            put(3, com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_3);
            put(4, com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_4);
            put(5, com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_5);
            put(6, com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_6);
            put(7, com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_7);
            put(8, com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_8);
            put(9, com.seewo.sdk.interfaces.g.MS_COLOR_TEMP_9);
        }
    }

    public x(Context context) {
        this.h = context;
        c();
        f();
        this.k = VmanMiddleWare.getInstance();
        this.i = b.c.c.d.f1449a.b();
        String strC = com.ifpdos.autotest.okhttp.e.c();
        this.j = strC;
        Log.d("WBGf3576Impl", "origin ColorSpace is " + strC);
    }

    private boolean a() {
        b(false);
        b.c.c.d.f1449a.c(this.i);
        h0.l().m();
        b(true);
        h0.l().G();
        com.ifpdos.autotest.o0.e.i(this.h);
        return true;
    }

    private void b(boolean z) {
        Intent intent = new Intent("com.cvte.intent.action_CONTROL_NO_SIGNAL");
        intent.putExtra("key_no_signal", z);
        this.h.sendBroadcast(intent);
    }

    private void c() {
        this.f2156g.clear();
        String strJ = com.seewo.vcommons.data.d.j("persist.sys.wb.pqtool_map_hal", null);
        if (TextUtils.isEmpty(strJ)) {
            this.f2156g.putAll(f2151b);
            return;
        }
        String[] strArrSplit = strJ.split(";");
        if (strArrSplit.length == 0) {
            this.f2156g.putAll(f2151b);
            return;
        }
        for (int i = 0; i < strArrSplit.length; i++) {
            try {
                int i2 = Integer.parseInt(strArrSplit[i].split("=")[0]);
                com.seewo.sdk.interfaces.g gVar = f2152c.get(Integer.valueOf(i));
                if (gVar != null) {
                    this.f2156g.put(gVar, Integer.valueOf(i2));
                }
            } catch (Exception e2) {
                Log.e("WBGf3576Impl", "initColorTempMode: ", e2);
            }
        }
    }

    private boolean e(int i, int i2, int i3) {
        Log.i("WBGf3576Impl", "openPixelPicture: " + this.l);
        if (!this.l) {
            this.l = true;
            this.f2153d = this.k.getPQCtrl().getPQPqEnable();
            this.k.getPQCtrl().setPQPqEnable(false);
            this.f2154e = com.ifpdos.autotest.okhttp.e.d();
            this.f2155f = com.ifpdos.autotest.okhttp.e.e();
            this.m = com.ifpdos.autotest.okhttp.e.i();
            this.n = com.ifpdos.autotest.okhttp.e.a();
            com.ifpdos.autotest.okhttp.e.p(false);
            com.ifpdos.autotest.okhttp.e.q(false);
            com.ifpdos.autotest.okhttp.e.v(false);
            com.ifpdos.autotest.okhttp.e.m(false);
            b.c.c.g gVar = b.c.c.g.f1452a;
            gVar.h(99);
            gVar.h(100);
            this.k.getPQCtrl().setAWBPartitionEnable(true);
            h0.l().C("ng");
            Log.i("WBGf3576Impl", "setPQPqEnable false, mDynamicContrastEnable = " + this.f2154e + ", mEnergyStarEnable = " + this.f2155f + ", mLocalDimming = " + this.m + ", mAutoLight = " + this.n);
        }
        b(false);
        closeNoSignalSleepTime();
        h0.l().o();
        h0.l().D(i, i2, i3);
        return true;
    }

    private void f() {
        this.f2156g.forEach(new BiConsumer() { // from class: com.ifpdos.autotest.lancontrol.module.other.e.g
            @Override // java.util.function.BiConsumer
            public final void accept(Object obj, Object obj2) {
                Log.d("WBGf3576Impl", "printColorTempMode: " + ((com.seewo.sdk.interfaces.g) obj) + " -> " + ((Integer) obj2));
            }
        });
    }

    @Override // com.ifpdos.autotest.api.IWB
    public String checkMd5() {
        File file = new File("/data/" + SystemProperties.get("persist.sys.file.name"));
        return file.exists() ? com.ifpdos.autotest.lancontrol.module.other.f.c.c(file) : "";
    }

    @Override // com.ifpdos.autotest.api.IWB
    public void closeNoSignalSleepTime() {
        b.c.c.d.f1449a.c(Integer.MAX_VALUE);
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean endTranFile() {
        com.ifpdos.autotest.k0.d.b.f(false);
        return true;
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean executeShell(String str) {
        return b.c.d.d.d.a(str).f1514a == 0;
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean exitStandPictureMode() {
        Log.i("WBGf3576Impl", "exitStandPictureMode: ");
        if (this.j == null) {
            return true;
        }
        Log.d("WBGf3576Impl", "reset ColorSpace " + this.j);
        com.ifpdos.autotest.okhttp.e.o(this.j);
        return true;
    }

    @Override // com.ifpdos.autotest.api.IWB
    public int get3DLutIndex() {
        Integer num;
        String strC = com.ifpdos.autotest.okhttp.e.c();
        if (strC == null || (num = f2150a.get(strC)) == null) {
            return -1;
        }
        Log.i("WBGf3576Impl", strC + " : " + num);
        return num.intValue();
    }

    @Override // com.ifpdos.autotest.api.IWB
    public com.seewo.sdk.interfaces.g getColorTemp() {
        com.seewo.sdk.interfaces.g gVarB = b.c.c.g.f1452a.b();
        Log.d("WBGf3576Impl", "getColorTemp: " + gVarB);
        return gVarB;
    }

    @Override // com.ifpdos.autotest.api.IWB
    public int[] getColorTempRGBValue(com.seewo.sdk.interfaces.g gVar) {
        Log.d("WBGf3576Impl", "getColorTempRGBValue: " + gVar);
        return b.c.c.g.f1452a.c(gVar);
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean mergeFile() {
        return b.c.d.d.d.a("cp data/3dlut.bin /mnt/vendor/factory/").f1514a == 0 && b.c.d.d.d.a("sync").f1514a == 0;
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean quit() {
        b.c.c.d.f1449a.c(this.i);
        this.h.sendBroadcast(new Intent("com.ifpdos.autotest.end"));
        com.seewo.vcommons.data.d.r(false);
        if (this.l) {
            this.k.getPQCtrl().setPQPqEnable(this.f2153d);
            com.ifpdos.autotest.okhttp.e.p(this.f2154e);
            com.ifpdos.autotest.okhttp.e.q(this.f2155f);
            com.ifpdos.autotest.okhttp.e.v(this.m);
            com.ifpdos.autotest.okhttp.e.m(this.n);
        }
        Log.i("WBGf3576Impl", "mDisablePq = " + this.l + ", setPQPqEnable = " + this.f2153d + ", mDynamicContrastEnable = " + this.f2154e + ", mEnergyStarEnable = " + this.f2155f + ", mLocalDimming = " + this.m + ", mAutoLight = " + this.n);
        this.l = false;
        return a();
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean result(String str) {
        h0.l().C(str);
        return true;
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean save(com.seewo.sdk.interfaces.g gVar, int i, int i2, int i3) {
        Integer num = this.f2156g.get(gVar);
        if (num != null) {
            return this.k.getPQCtrl().setPresetColorTempMode(0, num.intValue(), i, i2, i3) == 0;
        }
        Log.e("WBGf3576Impl", "save: colorTemp is error");
        return false;
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean set3DLutIndex(int i) {
        for (Map.Entry<String, Integer> entry : f2150a.entrySet()) {
            if (entry.getValue().intValue() == i) {
                Log.i("WBGf3576Impl", "set3DLutIndex: " + i + " -> " + entry.getKey());
                com.ifpdos.autotest.okhttp.e.o(entry.getKey());
                return true;
            }
        }
        return false;
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean setColorTemp(com.seewo.sdk.interfaces.g gVar) {
        Log.i("WBGf3576Impl", "setColorTemp: " + gVar);
        return b.c.c.g.f1452a.i(gVar);
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean setMasterPictureMode() {
        Log.i("WBGf3576Impl", "setMasterPictureMode: ");
        return true;
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean setPattern() {
        return e(255, 255, 255);
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean setPatternByUser(int i, int i2, int i3) {
        return e(i, i2, i3);
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean setStandPictureMode() {
        Log.i("WBGf3576Impl", "setStandPictureMode: ");
        com.seewo.vcommons.data.d.r(true);
        Log.d("WBGf3576Impl", "set ColorSpace COLOR_SPACE_OPTION_STANDARD");
        com.ifpdos.autotest.okhttp.e.o("COLOR_SPACE_OPTION_STANDARD");
        return true;
    }

    @Override // com.ifpdos.autotest.api.IWB
    public boolean startTranFile(String str) {
        SystemProperties.set("persist.sys.file.name", str);
        com.ifpdos.autotest.k0.d.b.f(true);
        return true;
    }
}
