summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/backup/IBackupManager.aidl22
-rw-r--r--services/java/com/android/server/BackupManagerService.java49
2 files changed, 71 insertions, 0 deletions
diff --git a/core/java/android/app/backup/IBackupManager.aidl b/core/java/android/app/backup/IBackupManager.aidl
index 8af59df..b315b3a 100644
--- a/core/java/android/app/backup/IBackupManager.aidl
+++ b/core/java/android/app/backup/IBackupManager.aidl
@@ -17,6 +17,7 @@
package android.app.backup;
import android.app.backup.IRestoreSession;
+import android.content.Intent;
/**
* Direct interface to the Backup Manager Service that applications invoke on. The only
@@ -144,6 +145,27 @@ interface IBackupManager {
String selectBackupTransport(String transport);
/**
+ * Get the configuration Intent, if any, from the given transport. Callers must
+ * hold the android.permission.BACKUP permission in order to use this method.
+ *
+ * @param transport The name of the transport to query.
+ * @return An Intent to use with Activity#startActivity() to bring up the configuration
+ * UI supplied by the transport. If the transport has no configuration UI, it should
+ * return {@code null} here.
+ */
+ Intent getConfigurationIntent(String transport);
+
+ /**
+ * Get the destination string supplied by the given transport. Callers must
+ * hold the android.permission.BACKUP permission in order to use this method.
+ *
+ * @param transport The name of the transport to query.
+ * @return A string describing the current backup destination. This string is used
+ * verbatim by the Settings UI as the summary text of the "configure..." item.
+ */
+ String getDestinationString(String transport);
+
+ /**
* Begin a restore session. Either or both of packageName and transportID
* may be null. If packageName is non-null, then only the given package will be
* considered for restore. If transportID is null, then the restore will use
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 2651fd3..1617a4e 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -2344,6 +2344,55 @@ class BackupManagerService extends IBackupManager.Stub {
}
}
+ // Supply the configuration Intent for the given transport. If the name is not one
+ // of the available transports, or if the transport does not supply any configuration
+ // UI, the method returns null.
+ public Intent getConfigurationIntent(String transportName) {
+ mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
+ "getConfigurationIntent");
+
+ synchronized (mTransports) {
+ final IBackupTransport transport = mTransports.get(transportName);
+ if (transport != null) {
+ try {
+ final Intent intent = transport.configurationIntent();
+ if (DEBUG) Slog.d(TAG, "getConfigurationIntent() returning config intent "
+ + intent);
+ return intent;
+ } catch (RemoteException e) {
+ /* fall through to return null */
+ }
+ }
+ }
+
+ return null;
+ }
+
+ // Supply the configuration summary string for the given transport. If the name is
+ // not one of the available transports, or if the transport does not supply any
+ // summary / destination string, the method can return null.
+ //
+ // This string is used VERBATIM as the summary text of the relevant Settings item!
+ public String getDestinationString(String transportName) {
+ mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
+ "getConfigurationIntent");
+
+ synchronized (mTransports) {
+ final IBackupTransport transport = mTransports.get(transportName);
+ if (transport != null) {
+ try {
+ final String text = transport.currentDestinationString();
+ if (DEBUG) Slog.d(TAG, "getDestinationString() returning " + text);
+ return text;
+ } catch (RemoteException e) {
+ /* fall through to return null */
+ }
+ }
+ }
+
+ return null;
+ }
+
// Callback: a requested backup agent has been instantiated. This should only
// be called from the Activity Manager.
public void agentConnected(String packageName, IBinder agentBinder) {