Android Open Source - Pimp_my_Z1 Battery Profile






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  .  j  a v a2 s  .c  om*/
 *    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.profiles;

import com.androguide.honamicontrol.helpers.CPUHelper;
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 java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class BatteryProfile extends Profile {

    @Override
    public String getCpuMaxFreq() {
        String[] freqs = CPUHelper.getAvailableCPUFreqs();
        prefs.edit().putString("CPU_MAX_FREQ", freqs[freqs.length - 3]).commit();
        return toShell(freqs[freqs.length - 3], CPUInterface.MAX_FREQ) + "\n" + toShell(freqs[freqs.length - 3], CPUInterface.SNAKE_CHARMER_MAX_FREQ);
    }

    @Override
    public String getGpuMaxFreq() {
        String[] freqs = CPUHelper.getAvailableGPUFreqs();
        List<String> frequencies = Arrays.asList(freqs);
        if (frequencies.contains("389000000")) {
            prefs.edit().putString("GPU_MAX_FREQ", "389000000").commit();
            return toShell("389000000", GPUInterface.maxFreq);
        } else if (frequencies.contains("320000000")) {
            prefs.edit().putString("GPU_MAX_FREQ", "320000000").commit();
            return toShell("320000000", GPUInterface.maxFreq);
        } else {
            prefs.edit().putString("GPU_MAX_FREQ", "450000000").commit();
            return toShell("450000000", GPUInterface.maxFreq);
        }
    }

    @Override
    public String getCPUGovernor() {
        String[] govs = CPUHelper.readOneLineNotRoot(CPUInterface.GOVERNORS_LIST).split(" ");
        List<String> governors = Arrays.asList(govs);
        if (governors.contains("intellidemand")) {
            prefs.edit().putString("CORE0_GOVERNOR", "intellidemand").commit();
            return toShell("intellidemand", CPUInterface.GOVERNOR) + "\necho 50 > /sys/devices/system/cpu/cpufreq/intellidemand/powersave_bias";
        } else if (governors.contains("lionheart")) {
            prefs.edit().putString("CORE0_GOVERNOR", "lionheart").commit();
            return toShell("lionheart", CPUInterface.GOVERNOR);
        } else if (governors.contains("Lionheart")) {
            prefs.edit().putString("CORE0_GOVERNOR", "Lionheart").commit();
            return toShell("Lionheart", CPUInterface.GOVERNOR);
        } else if (governors.contains("lagfree")) {
            prefs.edit().putString("CORE0_GOVERNOR", "lagfree").commit();
            return toShell("lagfree", CPUInterface.GOVERNOR);
        } else if (governors.contains("conservative")) {
            prefs.edit().putString("CORE0_GOVERNOR", "conservative").commit();
            return toShell("conservative", CPUInterface.GOVERNOR);
        } else
            return "";
    }

    @Override
    public String getGPUGovernor() {
        String[] govs = CPUHelper.readOneLineNotRoot(GPUInterface.availableGovernors).split(" ");
        List<String> governors = Arrays.asList(govs);
        if (governors.contains("powersave")) {
            prefs.edit().putString("GPU_GOVERNOR", "powersave").commit();
            return toShell("powersave", GPUInterface.currGovernor);
        } else if (governors.contains("simple_ondemand")) {
            prefs.edit().putString("GPU_GOVERNOR", "simple_ondemand").commit();
            return toShell("simple_ondemand", GPUInterface.currGovernor);
        } else if (governors.contains("msm_cpufreq")) {
            prefs.edit().putString("GPU_GOVERNOR", "msm_cpufreq").commit();
            return toShell("msm_cpufreq", GPUInterface.currGovernor);
        } else {
            prefs.edit().putString("GPU_GOVERNOR", "msm-adreno-tz").commit();
            return toShell("msm-adreno-tz", GPUInterface.currGovernor);
        }
    }

    @Override
    public String getIOScheduler() {
        ArrayList<String> scheds = CPUHelper.getAvailableIOSchedulers();
        if (scheds.contains("sio")) {
            prefs.edit().putString("IO_SCHEDULER", "sio").commit();
            prefs.edit().putString("IO_SCHEDULER_SD", "sio").commit();
            return toShell("sio", IOTweaksInterface.IO_SCHEDULER) + "\n" + toShell("sio", IOTweaksInterface.IO_SCHEDULER_SD);
        } else if (scheds.contains("bfq")) {
            prefs.edit().putString("IO_SCHEDULER", "bfq").commit();
            prefs.edit().putString("IO_SCHEDULER_SD", "bfq").commit();
            return toShell("bfq", IOTweaksInterface.IO_SCHEDULER) + "\n" + toShell("bfq", IOTweaksInterface.IO_SCHEDULER_SD);
        } else if (scheds.contains("deadline")) {
            prefs.edit().putString("IO_SCHEDULER", "deadline").commit();
            prefs.edit().putString("IO_SCHEDULER_SD", "deadline").commit();
            return toShell("deadline", IOTweaksInterface.IO_SCHEDULER) + "\n" + toShell("deadline", IOTweaksInterface.IO_SCHEDULER_SD);
        } else if (scheds.contains("row")) {
            prefs.edit().putString("IO_SCHEDULER", "row").commit();
            prefs.edit().putString("IO_SCHEDULER_SD", "row").commit();
            return toShell("row", IOTweaksInterface.IO_SCHEDULER) + "\n" + toShell("row", IOTweaksInterface.IO_SCHEDULER_SD);
        } else
            return "";
    }

    @Override
    public String isIntelliplugEnabled() {
        prefs.edit().putBoolean("INTELLI_PLUG", true).commit();
        return "stop mpdecision\n" + "busybox echo 0 > " + PowerManagementInterface.MSM_MPDECISION_TOGGLE + "\n"
                + toShell("1", PowerManagementInterface.INTELLI_PLUG_TOGGLE);
    }

    @Override
    public String isEcoModeEnabled() {
        prefs.edit().putBoolean("INTELLI_PLUG_ECO", true).commit();
        return toShell("1", PowerManagementInterface.INTELLI_PLUG_ECO_MODE);
    }

    @Override
    public String isPowerSuspendEnabled() {
        prefs.edit().putBoolean("POWER_SUSPEND", true).commit();
        return toShell("1", PowerManagementInterface.POWER_SUSPEND_TOGGLE);
    }

    @Override
    public String isKSMEnabled() {
        prefs.edit().putBoolean("KSM_ENABLED", false).commit();
        return toShell("0", MemoryManagementInterface.KSM_TOGGLE);
    }

    @Override
    public String isDynFsyncEnabled() {
        prefs.edit().putBoolean("DYNAMIC_FSYNC", false).commit();
        return toShell("0", IOTweaksInterface.DYNAMIC_FSYNC_TOGGLE);
    }

    @Override
    public String isEntropyContributionEnabled() {
        prefs.edit().putBoolean("EMMC_ENTROPY_CONTRIB", false).commit();
        prefs.edit().putBoolean("SD_ENTROPY_CONTRIB", false).commit();
        return toShell("0", IOTweaksInterface.EMMC_ENTROPY_CONTRIB) + "\n" + toShell("0", IOTweaksInterface.SD_ENTROPY_CONTRIB);
    }

    @Override
    public String schedMCLevel() {
        prefs.edit().putInt("SCHED_MC_LEVEL", 2).commit();
        return toShell("2", PowerManagementInterface.SCHED_MC_POWER_SAVINGS);
    }

    @Override
    public String readahead() {
        prefs.edit().putString("EMMC_READAHEAD", "512").commit();
        prefs.edit().putString("SD_READAHEAD", "512").commit();
        return toShell("512", IOTweaksInterface.EMMC_READAHEAD) + "\n" + toShell("512", IOTweaksInterface.SD_READAHEAD);
    }

    @Override
    public String KSMpagesToScan() {
        prefs.edit().putString("KSM_PAGES_TO_SCAN", "0").commit();
        return toShell("0", MemoryManagementInterface.KSM_PAGES_TO_SCAN);
    }

    @Override
    public String KSMTimer() {
        prefs.edit().putString("KSM_SLEEP_TIMER", "0").commit();
        return toShell("0", MemoryManagementInterface.KSM_SLEEP_TIMER);
    }
}




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