Update FlashZip

This commit is contained in:
topjohnwu
2016-09-18 04:32:49 +08:00
parent 11e1d04dd1
commit 1e09ccb4d9
2 changed files with 17 additions and 23 deletions
@@ -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);