Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3569788 authored by Sebastian Franco's avatar Sebastian Franco
Browse files

Adding logging for backup and restore

Bug: 353505773
Test: compiles
Flag: EXEMPT bugfix
Change-Id: I4c1e56365332557fa95a11526498505bf2063e12
parent 7640b08e
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ import com.android.launcher3.widget.LauncherWidgetHolder;

import org.xmlpull.v1.XmlPullParser;

import java.io.File;
import java.io.InputStream;
import java.io.StringReader;

@@ -104,10 +105,30 @@ public class ModelDbController {
        mContext = context;
    }

    private void printDBs(String prefix) {
        try {
            File directory = new File(
                    mContext.getDatabasePath(InvariantDeviceProfile.INSTANCE.get(mContext).dbFile)
                            .getParent()
            );
            if (directory.exists()) {
                for (File file : directory.listFiles()) {
                    Log.d("b/353505773", prefix + "Database file: " + file.getName());
                }
            } else {
                Log.d("b/353505773", prefix + "No files found in the database directory");
            }
        } catch (Exception e) {
            Log.e("b/353505773", prefix + e.getMessage());
        }
    }

    private synchronized void createDbIfNotExists() {
        if (mOpenHelper == null) {
            mOpenHelper = createDatabaseHelper(false /* forMigration */);
            printDBs("before: ");
            RestoreDbTask.restoreIfNeeded(mContext, this);
            printDBs("after: ");
        }
    }