| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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" + |
|
Wladimir Palant
2015/02/18 18:05:55
What is this type=0 about?
Felix Dahlke
2015/02/19 13:40:22
How I understood it, this means it's an automatic
Wladimir Palant
2015/02/23 12:32:24
Yes, that's what I remembered as well which is why
Felix Dahlke
2015/02/23 22:24:00
Yeah that's a good point, I've removed it.
| |
| 58 final String pkgSpecial; | 58 "&addonName=adblockbrowser" + |
| 59 if (AppConstants.MOZ_PKG_SPECIAL != null) { | 59 "&addonVersion=" + AppConstants.MOZ_APP_VERSION + ".%BUILDID%" + |
| 60 pkgSpecial = "-" + AppConstants.MOZ_PKG_SPECIAL; | 60 "&applicationName=android" + |
| 61 } else { | 61 "&applicationVersion=%OS_VERSION%" + |
| 62 pkgSpecial = ""; | 62 "&platform=mozilla" + |
| 63 } | 63 "&platformVersion=" + AppConstants.MOZILLA_VERSION + |
|
Wladimir Palant
2015/02/18 18:05:55
Technically speaking, isn't this Adblock Plus for
Felix Dahlke
2015/02/19 13:40:22
No, it's Adblock Browser's update mechanism, just
Felix Dahlke
2015/02/19 22:21:58
Note that we probably want to go with your variant
Wladimir Palant
2015/02/23 12:32:24
Fair enough. Still, the platform should be "gecko"
Felix Dahlke
2015/02/23 22:24:00
Done.
| |
| 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 Loading... | |
| 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)). |
| 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 Loading... | |
| 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 } |
| OLD | NEW |