public class SystemBackupAgent extends BackupAgentHelper
Context.BindServiceFlags, Context.CreatePackageOptions, Context.ServiceName
TYPE_DIRECTORY, TYPE_EOF, TYPE_FILE, TYPE_SYMLINK
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BACKUP_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_ALLOW_WHITELIST_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_FOREGROUND_SERVICE, BIND_FOREGROUND_SERVICE_WHILE_AWAKE, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_NOT_VISIBLE, BIND_SHOWING_UI, BIND_TREAT_LIKE_ACTIVITY, BIND_VISIBLE, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_CREDENTIAL_PROTECTED_STORAGE, CONTEXT_DEVICE_PROTECTED_STORAGE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_REGISTER_PACKAGE, CONTEXT_RESTRICTED, CONTEXTHUB_SERVICE, COUNTRY_DETECTOR, DEVICE_IDLE_CONTROLLER, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, ETHERNET_SERVICE, FINGERPRINT_SERVICE, GATEKEEPER_SERVICE, HARDWARE_PROPERTIES_SERVICE, HDMI_CONTROL_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_POLICY_SERVICE, NETWORK_SCORE_SERVICE, NETWORK_STATS_SERVICE, NETWORKMANAGEMENT_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, PERSISTENT_DATA_BLOCK_SERVICE, POWER_SERVICE, PRINT_SERVICE, RADIO_SERVICE, RECOVERY_SERVICE, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SERIAL_SERVICE, SHORTCUT_SERVICE, SIP_SERVICE, SOUND_TRIGGER_SERVICE, STATUS_BAR_SERVICE, STORAGE_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TRUST_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, UPDATE_LOCK_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, VOICE_INTERACTION_MANAGER_SERVICE, WALLPAPER_SERVICE, WIFI_NAN_SERVICE, WIFI_P2P_SERVICE, WIFI_RTT_SERVICE, WIFI_SCANNING_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
Constructor and Description |
---|
SystemBackupAgent() |
Modifier and Type | Method and Description |
---|---|
void |
onBackup(ParcelFileDescriptor oldState,
BackupDataOutput data,
ParcelFileDescriptor newState)
Run the backup process on each of the configured handlers.
|
void |
onFullBackup(FullBackupDataOutput data)
The application is having its entire file system contents backed up.
|
void |
onRestore(BackupDataInput data,
int appVersionCode,
ParcelFileDescriptor newState)
Run the restore process on each of the configured handlers.
|
void |
onRestoreFile(ParcelFileDescriptor data,
long size,
int type,
String domain,
String path,
long mode,
long mtime)
Only specialized platform agents should overload this entry point to support
restores to crazy non-app locations.
|
void |
onRestoreFinished()
The application's restore operation has completed.
|
addHelper, getDispatcher
attach, fullBackupFile, fullBackupFileTree, onBind, onCreate, onDestroy, onQuotaExceeded, onRestoreFile
attachBaseContext, bindService, bindServiceAsUser, canStartActivityForResult, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, checkUriPermission, clearWallpaper, createApplicationContext, createConfigurationContext, createCredentialProtectedStorageContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, createPackageContextAsUser, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getBasePackageName, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDir, getDisplay, getDisplayAdjustments, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getOpPackageName, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSharedPreferences, getSharedPreferencesPath, getSystemService, getSystemServiceName, getTheme, getThemeResId, getUserId, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isCredentialProtectedStorage, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, registerReceiverAsUser, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastMultiplePermissions, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivitiesAsUser, startActivity, startActivity, startActivityAsUser, startActivityAsUser, startActivityForResult, startInstrumentation, startIntentSender, startIntentSender, startService, startServiceAsUser, stopService, stopServiceAsUser, unbindService, unregisterReceiver
bindServiceAsUser, createCredentialEncryptedStorageContext, createDeviceEncryptedStorageContext, getColor, getColorStateList, getDrawable, getSharedPrefsFile, getString, getString, getSystemService, getText, isCredentialEncryptedStorage, isDeviceEncryptedStorage, migrateDatabaseFrom, migrateSharedPreferencesFrom, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) throws IOException
BackupAgentHelper
onBackup
in class BackupAgentHelper
oldState
- An open, read-only ParcelFileDescriptor pointing to the
last backup state provided by the application. May be
null
, in which case no prior state is being
provided and the application should perform a full backup.data
- A structured wrapper around an open, read/write
file descriptor pointing to the backup data destination.
Typically the application will use backup helper classes to
write to this file.newState
- An open, read/write ParcelFileDescriptor pointing to an
empty file. The application should record the final backup
state here after writing the requested data to the data
output stream.IOException
public void onFullBackup(FullBackupDataOutput data) throws IOException
BackupAgent
data
points to the backup destination, and the app has the opportunity to choose which
files are to be stored. To commit a file as part of the backup, call the
BackupAgent.fullBackupFile(File, FullBackupDataOutput)
helper method. After all file
data is written to the output, the agent returns from this method and the backup
operation concludes.
Certain parts of the app's data are never backed up even if the app explicitly sends them to the output:
ContextWrapper.getCacheDir()
directoryContextWrapper.getCodeCacheDir()
directoryContextWrapper.getNoBackupFilesDir()
directoryThe default implementation of this method backs up the entirety of the
application's "owned" file system trees to the output other than the few exceptions
listed above. Apps only need to override this method if they need to impose special
limitations on which files are being stored beyond the control that
ContextWrapper.getNoBackupFilesDir()
offers.
Alternatively they can provide an xml resource to specify what data to include or exclude.
onFullBackup
in class BackupAgent
data
- A structured wrapper pointing to the backup destination.IOException
Context.getNoBackupFilesDir()
,
ApplicationInfo.fullBackupContent
,
BackupAgent.fullBackupFile(File, FullBackupDataOutput)
,
BackupAgent.onRestoreFile(ParcelFileDescriptor, long, File, int, long, long)
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException
BackupAgentHelper
onRestore
in class BackupAgentHelper
data
- A structured wrapper around an open, read-only
file descriptor pointing to a full snapshot of the
application's data. The application should consume every
entity represented in this data stream.appVersionCode
- The value of the android:versionCode
manifest attribute,
from the application that backed up this particular data set. This
makes it possible for an application's agent to distinguish among any
possible older data versions when asked to perform the restore
operation.newState
- An open, read/write ParcelFileDescriptor pointing to an
empty file. The application should record the final backup
state here after restoring its data from the data
stream.
When a full-backup dataset is being restored, this will be null
.IOException
public void onRestoreFile(ParcelFileDescriptor data, long size, int type, String domain, String path, long mode, long mtime) throws IOException
BackupAgent
onRestoreFile
in class BackupAgent
IOException
public void onRestoreFinished()
BackupAgent
onRestore()
or
onRestoreFile()
callbacks). This provides the app with a stable end-of-restore opportunity to
perform any appropriate post-processing on the data that was just delivered.