Random changes

This commit is contained in:
topjohnwu 2017-07-22 17:39:34 +08:00
parent 73bb0b10ee
commit c325deb4ed
2 changed files with 7 additions and 8 deletions

View File

@ -32,7 +32,6 @@ public class SplashActivity extends Activity{
magiskManager.remoteMagiskVersionString = getIntent().getStringExtra(MagiskManager.INTENT_VERSION); magiskManager.remoteMagiskVersionString = getIntent().getStringExtra(MagiskManager.INTENT_VERSION);
magiskManager.magiskLink = getIntent().getStringExtra(MagiskManager.INTENT_LINK); magiskManager.magiskLink = getIntent().getStringExtra(MagiskManager.INTENT_LINK);
LoadModules loadModuleTask = new LoadModules(this); LoadModules loadModuleTask = new LoadModules(this);
if (Utils.checkNetworkStatus(this)) { if (Utils.checkNetworkStatus(this)) {
@ -44,10 +43,9 @@ public class SplashActivity extends Activity{
.setPersisted(true) .setPersisted(true)
.setPeriodic(8 * 60 * 60 * 1000) .setPeriodic(8 * 60 * 60 * 1000)
.build(); .build();
JobScheduler scheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE); ((JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE)).schedule(jobInfo);
scheduler.schedule(jobInfo);
} }
loadModuleTask.setCallBack(() -> new UpdateRepos(this).exec()); loadModuleTask.setCallBack(() -> new UpdateRepos(getApplication()).exec());
} }
// Now fire all async tasks // Now fire all async tasks

View File

@ -65,13 +65,14 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> {
ZipUtils.signZip(activity, temp1, temp2, true); ZipUtils.signZip(activity, temp1, temp2, true);
// Write it back to the downloaded zip, temp2 -> Uri // Write it back to the downloaded zip, temp2 -> Uri
FileInputStream in = new FileInputStream(temp2); try (OutputStream out = activity.getContentResolver().openOutputStream(mUri);
try (OutputStream target = activity.getContentResolver().openOutputStream(mUri)) { FileInputStream in = new FileInputStream(temp2)
) {
byte[] buffer = new byte[4096]; byte[] buffer = new byte[4096];
int length; int length;
if (target == null) throw new FileNotFoundException(); if (out == null) throw new FileNotFoundException();
while ((length = in.read(buffer)) > 0) while ((length = in.read(buffer)) > 0)
target.write(buffer, 0, length); out.write(buffer, 0, length);
} }
// Delete the temp file // Delete the temp file