36 Commits

Author SHA1 Message Date
Christopher Tate
4528186e0d Refactor android.backup => android.app.backup
Change-Id: I0b21316ff890d7f3c7d4b82837bb60670724c2e8
2010-03-05 16:27:15 -08:00
Ying Wang
c882ddacc8 Fix Proguard flags. 2010-03-02 09:36:33 -08:00
Christopher Tate
1bb6906c7a Automatically restore app data at install time
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
2010-02-19 17:24:07 -08:00
Christopher Tate
a87240c227 Remove BACKUP_DATA permission and associated checks
Any package can now participate in backup/restore, without requiring any
manifest-declared permission.  *Control* of the backup manager is still
guarded by the BACKUP permission, which is signatureOrSystem.

Change-Id: I116fcfcd4cd255e3c976330da1c4dea7d4faae9d
2010-02-12 15:49:30 -08:00
Omari Stephens
aa6e73a6c8 Revive backup tests 2009-12-02 17:39:27 -08:00
Android (Google) Code Review
1cf3229a40 Merge change 20918
* changes:
  Wrap up the stress test into a single script make test_restore.sh return a value signifying success or failure
2009-08-13 18:35:40 -07:00
Christopher Tate
0749dcd193 Backup participants must now hold the BACKUP_DATA permission
Packages that do not use android.permission.BACKUP_DATA will neither be backed
up nor restored.  That permission is currently signature-only.  In the future if
access to the backup/restore infrastructure is made available to arbitrary 3rd
party applications, the permission checks (and indeed, the permission itself)
can simply be removed.
2009-08-13 15:15:55 -07:00
Omari Stephens
259447bc64 Wrap up the stress test into a single script
make test_restore.sh return a value signifying success or failure
2009-08-12 00:30:59 -07:00
Omari Stephens
bf5ac2aac3 git rid of the "x" prefixes for test 2009-08-11 22:10:52 -07:00
Omari Stephens
0cfeb25707 The triumphant return of the shell scripts, with bugreports, less code dup, and
enhanced readability.
2009-08-11 21:51:03 -07:00
Omari Stephens
864ed1a9d7 Wipe data on backend before a backup run
Append the date to 3.txt so that we can see if/when backup failures occurred
  solely from the device/server state
Note that these files will probably be deleted from the tree immediately, to
  be replaced by the ruby versions.
2009-08-06 15:36:34 -07:00
Omari Stephens
1f808c6f6e Make test_backup and test_restore usable again
- Add copyright headers
 - Allow the user to pass options (like '-s FOO') to adb
 - Restart device adb as root if needed
 - Make test_restore to infer a restore set
2009-08-03 20:23:55 -07:00
Christopher Tate
c8daa76925 BackupManager wrapper class improvements
+ 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.
2009-07-07 11:40:07 -07:00
Joe Onorato
dc355a90a3 Add a test for SharedPreferencesBackupHelper
(which nobody had ever tested.  I like it when stuff
just works the first time).
2009-06-26 14:45:25 -04:00
Joe Onorato
aae628b445 Test that we correctly back up an empty file.
(It turns out that we do.  It didn't used to work, I'm not
sure what changed)
2009-06-26 12:57:45 -04:00
Joe Onorato
4a64bded06 Add some helpful tests scripts for backup and make bmgr restore wait until the backup is done. 2009-06-25 23:53:29 -04:00
Joe Onorato
4ababd922e Make the BackupHelperDispatcher properly handle multiple helpers. 2009-06-25 20:36:09 -04:00
Christopher Tate
5cbbf5652a Pass the originating app's versionCode along with a restore set
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.
2009-06-22 16:44:51 -07:00
Joe Onorato
06290a4bb9 Helper API cleanup. Allows multiple helpers to function,
because they'll always go in the same order, and this lets
us not have to write headers to keep them paired.
2009-06-22 13:02:24 -07:00
Joe Onorato
d2d9ceb730 Make RestoreHelper and friends also write out the snapshot state. 2009-06-18 18:41:11 -07:00
Joe Onorato
83248c432f backup fixes:
- BackupTestAgent calls the DispatchHelper
- Make BackupAgent.onRestore take a BackupDataInput, not just a
  generic ParcelFileDescriptor.
2009-06-17 17:57:30 -07:00
Joe Onorato
efd0fab04b FileRestoreHelper and RestoreHelperDispatcher work. 2009-06-17 16:20:55 -07:00
Joe Onorato
1cf587496f Add RestoreFileHelper, BackupDataInput, and add java wrappers for the methods on BackupDataOutput. 2009-06-12 16:21:24 -07:00
Joe Onorato
ce88cb15b5 Make the file backup helper not crash if a file you requested
can't be stated.  This means you don't need to know if the files
you are backing up exist or not -- we'll figure it out for you.
2009-06-11 14:51:45 -07:00
Joe Onorato
23ecae3bbb Fix SharedPrefsBackupHelper so it doesn't hard code the paths to the files.
This took quite a bit of refactoring.
2009-06-11 11:29:57 -07:00
Mathias Agopian
8ae2335a3c rename a few files to camel-case, add copyright notices 2009-06-04 13:53:57 -07:00
Christopher Tate
181fafaf48 Retool the backup process to use a new 'BackupAgent' class
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.
2009-05-31 13:10:03 -07:00
Joe Onorato
d2110dbce0 Hook up the backup data writer, and add a utility to read the backup data files. 2009-05-20 11:24:20 -07:00
Joe Onorato
2e1da32203 Add the backup data file writer C++ class. 2009-05-15 18:20:19 -04:00
Joe Onorato
4535e40544 Implement the C++ class to write the backed up file data. 2009-05-15 10:37:10 -04:00
Joe Onorato
290bb011c5 Get the backup calling through to the file backup helper.
This includes some cleanup to make the parameters match
between BackupService.onBackup and FileBackupHelper.performBackup.
2009-05-14 09:39:32 -04:00
Joe Onorato
8ad028117d With this, the BackupService onBackup method is called.
It took a bunch of refactoring inside BackupManagerService,
which is unfortunately all temporary anyway, but it unblocks
a bunch of stuff.
2009-05-13 01:41:44 -04:00
Joe Onorato
c825d3ebd6 fix the sim build. disables the tests for now. 2009-05-08 09:33:19 -07:00
Joe Onorato
b1a7ffef3a More backup tests 2009-05-07 15:32:48 -07:00
Joe Onorato
f9225f89aa Add a test app for the backup 2009-05-05 18:34:31 -07:00
Joe Onorato
3ad977b41c Add some C++ code to do raw files for backup 2009-05-05 13:45:25 -07:00