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

Commit 7c39e238 authored by Adam Cohen's avatar Adam Cohen Committed by Android (Google) Code Review
Browse files

Merge "Clearing DB before restore starts." into ub-now-queens

parents c7cd2cb2 cf30da59
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -69,13 +69,23 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper {
            Log.d(TAG, "Restore is only supported on devices running Lollipop and above.");
            return;
        }
        super.onRestore(data, appVersionCode, newState);

        // Clear dB before restore
        LauncherAppState.getLauncherProvider().createEmptyDB();

        boolean hasData;
        try {
            super.onRestore(data, appVersionCode, newState);
            // If no favorite was migrated, clear the data and start fresh.
            final Cursor c = getContentResolver().query(
                    LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, null, null, null, null);
        boolean hasData = c.moveToNext();
            hasData = c.moveToNext();
            c.close();
        } catch (Exception e) {
            // If the restore fails, we should do a fresh start.
            Log.e(TAG, "Restore failed", e);
            hasData = false;
        }

        if (hasData && mHelper.restoreSuccessful) {
            LauncherAppState.getLauncherProvider().clearFlagEmptyDbCreated();