Bug 741224 - Force unlock on tabs.db file when database is opened in read-only mode (r=blassey, a=blassey)
authorLucas Rocha <lucasr@mozilla.com>
Wed, 25 Apr 2012 17:24:48 -0400
changeset 95559 cf304a9f3c13bbb9ed29d618c19675f0a5724f9f
parent 95558 3fbddad3cfef5534439953dbc6a37ba18721c620
child 95560 14173aceb23e2eadfa2eeb839f56f250e5d83762
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey, blassey
bugs741224
milestone14.0a2
Bug 741224 - Force unlock on tabs.db file when database is opened in read-only mode (r=blassey, a=blassey)
mobile/android/base/db/TabsProvider.java.in
--- a/mobile/android/base/db/TabsProvider.java.in
+++ b/mobile/android/base/db/TabsProvider.java.in
@@ -201,18 +201,29 @@ public class TabsProvider extends Conten
         }
 
         DatabaseHelper dbHelper;
         synchronized (this) {
             dbHelper = mDatabasePerProfile.get(profile);
             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);
         return dbHelper;
     }
 
     private String getDatabasePath(String profile) {
         trace("Getting database path for profile: " + profile);