packages/apps/DeskClock
修订版 | 5d1b236620eec1456ca1e9a30085ce2ae27e984d (tree) |
---|---|
时间 | 2010-04-27 22:17:40 |
作者 | Daniel Sandler <dsandler@andr...> |
Commiter | Daniel Sandler |
Switch to explicitly managed cursors for weather query.
Previously, DeskClock used Activity.managedQuery, which
didn't exactly leak cursors, but it allowed them to
accumulate as long as the DeskClock Activity was running.
When used overnight as a bedside clock, the Activity can run
for a very long time without being paused.
Bug: 2627720
Change-Id: If4d53d3d6cba9dd96b41a3e25f4c8fad75339c42
@@ -23,6 +23,7 @@ import android.app.PendingIntent; | ||
23 | 23 | import android.app.UiModeManager; |
24 | 24 | import android.content.BroadcastReceiver; |
25 | 25 | import android.content.Context; |
26 | +import android.content.ContentResolver; | |
26 | 27 | import android.content.DialogInterface; |
27 | 28 | import android.content.Intent; |
28 | 29 | import android.content.IntentFilter; |
@@ -389,7 +390,7 @@ public class DeskClock extends Activity { | ||
389 | 390 | |
390 | 391 | Cursor cur; |
391 | 392 | try { |
392 | - cur = managedQuery( | |
393 | + cur = getContentResolver().query( | |
393 | 394 | queryUri, |
394 | 395 | WEATHER_CONTENT_COLUMNS, |
395 | 396 | null, |
@@ -447,6 +448,11 @@ public class DeskClock extends Activity { | ||
447 | 448 | mWeatherLowTemperatureString = ""; |
448 | 449 | } |
449 | 450 | |
451 | + if (cur != null) { | |
452 | + // clean up cursor | |
453 | + cur.close(); | |
454 | + } | |
455 | + | |
450 | 456 | mHandy.sendEmptyMessage(UPDATE_WEATHER_DISPLAY_MSG); |
451 | 457 | } |
452 | 458 |