From c325deb4ed5733f6ff19a6066f8acc1ad65c961e Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 22 Jul 2017 17:39:34 +0800 Subject: [PATCH] Random changes --- .../main/java/com/topjohnwu/magisk/SplashActivity.java | 6 ++---- .../java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java | 9 +++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java index b44749237..f28f5df24 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -32,7 +32,6 @@ public class SplashActivity extends Activity{ magiskManager.remoteMagiskVersionString = getIntent().getStringExtra(MagiskManager.INTENT_VERSION); magiskManager.magiskLink = getIntent().getStringExtra(MagiskManager.INTENT_LINK); - LoadModules loadModuleTask = new LoadModules(this); if (Utils.checkNetworkStatus(this)) { @@ -44,10 +43,9 @@ public class SplashActivity extends Activity{ .setPersisted(true) .setPeriodic(8 * 60 * 60 * 1000) .build(); - JobScheduler scheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE); - scheduler.schedule(jobInfo); + ((JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE)).schedule(jobInfo); } - loadModuleTask.setCallBack(() -> new UpdateRepos(this).exec()); + loadModuleTask.setCallBack(() -> new UpdateRepos(getApplication()).exec()); } // Now fire all async tasks diff --git a/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java b/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java index 3ecd63e5d..1e1e8d6a3 100644 --- a/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java +++ b/app/src/main/java/com/topjohnwu/magisk/asyncs/ProcessRepoZip.java @@ -65,13 +65,14 @@ public class ProcessRepoZip extends ParallelTask { ZipUtils.signZip(activity, temp1, temp2, true); // Write it back to the downloaded zip, temp2 -> Uri - FileInputStream in = new FileInputStream(temp2); - try (OutputStream target = activity.getContentResolver().openOutputStream(mUri)) { + try (OutputStream out = activity.getContentResolver().openOutputStream(mUri); + FileInputStream in = new FileInputStream(temp2) + ) { byte[] buffer = new byte[4096]; int length; - if (target == null) throw new FileNotFoundException(); + if (out == null) throw new FileNotFoundException(); while ((length = in.read(buffer)) > 0) - target.write(buffer, 0, length); + out.write(buffer, 0, length); } // Delete the temp file