Minor cleanup in check updates

This commit is contained in:
topjohnwu 2017-07-19 16:10:17 +08:00
parent 3550d1e61c
commit 240d14779a
4 changed files with 11 additions and 20 deletions

View File

@ -117,7 +117,6 @@ public class MagiskManager extends Application {
shellLogging = false;
}
magiskHide = prefs.getBoolean("magiskhide", true);
updateNotification = prefs.getBoolean("notification", true);
initSU();
updateMagiskInfo();
updateBlockInfo();
@ -183,6 +182,7 @@ public class MagiskManager extends Application {
}
public void updateMagiskInfo() {
updateNotification = prefs.getBoolean("notification", true);
List<String> ret;
ret = shell.sh("magisk -v");
if (!Utils.isValidShellResponse(ret)) {

View File

@ -54,7 +54,7 @@ public class LoadRepos extends ParallelTask<Void, Void, Void> {
repoDB.clearRepo();
}
etags = new ArrayList<>(
Arrays.asList(magiskManager.prefs.getString(ETAG_KEY, "").split(",")));
Arrays.asList(prefs.getString(ETAG_KEY, "").split(",")));
}
private void loadJSON(String jsonString) throws Exception {

View File

@ -42,9 +42,9 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> {
try {
// Create temp file
File temp1 = new File(magiskManager.getCacheDir(), "1.zip");
File temp2 = new File(magiskManager.getCacheDir(), "2.zip");
magiskManager.getCacheDir().mkdirs();
File temp1 = new File(activity.getCacheDir(), "1.zip");
File temp2 = new File(activity.getCacheDir(), "2.zip");
activity.getCacheDir().mkdirs();
temp1.createNewFile();
temp2.createNewFile();
@ -87,7 +87,7 @@ public class ProcessRepoZip extends ParallelTask<Void, Void, Boolean> {
progressDialog.dismiss();
if (result) {
if (Shell.rootAccess() && mInstall) {
magiskManager.startActivity(new Intent(magiskManager, FlashActivity.class).setData(mUri));
activity.startActivity(new Intent(activity, FlashActivity.class).setData(mUri));
} else {
Utils.showUriSnack(activity, mUri);
}

View File

@ -4,24 +4,15 @@ import android.app.job.JobParameters;
import android.app.job.JobService;
import com.topjohnwu.magisk.asyncs.CheckUpdates;
import com.topjohnwu.magisk.utils.Utils;
public class UpdateCheckService extends JobService {
@Override
public boolean onStartJob(JobParameters params) {
new CheckUpdates(this, true){
@Override
protected Void doInBackground(Void... voids) {
magiskManager.updateMagiskInfo();
magiskManager.updateNotification = magiskManager.prefs.getBoolean("notification", true);
return super.doInBackground(voids);
}
@Override
protected void onPostExecute(Void v) {
jobFinished(params, false);
super.onPostExecute(v);
}
}.exec();
public boolean onStartJob(JobParameters params) {
Utils.getMagiskManager(this).updateMagiskInfo();
new CheckUpdates(this, true)
.setCallBack(() -> jobFinished(params, false)).exec();
return true;
}