package ZtlApi;

import android.content.Intent;
import android.os.SystemProperties;
import android.util.Log;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ZtlManager32887_1 extends ZtlManager {
    private static final String PROP_RESOLUTION_HDMI = "persist.sys.resolution.aux";
    static final String SYSTEM_BAR_HIDE = "hide";
    static final String SYSTEM_BAR_SHOW = "show";
    static final String SYSTEM_BAR_STATE = "persist.sys.systemBar";
    private static final String SYS_NODE_VGA_MODE = "/sys/devices/platform/display-subsystem/drm/card0/card0-VGA-1/mode";
    private static final String SYS_NODE_VGA_MODES = "/sys/devices/platform/display-subsystem/drm/card0/card0-VGA-1/modes";
    private static final String SYS_NODE_VGA_STATUS = "/sys/devices/platform/display-subsystem/drm/card0/card0-VGA-1/status";
    Map<String, Integer> gpios = new HashMap();

    ZtlManager32887_1() {
        init_gpiomap();
    }

    private List<String> readStrListFromFile(String str) throws IOException {
        ArrayList arrayList = new ArrayList();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(str))));
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine != null) {
                arrayList.add(readLine);
            } else {
                String str2 = ZtlManager.TAG;
                Log.d(str2, "readStrListFromFile - " + arrayList.toString());
                return arrayList;
            }
        }
    }

    private String readStrFromFile(String str) throws IOException {
        String str2 = ZtlManager.TAG;
        Log.d(str2, "readStrFromFile - " + str);
        return new BufferedReader(new InputStreamReader(new FileInputStream(new File(str)))).readLine();
    }

    public void LwlTest(int i) {
        String str = ZtlManager.TAG;
        Log.d(str, "LLLLL ----> " + i);
        try {
            readStrListFromFile(SYS_NODE_VGA_MODES);
            readStrFromFile(SYS_NODE_VGA_MODE);
            Log.d(ZtlManager.TAG, getDisplayMode());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String getUsbStoragePath() {
        File file = new File("/storage/");
        String str = null;
        try {
            if (!file.exists() || !file.isDirectory()) {
                return null;
            }
            File[] listFiles = file.listFiles();
            if (listFiles.length <= 0) {
                return null;
            }
            str = listFiles[0].getAbsolutePath();
            LOGD("steve : get file path " + str);
            if (!str.contains("USB_DISK")) {
                return str;
            }
            LOGD("steve : open " + str);
            File file2 = new File(str);
            if (!file2.exists() || !file2.isDirectory()) {
                return str;
            }
            File[] listFiles2 = file2.listFiles();
            if (listFiles2.length == 1) {
                String absolutePath = listFiles2[0].getAbsolutePath();
                Log.e("steve : usbPath ", "" + absolutePath);
                return absolutePath;
            }
            for (int i = 0; i < listFiles2.length; i++) {
                if (!listFiles2[i].getAbsolutePath().contains("(")) {
                    String absolutePath2 = listFiles2[i].getAbsolutePath();
                    Log.e("steve : usbPath ", "" + absolutePath2);
                    return absolutePath2;
                }
            }
            return str;
        } catch (Exception e) {
            e.printStackTrace();
            return str;
        }
    }

    public int getDisplayOrientation() {
        return Integer.valueOf(getSystemProperty("persist.sys.orientation", "0")).intValue();
    }

    public void setOpenSystemBar() {
        this.mContext.sendBroadcast(new Intent("ZTL.ACTION.OPEN.SYSTEMBAR"));
    }

    public void setCloseSystemBar() {
        this.mContext.sendBroadcast(new Intent("ZTL.ACTION.CLOSE.SYSTEMBAR"));
    }

    public int getSystemBarState() {
        String str = SystemProperties.get(SYSTEM_BAR_STATE);
        if (str.equals(SYSTEM_BAR_SHOW)) {
            return 1;
        }
        return str.equals(SYSTEM_BAR_HIDE) ? 0 : -1;
    }

    public void setScreenMode(String str) {
        setSystemProperty("persist.sys.screenmode", str);
        setSystemProperty("ztl.Screen", "Set");
    }

    /* access modifiers changed from: package-private */
    public void init_gpiomap() {
        this.gpios.put("GPIO7_A5", 221);
        this.gpios.put("GPIO8_A1", 249);
        this.gpios.put("GPIO8_A0", 248);
        this.gpios.put("GPIO7_A6", 222);
        this.gpios.put("GPIO8_A2", 250);
        this.gpios.put("GPIO7_B3", 227);
        this.gpios.put("GPIO7_B1", 225);
        this.gpios.put("GPIO7_B2", 226);
        this.gpios.put("GPIO7_C5", 237);
        this.gpios.put("GPIO7_B4", 228);
        this.gpios.put("GPIO8_B0", 256);
        this.gpios.put("GPIO7_B5", 229);
        this.gpios.put("GPIO0_C2", 18);
        this.gpios.put("GPIO3_B0", 96);
        this.gpios.put("GPIO3_B2", 98);
        this.gpios.put("GPIO3_B3", 99);
        this.gpios.put("GPIO7_A0", 216);
        this.gpios.put("GPIO7_A2", 218);
        this.gpios.put("GPIO3_B6", 102);
        this.gpios.put("GPIO3_B7", 103);
        this.gpios.put("GPIO3_C1", 105);
        this.gpios.put("GPIO0_A7", 7);
        this.gpios.put("GPIO5_B2", 162);
        this.gpios.put("GPIO5_B3", 163);
        this.gpios.put("GPIO5_B4", 164);
        this.gpios.put("GPIO5_B5", 165);
        this.gpios.put("GPIO5_C0", 168);
    }

    public int gpioStringToInt(String str) {
        return super.gpioStringToInt(str) - 8;
    }

    public void setGPUMode(String str) {
        execRootCmdSilent(String.format("echo " + str + " >/sys/bus/platform/devices/ffa30000.gpu/devfreq/ffa30000.gpu/governor", new Object[0]));
    }
}
