From 7a440a1f4777246269c080ab95322f5d29dde49f Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 25 Apr 2012 17:24:48 -0400 Subject: [PATCH] Bug 741224 - Force unlock on tabs.db file when database is opened in read-only mode (r=blassey) --- mobile/android/base/db/TabsProvider.java.in | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mobile/android/base/db/TabsProvider.java.in b/mobile/android/base/db/TabsProvider.java.in index 979f69988fb..c2498b1a2c6 100644 --- a/mobile/android/base/db/TabsProvider.java.in +++ b/mobile/android/base/db/TabsProvider.java.in @@ -206,8 +206,19 @@ public class TabsProvider extends ContentProvider { if (dbHelper != null) { return dbHelper; } - dbHelper = new DatabaseHelper(getContext(), getDatabasePath(profile)); + + String databasePath = getDatabasePath(profile); + dbHelper = new DatabaseHelper(getContext(), databasePath); mDatabasePerProfile.put(profile, dbHelper); + + // When running on Android releases older than 8, the returned + // database path is just filename, not the full path. We need + // the full path when unlocking the database. + if (Build.VERSION.SDK_INT <= 8) { + databasePath = mContext.getDatabasePath(databasePath).getAbsolutePath(); + } + + DBUtils.ensureDatabaseIsNotLocked(dbHelper, databasePath); } debug("Created database helper for profile: " + profile);