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: Removed hard coded type=0, changed platform to gecko Created Feb. 23, 2015, 10:23 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 "?addonName=adblockbrowser" +
58 final String pkgSpecial; 58 "&addonVersion=" + AppConstants.MOZ_APP_VERSION + ".%BUILDID%" +
59 if (AppConstants.MOZ_PKG_SPECIAL != null) { 59 "&applicationName=android" +
60 pkgSpecial = "-" + AppConstants.MOZ_PKG_SPECIAL; 60 "&applicationVersion=%OS_VERSION%" +
61 } else { 61 "&platform=gecko" +
62 pkgSpecial = ""; 62 "&platformVersion=" + AppConstants.MOZILLA_VERSION +
63 } 63 "&locale=%LOCALE%";
64 UPDATE_URL = "https://aus4.mozilla.org/update/4/" + AppConstants.MOZ_APP _BASENAME + "/" +
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 64
72 public enum CheckUpdateResult { 65 public enum CheckUpdateResult {
73 // Keep these in sync with mobile/android/chrome/content/about.xhtml 66 // Keep these in sync with mobile/android/chrome/content/about.xhtml
74 NOT_AVAILABLE, 67 NOT_AVAILABLE,
75 AVAILABLE, 68 AVAILABLE,
76 DOWNLOADING, 69 DOWNLOADING,
77 DOWNLOADED 70 DOWNLOADED
78 } 71 }
79 72
80 public static URL getUpdateUrl(Context context, boolean force) { 73 public static URL getUpdateUrl(Context context, boolean force) {
(...skipping 10 matching lines...) Expand all
91 locale = locale.trim(); 84 locale = locale.trim();
92 else 85 else
93 locale = DEFAULT_UPDATE_LOCALE; 86 locale = DEFAULT_UPDATE_LOCALE;
94 } catch (android.content.pm.PackageManager.NameNotFoundException e) { 87 } catch (android.content.pm.PackageManager.NameNotFoundException e) {
95 // Shouldn't really be possible, but fallback to default locale 88 // 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); 89 Log.i(LOGTAG, "Failed to read update locale file, falling back to " + DEFAULT_UPDATE_LOCALE);
97 locale = DEFAULT_UPDATE_LOCALE; 90 locale = DEFAULT_UPDATE_LOCALE;
98 } 91 }
99 92
100 String url = UPDATE_URL.replace("%LOCALE%", locale). 93 String url = UPDATE_URL.replace("%LOCALE%", locale).
101 replace("%OS_VERSION%", Build.VERSION.RELEASE). 94 replace("%OS_VERSION%", String.valueOf(Build.VERSION.SDK_INT)).
102 replace("%BUILDID%", force ? "0" : AppConstants.MOZ_APP_BUILDID); 95 replace("%BUILDID%", force ? "0" : AppConstants.MOZ_APP_BUILDID);
103 96
104 try { 97 try {
105 return new URL(url); 98 return new URL(url);
106 } catch (java.net.MalformedURLException e) { 99 } catch (java.net.MalformedURLException e) {
107 Log.e(LOGTAG, "Failed to create update url: ", e); 100 Log.e(LOGTAG, "Failed to create update url: ", e);
108 return null; 101 return null;
109 } 102 }
110 } 103 }
111 104
(...skipping 24 matching lines...) Expand all
136 public static void registerForUpdates(Context context, int policy) { 129 public static void registerForUpdates(Context context, int policy) {
137 if (!isUpdaterEnabled()) 130 if (!isUpdaterEnabled())
138 return; 131 return;
139 132
140 Intent intent = new Intent(UpdateServiceHelper.ACTION_REGISTER_FOR_UPDAT ES, null, context, UpdateService.class); 133 Intent intent = new Intent(UpdateServiceHelper.ACTION_REGISTER_FOR_UPDAT ES, null, context, UpdateService.class);
141 intent.putExtra(EXTRA_AUTODOWNLOAD_NAME, policy); 134 intent.putExtra(EXTRA_AUTODOWNLOAD_NAME, policy);
142 135
143 context.startService(intent); 136 context.startService(intent);
144 } 137 }
145 } 138 }
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