summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorPaul Sliwowski <psliwowski@google.com>2013-05-20 16:28:10 -0700
committerPaul Sliwowski <psliwowski@google.com>2013-05-20 16:28:10 -0700
commit2c265858d0b923a27300c40b4f2121b9fc744785 (patch)
treea5ed74165dbaae8931da8ba28a8fe4436a106f9b /src/com
parent259000714bb271aef2f1b6507e21428d4101394f (diff)
downloadandroid_packages_apps_Calendar-2c265858d0b923a27300c40b4f2121b9fc744785.tar.gz
android_packages_apps_Calendar-2c265858d0b923a27300c40b4f2121b9fc744785.tar.bz2
android_packages_apps_Calendar-2c265858d0b923a27300c40b4f2121b9fc744785.zip
Fixed leak cursor in AlertReciever
Bug: 8764753 This fixed cleans up the code and make sure we close the location cursor when finished with it. Change-Id: I815c2e99bedbfe52d81e95ea7efd546ec1343635
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/calendar/alerts/AlertReceiver.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/com/android/calendar/alerts/AlertReceiver.java b/src/com/android/calendar/alerts/AlertReceiver.java
index e1f7dec6..da8e617e 100644
--- a/src/com/android/calendar/alerts/AlertReceiver.java
+++ b/src/com/android/calendar/alerts/AlertReceiver.java
@@ -764,23 +764,21 @@ public class AlertReceiver extends BroadcastReceiver {
*/
private static URLSpan[] getURLSpans(Context context, long eventId) {
Cursor locationCursor = getLocationCursor(context, eventId);
+
+ // Default to empty list
+ URLSpan[] urlSpans = new URLSpan[0];
if (locationCursor != null && locationCursor.moveToFirst()) {
String location = locationCursor.getString(0); // Only one item in this cursor.
- if (location == null || location.isEmpty()) {
- // Return an empty list if we know there was nothing in the location field.
- return new URLSpan[0];
+ if (location != null && !location.isEmpty()) {
+ Spannable text = Utils.extendedLinkify(location, true);
+ // The linkify method should have found at least one link, at the very least.
+ // If no smart links were found, it should have set the whole string as a geo link.
+ urlSpans = text.getSpans(0, text.length(), URLSpan.class);
}
-
- Spannable text = Utils.extendedLinkify(location, true);
-
- // The linkify method should have found at least one link, at the very least.
- // If no smart links were found, it should have set the whole string as a geo link.
- URLSpan[] urlSpans = text.getSpans(0, text.length(), URLSpan.class);
- return urlSpans;
+ locationCursor.close();
}
- // If no links were found or location was empty, return an empty list.
- return new URLSpan[0];
+ return urlSpans;
}
/**