Bug 768532 - Use profile database path on Android 2.2. r=lucasr,gbrown

This commit is contained in:
Brian Nicholson 2012-11-30 10:52:10 -08:00
parent a28afc521c
commit dd04fd27b6
2 changed files with 22 additions and 26 deletions

View File

@ -1675,16 +1675,20 @@ public class BrowserProvider extends ContentProvider {
}
String databasePath = getDatabasePath(profile, isTest);
// Before bug 768532, the database was located outside if the
// profile on Android 2.2. Make sure it is moved inside the profile
// directory.
if (Build.VERSION.SDK_INT == 8) {
File oldPath = mContext.getDatabasePath("browser-" + profile + ".db");
if (oldPath.exists()) {
oldPath.renameTo(new File(databasePath));
}
}
dbHelper = new DatabaseHelper(getContext(), databasePath);
mDatabasePerProfile.put(profile, dbHelper);
// When running inside a test or 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 (isTest || Build.VERSION.SDK_INT <= 8) {
databasePath = mContext.getDatabasePath(databasePath).getAbsolutePath();
}
DBUtils.ensureDatabaseIsNotLocked(dbHelper, databasePath);
}
@ -1695,13 +1699,8 @@ public class BrowserProvider extends ContentProvider {
public String getDatabasePath(String profile, boolean isTest) {
trace("Getting database path for profile: " + profile);
// On Android releases older than 2.3, it's not possible to use
// SQLiteOpenHelper with a full path. Fallback to using separate
// db files per profile in the app directory.
if (isTest) {
return DATABASE_NAME;
} else if(Build.VERSION.SDK_INT <= 8) {
return "browser-" + profile + ".db";
}
File profileDir = GeckoProfile.get(mContext, profile).getDir();

View File

@ -236,16 +236,20 @@ public class TabsProvider extends ContentProvider {
}
String databasePath = getDatabasePath(profile);
// Before bug 768532, the database was located outside if the
// profile on Android 2.2. Make sure it is moved inside the profile
// directory.
if (Build.VERSION.SDK_INT == 8) {
File oldPath = mContext.getDatabasePath("tabs-" + profile + ".db");
if (oldPath.exists()) {
oldPath.renameTo(new File(databasePath));
}
}
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);
}
@ -256,13 +260,6 @@ public class TabsProvider extends ContentProvider {
private String getDatabasePath(String profile) {
trace("Getting database path for profile: " + profile);
// On Android releases older than 2.3, it's not possible to use
// SQLiteOpenHelper with a full path. Fallback to using separate
// db files per profile in the app directory.
if (Build.VERSION.SDK_INT <= 8) {
return "tabs-" + profile + ".db";
}
File profileDir = GeckoProfile.get(mContext, profile).getDir();
if (profileDir == null) {
debug("Couldn't find directory for profile: " + profile);