Fix FlashZip crash when fails

This commit is contained in:
topjohnwu 2017-07-31 01:19:43 +08:00
parent 53477f0f59
commit 959aaee045

View File

@ -1,5 +1,6 @@
package com.topjohnwu.magisk.asyncs; package com.topjohnwu.magisk.asyncs;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.text.TextUtils; import android.text.TextUtils;
@ -26,7 +27,7 @@ public class FlashZip extends ParallelTask<Void, String, Integer> {
private String mFilename; private String mFilename;
private AdaptiveList<String> mList; private AdaptiveList<String> mList;
public FlashZip(Context context, Uri uri, AdaptiveList<String> list) { public FlashZip(Activity context, Uri uri, AdaptiveList<String> list) {
super(context); super(context);
mUri = uri; mUri = uri;
mList = list; mList = list;
@ -100,22 +101,22 @@ public class FlashZip extends ParallelTask<Void, String, Integer> {
MagiskManager magiskManager = getMagiskManager(); MagiskManager magiskManager = getMagiskManager();
if (magiskManager == null) return; if (magiskManager == null) return;
magiskManager.shell.su_raw( magiskManager.shell.su_raw(
"rm -rf " + mCachedFile.getParent() + "/*", "rm -rf " + mCachedFile.getParent(),
"rm -rf " + MagiskManager.TMP_FOLDER_PATH "rm -rf " + MagiskManager.TMP_FOLDER_PATH
); );
switch (result) { switch (result) {
case -1: case -1:
mList.add(magiskManager.getString(R.string.install_error)); mList.add(magiskManager.getString(R.string.install_error));
Utils.showUriSnack(getActivity(), mUri); Utils.showUriSnack(getActivity(), mUri);
return; break;
case 0: case 0:
mList.add(magiskManager.getString(R.string.invalid_zip)); mList.add(magiskManager.getString(R.string.invalid_zip));
return; break;
case 1: case 1:
// Success // Success
new LoadModules(magiskManager).exec();
break; break;
} }
new LoadModules(magiskManager).exec();
super.onPostExecute(result); super.onPostExecute(result);
} }
} }