summaryrefslogtreecommitdiff
path: root/core/java/android/backup
Commit message (Collapse)AuthorAgeFilesLines
* Refactor android.backup => android.app.backupChristopher Tate2010-03-0519-1788/+0
| | | | Change-Id: I0b21316ff890d7f3c7d4b82837bb60670724c2e8
* Add some backup Javadoc and clean importsKenny Root2010-02-2411-56/+107
| | | | | | | Add a bit more Javadoc to the backup infrastructure and clean up unused imports. Change-Id: I8ab7c3fb887ae2e8d2f1bfac42f03cb4b42685ef
* Remove never-used dead code from BackupManagerChristopher Tate2010-02-231-12/+0
| | | | Change-Id: I93a8341160815e29625a978fee27014beb2c6a26
* Automatically restore app data at install timeChristopher Tate2010-02-191-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an application being installed defines a backupAgent in its manifest, we now automatically perform a restore of the latest-known-good data for that app. This is defined as "data backed up by this app from this handset, if available; otherwise data for this app as it existed when the device was initially provisioned." If neither option exists for the app, no restore action is taken. The CL involves major changes in the Backup and Package Managers... * The Package Manager's act of installing an application has now been split into two separate phases, with a data-restore phase optionally occurring between these two PM actions. First, the details of the install are performed as usual. Instead of immediately notifying install observers and issuing the install-related broadcasts, the in-process install state is snapshotted and the backup manager notified that a restore operation should be attempted. It does this by calling a new API on IBackupManager, passing a token by which it identifies its in-progress install state. The backup manager then downloads [if possible] the data for the newly-installed application and invokes the app's backupAgent to do the restore. After this step, regardless of failure, it then calls back into the Package Manager to indicate that the restore phase has been completed, supplying the token that was passed in the original notification from the Package Manager. The Package Manager then runs the final post-install actions: notifying install observers and sending out all the appropriate broadcasts. It's only at this point that the app becomes visible to the Launcher and the rest of the OS. ... and a few other bits and pieces... * The ApplicationInfo.backupAgentName field has been exposed to the SDK. This can be reverted if there's a reason to do so, but it wasn't clear that this info needs to be hidden from 3rd party apps. * Debug logging of restore set IDs and operation timeout tokens [used during any asynchronous Backup Manager operation] are now consistently in hex for readability. * We now properly reset our binder identity before calling into the transport during restore-set operations. This fixes a permissions failure when a single-app restore was attempted. * The 'BackupTest' test app is no longer lumped onto the system partition by default. Change-Id: If3addefb846791f327e2a221de97c8d5d20ee7b3
* Change Javadocs to fix SDK buildKenny Root2010-02-172-4/+3
| | | | | | | Remove some hidden reference and update links to other classes and methods. Change-Id: I4b6561f1bac07329d75da13f72496aa7d5b20a62
* API CHANGE: expose backup/restore to the SDKChristopher Tate2010-02-1613-33/+162
| | | | | | | | | | | | | | The core backup/restore classes [BackupManager, BackupAgent, RestoreSession, and RestoreObserver] are now published for 3rd party developers, as well as the suite of helper classes that exist so far to aid authorship of backup/restore agents. In conjunction with the API change, the restore-time automatic data wipe has now been removed: applications are responsible for managing the logic of wipe vs merge themselves. If the app's agent onRestore() callback throws, the data is presumed to be incoherent and a wipe is issued via the Activity Manager; otherwise, no automatic action is ever taken. Change-Id: I0b3418b829d4689b58b88be3d9c4ace37a8583a9
* Add single-package restore from an app's most-recent dataChristopher Tate2010-02-042-10/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Renamed the RestoreSession performRestore() method to restoreAll(), and added a new restorePackage() method that only restores the single specified app. In order to restore an app other than itself, the caller must hold the android.permission.BACKUP permission. This change also introduces dataset tracking: the Backup Manager persistently remembers both the current backup dataset's identity and that of the "ancestral" dataset, i.e. the one most recently used for a whole-device restore such as performed by SetupWizard. When a single package is restored via restorePackage(), the selection of most-recent dataset to use is this: 1. The data from the currently-active backup dataset, if such exists. An app that has ever backed up data will therefore get its last- known-good data. 2. The app's data from the ancestral dataset, if such exists. This covers the case of a factory reset followed by reinstallation of an app at a later time. The app had not yet backed anything up post-wipe, but the old data is in the ancestral dataset and should be brought forward when the app reappears. 3. If neither 1. nor 2. exist, there is no data to restore, so just skip it and return failure. Note that the infrastructure to automatically attempt a restore after an application has been installed does not yet exist; that's coming. Change-Id: I0ba170df9885128000c46ed28d3dddda3a63a143
* Add auto-restore setting and Backup Manager awareness thereofChristopher Tate2010-02-031-0/+15
| | | | | | | | This setting, like BACKUP_ENABLE, should never be set directly in the secure settings database. Instead, it should be manipulated through the new IBackupManager method setAutoRestore(boolean). Change-Id: I5c3226ca85b6148bb756d753d7f9e4ea76e878c4
* Streamline: use Messages sent to a Handler subclass instead of posting RunnablesChristopher Tate2010-02-011-44/+28
| | | | Change-Id: I0ecbd2145300962839c0f87b761768a3bca4f010
* Make backup/restore asynchronous and enforce timeoutsChristopher Tate2010-01-292-3/+11
| | | | | | | | | | | | | | | | | | Callouts to app backup agents are now asynchronous, and timeouts are applied if they take too long, hang, etc. The initial timeouts are set to 15 seconds on backup, 60 seconds on restore. These operations typically run at background priority, so it's necessary to give them ample time to run. As part of setting up this asynchronicity, the Backup Manager's internal thread management has been overhauled. It now spins off a single HandlerThread at startup, and runs backup/restore/etc operations *synchronously* in that thread, applying timeouts as appropriate. This means we're no longer spinning up new threads all the time, and furthermore it ensures that we can never have more than one operation in flight at once. Later CLs will remove the now-redundant logic that previously ensured that operations didn't stomp on each other. Bug: 2053560 Change-Id: Ie4315c219c7ff6dd8f51f2ad6c0872595b18cff1
* Move towards a formal public API for backup and restoreChristopher Tate2010-01-253-4/+238
| | | | | | | | | | | | | | This commit makes a few changes towards establishing a formal application interface for interacting with the backup/restore mechanism: 1. Introduce public wrapper classes around the various binder interfaces; 3rd party code will never see the binders directly. 2. Progress update callbacks during a restore sequence now occur on the main thread, not in a binder thread [and not with system-process permissions!]. 3. Rename the BackupManagerService's inner "RestoreSession" class to avoid ambiguity with the new public "RestoreSession" class.
* Turn off most of the backup-related debug loggingChristopher Tate2009-09-303-6/+7
| | | | | | | The core logging in BackupManagerService and in the Google backup transport are still enabled at this point. Change-Id: I10abfa565bbd1097dd3631051b6aca163e4af33a
* Don't let bmgr leave a restore session hanging on errorChristopher Tate2009-08-111-0/+5
| | | | | | | | | | | Specifically, don't wait for the RestoreObserver to be informed that the restore has completed unless performRestore() ran. We were winding up in a case where bmgr was hanging forever waiting on a nonexistent restore process instead of calling endRestoreSession(). Also improve the documentation, explicitly calling out the need to call endRestoreSession() even if previous operations on the session were unsuccessful.
* Only restore the bits for wallpapers that aren't built in.Joe Onorato2009-07-291-6/+1
|
* Make the backup manager do nothing when backup is turned off.Joe Onorato2009-07-131-0/+9
|
* turn restore back in in eclairJoe Onorato2009-07-101-1/+1
|
* do not merge - add a big flag to turn off backupJoe Onorato2009-07-091-0/+3
|
* BackupManager wrapper class improvementsChristopher Tate2009-07-071-12/+37
| | | | | | | | | | | | | + Now rechecks the cached IBinder each time the wrapper is used, and if it's still null (i.e. the BackupManager was constructed before the system service came up) it's refetched. This lets even system code cache a single BackupManager instance and just keep making calls through it without worrying about interactions with the life cycle of the backup service. + Added a static dataChanged(packageName) method as a convenience for code that needs to indicate that some other package needs a backup pass. This is useful even for third party code in the case of multiple packages in a shared-uid situation.
* Make enable/provisioning of the backup service a two-step processChristopher Tate2009-07-061-0/+7
| | | | | | | | | | | | | | | This CL adds the concept of 'provisioned' to the backup manager. No backups will be scheduled until the user has indicated that backups are to be enabled *and* has clicked all the way through the setup wizard. When the user first turns on the backup system, the delay before the initial backup pass is different from the periodic backup interval. Currently that initial delay is 12 hours. The intent here is to guess at a less-active time for performing that first backup pass. NOTE: currently the backup service defaults to 'provisioned'. Once the real code goes live in Setup Wizard, this will be changed to default to not-provisioned until the user has confirmed all the relevant UI.
* Add a "clear backed-up data" method to the backup mechanismChristopher Tate2009-07-021-0/+14
| | | | | | | | | | It's now possible to ask that the backup manager wipe the saved data for a given application from the backing store. LocalTransport implements this now but the Google backend does not yet. When the data is wiped, the on-device backup state is also wiped to ensure that the next backup pushes all necessary data. Bmgr has not yet been modified to actually call into this method, but it will be soon.
* Implement persistent enable/disable of the backup managerChristopher Tate2009-06-291-0/+18
| | | | | | | | | Backup & restore is still enabled by default, but with the expectation that it will be enabled during the course of the Setup Wizard or some other privileged entity that has notified the user about the ramifications. While disabled, data-changed notices will still be collected, but no backup pass will be scheduled. When the backup manager is later enabled, any pending data-changed notices will then be processed and the apps invoked for backup.
* Use system properties to track the current transportChristopher Tate2009-06-262-8/+17
| | | | | | | | | | | | | | | This change retools the transport selection mechanism a fair bit. Transports are now specified by name rather than by numeric ID, and the name of the currently selected transport is stored in a persistent system property under the name "persist.service.bkup.trans". The name -> IBackupTransport translation is now handled by maintaining a map from the names to the live IBackupTransport objects that correspond. The Google transport service observer now registers and unregisters the transport as the service goes up and down. The bmgr command has been expanded to include real transport interrogation and selection by name, and some documentation has been written for it.
* Use a long for restore tokenDan Egnor2009-06-261-1/+1
|
* Don't crash in various ways when using backup services too earlyChristopher Tate2009-06-261-6/+10
| | | | | | | BackupManager now no longer tries to use a null service binder if it's used early during the boot process. ActivityManagerService no longer tries to dereference null pointers if bind/unbind semantics get out of step due to things being run too early.
* Add a test for SharedPreferencesBackupHelperJoe Onorato2009-06-261-1/+1
| | | | | (which nobody had ever tested. I like it when stuff just works the first time).
* Add a new IRestoreObserver callback class to the restore processChristopher Tate2009-06-252-1/+54
| | | | | | | | The observer is told when restore begins how many packages are being restored. It then gets an onUpdate() call telling it that the Nth package is now undergoing restore. Ultimately, its restoreFinished() callback is invoked, passing a simple success/fail error code, to let it know that the restore operation has concluded.
* Make the BackupHelperDispatcher properly handle multiple helpers.Joe Onorato2009-06-252-7/+71
|
* Start backing up wallpaperChristopher Tate2009-06-241-0/+66
| | | | | | | | | | | | | | | | | | This CL does the following: + adds an AbsoluteFileBackupHelper class for managing backup of files known by absolute path, not based off of the app's getFilesDir() root + bumps up the collection interval from its testing-only default of 1 second to 3 minutes + adds a SystemBackupAgent class to the main system package and names it as the android:backupAgent for the main OS package. Right now this agent only backs up & restores the wallpaper file. + amend the Wallpaper Service to inform the Backup Manager when the wallpaper changes. On the subject of the 3-minute collection interval before the backup actually occurs: this can be short-circuited from an adb shell. Running the command 'bmgr run' will cause the Backup Manager to kick off any pending backup operations immediately.
* Modify the IBackupTransport API to support bulk restore operations.Dan Egnor2009-06-241-5/+5
| | | | Change the BackupManagerService and LocalTransport to support the new API.
* Pass the originating app's versionCode along with a restore setChristopher Tate2009-06-223-7/+8
| | | | | | | This change amends the doRestore() / onRestore() interface to backup agents to provide the integer android:versionCode of the app that stored the backup set. This should help agents figure out how to handle whatever historical data set they're handed at restore time.
* Helper API cleanup. Allows multiple helpers to function,Joe Onorato2009-06-228-143/+196
| | | | | because they'll always go in the same order, and this lets us not have to write headers to keep them paired.
* Make RestoreHelper and friends also write out the snapshot state.Joe Onorato2009-06-183-38/+52
|
* Store the app signatures as part of the backup setChristopher Tate2009-06-181-0/+1
| | | | | | | | | | | Under a pseudo-app for the Package Manager, we store the app signatures for all participating applications installed on the device. At restore time we will restore this first, then ensure that the current on-device signature chain is compatible with the one in the backup set. If there's a mismatch, this may be a spoof attempt and we will refuse to restore that app's data. The restore side of this is not implemented, but the Package Manager agent is here as well as the backup side theoretically pushing the data now.
* backup fixes:Joe Onorato2009-06-172-3/+18
| | | | | | - BackupTestAgent calls the DispatchHelper - Make BackupAgent.onRestore take a BackupDataInput, not just a generic ParcelFileDescriptor.
* FileRestoreHelper and RestoreHelperDispatcher work.Joe Onorato2009-06-175-3/+131
|
* checkpoint BackupDatAInput / RestoreHelperJoe Onorato2009-06-164-5/+107
|
* More bmgr work; fix clear-data signallingChristopher Tate2009-06-161-2/+2
| | | | | | The 'list sets' and 'restore token#' commands from bmgr now do what they are supposed to. At this point we see the restore target's data being cleared properly and its agent being launched and invoked for restore.
* Sketch out a 'bmgr' command line toolChristopher Tate2009-06-151-2/+14
| | | | | Not finished, but eventually will allow adb shell access to the Backup Manager for testing purposes etc.
* Add RestoreFileHelper, BackupDataInput, and add java wrappers for the ↵Joe Onorato2009-06-126-7/+235
| | | | methods on BackupDataOutput.
* Fix SharedPrefsBackupHelper so it doesn't hard code the paths to the files.Joe Onorato2009-06-112-15/+27
| | | | This took quite a bit of refactoring.
* Flesh out restore interface on manager; work up most of LocalTransportChristopher Tate2009-06-101-1/+1
|
* Revamp IRestoreSession a bitChristopher Tate2009-06-084-5/+128
| | | | | | | | | We now supply an array of RestoreSet objects instead of wacky Bundle shenanigans. Also, pushed beginRestoreSession() out to the BackupManager concrete interface class so that SetupWizard can use it. (beginRestoreSession() is @hide, non-privileged apps cannot use it. It's also guarded by android.permission.BACKUP enforcement.)
* Add IRestoreSession interface for the restore flowChristopher Tate2009-06-072-0/+62
| | | | | | | | Restore is a fairly complicated, somewhat stateful process, so we introduce a new interface to encapsulate the various bits and pieces into a nicely separable component. In particular, this will make it much cleaner to open and interrogate an expensive-to-construct transport and then reuse it for the actual restore process itself.
* More backup workChristopher Tate2009-06-032-4/+18
| | | | | | | | | | | | | | | | | | | | * Put in some permission enforcement around agent connection notification and full-backup scheduling. * Full backup now applies to any package, not just backup participants who have declared their own android:backupAgent * The process of running the backup operation on the set of apps who have been queued for it is now done in a separate thread, with a notification mechanism from the main Backup Manager service to pass along new-agent binding knowledge. There's no longer one do-backup message on the primary Handler per target application. * The new backup thread sets up the desired transport now and passes along the newly backed-up data to it for each backup target. Two transports have been defined so far, GoogleTransport and AdbTransport; both are stubs at present. Note that at present the backup data output file seems to be properly created, but after doBackup() is called on the test app's agent it's still zero size.
* Retool the backup process to use a new 'BackupAgent' classChristopher Tate2009-05-313-197/+15
| | | | | | | | | | | | | | | Backups will be handled by launching the application in a special mode under which no activities or services will be started, only the BackupAgent subclass named in the app's android:backupAgent manifest property. This takes the place of the BackupService class used earlier during development. In the cases of *full* backup or restore, an application that does not supply its own BackupAgent will be launched in a restricted manner; in particular, it will be using the default Application class rather than any manifest-declared one. This ensures that the app is not running any code that may try to manipulate its data while the backup system reads/writes its data set.
* Hook up the backup data writer, and add a utility to read the backup data files.Joe Onorato2009-05-202-16/+19
|
* Remove unnecessary code.Marco Nelissen2009-05-141-3/+0
|
* Get the backup calling through to the file backup helper.Joe Onorato2009-05-144-24/+41
| | | | | This includes some cleanup to make the parameters match between BackupService.onBackup and FileBackupHelper.performBackup.
* More backup testsJoe Onorato2009-05-073-0/+152
|
* Track install/removal/update of packages that provide backup servicesChristopher Tate2009-05-061-1/+1
|