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

View File

@ -54,7 +54,7 @@ public class LoadRepos extends ParallelTask<Void, Void, Void> {
repoDB.clearRepo(); repoDB.clearRepo();
} }
etags = new ArrayList<>( 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 { private void loadJSON(String jsonString) throws Exception {

View File

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

View File

@ -4,24 +4,15 @@ import android.app.job.JobParameters;
import android.app.job.JobService; import android.app.job.JobService;
import com.topjohnwu.magisk.asyncs.CheckUpdates; import com.topjohnwu.magisk.asyncs.CheckUpdates;
import com.topjohnwu.magisk.utils.Utils;
public class UpdateCheckService extends JobService { public class UpdateCheckService extends JobService {
@Override @Override
public boolean onStartJob(JobParameters params) { public boolean onStartJob(JobParameters params) {
new CheckUpdates(this, true){ Utils.getMagiskManager(this).updateMagiskInfo();
@Override new CheckUpdates(this, true)
protected Void doInBackground(Void... voids) { .setCallBack(() -> jobFinished(params, false)).exec();
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();
return true; return true;
} }