Skip to content

Commit

Permalink
cpu: add a new cardview for cpu_input_boost
Browse files Browse the repository at this point in the history
which includes an option to configure Input Boost Duration (ms) and set Input Boost Frequencies

Signed-off-by: sunilpaulmathew <sunil.kde@gmail.com>
  • Loading branch information
sunilpaulmathew committed Mar 22, 2018
1 parent fd486e2 commit 37c97a0
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected void addItems(List<RecyclerViewItem> items) {
cpuTouchBoostInit(items);
}
if (Misc.hascpuinputboost()) {
cpuinputboostInit(items);
cpuiboostInit(items);
}
}

Expand Down Expand Up @@ -626,20 +626,64 @@ public void onChanged(SwitchView switchView, boolean isChecked) {
items.add(touchBoost);
}

private void cpuinputboostInit(List<RecyclerViewItem> items) {
private void cpuiboostInit(List<RecyclerViewItem> items) {
CardView cpuiboostCard = new CardView(getActivity());
cpuiboostCard.setTitle(getString(R.string.cpuiboost));

if (Misc.hascpuinputboost()) {
SwitchView cpuinputboost = new SwitchView();
cpuinputboost.setTitle(getString(R.string.cpu_input_boost));
cpuinputboost.setSummary(getString(R.string.cpu_input_boost_summary));
cpuinputboost.setChecked(Misc.iscpuinputboostEnabled());
cpuinputboost.addOnSwitchListener(new SwitchView.OnSwitchListener() {
SwitchView cpuinputboost = new SwitchView();
cpuinputboost.setTitle(getString(R.string.cpu_input_boost));
cpuinputboost.setSummary(getString(R.string.cpu_input_boost_summary));
cpuinputboost.setChecked(Misc.iscpuinputboostEnabled());
cpuinputboost.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
Misc.enablecpuinputboost(isChecked, getActivity());
}
});

cpuiboostCard.addItem(cpuinputboost);
}

if (Misc.hascpuiboostduration()) {
SeekBarView cpuiboostduration = new SeekBarView();
cpuiboostduration.setTitle(getString(R.string.cpuiboost_duration));
cpuiboostduration.setTitle(getString(R.string.cpuiboost_duration_summary));
cpuiboostduration.setUnit(getString(R.string.ms));
cpuiboostduration.setMax(5000);
cpuiboostduration.setOffset(10);
cpuiboostduration.setProgress(Misc.getcpuiboostduration() / 10 );
cpuiboostduration.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
Misc.enablecpuinputboost(isChecked, getActivity());
public void onStop(SeekBarView seekBarView, int position, String value) {
Misc.setcpuiboostduration((position * 10), getActivity());
}

@Override
public void onMove(SeekBarView seekBarView, int position, String value) {
}
});

items.add(cpuinputboost);
cpuiboostCard.addItem(cpuiboostduration);
}

if (Misc.hascpuiboostfreq()) {
SwitchView cpuiboostfreq = new SwitchView();
cpuiboostfreq.setTitle(getString(R.string.cpuiboost_freq));
cpuiboostfreq.setSummary(getString(R.string.cpuiboost_freq_summary));
cpuiboostfreq.setChecked(Misc.iscpuiboostfreqEnabled());
cpuiboostfreq.addOnSwitchListener(new SwitchView.OnSwitchListener() {
@Override
public void onChanged(SwitchView switchView, boolean isChecked) {
Misc.enablecpuiboostfreq(isChecked, getActivity());
}
});

cpuiboostCard.addItem(cpuiboostfreq);
}

if (cpuiboostCard.size() > 0) {
items.add(cpuiboostCard);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public class Misc {
private static final String CPU_QUIET_CURRENT_GOVERNOR = CPU_QUIET + "/current_governor";

private static final String CPU_TOUCH_BOOST = "/sys/module/msm_performance/parameters/touchboost";
private static final String CPU_INPUT_BOOST = "/sys/kernel/cpu_input_boost/enabled";

private static final String CPU_INPUT_BOOST = "/sys/kernel/cpu_input_boost";
private static final String CPU_INPUT_BOOST_ENABLED = CPU_INPUT_BOOST + "/enabled";
private static final String CPU_INPUT_BOOST_DURATION = CPU_INPUT_BOOST + "/ib_duration_ms";
private static final String CPU_INPUT_BOOST_FREQ = CPU_INPUT_BOOST + "/ib_freqs";

private static String[] sAvailableCFSSchedulers;
private static String[] sCpuQuietAvailableGovernors;
Expand All @@ -64,15 +68,39 @@ public static boolean hasCpuTouchBoost() {
}

public static void enablecpuinputboost(boolean enable, Context context) {
run(Control.write(enable ? "1" : "0", CPU_INPUT_BOOST), CPU_INPUT_BOOST, context);
run(Control.write(enable ? "1" : "0", CPU_INPUT_BOOST_ENABLED), CPU_INPUT_BOOST_ENABLED, context);
}

public static boolean iscpuinputboostEnabled() {
return Utils.readFile(CPU_INPUT_BOOST).equals("1");
return Utils.readFile(CPU_INPUT_BOOST_ENABLED).equals("1");
}

public static boolean hascpuinputboost() {
return Utils.existFile(CPU_INPUT_BOOST);
return Utils.existFile(CPU_INPUT_BOOST_ENABLED);
}

public static void setcpuiboostduration(int value, Context context) {
run(Control.write(String.valueOf(value), CPU_INPUT_BOOST_DURATION), CPU_INPUT_BOOST_DURATION, context);
}

public static int getcpuiboostduration() {
return Utils.strToInt(Utils.readFile(CPU_INPUT_BOOST_DURATION));
}

public static boolean hascpuiboostduration() {
return Utils.existFile(CPU_INPUT_BOOST_DURATION);
}

public static void enablecpuiboostfreq(boolean enable, Context context) {
run(Control.write(enable ? "1190400 1497600" : "0 0", CPU_INPUT_BOOST_FREQ), CPU_INPUT_BOOST_FREQ, context);
}

public static boolean iscpuiboostfreqEnabled() {
return Utils.readFile(CPU_INPUT_BOOST_FREQ).equals("1190400 1497600");
}

public static boolean hascpuiboostfreq() {
return Utils.existFile(CPU_INPUT_BOOST_FREQ);
}

public static void setCpuQuietGovernor(String value, Context context) {
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,15 @@
<string name="hotplug_boost_summary">Hotplug Boost is similar to input boost but it occurs when CPUs go online.</string>
<string name="touch_boost">Touch Boost</string>
<string name="touch_boost_summary">This will boost your minimum CPU speed if you touch the screen or press a button.</string>

<!-- CPU Input Boost -->
<string name="cpuiboost">CPU Input Boost</string>
<string name="cpu_input_boost">CPU Input Boost</string>
<string name="cpu_input_boost_summary">Enable CPU Input Boost developed by Sultanxda.</string>
<string name="cpuiboost_duration">Input Boost duration (ms)</string>
<string name="cpuiboost_duration_summary">Select Input Boost duration</string>
<string name="cpuiboost_freq">Input Boost Frequencies</string>
<string name="cpuiboost_freq_summary">Apply Input Boost Frequencies\nNote: If enabled, a reboot is necessary to disable</string>

<!-- CPU Voltage -->
<string name="global_offset">Global Offset</string>
Expand Down

0 comments on commit 37c97a0

Please sign in to comment.