| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.invalidation; | 5 package org.chromium.chrome.browser.invalidation; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.Intent; | 8 import android.content.Intent; |
| 9 import android.os.AsyncTask; | 9 import android.os.AsyncTask; |
| 10 import android.os.Handler; | 10 import android.os.Handler; |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 mUseGcmUpstream = canUseGcmUpstream; | 353 mUseGcmUpstream = canUseGcmUpstream; |
| 354 mCanDisableSessionInvalidations = canDisableSessionInvalidations; | 354 mCanDisableSessionInvalidations = canDisableSessionInvalidations; |
| 355 mSessionInvalidationsEnabled = !mCanDisableSessionInvalidations; | 355 mSessionInvalidationsEnabled = !mCanDisableSessionInvalidations; |
| 356 mEnableSessionInvalidationsTimer = new Timer(); | 356 mEnableSessionInvalidationsTimer = new Timer(); |
| 357 | 357 |
| 358 ApplicationStatus.registerApplicationStateListener(this); | 358 ApplicationStatus.registerApplicationStateListener(this); |
| 359 } | 359 } |
| 360 | 360 |
| 361 private boolean shouldRestrictBackgroundServices() { | 361 private boolean shouldRestrictBackgroundServices() { |
| 362 // Restricts the use of background services when not in foreground. See
crbug.com/680812. | 362 // Restricts the use of background services when not in foreground. See
crbug.com/680812. |
| 363 return BuildInfo.isGreaterThanN() && !ApplicationStatus.hasVisibleActivi
ties(); | 363 return BuildInfo.isAtLeastO() && !ApplicationStatus.hasVisibleActivities
(); |
| 364 } | 364 } |
| 365 | 365 |
| 366 @Override | 366 @Override |
| 367 public void onApplicationStateChange(int newState) { | 367 public void onApplicationStateChange(int newState) { |
| 368 // The isSyncEnabled() check is used to check whether the InvalidationCo
ntroller would be | 368 // The isSyncEnabled() check is used to check whether the InvalidationCo
ntroller would be |
| 369 // started if it did not stop itself when the application is paused. | 369 // started if it did not stop itself when the application is paused. |
| 370 if (AndroidSyncSettings.isSyncEnabled(mContext)) { | 370 if (AndroidSyncSettings.isSyncEnabled(mContext)) { |
| 371 if (newState == ApplicationState.HAS_RUNNING_ACTIVITIES) { | 371 if (newState == ApplicationState.HAS_RUNNING_ACTIVITIES) { |
| 372 start(); | 372 start(); |
| 373 } else if (newState == ApplicationState.HAS_PAUSED_ACTIVITIES) { | 373 } else if (newState == ApplicationState.HAS_PAUSED_ACTIVITIES) { |
| 374 stop(); | 374 stop(); |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 } | 378 } |
| OLD | NEW |