Update error messages

This commit is contained in:
topjohnwu 2016-11-29 13:38:32 +08:00
parent 24ef80351c
commit cb1df5217e
4 changed files with 20 additions and 13 deletions

View File

@ -81,6 +81,7 @@ public class MagiskFragment extends Fragment {
@Override @Override
protected boolean unzipAndCheck() { protected boolean unzipAndCheck() {
publishProgress(mContext.getString(R.string.zip_install_unzip_zip_msg)); publishProgress(mContext.getString(R.string.zip_install_unzip_zip_msg));
if (Shell.rootAccess()) {
// We might not have busybox yet, unzip with Java // We might not have busybox yet, unzip with Java
// We will have complete busybox after Magisk installation // We will have complete busybox after Magisk installation
ZipUtils.unzip(mCachedFile, new File(mCachedFile.getParent(), "magisk")); ZipUtils.unzip(mCachedFile, new File(mCachedFile.getParent(), "magisk"));
@ -88,7 +89,9 @@ public class MagiskFragment extends Fragment {
"mkdir -p " + Async.TMP_FOLDER_PATH + "/magisk", "mkdir -p " + Async.TMP_FOLDER_PATH + "/magisk",
"cp -af " + mCachedFile.getParent() + "/magisk/. " + Async.TMP_FOLDER_PATH + "/magisk" "cp -af " + mCachedFile.getParent() + "/magisk/. " + Async.TMP_FOLDER_PATH + "/magisk"
); );
return super.unzipAndCheck(); }
super.unzipAndCheck();
return true;
} }
@Override @Override

View File

@ -37,7 +37,6 @@ public class SplashActivity extends AppCompatActivity {
.apply(); .apply();
new Async.CheckUpdates(prefs).exec(); new Async.CheckUpdates(prefs).exec();
// new Async.ConstructEnv(getApplicationInfo()).exec();
new Async.LoadModules(prefs) { new Async.LoadModules(prefs) {
@Override @Override

View File

@ -207,7 +207,7 @@ public class Async {
@Override @Override
protected Integer doInBackground(Void... voids) { protected Integer doInBackground(Void... voids) {
Logger.dev("FlashZip Running... " + mFilename); Logger.dev("FlashZip Running... " + mFilename);
List<String> ret = null; List<String> ret;
try { try {
preProcessing(); preProcessing();
copyToCache(); copyToCache();
@ -216,8 +216,8 @@ public class Async {
return -1; return -1;
} }
if (!unzipAndCheck()) return 0; if (!unzipAndCheck()) return 0;
publishProgress(mContext.getString(R.string.zip_install_progress_msg, mFilename));
if (Shell.rootAccess()) { if (Shell.rootAccess()) {
publishProgress(mContext.getString(R.string.zip_install_progress_msg, mFilename));
ret = Shell.su( ret = Shell.su(
"BOOTMODE=true sh " + mCachedFile.getParent() + "BOOTMODE=true sh " + mCachedFile.getParent() +
"/META-INF/com/google/android/update-binary dummy 1 " + mCachedFile.getPath(), "/META-INF/com/google/android/update-binary dummy 1 " + mCachedFile.getPath(),
@ -231,6 +231,11 @@ public class Async {
"rm -rf " + mCachedFile.getParent() + "/*", "rm -rf " + mCachedFile.getParent() + "/*",
"rm -rf " + TMP_FOLDER_PATH "rm -rf " + TMP_FOLDER_PATH
); );
} else {
if (mCachedFile != null && mCachedFile.exists() && !mCachedFile.delete()) {
Utils.removeItem(mCachedFile.getPath());
}
return -1;
} }
if (ret != null && Boolean.parseBoolean(ret.get(ret.size() - 1))) { if (ret != null && Boolean.parseBoolean(ret.get(ret.size() - 1))) {
return 1; return 1;
@ -238,7 +243,7 @@ public class Async {
return -1; return -1;
} }
// -1 = error; 0 = invalid zip; 1 = success // -1 = error, manual install; 0 = invalid zip; 1 = success
@Override @Override
protected void onPostExecute(Integer result) { protected void onPostExecute(Integer result) {
super.onPostExecute(result); super.onPostExecute(result);

View File

@ -139,7 +139,7 @@ public class ZipUtils {
if (!entry.getName().contains(path)) { if (!entry.getName().contains(path)) {
continue; continue;
} }
Logger.dev("Extracting: " + entry); Logger.dev("ZipUtils: Extracting: " + entry);
is = zipfile.getInputStream(entry); is = zipfile.getInputStream(entry);
dest = new File(folder, entry.getName()); dest = new File(folder, entry.getName());
if (dest.getParentFile().mkdirs()) { if (dest.getParentFile().mkdirs()) {