Small fixes

This commit is contained in:
topjohnwu 2016-09-30 03:18:08 +08:00
parent e4cba70008
commit 0f5465c5da
3 changed files with 14 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import android.preference.PreferenceManager;
import android.util.Log;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.ModuleHelper;
import com.topjohnwu.magisk.utils.Utils;
import com.topjohnwu.magisk.utils.WebRequest;
@ -30,12 +31,15 @@ public class Repo extends BaseModule {
}
public void update() {
Logger.dev("Repo: Re-fetch prop " + mId);
String props = WebRequest.makeWebServiceCall(mManifestUrl, WebRequest.GET, true);
String lines[] = props.split("\\n");
parseProps(lines);
}
public void update(Date lastUpdate) {
Logger.dev("Repo: Old: " + mLastUpdate);
Logger.dev("Repo: New: " + lastUpdate);
if (lastUpdate.after(mLastUpdate)) {
mLastUpdate = lastUpdate;
update();

View File

@ -203,6 +203,7 @@ public class Async {
try {
InputStream in = mContext.getContentResolver().openInputStream(mUri);
mFile = new File(mContext.getCacheDir().getAbsolutePath() + "/install.zip");
Utils.removeFile(mFile.getPath());
createFileFromInputStream(in, mFile);
in.close();
} catch (FileNotFoundException e) {
@ -251,7 +252,12 @@ public class Async {
}
// Copy the file to sdcard
if (copyToSD && mFile != null) {
sdFile = new File(Environment.getExternalStorageDirectory() + "/MagiskManager/" + (mName.contains(".zip") ? mName : mName + ".zip").replace(" ", "_"));
String filename = (mName.contains(".zip") ? mName : mName + ".zip");
filename = filename.replace(" ", "_").replace("'", "").replace("\"", "")
.replace("$", "").replace("`", "").replace("(", "_").replace(")", "_")
.replace("#", "").replace("@", "").replace("*", "");
sdFile = new File(Environment.getExternalStorageDirectory() + "/MagiskManager/" + filename);
Logger.dev("FlashZip: Copy zip back to " + sdFile.getPath());
if ((!sdFile.getParentFile().exists() && !sdFile.getParentFile().mkdirs()) || (sdFile.exists() && !sdFile.delete())) {
sdFile = null;
} else {
@ -269,7 +275,7 @@ public class Async {
}
}
if (mFile.exists() && !mFile.delete()) {
Shell.su("rm -f " + mFile.getPath());
Utils.removeFile(mFile.getPath());
}
}
if (ret != null && Boolean.parseBoolean(ret.get(ret.size() - 1))) {

View File

@ -191,9 +191,11 @@ public class Shell {
}
} catch (IOException e) {
if (!e.getMessage().contains("EPIPE")) {
Logger.dev("Shell: Root shell error...");
return null;
}
} catch(InterruptedException e) {
Logger.dev("Shell: Root shell error...");
return null;
}