18 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
Christian Sonntag
485c3a16ce fix hex parsing of bmgr 2010-03-04 14:59:04 -08:00
Christopher Tate
7d411a3b94 Add single-package restore to Bmgr feature set
Also sanity-check the package name on the Backup Manager side, failing gracefully
if the given package is not a backup/restore participant.

Bug: 2293977

Change-Id: I3575046ffcaa3cf45c1c602824baeadd64082f70
2010-02-26 12:45:22 -08:00
Christopher Tate
8472581aa3 Add single-package restore from an app's most-recent data
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
2010-02-04 16:01:09 -08:00
Christopher Tate
0e0b4ae5bc Don't let bmgr leave a restore session hanging on error
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.
2009-08-11 17:25:12 -07:00
Christopher Tate
84780f56f4 Don't crash if the Backup Manager returns a null RestoreSet[] 2009-08-07 15:50:02 -07:00
Christian Sonntag
77095d49f2 make restore tokens shown in hex.
Since they are android ids, it is much easier to use them as hex, since we can just copy then into android inspector and learn more about the restore set.
2009-08-07 13:42:45 -07:00
Christopher Tate
08e40b858e Fix Bmgr's logic around restore completion
The caller needs to wait for the restore observer to be informed that the
restore has finished processing before it can safely shut down the restore
session.
2009-08-07 11:35:35 -07:00
Christopher Tate
d23d7f2d12 Add a 'wipe' operation to Bmgr
"bmgr wipe PACKAGE" now issues the backup transport clearBackupData() operation
for the given package.
2009-07-02 14:37:50 -07:00
Christopher Tate
6ef58a1509 Implement persistent enable/disable of the backup manager
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.
2009-06-29 15:33:27 -07:00
Christopher Tate
9171749700 Use system properties to track the current transport
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.
2009-06-26 21:14:41 -07:00
Dan Egnor
156411df46 Use a long for restore token 2009-06-26 13:25:27 -07:00
Christopher Tate
c73a218c26 Add some error reporting & info to bmgr's output 2009-06-26 12:20:10 -07: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
5e8a4b842c Give the bmgr command an IRestoreObserver too. 2009-06-25 21:34:49 -04:00
Christopher Tate
abce4e8714 Use signatures on restore
On restore now, the backup manager gets the signature blocks corresponding to
the restore set from the transport.  It then validates those signatures against
the on-device app signatures, and refuses to restore data to an app whose
on-device sig block does not match the backup image's.

Also actually implement 'bmgr transport N' so that we can select the local
transport easily during runtime.
2009-06-18 18:38:02 -07:00
Christopher Tate
f68eb500f9 More bmgr work; fix clear-data signalling
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.
2009-06-16 13:58:17 -07:00
Christopher Tate
ace7f094bf Sketch out a 'bmgr' command line tool
Not finished, but eventually will allow adb shell access to the Backup Manager
for testing purposes etc.
2009-06-15 18:07:25 -07:00