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

Delta Between Two Patch Sets: src/org/adblockplus/android/updater/AlarmReceiver.java

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Left Patch Set: Adressed first batch of review issues. Created April 16, 2014, 5:36 p.m.
Right Patch Set: Even more review issues fixed. Created April 28, 2014, 10:18 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/org/adblockplus/android/Utils.java ('k') | src/org/adblockplus/android/updater/UpdaterActivity.java » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 import android.util.Log; 55 import android.util.Log;
56 56
57 /** 57 /**
58 * Processes Alarm event to check for update availability. 58 * Processes Alarm event to check for update availability.
59 */ 59 */
60 public class AlarmReceiver extends BroadcastReceiver 60 public class AlarmReceiver extends BroadcastReceiver
61 { 61 {
62 private static final String TAG = Utils.getTag(AlarmReceiver.class); 62 private static final String TAG = Utils.getTag(AlarmReceiver.class);
63 private static final int NOTIFICATION_ID = R.string.app_name + 1; 63 private static final int NOTIFICATION_ID = R.string.app_name + 1;
64 64
65 @SuppressWarnings("deprecation")
66 @Override 65 @Override
67 public void onReceive(final Context context, final Intent intent) 66 public void onReceive(final Context context, final Intent intent)
68 { 67 {
69 Log.i(TAG, "Alarm; requesting updater service"); 68 Log.i(TAG, "Alarm; requesting updater service");
70 69
71 final AdblockPlus application = AdblockPlus.getApplication(); 70 final AdblockPlus application = AdblockPlus.getApplication();
72 71
73 // Indicates manual (immediate) update check which requires response to user . 72 // Indicates manual (immediate) update check which requires response to user .
74 final boolean notify = intent.getBooleanExtra("notifynoupdate", false); 73 final boolean notify = intent.getBooleanExtra("notifynoupdate", false);
75 74
(...skipping 28 matching lines...) Expand all
104 boolean success = false; 103 boolean success = false;
105 try 104 try
106 { 105 {
107 // Read updates manifest 106 // Read updates manifest
108 final DefaultHttpClient httpClient = new DefaultHttpClient(); 107 final DefaultHttpClient httpClient = new DefaultHttpClient();
109 108
110 final String locale = Locale.getDefault().toString().toLowerCase(); 109 final String locale = Locale.getDefault().toString().toLowerCase();
111 final String device = AdblockPlus.getDeviceName(); 110 final String device = AdblockPlus.getDeviceName();
112 final boolean releaseBuild = context.getResources().getBoolean(R.boo l.def_release); 111 final boolean releaseBuild = context.getResources().getBoolean(R.boo l.def_release);
113 final String updateUrlTemplate = context.getString(releaseBuild ? R. string.update_url : R.string.devbuild_update_url); 112 final String updateUrlTemplate = context.getString(releaseBuild ? R. string.update_url : R.string.devbuild_update_url);
114 final URL updateUrl = new URL(String.format(updateUrlTemplate, Build .VERSION.SDK_INT, AdblockPlus.getApplication().getBuildNumber(), 113 final URL updateUrl = new URL(String.format(updateUrlTemplate, Build .VERSION.SDK_INT, AdblockPlus.getApplication().getBuildNumber(), locale, device) );
115 locale, device));
116 // The following line correctly url-encodes query string parameters 114 // The following line correctly url-encodes query string parameters
117 final URI uri = new URI(updateUrl.getProtocol(), updateUrl.getUserIn fo(), updateUrl.getHost(), updateUrl.getPort(), updateUrl.getPath(), 115 final URI uri = new URI(updateUrl.getProtocol(), updateUrl.getUserIn fo(), updateUrl.getHost(), updateUrl.getPort(), updateUrl.getPath(), updateUrl.g etQuery(), updateUrl.getRef());
118 updateUrl.getQuery(), updateUrl.getRef());
119 final HttpGet httpGet = new HttpGet(uri); 116 final HttpGet httpGet = new HttpGet(uri);
120 117
121 final HttpResponse httpResponse = httpClient.execute(httpGet); 118 final HttpResponse httpResponse = httpClient.execute(httpGet);
122 final HttpEntity httpEntity = httpResponse.getEntity(); 119 final HttpEntity httpEntity = httpResponse.getEntity();
123 final String xml = EntityUtils.toString(httpEntity); 120 final String xml = EntityUtils.toString(httpEntity);
124 121
125 // Parse XML 122 // Parse XML
126 final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstanc e(); 123 final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstanc e();
127 final DocumentBuilder db = dbf.newDocumentBuilder(); 124 final DocumentBuilder db = dbf.newDocumentBuilder();
128 125
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 if (notify) 214 if (notify)
218 { 215 {
219 notification.setLatestEventInfo(context, context.getText(R.string.app_na me), context.getString(R.string.msg_update_fail), emptyIntent); 216 notification.setLatestEventInfo(context, context.getText(R.string.app_na me), context.getString(R.string.msg_update_fail), emptyIntent);
220 notificationManager.notify(NOTIFICATION_ID, notification); 217 notificationManager.notify(NOTIFICATION_ID, notification);
221 } 218 }
222 // Schedule retry in 30 minutes - there is no connection available at this time 219 // Schedule retry in 30 minutes - there is no connection available at this time
223 application.scheduleUpdater(30); 220 application.scheduleUpdater(30);
224 } 221 }
225 } 222 }
226 } 223 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld