package xn.hxp.util;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.Utils;
import com.lztek.toolkit.Lztek;

import java.util.Locale;

public enum Tool {
    INSTANCE;
    private Lztek lztek;

    Tool() {
        lztek = Lztek.create(Utils.getApp());
    }

    public void cmd(String cmd) {
        LogUtils.d(cmd);
        lztek.suExec(cmd);
    }

    public void reboot() {
        lztek.hardReboot();
    }

    public void reStartApp() {
        exitApp();
        cmd("monkey -p " + AppUtils.getAppPackageName() + " -c android.intent.category.LAUNCHER 1");
    }

    public void openFileBrowser() {
        openApp("display.interactive.filebrowser");
    }

    public void exitApp() {
        cmd("am force-stop " + AppUtils.getAppPackageName());
    }

    public void openSetting() {
        openApp("com.android.settings");
    }

    public void openApp(String packageName) {
        cmd("monkey -p " + packageName + " -c android.intent.category.LAUNCHER 1");
    }

    public void setBluetooth(boolean isEnable) {
        cmd("settings put global bluetooth_on " + (isEnable ? "1" : "0"));
    }

    public String getSerialNumber() {
        String mac = lztek.getEthMac().toUpperCase(Locale.getDefault());
        return mac.replace(":", "");
    }

    public void showBar(boolean isShow) {
        lztek.navigationBarSlideShow(isShow);
    }
}
