Skip to content

Commit

Permalink
VMFragment: Fix ZRam Max Value
Browse files Browse the repository at this point in the history
Signed-off-by: morogoku <morogoku@hotmail.com>
  • Loading branch information
morogoku committed Dec 30, 2018
1 parent 02f3b0d commit ef8a32d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,14 @@ private void zramInit(List<RecyclerViewItem> items) {
zram.setTitle(getString(R.string.disksize));
zram.setSummary(getString(R.string.disksize_summary));
zram.setUnit(getString(R.string.mb));
zram.setMax(2048);
zram.setOffset(10);
zram.setProgress(ZRAM.getDisksize() / 10);
zram.setMax(2560);
zram.setOffset(32);
zram.setProgress(ZRAM.getDisksize() / 32);
zram.setOnSeekBarListener(new SeekBarView.OnSeekBarListener() {
@Override
public void onStop(SeekBarView seekBarView, int position, String value) {
ZRAM.setDisksize(position * 10, getActivity());
ZRAM.setDisksize(position * 32, getActivity());
getHandler().postDelayed(() -> refreshBars(), 500);
}

@Override
Expand Down Expand Up @@ -278,9 +279,8 @@ private void refreshVMs() {
}
}, 250);
}
/*
protected void refresh() {
super.refresh();

protected void refreshBars() {

if (swap != null) {
long total = mMemInfo.getItemMb("SwapTotal");
Expand All @@ -293,5 +293,5 @@ protected void refresh() {
mem.setItems(total, progress);
}
}
*/

}
10 changes: 7 additions & 3 deletions app/src/main/java/com/moro/mtweaks/utils/kernel/vm/ZRAM.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public class ZRAM {
private static final String RESET = "/sys/block/zram0/reset";
private static final String MAX_COMP_STREAMS = "/sys/block/zram0/max_comp_streams";

public static void setDisksize(final int value, final Context context) {
public static void setDisksize(final long value, final Context context) {
String maxCompStrems = null;
if (Utils.existFile(MAX_COMP_STREAMS)) {
maxCompStrems = Utils.readFile(MAX_COMP_STREAMS);
}
int size = value * 1024 * 1024;
long size = value * 1024 * 1024;
run("swapoff " + BLOCK + " > /dev/null 2>&1", BLOCK + "swapoff", context);
run(Control.write("1", RESET), RESET, context);
run(Control.write("0", DISKSIZE), DISKSIZE + "reset", context);
Expand All @@ -52,11 +52,15 @@ public static void setDisksize(final int value, final Context context) {
run(Control.write(String.valueOf(size), DISKSIZE), DISKSIZE, context);
run("mkswap " + BLOCK + " > /dev/null 2>&1", BLOCK + "mkswap", context);
run("swapon " + BLOCK + " > /dev/null 2>&1", BLOCK + "swapon", context);
}else {
run("swapoff " + BLOCK + " > /dev/null 2>&1", BLOCK + "swapoff", context);
}
}

public static int getDisksize() {
return Utils.strToInt(Utils.readFile(DISKSIZE)) / 1024 / 1024;
long value = Utils.strToLong(Utils.readFile(DISKSIZE)) / 1024 / 1024;

return (int) value;
}

public static boolean supported() {
Expand Down

0 comments on commit ef8a32d

Please sign in to comment.