Partially revert "LineageSettingsProvider: Support migration from cmsettings"

The migration happened in lineage 15.1,
we only support direct upgrades from 17.1.

This partially reverts commit e7008a222e17d4868e74bd8758ccf842852df389.

Change-Id: Ic2acd93565e21475ea6f896941107230d880e890
diff --git a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
index 2f0f7c1..412b474 100644
--- a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
+++ b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
@@ -43,8 +43,6 @@
 
 import lineageos.providers.LineageSettings;
 
-import org.lineageos.internal.util.FileUtils;
-
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
@@ -63,8 +61,6 @@
     private static final String DATABASE_NAME = "lineagesettings.db";
     private static final int DATABASE_VERSION = 19;
 
-    private static final String DATABASE_NAME_OLD = "cmsettings.db";
-
     public static class LineageTableNames {
         public static final String TABLE_SYSTEM = "system";
         public static final String TABLE_SECURE = "secure";
@@ -94,65 +90,26 @@
      * @param userId The database path for this user
      * @return The database path string
      */
-    private static String dbNameForUser(Context context, int userId, String baseName) {
+    static String dbNameForUser(final int userId) {
+        // The owner gets the unadorned db name;
         if (userId == UserHandle.USER_SYSTEM) {
-            return context.getDatabasePath(baseName).getPath();
+            return DATABASE_NAME;
         } else {
             // Place the database in the user-specific data tree so that it's
             // cleaned up automatically when the user is deleted.
             File databaseFile = new File(
-                    Environment.getUserSystemDirectory(userId), baseName);
+                    Environment.getUserSystemDirectory(userId), DATABASE_NAME);
             return databaseFile.getPath();
         }
     }
 
     /**
-     * Migrate db files (if needed).
-     */
-    public static void migrateDbFiles(Context context, int userId) {
-        final String dbPath = dbNameForUser(context, userId, DATABASE_NAME);
-        final String dbPathOld = dbNameForUser(context, userId, DATABASE_NAME_OLD);
-
-        // Only rename databases that we know we can write to later.
-        if (!FileUtils.isFileWritable(dbPathOld)) {
-            return;
-        }
-        if (FileUtils.fileExists(dbPath) && !FileUtils.delete(dbPath)) {
-            Log.e(TAG, "Unable to delete existing settings db file " + dbPath);
-            return;
-        }
-        if (!FileUtils.rename(dbPathOld, dbPath)) {
-            Log.e(TAG, "Found old settings db " + dbPathOld + " but could not rename it to "
-                    + dbPath);
-            return;
-        }
-        // Move any additional sqlite files that might exist.
-        // The list of suffixes is taken from fw/b SQLiteDatabase.java deleteDatabase().
-        final String[] suffixes = { "-journal", "-shm", "-wal" };
-        for (String s: suffixes) {
-            final String oldFile = dbPathOld + s;
-            final String newFile = dbPath + s;
-            if (!FileUtils.fileExists(oldFile)) {
-                continue;
-            }
-            if (FileUtils.fileExists(newFile) && !FileUtils.delete(newFile)) {
-                Log.e(TAG, "Unable to delete existing settings db file " + newFile);
-                continue;
-            }
-            if (!FileUtils.rename(oldFile, newFile)) {
-                Log.e(TAG, "Unable to rename existing settings db file " + oldFile + " to "
-                        + newFile);
-            }
-        }
-    }
-
-    /**
      * Creates an instance of {@link LineageDatabaseHelper}
      * @param context
      * @param userId
      */
     public LineageDatabaseHelper(Context context, int userId) {
-        super(context, dbNameForUser(context, userId, DATABASE_NAME), null, DATABASE_VERSION);
+        super(context, dbNameForUser(userId), null, DATABASE_VERSION);
         mContext = context;
         mUserHandle = userId;
 
diff --git a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageSettingsProvider.java b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageSettingsProvider.java
index 06e4324..174dcb9 100644
--- a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageSettingsProvider.java
+++ b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageSettingsProvider.java
@@ -57,8 +57,6 @@
     public static final String TAG = "LineageSettingsProvider";
     private static final boolean LOCAL_LOGV = false;
 
-    private static final String SHARED_PREF_NAME_OLD = "CMSettingsProvider";
-
     private static final boolean USER_CHECK_THROWS = true;
 
     public static final String PREF_HAS_MIGRATED_LINEAGE_SETTINGS =
@@ -152,9 +150,6 @@
         if (!hasMigratedLineageSettings) {
             long startTime = System.currentTimeMillis();
 
-            // Remove any lingering old shared_prefs file
-            getContext().deleteSharedPreferences(SHARED_PREF_NAME_OLD);
-
             for (UserInfo user : mUserManager.getUsers()) {
                 migrateLineageSettingsForUser(user.id);
             }
@@ -175,18 +170,6 @@
         synchronized (this) {
             if (LOCAL_LOGV) Log.d(TAG, "Lineage settings will be migrated for user id: " + userId);
 
-            // Rename database files (if needed)
-            LineageDatabaseHelper dbHelper = mDbHelpers.get(userId);
-            if (dbHelper != null) {
-                dbHelper.close();
-                mDbHelpers.delete(userId);
-            }
-            LineageDatabaseHelper.migrateDbFiles(getContext(), userId);
-            if (dbHelper != null) {
-                establishDbTracking(userId);
-                dbHelper = null;
-            }
-
             // Migrate system settings
             int rowsMigrated = migrateLineageSettingsForTable(userId,
                     LineageDatabaseHelper.LineageTableNames.TABLE_SYSTEM, LineageSettings.System.LEGACY_SYSTEM_SETTINGS);