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

Side by Side Diff: src/org/adblockplus/android/updater/AlarmReceiver.java

Issue 9752046: Add automatic updates for release builds (Closed)
Patch Set: Request WRITE_EXTERNAL_STORAGE permission for release builds as well Created March 15, 2013, 7:27 a.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 | « src/org/adblockplus/android/AdblockPlus.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of the Adblock Plus, 2 * This file is part of the Adblock Plus,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 public void run() 100 public void run()
101 { 101 {
102 boolean success = false; 102 boolean success = false;
103 try 103 try
104 { 104 {
105 // Read updates manifest 105 // Read updates manifest
106 DefaultHttpClient httpClient = new DefaultHttpClient(); 106 DefaultHttpClient httpClient = new DefaultHttpClient();
107 107
108 String locale = Locale.getDefault().toString().toLowerCase(); 108 String locale = Locale.getDefault().toString().toLowerCase();
109 String device = AdblockPlus.getDeviceName(); 109 String device = AdblockPlus.getDeviceName();
110 URL updateUrl = new URL(String.format(context.getString(R.string.upd ate_url), Build.VERSION.SDK_INT, AdblockPlus.getApplication().getBuildNumber(), locale, device)); 110 boolean releaseBuild = context.getResources().getBoolean(R.bool.def_ release);
111 String updateUrlTemplate = context.getString(releaseBuild ? R.string .update_url : R.string.devbuild_update_url);
112 URL updateUrl = new URL(String.format(updateUrlTemplate, Build.VERSI ON.SDK_INT, AdblockPlus.getApplication().getBuildNumber(), locale, device));
111 // The following line correctly url-encodes query string parameters 113 // The following line correctly url-encodes query string parameters
112 URI uri = new URI(updateUrl.getProtocol(), updateUrl.getUserInfo(), updateUrl.getHost(), updateUrl.getPort(), updateUrl.getPath(), updateUrl.getQuer y(), updateUrl.getRef()); 114 URI uri = new URI(updateUrl.getProtocol(), updateUrl.getUserInfo(), updateUrl.getHost(), updateUrl.getPort(), updateUrl.getPath(), updateUrl.getQuer y(), updateUrl.getRef());
113 HttpGet httpGet = new HttpGet(uri); 115 HttpGet httpGet = new HttpGet(uri);
114 116
115 HttpResponse httpResponse = httpClient.execute(httpGet); 117 HttpResponse httpResponse = httpClient.execute(httpGet);
116 HttpEntity httpEntity = httpResponse.getEntity(); 118 HttpEntity httpEntity = httpResponse.getEntity();
117 String xml = EntityUtils.toString(httpEntity); 119 String xml = EntityUtils.toString(httpEntity);
118 120
119 // Parse XML 121 // Parse XML
120 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 122 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 if (notify) 215 if (notify)
214 { 216 {
215 notification.setLatestEventInfo(context, context.getText(R.string.app_na me), context.getString(R.string.msg_update_fail), emptyIntent); 217 notification.setLatestEventInfo(context, context.getText(R.string.app_na me), context.getString(R.string.msg_update_fail), emptyIntent);
216 notificationManager.notify(NOTIFICATION_ID, notification); 218 notificationManager.notify(NOTIFICATION_ID, notification);
217 } 219 }
218 // Schedule retry in 30 minutes - there is no connection available at this time 220 // Schedule retry in 30 minutes - there is no connection available at this time
219 application.scheduleUpdater(30); 221 application.scheduleUpdater(30);
220 } 222 }
221 } 223 }
222 } 224 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/android/AdblockPlus.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld