mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 17:36:49 +00:00
Resetting launcherProvider data if restore set was empty
Bug: 17332300 Change-Id: I6d2187cd1b1fa7a53e49b96eb109263f6b74b258
This commit is contained in:
@@ -17,13 +17,16 @@
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.app.backup.BackupAgentHelper;
|
||||
import android.app.backup.BackupDataInput;
|
||||
import android.app.backup.BackupManager;
|
||||
import android.app.backup.SharedPreferencesBackupHelper;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class LauncherBackupAgentHelper extends BackupAgentHelper {
|
||||
|
||||
private static final String TAG = "LauncherBackupAgentHelper";
|
||||
@@ -54,7 +57,7 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper {
|
||||
// modifies the file outside the normal codepaths, so it looks like another
|
||||
// process. This forces a reload of the file, in case this process persists.
|
||||
String spKey = LauncherAppState.getSharedPreferencesKey();
|
||||
SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_MULTI_PROCESS);
|
||||
getSharedPreferences(spKey, Context.MODE_MULTI_PROCESS);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -71,4 +74,21 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper {
|
||||
addHelper(LauncherBackupHelper.LAUNCHER_PREFIX,
|
||||
new LauncherBackupHelper(this, restoreEnabled));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
|
||||
throws IOException {
|
||||
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();
|
||||
c.close();
|
||||
|
||||
if (!hasData) {
|
||||
if (VERBOSE) Log.v(TAG, "Nothing was restored, clearing DB");
|
||||
LauncherAppState.getLauncherProvider().createEmptyDB();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user