From b32129e774e4c88c9193303ec7f0c0d3a2452b3e Mon Sep 17 00:00:00 2001 From: nift4 Date: Thu, 11 Feb 2021 11:51:28 +0100 Subject: [PATCH] Bugfixes --- .../app/ui/home/HomeFragment.java | 3 ++- .../app/ui/roms/ROMFragment.java | 19 +++++++++++-------- .../app/util/ConfigFile.java | 5 +++-- .../androidbootmanager/app/util/SDUtils.java | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/androidbootmanager/app/ui/home/HomeFragment.java b/app/src/main/java/org/androidbootmanager/app/ui/home/HomeFragment.java index 9c54980c..17b8e5d8 100644 --- a/app/src/main/java/org/androidbootmanager/app/ui/home/HomeFragment.java +++ b/app/src/main/java/org/androidbootmanager/app/ui/home/HomeFragment.java @@ -29,6 +29,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; @@ -66,7 +67,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, byte[] buf = new byte[100]; int len; ByteArrayOutputStream s = new ByteArrayOutputStream(); - SuFileInputStream i = new SuFileInputStream("/data/abm/codename.cfg"); + InputStream i = SuFileInputStream.open("/data/abm/codename.cfg"); while ((len = i.read(buf)) > 0) s.write(buf, 0, len); model.setCodename(s.toString("UTF-8").replace("\n","")); diff --git a/app/src/main/java/org/androidbootmanager/app/ui/roms/ROMFragment.java b/app/src/main/java/org/androidbootmanager/app/ui/roms/ROMFragment.java index 457d9569..5e4da6c7 100644 --- a/app/src/main/java/org/androidbootmanager/app/ui/roms/ROMFragment.java +++ b/app/src/main/java/org/androidbootmanager/app/ui/roms/ROMFragment.java @@ -2,6 +2,7 @@ import android.content.Intent; import android.os.Bundle; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -145,20 +146,22 @@ public ViewHolder(View view) { .setCancelable(true) .setNeutralButton(R.string.cancel, (p1, p2) -> p1.dismiss()) .setNegativeButton(R.string.delete, (p1, p2) -> MiscUtils.sure(requireContext(), p1, getString(R.string.delete_msg_2, e.config.get("title")), (p112, p212) -> { - if (e.config.get("xsystem") != null && e.config.get("xdata") != null) { - if (e.config.get("xsystem").equals("real") || e.config.get("xdata").equals("real")) + Log.i("ABM","tryna1"); + if (e.config.get("xsystem") != null && e.config.get("xdata") != null) + if (e.config.get("xsystem").equals("real") || e.config.get("xdata").equals("real")) { new AlertDialog.Builder(requireContext()) .setTitle(R.string.failed) .setMessage(R.string.delete_real_rom) .setCancelable(true) .setNegativeButton(R.string.ok, (d, p) -> d.dismiss()) .show(); - } else { - if (!SuFile.open(e.file).delete()) - Toast.makeText(requireContext(),"Deleting configuration file: Error.",Toast.LENGTH_LONG).show(); - Shell.su("rm -rf /data/abm/bootset/" + e.file.replace("/data/abm/bootset/lk2nd/entries/","").replace(".conf","")).submit(); - updateEntries(); - } + return; + } + + if (!SuFile.open(e.file).delete()) + Toast.makeText(requireContext(),"Deleting configuration file: Error.",Toast.LENGTH_LONG).show(); + Shell.su("rm -rf /data/abm/bootset/" + e.file.replace("/data/abm/bootset/lk2nd/entries/","").replace(".conf","")).submit(); + updateEntries(); })) .setPositiveButton(R.string.save, (p1, p2) -> { e.config = proposed; diff --git a/app/src/main/java/org/androidbootmanager/app/util/ConfigFile.java b/app/src/main/java/org/androidbootmanager/app/util/ConfigFile.java index 82337cb9..bf59a705 100644 --- a/app/src/main/java/org/androidbootmanager/app/util/ConfigFile.java +++ b/app/src/main/java/org/androidbootmanager/app/util/ConfigFile.java @@ -9,6 +9,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; @@ -62,11 +63,11 @@ public static ConfigFile importFromString(String s) { public static ConfigFile importFromFile(File f) throws ActionAbortedCleanlyError { ByteArrayOutputStream s = new ByteArrayOutputStream(); - SuFileInputStream i; + InputStream i; byte[] b = new byte[1024]; int o; try { - i = new SuFileInputStream(f); + i = SuFileInputStream.open(f); } catch (FileNotFoundException e) { throw new ActionAbortedCleanlyError(e); } diff --git a/app/src/main/java/org/androidbootmanager/app/util/SDUtils.java b/app/src/main/java/org/androidbootmanager/app/util/SDUtils.java index ea8aa962..f9153612 100644 --- a/app/src/main/java/org/androidbootmanager/app/util/SDUtils.java +++ b/app/src/main/java/org/androidbootmanager/app/util/SDUtils.java @@ -154,7 +154,7 @@ public static String umsd(SDPartitionMeta meta) { for (Partition p : meta.p) s.append(umsd(p.type, meta.major, p.minor)).append(" && "); String e = s.toString(); - if (e.isEmpty()) return e; + if (e.isEmpty()) return "true"; return e.substring(0, e.length()-4); }