public class WallpaperBackupAgent extends BackupAgent
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 |
---|
WallpaperBackupAgent() |
Modifier and Type | Method and Description |
---|---|
void |
onBackup(ParcelFileDescriptor oldState,
BackupDataOutput data,
ParcelFileDescriptor newState)
The application is being asked to write any data changed since the last
time it performed a backup operation.
|
void |
onCreate()
Provided as a convenience for agent implementations that need an opportunity
to do one-time initialization before the actual backup or restore operation
is begun.
|
void |
onFullBackup(FullBackupDataOutput data)
The application is having its entire file system contents backed up.
|
void |
onQuotaExceeded(long backupDataBytes,
long quotaBytes)
Notification that the application's current backup operation causes it to exceed
the maximum size permitted by the transport.
|
void |
onRestore(BackupDataInput data,
int appVersionCode,
ParcelFileDescriptor newState)
The application is being restored from backup and should replace any
existing data with the contents of the backup.
|
void |
onRestoreFinished()
The application's restore operation has completed.
|
attach, fullBackupFile, fullBackupFileTree, onBind, onDestroy, onRestoreFile, 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 onCreate()
BackupAgent
onCreate
in class BackupAgent
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 onQuotaExceeded(long backupDataBytes, long quotaBytes)
BackupAgent
The quotaBytes
value is the total data size currently permitted for this
application. If desired, the application can use this as a hint for determining
how much data to store. For example, a messaging application might choose to
store only the newest messages, dropping enough older content to stay under
the quota.
Note that the maximum quota for the application can change over time. In particular, in the future the quota may grow. Applications that adapt to the quota when deciding what data to store should be aware of this and implement their data storage mechanisms in a way that can take advantage of additional quota.
onQuotaExceeded
in class BackupAgent
backupDataBytes
- The amount of data measured while initializing the backup
operation, if the total exceeds the app's alloted quota. If initial measurement
suggested that the data would fit but then too much data was actually submitted
as part of the operation, then this value is the amount of data that had been
streamed into the transport at the time the quota was reached.quotaBytes
- The maximum data size that the transport currently permits
this application to store as a backup.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.public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) throws IOException
BackupAgent
oldState
file
descriptor. If oldState
is null
, no old state
is available and the application should perform a full backup. In both
cases, a representation of the final backup state after this pass should
be written to the file pointed to by the file descriptor wrapped in
newState
.
Each entity written to the BackupDataOutput
data
stream will be transmitted
over the current backup transport and stored in the remote data set under
the key supplied as part of the entity. Writing an entity with a negative
data size instructs the transport to delete whatever entity currently exists
under that key from the remote data set.
onBackup
in class BackupAgent
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 onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException
BackupAgent
data
parameter. Once
the restore is finished, the application should write a representation of
the final state to the newState
file descriptor.
The application is responsible for properly erasing its old data and replacing it with the data supplied to this method. No "clear user data" operation will be performed automatically by the operating system. The exception to this is in the case of a failed restore attempt: if onRestore() throws an exception, the OS will assume that the application's data may now be in an incoherent state, and will clear it before proceeding.
onRestore
in class BackupAgent
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