From 1e09ccb4d96ca8a5ec8c90c74eabad48da47190f Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 18 Sep 2016 04:32:49 +0800 Subject: [PATCH] Update FlashZip --- .../com/topjohnwu/magisk/ModulesFragment.java | 14 +++------- .../com/topjohnwu/magisk/utils/Utils.java | 26 +++++++++---------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java b/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java index 5db423f50..0354f4184 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java @@ -43,14 +43,10 @@ public class ModulesFragment extends Fragment { private static final int FETCH_ZIP_CODE = 2; public static List listModules = new ArrayList<>(); public static List listModulesCache = new ArrayList<>(); - @BindView(R.id.progressBar) - ProgressBar progressBar; - @BindView(R.id.fab) - FloatingActionButton fabio; - @BindView(R.id.pager) - ViewPager viewPager; - @BindView(R.id.tab_layout) - TabLayout tabLayout; + @BindView(R.id.progressBar) ProgressBar progressBar; + @BindView(R.id.fab) FloatingActionButton fabio; + @BindView(R.id.pager) ViewPager viewPager; + @BindView(R.id.tab_layout) TabLayout tabLayout; private int viewPagePosition; private RepoHelper.TaskDelegate mTaskDelegate; @@ -69,12 +65,10 @@ public class ModulesFragment extends Fragment { }); - new Utils.LoadModules(getActivity()).execute(); mTaskDelegate = result -> { if (result.equals("OK")) { RefreshUI(); } - }; new updateUI().execute(); diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java index fb4d11322..74d0babcc 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java @@ -517,13 +517,13 @@ public class Utils { final String docId = DocumentsContract.getDocumentId(mUri); Log.d("Magisk","Utils: FlashZip Running, " + docId + " and " + mUri.toString()); - String[] split = docId.split(":"); - mName = split[1]; - if (mName.contains("/")) { - split = mName.split("/"); - } - if (split[1].contains(".zip")) { - file = mContext.getFilesDir() + "/" + split[1]; + if (docId.contains(":")) + mName = docId.split(":")[1]; + else mName = docId; + if (mName.contains("/")) + mName = mName.substring(mName.lastIndexOf('/') + 1); + if (mName.contains(".zip")) { + file = mContext.getFilesDir() + "/" + mName; Log.d("Magisk", "Utils: FlashZip running for uRI " + mUri.toString()); } else { Log.e("Magisk", "Utils: error parsing Zipfile " + mUri.getPath()); @@ -587,6 +587,7 @@ public class Utils { protected Boolean doInBackground(Void... voids) { if (mPath != null) { Log.e("Magisk", "Utils: Error, flashZIP called without a valid zip file to flash."); + progress.dismiss(); this.cancel(true); return false; } @@ -594,11 +595,11 @@ public class Utils { return false; } else { ret = Shell.su( - "rm -rf /data/tmp", - "mkdir -p /data/tmp", - "cp -af " + mPath + " /data/tmp/install.zip", - "unzip -o /data/tmp/install.zip META-INF/com/google/android/* -d /data/tmp", - "BOOTMODE=true sh /data/tmp/META-INF/com/google/android/update-binary dummy 1 /data/tmp/install.zip", + "rm -rf /dev/tmp", + "mkdir -p /dev/tmp", + "cp -af " + mPath + " /dev/tmp/install.zip", + "unzip -o /dev/tmp/install.zip META-INF/com/google/android/* -d /dev/tmp", + "BOOTMODE=true sh /dev/tmp/META-INF/com/google/android/update-binary dummy 1 /dev/tmp/install.zip", "if [ $? -eq 0 ]; then echo true; else echo false; fi" ); return ret != null && Boolean.parseBoolean(ret.get(ret.size() - 1)); @@ -608,7 +609,6 @@ public class Utils { @Override protected void onPostExecute(Boolean result) { super.onPostExecute(result); - Shell.su("rm -rf /data/tmp"); if (deleteFileAfter) { Shell.su("rm -rf " + mPath); Log.d("Magisk", "Utils: Deleting file " + mPath);