package ZtlApi;

import android.content.Intent;
import android.os.SystemProperties;
import android.util.Log;
import java.io.File;
import java.io.IOException;

public class ZtlManager33997_1 extends ZtlManager {
    ZtlManager33997_1() {
        this.DEBUG_ZTL = SystemProperties.get("persist.sys.ztl.debug", "false").equals("true");
    }

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

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

    public int getUsbDebugState() {
        String str = "1";
        String systemProperty = getSystemProperty("persist.usb.mode", str);
        if (!systemProperty.equals("0") && !systemProperty.equals("2")) {
            str = "0";
        }
        return Integer.valueOf(str).intValue();
    }

    public boolean getUSBtoPC() {
        try {
            if (loadFileAsString("/sys/kernel/debug/usb@fe800000/rk_usb_force_mode").equals("2")) {
                return true;
            }
            return false;
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
    }

    public void setUSBtoPC(boolean z) {
        if (z) {
            setSystemProperty("persist.usb.mode", "2");
            writeMethod("/sys/kernel/debug/usb@fe800000/rk_usb_force_mode", "2");
        } else {
            setSystemProperty("persist.usb.mode", "1");
        }
        writeMethod("/sys/kernel/debug/usb@fe800000/rk_usb_force_mode", "1");
    }

    public int getSystemBarState() {
        return Integer.valueOf(getSystemProperty("persist.sys.barState", "1")).intValue();
    }

    public void setSplitScreenLeftRightEnable(boolean z) {
        Log.e("ztllib", "unsupport fucntion now for this board.todo later.");
    }

    public void setSplitScreenUpDownEnable(boolean z) {
        Log.e("ztllib", "unsupport fucntion now for this board.todo later.");
    }

    public String[] getScreenModes() {
        return getSystemProperty("persist.sys.displaymdoes", "").split(",");
    }

    public void setScreenMode(String str) {
        Intent intent = new Intent("android.ztl.action.SET_SCREEN_MODE");
        intent.putExtra("mode", str);
        this.mContext.sendBroadcast(intent);
    }

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