@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { super.onRestore(data, appVersionCode, newState); copyPrefs(RESTORE_PREFS, CacheVar.DEFAULT_PREFS); CacheVar.reinit(); }
@Override public void onBackup( ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) throws IOException { copyPrefs(CacheVar.DEFAULT_PREFS, RESTORE_PREFS); super.onBackup(oldState, data, newState); }
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { if (!Utilities.isLmpOrAbove()) { // No restore for old devices. Log.i(TAG, "You shall not pass!!!"); Log.d(TAG, "Restore is only supported on devices running Lollipop and above."); return; } // 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, null, null, null, null); 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(); LauncherClings.synchonouslyMarkFirstRunClingDismissed(this); // TODO: Update the backup set to include rank. if (mHelper.restoredBackupVersion <= 3) { LauncherAppState.getLauncherProvider().updateFolderItemsRank(); LauncherAppState.getLauncherProvider().convertShortcutsToLauncherActivities(); } } else { if (VERBOSE) Log.v(TAG, "Nothing was restored, clearing DB"); LauncherAppState.getLauncherProvider().createEmptyDB(); } }
@Override public void onCreate() { super.onCreate(); mHelper = new LauncherBackupHelper(this); addHelper(LAUNCHER_DATA_PREFIX, mHelper); }