Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: mobile/android/base/updater/UpdateServiceHelper.java

Issue 4865921483014144: Check adblockplus.org for updates (Closed)
Patch Set: Created Dec. 9, 2014, 7:56 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | mobile/android/branding/adblockbrowser/configure.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- 1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public 2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 5
6 package org.mozilla.gecko.updater; 6 package org.mozilla.gecko.updater;
7 7
8 import org.mozilla.gecko.AppConstants; 8 import org.mozilla.gecko.AppConstants;
9 import org.mozilla.gecko.util.GeckoJarReader; 9 import org.mozilla.gecko.util.GeckoJarReader;
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // Name of the Intent extra that holds the flags for ACTION_CHECK_FOR_UPDATE 46 // Name of the Intent extra that holds the flags for ACTION_CHECK_FOR_UPDATE
47 public static final String EXTRA_UPDATE_FLAGS_NAME = "updateFlags"; 47 public static final String EXTRA_UPDATE_FLAGS_NAME = "updateFlags";
48 48
49 // Name of the Intent extra that holds the APK path, used with ACTION_APPLY_ UPDATE 49 // Name of the Intent extra that holds the APK path, used with ACTION_APPLY_ UPDATE
50 public static final String EXTRA_PACKAGE_PATH_NAME = "packagePath"; 50 public static final String EXTRA_PACKAGE_PATH_NAME = "packagePath";
51 51
52 private static final String LOGTAG = "UpdateServiceHelper"; 52 private static final String LOGTAG = "UpdateServiceHelper";
53 private static final String DEFAULT_UPDATE_LOCALE = "en-US"; 53 private static final String DEFAULT_UPDATE_LOCALE = "en-US";
54 54
55 private static final String UPDATE_URL; 55 private static final String UPDATE_URL =
56 56 "https://adblockplus.org/devbuilds/adblockbrowser/updates.xml" +
57 static { 57 "?type=0" +
58 final String pkgSpecial; 58 "&addonName=adblockbrowser" +
59 if (AppConstants.MOZ_PKG_SPECIAL != null) { 59 "&addonVersion=%BUILDID%" +
60 pkgSpecial = "-" + AppConstants.MOZ_PKG_SPECIAL; 60 "&applicationName=android" +
61 } else { 61 "&applicationVersion=%OS_VERSION%" +
62 pkgSpecial = ""; 62 "&platform=" + AppConstants.MOZ_APP_BASENAME +
Felix Dahlke 2014/12/09 19:58:34 This just says "Fennec". We can change it to somet
63 } 63 "&platformVersion=" + AppConstants.MOZ_APP_VERSION +
Felix Dahlke 2014/12/09 19:58:34 We can and probably will change this since it's th
64 UPDATE_URL = "https://aus4.mozilla.org/update/4/" + AppConstants.MOZ_APP _BASENAME + "/" + 64 "&locale=%LOCALE%";
65 AppConstants.MOZ_APP_VERSION +
66 "/%BUILDID%/Android_" + AppConstants.MOZ_APP _ABI + pkgSpecial +
67 "/%LOCALE%/" + AppConstants.MOZ_UPD ATE_CHANNEL +
68 "/%OS_VERSION%/default/default/" + AppConstants.MOZILLA _VERSION +
69 "/update.xml";
70 }
71 65
72 public enum CheckUpdateResult { 66 public enum CheckUpdateResult {
73 // Keep these in sync with mobile/android/chrome/content/about.xhtml 67 // Keep these in sync with mobile/android/chrome/content/about.xhtml
74 NOT_AVAILABLE, 68 NOT_AVAILABLE,
75 AVAILABLE, 69 AVAILABLE,
76 DOWNLOADING, 70 DOWNLOADING,
77 DOWNLOADED 71 DOWNLOADED
78 } 72 }
79 73
80 public static URL getUpdateUrl(Context context, boolean force) { 74 public static URL getUpdateUrl(Context context, boolean force) {
(...skipping 10 matching lines...) Expand all
91 locale = locale.trim(); 85 locale = locale.trim();
92 else 86 else
93 locale = DEFAULT_UPDATE_LOCALE; 87 locale = DEFAULT_UPDATE_LOCALE;
94 } catch (android.content.pm.PackageManager.NameNotFoundException e) { 88 } catch (android.content.pm.PackageManager.NameNotFoundException e) {
95 // Shouldn't really be possible, but fallback to default locale 89 // Shouldn't really be possible, but fallback to default locale
96 Log.i(LOGTAG, "Failed to read update locale file, falling back to " + DEFAULT_UPDATE_LOCALE); 90 Log.i(LOGTAG, "Failed to read update locale file, falling back to " + DEFAULT_UPDATE_LOCALE);
97 locale = DEFAULT_UPDATE_LOCALE; 91 locale = DEFAULT_UPDATE_LOCALE;
98 } 92 }
99 93
100 String url = UPDATE_URL.replace("%LOCALE%", locale). 94 String url = UPDATE_URL.replace("%LOCALE%", locale).
101 replace("%OS_VERSION%", Build.VERSION.RELEASE). 95 replace("%OS_VERSION%", String.valueOf(Build.VERSION.SDK_INT)).
Felix Dahlke 2014/12/09 19:58:34 Firefox uses the full version string here, but I f
102 replace("%BUILDID%", force ? "0" : AppConstants.MOZ_APP_BUILDID); 96 replace("%BUILDID%", force ? "0" : AppConstants.MOZ_APP_BUILDID);
103 97
104 try { 98 try {
105 return new URL(url); 99 return new URL(url);
106 } catch (java.net.MalformedURLException e) { 100 } catch (java.net.MalformedURLException e) {
107 Log.e(LOGTAG, "Failed to create update url: ", e); 101 Log.e(LOGTAG, "Failed to create update url: ", e);
108 return null; 102 return null;
109 } 103 }
110 } 104 }
111 105
(...skipping 24 matching lines...) Expand all
136 public static void registerForUpdates(Context context, int policy) { 130 public static void registerForUpdates(Context context, int policy) {
137 if (!isUpdaterEnabled()) 131 if (!isUpdaterEnabled())
138 return; 132 return;
139 133
140 Intent intent = new Intent(UpdateServiceHelper.ACTION_REGISTER_FOR_UPDAT ES, null, context, UpdateService.class); 134 Intent intent = new Intent(UpdateServiceHelper.ACTION_REGISTER_FOR_UPDAT ES, null, context, UpdateService.class);
141 intent.putExtra(EXTRA_AUTODOWNLOAD_NAME, policy); 135 intent.putExtra(EXTRA_AUTODOWNLOAD_NAME, policy);
142 136
143 context.startService(intent); 137 context.startService(intent);
144 } 138 }
145 } 139 }
OLDNEW
« no previous file with comments | « no previous file | mobile/android/branding/adblockbrowser/configure.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld