Add description and configuration methods to the transport interface
It's now possible for the transport to supply a descriptive string to inform the user about the nature of the backup destination (e.g. telling the user what account the data is being stored under), and to supply an Intent with which the system can initiate a configuration Activity supplied by the transport (e.g. allowing the user to select which account their data is being stored under). The transport interface is not public. Part of bug 2753632 and bug 2987804 Change-Id: I911f70a3ea440daf2a7a04710e9d7e65b61a58db
This commit is contained in:
@ -17,11 +17,38 @@
|
||||
package com.android.internal.backup;
|
||||
|
||||
import android.app.backup.RestoreSet;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
|
||||
/** {@hide} */
|
||||
interface IBackupTransport {
|
||||
/**
|
||||
* Ask the transport for an Intent that can be used to launch any internal
|
||||
* configuration Activity that it wishes to present. For example, the transport
|
||||
* may offer a UI for allowing the user to supply login credentials for the
|
||||
* transport's off-device backend.
|
||||
*
|
||||
* If the transport does not supply any user-facing configuration UI, it should
|
||||
* return null from this method.
|
||||
*
|
||||
* @return An Intent that can be passed to Context.startActivity() in order to
|
||||
* launch the transport's configuration UI. This method will return null
|
||||
* if the transport does not offer any user-facing configuration UI.
|
||||
*/
|
||||
Intent configurationIntent();
|
||||
|
||||
/**
|
||||
* On demand, supply a one-line string that can be shown to the user that
|
||||
* describes the current backend destination. For example, a transport that
|
||||
* can potentially associate backup data with arbitrary user accounts should
|
||||
* include the name of the currently-active account here.
|
||||
*
|
||||
* @return A string describing the destination to which the transport is currently
|
||||
* sending data. This method should not return null.
|
||||
*/
|
||||
String currentDestinationString();
|
||||
|
||||
/**
|
||||
* Ask the transport where, on local device storage, to keep backup state blobs.
|
||||
* This is per-transport so that mock transports used for testing can coexist with
|
||||
|
@ -20,6 +20,7 @@ import android.app.backup.BackupDataInput;
|
||||
import android.app.backup.BackupDataOutput;
|
||||
import android.app.backup.RestoreSet;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
@ -49,11 +50,13 @@ public class LocalTransport extends IBackupTransport.Stub {
|
||||
private static final String TRANSPORT_DIR_NAME
|
||||
= "com.android.internal.backup.LocalTransport";
|
||||
|
||||
private static final String TRANSPORT_DESTINATION_STRING
|
||||
= "Backing up to debug-only private cache";
|
||||
|
||||
// The single hardcoded restore set always has the same (nonzero!) token
|
||||
private static final long RESTORE_TOKEN = 1;
|
||||
|
||||
private Context mContext;
|
||||
private PackageManager mPackageManager;
|
||||
private File mDataDir = new File(Environment.getDownloadCacheDirectory(), "backup");
|
||||
private PackageInfo[] mRestorePackages = null;
|
||||
private int mRestorePackage = -1; // Index into mRestorePackages
|
||||
@ -61,9 +64,16 @@ public class LocalTransport extends IBackupTransport.Stub {
|
||||
|
||||
public LocalTransport(Context context) {
|
||||
mContext = context;
|
||||
mPackageManager = context.getPackageManager();
|
||||
}
|
||||
|
||||
public Intent configurationIntent() {
|
||||
// The local transport is not user-configurable
|
||||
return null;
|
||||
}
|
||||
|
||||
public String currentDestinationString() {
|
||||
return TRANSPORT_DESTINATION_STRING;
|
||||
}
|
||||
|
||||
public String transportDirName() {
|
||||
return TRANSPORT_DIR_NAME;
|
||||
|
Reference in New Issue
Block a user