From f5e1c296370b45503a6c48bdb7da8b829bc0b906 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Wed, 8 Dec 2010 18:40:26 -0800 Subject: Add a couple of transport-descriptive methods to IBackupManager Privileged callers can now ask the transport for a string describing its current state, and for an Intent that can be passed to startActivity() in order to bring up its exported configuration UI. These will be used in Settings in order to e.g. show the user the currently active account being used for backup, and allow the user to choose an account. The data being funnelled through IBackupManager here are the ones already exposed by the transports in their implementation of the IBackupTransport interface. Bug: 2753632 Change-Id: I2227a2b111d8d0ddf221d63020e20c1316fff55b --- .../com/android/server/BackupManagerService.java | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'services') 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) { -- cgit v1.1