Skip to content

Commit

Permalink
add basic fstrim
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed Hady committed Jan 18, 2017
1 parent da20519 commit 6f2f6d8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Binary file added app/src/main/assets/fstrim
Binary file not shown.
37 changes: 37 additions & 0 deletions app/src/main/java/com/ultrakernel/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.Toast;

import com.eminayar.panter.PanterDialog;
import com.eminayar.panter.enums.Animation;
Expand All @@ -36,6 +37,12 @@
import com.ultrakernel.fragment.KernelFragment;
import com.ultrakernel.fragment.SystemInfo_fragement;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import eu.chainfire.libsuperuser.Shell;
import me.drakeet.materialdialog.MaterialDialog;

import static com.ultrakernel.util.Config.UpdaterUrl;
Expand Down Expand Up @@ -271,6 +278,36 @@ public void onClick(View v) {
}
});

public void fstrim(View v){
try {
fstrim_tmp();
Toast.makeText(getApplicationContext(), Shell.SU.run("cd " + package_path + " && fstrim -v /system").toString(), Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), Shell.SU.run("cd " + package_path + " && fstrim -v /data").toString(), Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), Shell.SU.run("cd " + package_path + " && fstrim -v /cache && rm -rf fstrim && cd").toString(), Toast.LENGTH_LONG).show();

} catch (IOException e) {
e.printStackTrace();
}
}

public final String package_path = "/data/data/com.ultrakernel/";
public final String fstrim = "fstrim";

public void fstrim_tmp() throws IOException {

OutputStream myOutput = new FileOutputStream(package_path + fstrim);
byte[] buffer = new byte[1024];
int length;
InputStream myInput = getBaseContext().getAssets().open("fstrim");
while ((length = myInput.read(buffer)) > 0) {
myOutput.write(buffer, 0, length);
}
myInput.close();
myOutput.flush();
myOutput.close();

}

//********************************* Getting & Setting Info ***********************************
public void PutStringPreferences(String Name,String Function){
SharedPreferences settings = getSharedPreferences(Name, 0);
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/float_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
fab:fab_colorNormal="?attr/colorAccent"
fab:fab_icon="@drawable/ic_trim"
fab:fab_size="mini"
fab:fab_title="FsTrim" />
fab:fab_title="FsTrim"
android:onClick="fstrim" />

<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/kill"
Expand Down

0 comments on commit 6f2f6d8

Please sign in to comment.