android.app.backup.BackupDataInput Java Examples
The following examples show how to use
android.app.backup.BackupDataInput.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MyTracksBackupAgent.java From mytracks with Apache License 2.0 | 6 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { Log.i(TAG, "Restoring from backup"); while (data.readNextHeader()) { String key = data.getKey(); Log.d(TAG, "Restoring entity " + key); if (key.equals(PREFERENCES_ENTITY)) { restorePreferences(data); } else { Log.e(TAG, "Found unknown backup entity: " + key); data.skipEntityData(); } } Log.i(TAG, "Done restoring from backup"); }
Example #2
Source File: SettingsBackupAgent.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
void incorporateWifiSupplicant(BackupDataInput data) { restoredSupplicantData = new byte[data.getDataSize()]; if (restoredSupplicantData.length <= 0) return; try { data.readEntityData(restoredSupplicantData, 0, data.getDataSize()); } catch (IOException e) { Log.w(TAG, "Unable to read supplicant data"); restoredSupplicantData = null; } }
Example #3
Source File: BackupAgent.java From ministocks with MIT License | 5 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { // Hold the lock while the FileBackupHelper restores the file synchronized (UserData.sFileBackupLock) { super.onRestore(data, appVersionCode, newState); } }
Example #4
Source File: MyBackupAgent.java From ghwatch with Apache License 2.0 | 5 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { Log.i(TAG, "Restore from backup started"); super.onRestore(data, appVersionCode, newState); PreferencesUtils.patchAfterRestore(this); Log.i(TAG, "Restore from backup finished"); }
Example #5
Source File: BackupAgent.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { // Let the restore operation go through super.onRestore(data, appVersionCode, newState); // Remove the preferences that we don't want restored. final SharedPreferences.Editor prefEditor = getSharedPreferences( getPackageName() + PREF_SUFFIX, MODE_PRIVATE).edit(); for (final String key : LocalSettingsConstants.PREFS_TO_SKIP_RESTORING) { prefEditor.remove(key); } // Flush the changes to disk. prefEditor.commit(); }
Example #6
Source File: LauncherBackupAgentHelper.java From LB-Launcher with Apache License 2.0 | 5 votes |
@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_NO_NOTIFICATION, 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); } else { if (VERBOSE) Log.v(TAG, "Nothing was restored, clearing DB"); LauncherAppState.getLauncherProvider().createEmptyDB(); } }
Example #7
Source File: SettingsBackupAgent.java From Popeens-DSub with GNU General Public License v3.0 | 5 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { super.onRestore(data, appVersionCode, newState); SharedPreferences.Editor editor = Util.getPreferences(this).edit(); editor.remove(Constants.PREFERENCES_KEY_CACHE_LOCATION); editor.remove(Constants.CACHE_AUDIO_SESSION_ID); editor.apply(); }
Example #8
Source File: SettingsBackupAgent.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private void restoreLockSettings(BackupDataInput data) { final byte[] settings = new byte[data.getDataSize()]; try { data.readEntityData(settings, 0, settings.length); } catch (IOException ioe) { Log.e(TAG, "Couldn't read entity data"); return; } restoreLockSettings(settings, settings.length); }
Example #9
Source File: SettingsBackupAgent.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private void restoreSettings(BackupDataInput data, Uri contentUri, HashSet<String> movedToGlobal) { byte[] settings = new byte[data.getDataSize()]; try { data.readEntityData(settings, 0, settings.length); } catch (IOException ioe) { Log.e(TAG, "Couldn't read entity data"); return; } restoreSettings(settings, settings.length, contentUri, movedToGlobal); }
Example #10
Source File: SettingsBackupAgent.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private void restoreSettings(BackupDataInput data, Uri contentUri, HashSet<String> movedToGlobal) { byte[] settings = new byte[data.getDataSize()]; try { data.readEntityData(settings, 0, settings.length); } catch (IOException ioe) { Log.e(TAG, "Couldn't read entity data"); return; } restoreSettings(settings, settings.length, contentUri, movedToGlobal); }
Example #11
Source File: SettingsBackupAgent.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
void incorporateWifiConfigFile(BackupDataInput data) { restoredWifiConfigFile = new byte[data.getDataSize()]; if (restoredWifiConfigFile.length <= 0) return; try { data.readEntityData(restoredWifiConfigFile, 0, data.getDataSize()); } catch (IOException e) { Log.w(TAG, "Unable to read config file"); restoredWifiConfigFile = null; } }
Example #12
Source File: BackupAgent.java From openboard with GNU General Public License v3.0 | 5 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { // Let the restore operation go through super.onRestore(data, appVersionCode, newState); // Remove the preferences that we don't want restored. final SharedPreferences.Editor prefEditor = getSharedPreferences( getPackageName() + PREF_SUFFIX, MODE_PRIVATE).edit(); for (final String key : LocalSettingsConstants.PREFS_TO_SKIP_RESTORING) { prefEditor.remove(key); } // Flush the changes to disk. prefEditor.commit(); }
Example #13
Source File: MyTracksBackupAgent.java From mytracks with Apache License 2.0 | 5 votes |
/** * Restores all preferences from the backup. * * @param data the backup data to read from * @throws IOException if there are any errors while reading */ private void restorePreferences(BackupDataInput data) throws IOException { int dataSize = data.getDataSize(); byte[] dataBuffer = new byte[dataSize]; int read = data.readEntityData(dataBuffer, 0, dataSize); if (read != dataSize) { throw new IOException("Failed to read all the preferences data"); } SharedPreferences preferences = this.getSharedPreferences( Constants.SETTINGS_NAME, Context.MODE_PRIVATE); PreferenceBackupHelper importer = createPreferenceBackupHelper(); importer.importPreferences(dataBuffer, preferences); }
Example #14
Source File: BackupAgent.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { // Let the restore operation go through super.onRestore(data, appVersionCode, newState); // Remove the preferences that we don't want restored. final SharedPreferences.Editor prefEditor = getSharedPreferences( getPackageName() + PREF_SUFFIX, MODE_PRIVATE).edit(); for (final String key : LocalSettingsConstants.PREFS_TO_SKIP_RESTORING) { prefEditor.remove(key); } // Flush the changes to disk. prefEditor.commit(); }
Example #15
Source File: SipBackupAgent.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { Log.d(THIS_FILE, "App version code : " + appVersionCode); super.onRestore(data, appVersionCode, newState); }
Example #16
Source File: MyBackupAgent.java From mobikul-standalone-pos with MIT License | 5 votes |
/** * Adding locking around the file rewrite that happens during restore is * similarly straightforward. */ @Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { // Hold the lock while the FileBackupHelper restores the file from // the data provided here. synchronized (sDataLock) { super.onRestore(data, appVersionCode, newState); } }
Example #17
Source File: BackupAgent.java From Android-Keyboard with Apache License 2.0 | 5 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { // Let the restore operation go through super.onRestore(data, appVersionCode, newState); // Remove the preferences that we don't want restored. final SharedPreferences.Editor prefEditor = getSharedPreferences( getPackageName() + PREF_SUFFIX, MODE_PRIVATE).edit(); for (final String key : LocalSettingsConstants.PREFS_TO_SKIP_RESTORING) { prefEditor.remove(key); } // Flush the changes to disk. prefEditor.commit(); }
Example #18
Source File: SettingsBackupAgent.java From Audinaut with GNU General Public License v3.0 | 4 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { super.onRestore(data, appVersionCode, newState); Util.getPreferences(this).edit().remove(Constants.PREFERENCES_KEY_CACHE_LOCATION).apply(); }
Example #19
Source File: OctoBackupAgent.java From octoandroid with GNU General Public License v3.0 | 4 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { synchronized (DbHelper.sLock) { super.onRestore(data, appVersionCode, newState); } }
Example #20
Source File: SettingsBackupAgent.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { HashSet<String> movedToGlobal = new HashSet<String>(); Settings.System.getMovedKeys(movedToGlobal); Settings.Secure.getMovedKeys(movedToGlobal); while (data.readNextHeader()) { final String key = data.getKey(); final int size = data.getDataSize(); if (KEY_SYSTEM.equals(key)) { restoreSettings(data, Settings.System.CONTENT_URI, movedToGlobal); mSettingsHelper.applyAudioSettings(); } else if (KEY_SECURE.equals(key)) { restoreSettings(data, Settings.Secure.CONTENT_URI, movedToGlobal); } else if (KEY_GLOBAL.equals(key)) { restoreSettings(data, Settings.Global.CONTENT_URI, null); } else if (KEY_WIFI_SUPPLICANT.equals(key)) { initWifiRestoreIfNecessary(); mWifiRestore.incorporateWifiSupplicant(data); } else if (KEY_LOCALE.equals(key)) { byte[] localeData = new byte[size]; data.readEntityData(localeData, 0, size); mSettingsHelper.setLocaleData(localeData, size); } else if (KEY_WIFI_CONFIG.equals(key)) { initWifiRestoreIfNecessary(); mWifiRestore.incorporateWifiConfigFile(data); } else { data.skipEntityData(); } } // If we have wifi data to restore, post a runnable to perform the // bounce-and-update operation a little ways in the future. if (mWifiRestore != null) { long wifiBounceDelayMillis = Settings.Global.getLong( getContentResolver(), Settings.Global.WIFI_BOUNCE_DELAY_OVERRIDE_MS, WIFI_BOUNCE_DELAY_MILLIS); new Handler(getMainLooper()).postDelayed(mWifiRestore, wifiBounceDelayMillis); } }
Example #21
Source File: ChromeBackupAgent.java From delion with Apache License 2.0 | 4 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { // No implementation needed for Android 6.0 Auto Backup. Used only on older versions of // Android Backup }
Example #22
Source File: SettingsBackupAgent.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { HashSet<String> movedToGlobal = new HashSet<String>(); Settings.System.getMovedToGlobalSettings(movedToGlobal); Settings.Secure.getMovedToGlobalSettings(movedToGlobal); byte[] restoredWifiSupplicantData = null; byte[] restoredWifiIpConfigData = null; while (data.readNextHeader()) { final String key = data.getKey(); final int size = data.getDataSize(); switch (key) { case KEY_SYSTEM : restoreSettings(data, Settings.System.CONTENT_URI, movedToGlobal); mSettingsHelper.applyAudioSettings(); break; case KEY_SECURE : restoreSettings(data, Settings.Secure.CONTENT_URI, movedToGlobal); break; case KEY_GLOBAL : restoreSettings(data, Settings.Global.CONTENT_URI, null); break; case KEY_WIFI_SUPPLICANT : restoredWifiSupplicantData = new byte[size]; data.readEntityData(restoredWifiSupplicantData, 0, size); break; case KEY_LOCALE : byte[] localeData = new byte[size]; data.readEntityData(localeData, 0, size); mSettingsHelper.setLocaleData(localeData, size); break; case KEY_WIFI_CONFIG : restoredWifiIpConfigData = new byte[size]; data.readEntityData(restoredWifiIpConfigData, 0, size); break; case KEY_LOCK_SETTINGS : restoreLockSettings(data); break; case KEY_SOFTAP_CONFIG : byte[] softapData = new byte[size]; data.readEntityData(softapData, 0, size); restoreSoftApConfiguration(softapData); break; case KEY_NETWORK_POLICIES: byte[] netPoliciesData = new byte[size]; data.readEntityData(netPoliciesData, 0, size); restoreNetworkPolicies(netPoliciesData); break; case KEY_WIFI_NEW_CONFIG: byte[] restoredWifiNewConfigData = new byte[size]; data.readEntityData(restoredWifiNewConfigData, 0, size); restoreNewWifiConfigData(restoredWifiNewConfigData); break; default : data.skipEntityData(); } } // Do this at the end so that we also pull in the ipconfig data. if (restoredWifiSupplicantData != null) { restoreSupplicantWifiConfigData( restoredWifiSupplicantData, restoredWifiIpConfigData); } }
Example #23
Source File: SimpleBackupAgent.java From science-journal with Apache License 2.0 | 4 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { super.onRestore(data, appVersionCode, newState); }
Example #24
Source File: LauncherBackupAgentHelper.java From Trebuchet with GNU General Public License v3.0 | 4 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { if (!Utilities.ATLEAST_LOLLIPOP) { // 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); // Rank was added in v4. if (mHelper.restoredBackupVersion <= 3) { LauncherAppState.getLauncherProvider().updateFolderItemsRank(); } if (MigrateFromRestoreTask.ENABLED && mHelper.shouldAttemptWorkspaceMigration()) { MigrateFromRestoreTask.markForMigration(getApplicationContext(), (int) mHelper.migrationCompatibleProfileData.desktopCols, (int) mHelper.migrationCompatibleProfileData.desktopRows, mHelper.widgetSizes); } LauncherAppState.getLauncherProvider().convertShortcutsToLauncherActivities(); } else { if (VERBOSE) Log.v(TAG, "Nothing was restored, clearing DB"); LauncherAppState.getLauncherProvider().createEmptyDB(); } }
Example #25
Source File: BackupAgent.java From andOTP with MIT License | 4 votes |
@Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { synchronized (DatabaseHelper.DatabaseFileLock) { super.onRestore(data, appVersionCode, newState); } }
Example #26
Source File: LauncherBackupAgent.java From LaunchEnr with GNU General Public License v3.0 | 4 votes |
@Override public void onRestore( BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) { // Doesn't do incremental backup/restore }
Example #27
Source File: AndroidBackupHandler.java From shattered-pixel-dungeon with GNU General Public License v3.0 | votes |
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) {}