Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3914)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaDelegateImpl.java

Issue 2665133005: [Omaha] Make the whole pipeline run each time (Closed)
Patch Set: Comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaDelegateImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaDelegateImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaDelegateImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..b0ae4375f1e928b3bdc004e7edb68fc93606b430
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaDelegateImpl.java
@@ -0,0 +1,62 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.omaha;
+
+import android.app.Service;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+
+import org.chromium.base.ApiCompatibilityUtils;
+import org.chromium.base.ApplicationStatus;
+import org.chromium.chrome.browser.ChromeApplication;
+
+import java.util.UUID;
+
+/** Delegates calls out from the OmahaClient. */
+public class OmahaDelegateImpl extends OmahaDelegate {
+ private final ExponentialBackoffScheduler mScheduler;
+
+ OmahaDelegateImpl(Context context) {
+ super(context);
+ mScheduler = new ExponentialBackoffScheduler(OmahaBase.PREF_PACKAGE, context,
+ OmahaClient.MS_POST_BASE_DELAY, OmahaClient.MS_POST_MAX_DELAY);
+ }
+
+ @Override
+ boolean isInSystemImage() {
+ return (getContext().getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) != 0;
+ }
+
+ @Override
+ ExponentialBackoffScheduler getScheduler() {
+ return mScheduler;
+ }
+
+ @Override
+ String generateUUID() {
+ return UUID.randomUUID().toString();
+ }
+
+ @Override
+ boolean isChromeBeingUsed() {
+ boolean isChromeVisible = ApplicationStatus.hasVisibleActivities();
+ boolean isScreenOn = ApiCompatibilityUtils.isInteractive(getContext());
+ return isChromeVisible && isScreenOn;
+ }
+
+ @Override
+ void scheduleService(Service service, long nextTimestamp) {
+ if (service instanceof OmahaClient) {
+ getScheduler().createAlarm(OmahaClient.createOmahaIntent(getContext()), nextTimestamp);
+ } else {
+ // TODO(dfalcantara): Do something here with a JobService.
+ }
+ }
+
+ @Override
+ protected RequestGenerator createRequestGenerator(Context context) {
+ return ((ChromeApplication) context.getApplicationContext()).createOmahaRequestGenerator();
+ }
+}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaDelegate.java ('k') | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698