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,6 +39,7 @@ 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
if (!"install".equals(getIntent().getStringExtra(MainActivity.SECTION))) {
ComponentName service = new ComponentName(magiskManager, UpdateCheckService.class); ComponentName service = new ComponentName(magiskManager, UpdateCheckService.class);
JobInfo jobInfo = new JobInfo.Builder(UPDATE_SERVICE_ID, service) JobInfo jobInfo = new JobInfo.Builder(UPDATE_SERVICE_ID, service)
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
@ -47,6 +48,7 @@ public class SplashActivity extends Activity{
.build(); .build();
JobScheduler scheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE); JobScheduler scheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
scheduler.schedule(jobInfo); 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))