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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/omaha/OmahaDelegateBase.java

Issue 2664253005: [Omaha] Move most functionality to OmahaBase, add JobService (Closed)
Patch Set: [Omaha] Move most functionality to OmahaBase, add JobService Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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.omaha; 5 package org.chromium.chrome.browser.omaha;
6 6
7 import android.app.Service;
8 import android.content.Context; 7 import android.content.Context;
9 import android.content.pm.ApplicationInfo; 8 import android.content.pm.ApplicationInfo;
10 9
11 import org.chromium.base.ApiCompatibilityUtils; 10 import org.chromium.base.ApiCompatibilityUtils;
12 import org.chromium.base.ApplicationStatus; 11 import org.chromium.base.ApplicationStatus;
13 import org.chromium.chrome.browser.ChromeApplication; 12 import org.chromium.chrome.browser.ChromeApplication;
14 13
15 import java.util.UUID; 14 import java.util.UUID;
16 15
17 /** Delegates calls out from the OmahaClient. */ 16 /** Delegates calls out from the OmahaClient. */
18 public class OmahaDelegateImpl extends OmahaDelegate { 17 public abstract class OmahaDelegateBase extends OmahaDelegate {
19 private final ExponentialBackoffScheduler mScheduler; 18 private final ExponentialBackoffScheduler mScheduler;
19 private final Context mContext;
20 20
21 OmahaDelegateImpl(Context context) { 21 OmahaDelegateBase(Context context) {
22 super(context); 22 mContext = context;
23 mScheduler = new ExponentialBackoffScheduler(OmahaBase.PREF_PACKAGE, con text, 23 mScheduler = new ExponentialBackoffScheduler(OmahaBase.PREF_PACKAGE, con text,
24 OmahaClient.MS_POST_BASE_DELAY, OmahaClient.MS_POST_MAX_DELAY); 24 OmahaBase.MS_POST_BASE_DELAY, OmahaBase.MS_POST_MAX_DELAY);
25 } 25 }
26 26
27 @Override 27 @Override
28 Context getContext() {
29 return mContext;
30 }
31
32 @Override
28 boolean isInSystemImage() { 33 boolean isInSystemImage() {
29 return (getContext().getApplicationInfo().flags & ApplicationInfo.FLAG_S YSTEM) != 0; 34 return (getContext().getApplicationInfo().flags & ApplicationInfo.FLAG_S YSTEM) != 0;
30 } 35 }
31 36
32 @Override 37 @Override
33 ExponentialBackoffScheduler getScheduler() { 38 ExponentialBackoffScheduler getScheduler() {
34 return mScheduler; 39 return mScheduler;
35 } 40 }
36 41
37 @Override 42 @Override
38 String generateUUID() { 43 String generateUUID() {
39 return UUID.randomUUID().toString(); 44 return UUID.randomUUID().toString();
40 } 45 }
41 46
42 @Override 47 @Override
43 boolean isChromeBeingUsed() { 48 boolean isChromeBeingUsed() {
44 boolean isChromeVisible = ApplicationStatus.hasVisibleActivities(); 49 boolean isChromeVisible = ApplicationStatus.hasVisibleActivities();
45 boolean isScreenOn = ApiCompatibilityUtils.isInteractive(getContext()); 50 boolean isScreenOn = ApiCompatibilityUtils.isInteractive(getContext());
46 return isChromeVisible && isScreenOn; 51 return isChromeVisible && isScreenOn;
47 } 52 }
48 53
49 @Override 54 @Override
50 void scheduleService(Service service, long nextTimestamp) {
51 if (service instanceof OmahaClient) {
52 getScheduler().createAlarm(OmahaClient.createOmahaIntent(getContext( )), nextTimestamp);
53 } else {
54 // TODO(dfalcantara): Do something here with a JobService.
55 }
56 }
57
58 @Override
59 protected RequestGenerator createRequestGenerator(Context context) { 55 protected RequestGenerator createRequestGenerator(Context context) {
60 return ((ChromeApplication) context.getApplicationContext()).createOmaha RequestGenerator(); 56 return ((ChromeApplication) context.getApplicationContext()).createOmaha RequestGenerator();
61 } 57 }
62 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698