summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/provider
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-07-28 12:08:11 +0100
committerBen Murdoch <benm@google.com>2011-07-28 15:49:33 +0100
commitb98cb5187fcb3034ee3675de791fd811d76d1593 (patch)
treeaa05b277242b693ff50af5822862e70027a9339b /src/com/android/browser/provider
parent56e7068864733e18c666f689c5667d49dcc7b241 (diff)
downloadpackages_apps_Browser-b98cb5187fcb3034ee3675de791fd811d76d1593.zip
packages_apps_Browser-b98cb5187fcb3034ee3675de791fd811d76d1593.tar.gz
packages_apps_Browser-b98cb5187fcb3034ee3675de791fd811d76d1593.tar.bz2
Fix Strict Mode violation in SnapshotProvider.
Don't initialise the database helper until we need it - doing it in onCreate hits the disk. Bug: 5090265 Change-Id: I84ddde4da46452804fd3030ef1a49c4ba6eb69b4
Diffstat (limited to 'src/com/android/browser/provider')
-rw-r--r--src/com/android/browser/provider/SnapshotProvider.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/com/android/browser/provider/SnapshotProvider.java b/src/com/android/browser/provider/SnapshotProvider.java
index 49557f7..c0aad23 100644
--- a/src/com/android/browser/provider/SnapshotProvider.java
+++ b/src/com/android/browser/provider/SnapshotProvider.java
@@ -106,7 +106,6 @@ public class SnapshotProvider extends ContentProvider {
@Override
public boolean onCreate() {
- mOpenHelper = new SnapshotDatabaseHelper(getContext());
IntentFilter filter = new IntentFilter(Intent.ACTION_MEDIA_EJECT);
filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
getContext().registerReceiver(mExternalStorageReceiver, filter);
@@ -117,13 +116,15 @@ public class SnapshotProvider extends ContentProvider {
@Override
public void onReceive(Context context, Intent intent) {
- try {
- mOpenHelper.close();
- } catch (Throwable t) {
- // We failed to close the open helper, which most likely means
- // another thread is busy attempting to open the database
- // or use the database. Let that thread try to gracefully
- // deal with the error
+ if (mOpenHelper != null) {
+ try {
+ mOpenHelper.close();
+ } catch (Throwable t) {
+ // We failed to close the open helper, which most likely means
+ // another thread is busy attempting to open the database
+ // or use the database. Let that thread try to gracefully
+ // deal with the error
+ }
}
}
};
@@ -132,6 +133,9 @@ public class SnapshotProvider extends ContentProvider {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
try {
+ if (mOpenHelper == null) {
+ mOpenHelper = new SnapshotDatabaseHelper(getContext());
+ }
return mOpenHelper.getWritableDatabase();
} catch (Throwable t) {
return null;
@@ -145,6 +149,9 @@ public class SnapshotProvider extends ContentProvider {
if (Environment.MEDIA_MOUNTED.equals(state)
|| Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
try {
+ if (mOpenHelper == null) {
+ mOpenHelper = new SnapshotDatabaseHelper(getContext());
+ }
return mOpenHelper.getReadableDatabase();
} catch (Throwable t) {
return null;