Android Open Source - Pimp_my_Z1 Boot Helper






From Project

Back to project page Pimp_my_Z1.

License

The source code is released under:

GNU General Public License

If you think the Android project Pimp_my_Z1 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**   Copyright (C) 2013  Louis Teboul (a.k.a Androguide)
 */*from  w ww  .  java  2 s  .  c  o  m*/
 *    admin@pimpmyrom.org  || louisteboul@gmail.com
 *    http://pimpmyrom.org || http://androguide.fr
 *    71 quai Clmenceau, 69300 Caluire-et-Cuire, FRANCE.
 *
 *     This program is free software; you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation; either version 2 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License along
 *      with this program; if not, write to the Free Software Foundation, Inc.,
 *      51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 **/

package com.androguide.honamicontrol.bootservice;

import android.content.Context;
import android.content.SharedPreferences;

import com.androguide.honamicontrol.helpers.CMDProcessor.CMDProcessor;
import com.androguide.honamicontrol.helpers.CPUHelper;
import com.androguide.honamicontrol.helpers.Helpers;
import com.androguide.honamicontrol.kernel.colorcontrol.ColorControlInterface;
import com.androguide.honamicontrol.kernel.cpucontrol.CPUInterface;
import com.androguide.honamicontrol.kernel.gpucontrol.GPUInterface;
import com.androguide.honamicontrol.kernel.iotweaks.IOTweaksInterface;
import com.androguide.honamicontrol.kernel.memory.MemoryManagementInterface;
import com.androguide.honamicontrol.kernel.misc.MiscInterface;
import com.androguide.honamicontrol.kernel.powermanagement.PowerManagementInterface;
import com.androguide.honamicontrol.kernel.voltagecontrol.VoltageInterface;
import com.androguide.honamicontrol.soundcontrol.SoundControlInterface;
import com.androguide.honamicontrol.touchscreen.TouchScreenInterface;

public class BootHelper {
    public static void generateScriptFromPrefs(SharedPreferences prefs, Context context) {
        int CPU_MAX_FREQ = Integer.valueOf(prefs.getString("CPU_MAX_FREQ", "2150400"));
        int CPU_MIN_FREQ = Integer.valueOf(prefs.getString("CPU_MIN_FREQ", "300000"));
        int GPU_MAX_FREQ = Integer.valueOf(prefs.getString("GPU_MAX_FREQ", "450000000"));
        int GPU_MIN_FREQ = Integer.valueOf(prefs.getString("GPU_MIN_FREQ", "200000000"));
        int SCHED_MC_LEVEL = prefs.getInt("SCHED_MC_LEVEL", 0);
        int KSM_PAGES_TO_SCAN = prefs.getInt(MemoryManagementInterface.KSM_PAGES_TO_SCAN.replaceAll("/", "_"), 100);
        int KSM_SLEEP_TIMER = prefs.getInt(MemoryManagementInterface.KSM_SLEEP_TIMER.replaceAll("/", "_"), 500);
        int FASTCHARGE_MODE = prefs.getInt("FASTCHARGE_MODE", 0);
        int HOTPLUG_DRIVER = prefs.getInt("HOTPLUG_DRIVER", 0);
        int ALUCARD_CORES = prefs.getInt("ALUCARD_CORES", 4);
        int INTELLI_CORES = prefs.getInt("INTELLI_PLUG_ECO_CORES", 2);
        int VFS_CACHE_PRESSURE = prefs.getInt(MemoryManagementInterface.VFS_CACHE_PRESSURE, 100);
        int SWAPPINESS = prefs.getInt(MemoryManagementInterface.SWAPPINESS, 60);
        int DIRTY_RATIO = prefs.getInt(MemoryManagementInterface.DIRTY_RATIO, 20);
        int DIRTY_BG_RATIO = prefs.getInt(MemoryManagementInterface.DIRTY_BG_RATIO, 5);
        int DIRTY_WRITEBACK = prefs.getInt(MemoryManagementInterface.DIRTY_WRITEBACK_CENTISECS, 500);
        int DIRTY_EXPIRE = prefs.getInt(MemoryManagementInterface.DIRTY_EXPIRE_CENTISECS, 200);
        Boolean DYNAMIC_FSYNC = prefs.getBoolean("DYNAMIC_FSYNC", false);
        Boolean INTELLI_PLUG_ECO = prefs.getBoolean("INTELLI_PLUG_ECO", false);
        Boolean POWER_SUSPEND = prefs.getBoolean("POWER_SUSPEND", false);
        Boolean PEN_MODE = prefs.getBoolean("PEN_MODE", false);
        Boolean GLOVE_MODE = prefs.getBoolean("GLOVE_MODE", false);
        Boolean DT2WAKE = prefs.getBoolean("DT2WAKE", false);
        Boolean KSM_ENABLED = prefs.getBoolean("KSM_ENABLED", false);
        Boolean SNAKE_CHARMER = prefs.getBoolean("SNAKE_CHARMER", true);
        Boolean EMMC_ENTROPY = prefs.getBoolean("EMMC_ENTROPY_CONTRIB", true);
        Boolean SD_ENTROPY = prefs.getBoolean("SD_ENTROPY_CONTRIB", true);
        Boolean MSM_THERMAL = prefs.getBoolean("MSM_THERMAL", false);
        String CORE0_GOV = prefs.getString("CORE0_GOVERNOR", "intellidemand");
        String CORE1_GOV = prefs.getString("CORE1_GOVERNOR", "intellidemand");
        String CORE2_GOV = prefs.getString("CORE2_GOVERNOR", "intellidemand");
        String CORE3_GOV = prefs.getString("CORE3_GOVERNOR", "intellidemand");
        String GPU_GOV = prefs.getString("GPU_GOVERNOR", "msm-adreno-tz");
        String IO_SCHED_EMMC = prefs.getString("IO_SCHEDULER", "row");
        String IO_SCHED_SD = prefs.getString("IO_SCHEDULER_SD", "row");
        String TCP_ALGORITHM = prefs.getString("TCP_ALGORITHM", "cubic");
        String EMMC_READAHEAD = prefs.getString("EMMC_READAHEAD", "1024");
        String SD_READAHEAD = prefs.getString("SD_READAHEAD", "1024");
        String SC_MIC = prefs.getString("SC_MIC", "0 0 255");
        String SC_CAM_MIC = prefs.getString("SC_CAM_MIC", "0 0 255");
        String SC_HEADPHONE_PA = prefs.getString("HEADPHONE_PA", "38 38 179");
        String SC_HEADPHONE = prefs.getString("HEADPHONE", "0 0 255");
        String SC_SPEAKER = prefs.getString("SPEAKER", "0 0 255");
        String FASTCHARGE_LEVEL = prefs.getString("FASTCHARGE_LEVEL", "500");
        String KCAL_CONFIG = prefs.getString("KCAL_CONFIG", "255 255 255");
        String VOLTAGE_TABLE = prefs.getString("CURRENT_VOLTAGE_TABLE", prefs.getString("DEFAULT_VOLTAGE_TABLE", ""));

        // Governor Customization
        SharedPreferences govPrefs = context.getSharedPreferences("GOVERNOR_CUSTOMIZATION", 0);
        String TARGET_GOV = govPrefs.getString("TARGET_GOV", CPUHelper.readOneLineNotRoot(CPUInterface.GOVERNOR_ALL_CORES));
        if (Helpers.doesFileExist(CPUInterface.GOV_CUSTOMIZATION + "/" + TARGET_GOV)) {
            String[] paramsList = CMDProcessor.runShellCommand("ls " + CPUInterface.GOV_CUSTOMIZATION + "/" + TARGET_GOV)
                    .getStdout().split("\n");

            String commands = "";

            for (final String param : paramsList) {
                String key = govPrefs.getString(param, "null");
                if (!key.equals("null"))
                    commands += key + "\n";
            }

            CMDProcessor.runSuCommand(commands);
        }

        String applyMaxCpuFreq = "busybox echo " + CPU_MAX_FREQ + " > " + CPUInterface.MAX_FREQ;
        String applyMsmThermal;

        if (SNAKE_CHARMER)
            applyMaxCpuFreq += "\nbusybox echo " + CPU_MAX_FREQ + " > " + CPUInterface.SNAKE_CHARMER_MAX_FREQ;
        if (MSM_THERMAL)
            applyMsmThermal = "busybox echo Y > " + CPUInterface.MSM_THERMAL;
        else
            applyMsmThermal = "busybox echo N > " + CPUInterface.MSM_THERMAL;

        String applyMinCpuFreq = "busybox echo " + CPU_MIN_FREQ + " > " + CPUInterface.MIN_FREQ;
        String applyMaxGpuFreq = "busybox echo " + GPU_MAX_FREQ + " > " + GPUInterface.maxFreq;
        String applyMinGpuFreq = "busybox echo " + GPU_MIN_FREQ + " > " + GPUInterface.minFreq;
        String applyCore0Governor = "busybox echo " + CORE0_GOV + " > " + CPUInterface.GOVERNOR;
        String applyCore1Governor = "busybox echo " + CORE1_GOV + " > " + CPUInterface.GOVERNOR2;
        String applyCore2Governor = "busybox echo " + CORE2_GOV + " > " + CPUInterface.GOVERNOR3;
        String applyCore3Governor = "busybox echo " + CORE3_GOV + " > " + CPUInterface.GOVERNOR4;
        String applyGpuGovernor = "busybox echo " + GPU_GOV + " > " + GPUInterface.currGovernor;
        String applyIOScheduler = "busybox echo " + IO_SCHED_EMMC + " > " + IOTweaksInterface.IO_SCHEDULER;
        String applyIOSchedulerSD = "busybox echo " + IO_SCHED_SD + " > " + IOTweaksInterface.IO_SCHEDULER_SD;
        String applyTcpAlgorithm = "busybox echo " + TCP_ALGORITHM + " > " + CPUInterface.CURR_TCP_ALGORITHM + "\n" + CPUInterface.SYSCTL_TCP_ALGORITHM + TCP_ALGORITHM;
        String applySchedMcLevel = "busybox echo " + SCHED_MC_LEVEL + " > " + PowerManagementInterface.SCHED_MC_POWER_SAVINGS;
        String applyDynamicFsync = "busybox echo " + getIntFromBoolean(DYNAMIC_FSYNC) + " > " + IOTweaksInterface.DYNAMIC_FSYNC_TOGGLE;
        String applyIntelliPlugEco = "busybox echo " + getIntFromBoolean(INTELLI_PLUG_ECO) + " > " + PowerManagementInterface.INTELLI_PLUG_ECO_MODE;
        String applyPowerSuspend = "busybox echo " + getIntFromBoolean(POWER_SUSPEND) + " > " + PowerManagementInterface.POWER_SUSPEND_TOGGLE;
        String applyPenMode = "chown system:system " + TouchScreenInterface.PEN_MODE + "\nbusybox echo " + getIntFromBoolean(PEN_MODE) + " > " + TouchScreenInterface.PEN_MODE;
        String applyGloveMode = "chown system:system " + TouchScreenInterface.PEN_MODE + "\nbusybox echo " + getIntFromBoolean(GLOVE_MODE) + " > " + TouchScreenInterface.GLOVE_MODE;
        String applyDt2Wake = "busybox echo " + getIntFromBoolean(DT2WAKE) + " > " + TouchScreenInterface.DT2WAKE;
        String applyScHeadphone = "busybox echo " + SC_HEADPHONE + " > " + SoundControlInterface.FAUX_SC_HEADPHONE;
        String applyScHeadphonePa = "busybox echo " + SC_HEADPHONE_PA + " > " + SoundControlInterface.FAUX_SC_HEADPHONE_POWERAMP;
        String applyScSpeaker = "busybox echo " + SC_SPEAKER + " > " + SoundControlInterface.FAUX_SC_SPEAKER;
        String applyScMic = "busybox echo " + SC_MIC + " > " + SoundControlInterface.FAUX_SC_MIC;
        String applyScCamMic = "busybox echo " + SC_CAM_MIC + " > " + SoundControlInterface.FAUX_SC_CAM_MIC;
        String applyKSM = "busybox echo " + getIntFromBoolean(KSM_ENABLED) + " > " + MemoryManagementInterface.KSM_TOGGLE;
        String applyKSMPages = "busybox echo " + KSM_PAGES_TO_SCAN + " > " + MemoryManagementInterface.KSM_PAGES_TO_SCAN;
        String applyKSMTimer = "busybox echo " + KSM_SLEEP_TIMER + " > " + MemoryManagementInterface.KSM_SLEEP_TIMER;
        String applyEmmcReadahead = "busybox echo " + EMMC_READAHEAD + " > " + IOTweaksInterface.EMMC_READAHEAD;
        String applySDReadahead = "busybox echo " + SD_READAHEAD + " > " + IOTweaksInterface.SD_READAHEAD;
        String applyEmmcEntropy = "busybox echo " + EMMC_ENTROPY + " > " + IOTweaksInterface.EMMC_ENTROPY_CONTRIB;
        String applySDEntropy = "busybox echo " + SD_ENTROPY + " > " + IOTweaksInterface.SD_ENTROPY_CONTRIB;
        String applyFastChargeMode = "busybox echo " + FASTCHARGE_MODE + " > " + MiscInterface.FORCE_FAST_CHARGE;
        String applyFastChargeLevel = "busybox echo " + FASTCHARGE_LEVEL + " > " + MiscInterface.FAST_CHARGE_LEVEL;
        String applyColorControl = "busybox echo \"" + KCAL_CONFIG + "\" > " + ColorControlInterface.GAMMA_KCAL + "\nbusybox echo 1 > " + ColorControlInterface.GAMMA_OK;
        String applyVoltages = "busybox echo \"" + VOLTAGE_TABLE + "\" > " + VoltageInterface.UV_MV_TABLE;

        Helpers.CMDProcessorWrapper.runSuCommand(
                applyMaxCpuFreq + "\n" +
                        applyMinCpuFreq + "\n" +
                        applyMaxGpuFreq + "\n" +
                        applyMinGpuFreq + "\n" +
                        applyCore0Governor + "\n" +
                        applyCore1Governor + "\n" +
                        applyCore2Governor + "\n" +
                        applyCore3Governor + "\n" +
                        applyIOScheduler + "\n" +
                        applyIOSchedulerSD + "\n" +
                        applyEmmcReadahead + "\n" +
                        applySDReadahead + "\n" +
                        applyEmmcEntropy + "\n" +
                        applySDEntropy + "\n" +
                        applyTcpAlgorithm + "\n" +
                        applyGpuGovernor + "\n" +
                        "echo 0 > " + SoundControlInterface.FAUX_SC_LOCKED + "\n" +
                        applyScHeadphone + "\n" +
                        applyScHeadphonePa + "\n" +
                        applyScSpeaker + "\n" +
                        applyScMic + "\n" +
                        applyScCamMic + "\n" +
                        "echo 1 > " + SoundControlInterface.FAUX_SC_LOCKED + "\n" +
                        applySchedMcLevel + "\n" +
                        applyDynamicFsync + "\n" +
                        applyPowerSuspend + "\n" +
                        applyMsmThermal + "\n" +
                        applyKSM + "\n" +
                        applyKSMPages + "\n" +
                        applyKSMTimer + "\n" +
                        applyColorControl + "\n" +
                        applyFastChargeMode + "\n" +
                        applyFastChargeLevel + "\n" +
                        applyPenMode + "\n" +
                        applyGloveMode + "\n" +
                        applyDt2Wake + "\n" +
                        applyVoltages
        );

        switch (HOTPLUG_DRIVER) {
            case 0:
                CMDProcessor.runSuCommand("echo 0 > " + PowerManagementInterface.INTELLI_PLUG_TOGGLE);
                CMDProcessor.runSuCommand("echo 0 > " + PowerManagementInterface.ALUCARD_HOTPLUG_TOGGLE);
                CMDProcessor.runSuCommand("start mpdecision");
                break;
            case 1:
                CMDProcessor.runSuCommand("echo 0 > " + PowerManagementInterface.ALUCARD_HOTPLUG_TOGGLE);
                CMDProcessor.runSuCommand("stop mpdecision");
                CMDProcessor.runSuCommand("echo 1 > " + PowerManagementInterface.INTELLI_PLUG_TOGGLE);
                CMDProcessor.runSuCommand("echo " + INTELLI_CORES + " > " + PowerManagementInterface.INTELLI_PLUG_ECO_CORES);
                break;
            case 2:
                CMDProcessor.runSuCommand("echo 0 > " + PowerManagementInterface.INTELLI_PLUG_TOGGLE);
                CMDProcessor.runSuCommand("stop mpdecision");
                CMDProcessor.runSuCommand("echo 1 > " + PowerManagementInterface.ALUCARD_HOTPLUG_TOGGLE);
                CMDProcessor.runSuCommand("echo " + ALUCARD_CORES + " > " + PowerManagementInterface.ALUCARD_HOTPLUG_CORES);
                break;
            default:
                break;
        }

        CMDProcessor.runSuCommand(applyIntelliPlugEco);

        Helpers.applySysctlValue(MemoryManagementInterface.VFS_CACHE_PRESSURE, VFS_CACHE_PRESSURE + "");
        Helpers.applySysctlValue(MemoryManagementInterface.SWAPPINESS, SWAPPINESS + "");
        Helpers.applySysctlValue(MemoryManagementInterface.DIRTY_RATIO, DIRTY_RATIO + "");
        Helpers.applySysctlValue(MemoryManagementInterface.DIRTY_BG_RATIO, DIRTY_BG_RATIO + "");
        Helpers.applySysctlValue(MemoryManagementInterface.DIRTY_WRITEBACK_CENTISECS, DIRTY_WRITEBACK + "");
        Helpers.applySysctlValue(MemoryManagementInterface.DIRTY_EXPIRE_CENTISECS, DIRTY_EXPIRE + "");
    }

    private static int getIntFromBoolean(Boolean bool) {
        if (bool)
            return 1;
        else
            return 0;
    }
}




Java Source Code List

com.androguide.honamicontrol.MainActivity.java
com.androguide.honamicontrol.PresentationActivity.java
com.androguide.honamicontrol.SettingsActivity.java
com.androguide.honamicontrol.bootservice.BootHelper.java
com.androguide.honamicontrol.bootservice.BootReceiver.java
com.androguide.honamicontrol.cards.CardDoubleSeekBarPA.java
com.androguide.honamicontrol.cards.CardDoubleSeekBar.java
com.androguide.honamicontrol.cards.CardImageLocal.java
com.androguide.honamicontrol.cards.CardSeekBarGeneric.java
com.androguide.honamicontrol.cards.CardSeekBarReadahead.java
com.androguide.honamicontrol.cards.CardSeekBarSC.java
com.androguide.honamicontrol.cards.CardSeekBarSysctl.java
com.androguide.honamicontrol.cards.CardSeekBarVibrator.java
com.androguide.honamicontrol.cards.CardSeekBar.java
com.androguide.honamicontrol.cards.CardSpinnerSchedMCDisabled.java
com.androguide.honamicontrol.cards.CardSpinnerSchedMC.java
com.androguide.honamicontrol.cards.CardSpinnerVoltage.java
com.androguide.honamicontrol.cards.CardSpinner.java
com.androguide.honamicontrol.cards.CardSwitchDisabled.java
com.androguide.honamicontrol.cards.CardSwitchPlugin.java
com.androguide.honamicontrol.cards.CardTopImageLocal.java
com.androguide.honamicontrol.fragments.CardsFragment.java
com.androguide.honamicontrol.fragments.HelpFragment.java
com.androguide.honamicontrol.fragments.WelcomeFragment.java
com.androguide.honamicontrol.helpers.CPUHelper.java
com.androguide.honamicontrol.helpers.FileHelper.java
com.androguide.honamicontrol.helpers.Helpers.java
com.androguide.honamicontrol.helpers.NegativeSeekBar.java
com.androguide.honamicontrol.helpers.ShellInterface.java
com.androguide.honamicontrol.helpers.SystemPropertiesReflection.java
com.androguide.honamicontrol.helpers.CMDProcessor.AbstractAsyncSuCMDProcessor.java
com.androguide.honamicontrol.helpers.CMDProcessor.CMDProcessor.java
com.androguide.honamicontrol.helpers.CMDProcessor.ChildProcess.java
com.androguide.honamicontrol.helpers.CMDProcessor.CommandResult.java
com.androguide.honamicontrol.helpers.CMDProcessor.Constants.java
com.androguide.honamicontrol.helpers.CMDProcessor.Shell.java
com.androguide.honamicontrol.kernel.KernelFragment.java
com.androguide.honamicontrol.kernel.colorcontrol.ColorControlActivity.java
com.androguide.honamicontrol.kernel.colorcontrol.ColorControlInterface.java
com.androguide.honamicontrol.kernel.cpucontrol.CPUActivity.java
com.androguide.honamicontrol.kernel.cpucontrol.CPUFragment.java
com.androguide.honamicontrol.kernel.cpucontrol.CPUInterface.java
com.androguide.honamicontrol.kernel.cpucontrol.GovernorDialog.java
com.androguide.honamicontrol.kernel.gpucontrol.GPUActivity.java
com.androguide.honamicontrol.kernel.gpucontrol.GPUInterface.java
com.androguide.honamicontrol.kernel.iotweaks.IOTweaksActivity.java
com.androguide.honamicontrol.kernel.iotweaks.IOTweaksInterface.java
com.androguide.honamicontrol.kernel.memory.MemoryManagementActivity.java
com.androguide.honamicontrol.kernel.memory.MemoryManagementInterface.java
com.androguide.honamicontrol.kernel.misc.MiscActivity.java
com.androguide.honamicontrol.kernel.misc.MiscInterface.java
com.androguide.honamicontrol.kernel.powermanagement.PowerManagementActivity.java
com.androguide.honamicontrol.kernel.powermanagement.PowerManagementInterface.java
com.androguide.honamicontrol.kernel.voltagecontrol.VoltageActivity.java
com.androguide.honamicontrol.kernel.voltagecontrol.VoltageInterface.java
com.androguide.honamicontrol.profiles.BalancedProfile.java
com.androguide.honamicontrol.profiles.BatteryMaxProfile.java
com.androguide.honamicontrol.profiles.BatteryProfile.java
com.androguide.honamicontrol.profiles.BenchmarkProfile.java
com.androguide.honamicontrol.profiles.PerformanceProfile.java
com.androguide.honamicontrol.profiles.ProfileEnabler.java
com.androguide.honamicontrol.profiles.Profile.java
com.androguide.honamicontrol.soundcontrol.SoundControlActivity.java
com.androguide.honamicontrol.soundcontrol.SoundControlFragment.java
com.androguide.honamicontrol.soundcontrol.SoundControlInterface.java
com.androguide.honamicontrol.soundcontrol.SoundFragment.java
com.androguide.honamicontrol.touchscreen.TouchScreenFragment.java
com.androguide.honamicontrol.touchscreen.TouchScreenInterface.java
com.astuetz.viewpager.extensions.PagerSlidingTabStrip.java
com.echo.holographlibrary.BarGraph.java
com.echo.holographlibrary.Bar.java
com.echo.holographlibrary.LineGraph.java
com.echo.holographlibrary.LinePoint.java
com.echo.holographlibrary.Line.java
com.echo.holographlibrary.PieGraph.java
com.echo.holographlibrary.PieSlice.java
com.fima.cardsui.StackAdapter.java
com.fima.cardsui.SwipeDismissTouchListener.java
com.fima.cardsui.Utils.java
com.fima.cardsui.objects.AbstractCard.java
com.fima.cardsui.objects.CardStack.java
com.fima.cardsui.objects.Card.java
com.fima.cardsui.views.CardCategory.java
com.fima.cardsui.views.CardDownload.java
com.fima.cardsui.views.CardEditText.java
com.fima.cardsui.views.CardEdit.java
com.fima.cardsui.views.CardImage.java
com.fima.cardsui.views.CardPresentation.java
com.fima.cardsui.views.CardSeekBar.java
com.fima.cardsui.views.CardSpinner.java
com.fima.cardsui.views.CardTextStripe.java
com.fima.cardsui.views.CardText.java
com.fima.cardsui.views.CardTopImage.java
com.fima.cardsui.views.CardUI.java
com.fima.cardsui.views.QuickReturnListView.java