Don't show notification again if coming from notification

This commit is contained in:
topjohnwu 2017-02-17 09:26:17 +08:00
parent ac44f05811
commit 1d70d0fe94
3 changed files with 12 additions and 12 deletions

View File

@ -47,7 +47,6 @@ public class MagiskManager extends Application {
public boolean isSuClient = false; public boolean isSuClient = false;
public String suVersion = null; public String suVersion = null;
public boolean disabled = false; public boolean disabled = false;
public boolean isNotified = false;
// Data // Data
public ValueSortedMap<String, Repo> repoMap; public ValueSortedMap<String, Repo> repoMap;

View File

@ -39,14 +39,16 @@ public class SplashActivity extends Activity{
boolean started = Utils.isValidShellResponse(ret) && Integer.parseInt(ret.get(0)) != 0; boolean started = Utils.isValidShellResponse(ret) && Integer.parseInt(ret.get(0)) != 0;
// Initialize the update check service, notify every 3 hours // Initialize the update check service, notify every 3 hours
ComponentName service = new ComponentName(magiskManager, UpdateCheckService.class); if (!"install".equals(getIntent().getStringExtra(MainActivity.SECTION))) {
JobInfo jobInfo = new JobInfo.Builder(UPDATE_SERVICE_ID, service) ComponentName service = new ComponentName(magiskManager, UpdateCheckService.class);
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) JobInfo jobInfo = new JobInfo.Builder(UPDATE_SERVICE_ID, service)
.setPersisted(true) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
.setPeriodic(3 * 60 * 60 * 1000) .setPersisted(true)
.build(); .setPeriodic(3 * 60 * 60 * 1000)
JobScheduler scheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE); .build();
scheduler.schedule(jobInfo); JobScheduler scheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
scheduler.schedule(jobInfo);
}
// Now fire all async tasks // Now fire all async tasks
new GetBootBlocks(this).exec(); new GetBootBlocks(this).exec();
@ -62,7 +64,7 @@ public class SplashActivity extends Activity{
} }
}.exec(); }.exec();
new LoadApps(this).exec(); new LoadApps(this).exec();
new CheckUpdates(this, true){ new CheckUpdates(this, !"install".equals(getIntent().getStringExtra(MainActivity.SECTION))){
@Override @Override
protected void onPostExecute(Void v) { protected void onPostExecute(Void v) {
super.onPostExecute(v); super.onPostExecute(v);

View File

@ -25,7 +25,7 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> {
public CheckUpdates(Context context, boolean b) { public CheckUpdates(Context context, boolean b) {
this(context); this(context);
showNotification = b && !magiskManager.isNotified; showNotification = b;
} }
public CheckUpdates(Context context) { public CheckUpdates(Context context) {
@ -49,7 +49,6 @@ public class CheckUpdates extends ParallelTask<Void, Void, Void> {
@Override @Override
protected void onPostExecute(Void v) { protected void onPostExecute(Void v) {
if (magiskManager.magiskVersion < magiskManager.remoteMagiskVersion && showNotification) { if (magiskManager.magiskVersion < magiskManager.remoteMagiskVersion && showNotification) {
magiskManager.isNotified = true;
NotificationCompat.Builder builder = new NotificationCompat.Builder(magiskManager); NotificationCompat.Builder builder = new NotificationCompat.Builder(magiskManager);
builder.setSmallIcon(R.drawable.ic_magisk) builder.setSmallIcon(R.drawable.ic_magisk)
.setContentTitle(magiskManager.getString(R.string.magisk_update_title)) .setContentTitle(magiskManager.getString(R.string.magisk_update_title))