summaryrefslogtreecommitdiffstats
path: root/cmds/bu
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2014-02-04 16:23:32 -0800
committerChristopher Tate <ctate@google.com>2014-03-20 12:30:51 -0700
commitadfe8b86e9178a553b6db9722340fa4ff5201cf1 (patch)
tree2054d99dc17b0ada61693b97d9f3e306b4fe4d4a /cmds/bu
parentaef4f6ebc8f8eb1f9fbfbe4ae2556c9f1a26a63c (diff)
downloadframeworks_base-adfe8b86e9178a553b6db9722340fa4ff5201cf1.zip
frameworks_base-adfe8b86e9178a553b6db9722340fa4ff5201cf1.tar.gz
frameworks_base-adfe8b86e9178a553b6db9722340fa4ff5201cf1.tar.bz2
App widget backup/restore infrastructure
Backup/restore now supports app widgets. An application involved with app widgets, either hosting or publishing, now has associated data in its backup dataset related to the state of widget instantiation on the ancestral device. That data is processed by the OS during restore so that the matching widget instances can be "automatically" regenerated. To take advantage of this facility, widget-using apps need to do two things: first, implement a backup agent and store whatever widget state they need to properly deal with them post-restore (e.g. the widget instance size & location, for a host); and second, implement handlers for new AppWidgetManager broadcasts that describe how to translate ancestral-dataset widget id numbers to the post-restore world. Note that a host or provider doesn't technically need to store *any* data on its own via its agent; it just needs to opt in to the backup/restore process by publishing an agent. The OS will then store a small amount of data on behalf of each widget-savvy app within the backup dataset, and act on that data at restore time. The broadcasts are AppWidgetManager.ACTION_APPWIDGET_RESTORED and ACTION_APPWIDGET_HOST_RESTORED, and have three associated extras: EXTRA_APPWIDGET_OLD_IDS EXTRA_APPWIDGET_IDS EXTRA_HOST_ID [for the host-side broadcast] The first two are same-sized arrays of integer widget IDs. The _OLD_IDS values are the widget IDs as known to the ancestral device. The _IDS array holds the corresponding widget IDs in the new post- restore environment. The app should simply update the stored widget IDs in its bookkeeping to the new values, and things are off and running. The HOST_ID extra, as one might expect, is the app-defined host ID value of the particular host instance which has just been restored. The broadcasts are sent following the conclusion of the overall restore pass. This is because the restore might have occurred in a tightly restricted lifecycle environment without content providers or the package's custom Application class. The _RESTORED broadcast, however, is always delivered into a normal application environment, so that the app can use its content provider etc as expected. *All* widget instances that were processed over the course of the system restore are indicated in the _RESTORED broadcast, even if the backing provider or host is not yet installed. The widget participant is responsible for understanding that these are promises that might be fulfilled later rather than necessarily reflecting the immediate presentable widget state. (Remember that following a cloud restore, apps may be installed piecemeal over a lengthy period of time.) Telling the hosts up front about all intended widget instances allows them to show placeholder UI or similarly useful information rather than surprising the user with piecemeal unexpected appearances. The AppWidgetProvider helper class has been updated to add a new callback, onRestored(...), invoked when the _RESTORED broadcast is received. The call to onRestored() is immediately followed by an invocation of onUpdate() for the affected widgets because they will need to have their RemoteViews regenerated under the new ID values. Bug 10622506 Bug 10707117 Change-Id: Ie0007cdf809600b880d91989c00c3c3b8a4f988b
Diffstat (limited to 'cmds/bu')
-rw-r--r--cmds/bu/src/com/android/commands/bu/Backup.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmds/bu/src/com/android/commands/bu/Backup.java b/cmds/bu/src/com/android/commands/bu/Backup.java
index 73fd660..2673031 100644
--- a/cmds/bu/src/com/android/commands/bu/Backup.java
+++ b/cmds/bu/src/com/android/commands/bu/Backup.java
@@ -68,6 +68,7 @@ public final class Backup {
boolean saveObbs = false;
boolean saveShared = false;
boolean doEverything = false;
+ boolean doWidgets = false;
boolean allIncludesSystem = true;
String arg;
@@ -89,6 +90,10 @@ public final class Backup {
allIncludesSystem = true;
} else if ("-nosystem".equals(arg)) {
allIncludesSystem = false;
+ } else if ("-widgets".equals(arg)) {
+ doWidgets = true;
+ } else if ("-nowidgets".equals(arg)) {
+ doWidgets = false;
} else if ("-all".equals(arg)) {
doEverything = true;
} else {
@@ -114,8 +119,8 @@ public final class Backup {
try {
fd = ParcelFileDescriptor.adoptFd(socketFd);
String[] packArray = new String[packages.size()];
- mBackupManager.fullBackup(fd, saveApks, saveObbs, saveShared, doEverything,
- allIncludesSystem, packages.toArray(packArray));
+ mBackupManager.fullBackup(fd, saveApks, saveObbs, saveShared, doWidgets,
+ doEverything, allIncludesSystem, packages.toArray(packArray));
} catch (RemoteException e) {
Log.e(TAG, "Unable to invoke backup manager for backup");
} finally {