Merge "[Multi-user] Change more BackupManager AIDL methods to accept userId in methods"
This commit is contained in:
@@ -247,7 +247,7 @@ public class Bmgr {
|
||||
}
|
||||
|
||||
try {
|
||||
mBmgr.dataChanged(pkg);
|
||||
mBmgr.dataChangedForUser(userId, pkg);
|
||||
} catch (RemoteException e) {
|
||||
System.err.println(e.toString());
|
||||
System.err.println(BMGR_NOT_RUNNING_ERR);
|
||||
@@ -264,7 +264,8 @@ public class Bmgr {
|
||||
}
|
||||
if (allPkgs.size() > 0) {
|
||||
try {
|
||||
mBmgr.fullTransportBackup(allPkgs.toArray(new String[allPkgs.size()]));
|
||||
mBmgr.fullTransportBackupForUser(
|
||||
userId, allPkgs.toArray(new String[allPkgs.size()]));
|
||||
} catch (RemoteException e) {
|
||||
System.err.println(e.toString());
|
||||
System.err.println(BMGR_NOT_RUNNING_ERR);
|
||||
@@ -393,7 +394,7 @@ public class Bmgr {
|
||||
installedPackages.stream().map(p -> p.packageName).toArray(String[]::new);
|
||||
String[] filteredPackages = {};
|
||||
try {
|
||||
filteredPackages = mBmgr.filterAppsEligibleForBackup(packages);
|
||||
filteredPackages = mBmgr.filterAppsEligibleForBackupForUser(userId, packages);
|
||||
} catch (RemoteException e) {
|
||||
System.err.println(e.toString());
|
||||
System.err.println(BMGR_NOT_RUNNING_ERR);
|
||||
@@ -498,11 +499,11 @@ public class Bmgr {
|
||||
}
|
||||
|
||||
if ("-c".equals(which)) {
|
||||
doTransportByComponent();
|
||||
doTransportByComponent(userId);
|
||||
return;
|
||||
}
|
||||
|
||||
String old = mBmgr.selectBackupTransport(which);
|
||||
String old = mBmgr.selectBackupTransportForUser(userId, which);
|
||||
if (old == null) {
|
||||
System.out.println("Unknown transport '" + which
|
||||
+ "' specified; no changes made.");
|
||||
@@ -516,7 +517,7 @@ public class Bmgr {
|
||||
}
|
||||
}
|
||||
|
||||
private void doTransportByComponent() {
|
||||
private void doTransportByComponent(@UserIdInt int userId) {
|
||||
String which = nextArg();
|
||||
if (which == null) {
|
||||
showUsage();
|
||||
@@ -526,7 +527,9 @@ public class Bmgr {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
try {
|
||||
mBmgr.selectBackupTransportAsync(ComponentName.unflattenFromString(which),
|
||||
mBmgr.selectBackupTransportAsyncForUser(
|
||||
userId,
|
||||
ComponentName.unflattenFromString(which),
|
||||
new ISelectBackupTransportCallback.Stub() {
|
||||
@Override
|
||||
public void onSuccess(String transportName) {
|
||||
@@ -567,7 +570,7 @@ public class Bmgr {
|
||||
}
|
||||
|
||||
try {
|
||||
mBmgr.clearBackupData(transport, pkg);
|
||||
mBmgr.clearBackupDataForUser(userId, transport, pkg);
|
||||
System.out.println("Wiped backup data for " + pkg + " on " + transport);
|
||||
} catch (RemoteException e) {
|
||||
System.err.println(e.toString());
|
||||
@@ -599,7 +602,8 @@ public class Bmgr {
|
||||
InitObserver observer = new InitObserver();
|
||||
try {
|
||||
System.out.println("Initializing transports: " + transports);
|
||||
mBmgr.initializeTransports(transports.toArray(new String[transports.size()]), observer);
|
||||
mBmgr.initializeTransportsForUser(
|
||||
userId, transports.toArray(new String[transports.size()]), observer);
|
||||
observer.waitForCompletion(30*1000L);
|
||||
System.out.println("Initialization result: " + observer.result);
|
||||
} catch (RemoteException e) {
|
||||
@@ -611,13 +615,13 @@ public class Bmgr {
|
||||
private void doList(@UserIdInt int userId) {
|
||||
String arg = nextArg(); // sets, transports, packages set#
|
||||
if ("transports".equals(arg)) {
|
||||
doListTransports();
|
||||
doListTransports(userId);
|
||||
return;
|
||||
}
|
||||
|
||||
// The rest of the 'list' options work with a restore session on the current transport
|
||||
try {
|
||||
mRestore = mBmgr.beginRestoreSession(null, null);
|
||||
mRestore = mBmgr.beginRestoreSessionForUser(userId, null, null);
|
||||
if (mRestore == null) {
|
||||
System.err.println(BMGR_NOT_RUNNING_ERR);
|
||||
return;
|
||||
@@ -634,19 +638,19 @@ public class Bmgr {
|
||||
}
|
||||
}
|
||||
|
||||
private void doListTransports() {
|
||||
private void doListTransports(@UserIdInt int userId) {
|
||||
String arg = nextArg();
|
||||
|
||||
try {
|
||||
if ("-c".equals(arg)) {
|
||||
for (ComponentName transport : mBmgr.listAllTransportComponents()) {
|
||||
for (ComponentName transport : mBmgr.listAllTransportComponentsForUser(userId)) {
|
||||
System.out.println(transport.flattenToShortString());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String current = mBmgr.getCurrentTransport();
|
||||
String[] transports = mBmgr.listAllTransports();
|
||||
String current = mBmgr.getCurrentTransportForUser(userId);
|
||||
String[] transports = mBmgr.listAllTransportsForUser(userId);
|
||||
if (transports == null || transports.length == 0) {
|
||||
System.out.println("No transports available.");
|
||||
return;
|
||||
@@ -756,7 +760,7 @@ public class Bmgr {
|
||||
filter.add(arg);
|
||||
}
|
||||
|
||||
doRestoreAll(token, filter);
|
||||
doRestoreAll(userId, token, filter);
|
||||
} catch (NumberFormatException e) {
|
||||
showUsage();
|
||||
return;
|
||||
@@ -769,12 +773,12 @@ public class Bmgr {
|
||||
System.err.println("'restore <token> <package>'.");
|
||||
}
|
||||
|
||||
private void doRestoreAll(long token, HashSet<String> filter) {
|
||||
private void doRestoreAll(@UserIdInt int userId, long token, HashSet<String> filter) {
|
||||
RestoreObserver observer = new RestoreObserver();
|
||||
|
||||
try {
|
||||
boolean didRestore = false;
|
||||
mRestore = mBmgr.beginRestoreSession(null, null);
|
||||
mRestore = mBmgr.beginRestoreSessionForUser(userId, null, null);
|
||||
if (mRestore == null) {
|
||||
System.err.println(BMGR_NOT_RUNNING_ERR);
|
||||
return;
|
||||
|
||||
@@ -335,7 +335,8 @@ public class BackupManager {
|
||||
if (sService != null) {
|
||||
try {
|
||||
// All packages, current transport
|
||||
IRestoreSession binder = sService.beginRestoreSession(null, null);
|
||||
IRestoreSession binder =
|
||||
sService.beginRestoreSessionForUser(mContext.getUserId(), null, null);
|
||||
if (binder != null) {
|
||||
session = new RestoreSession(mContext, binder);
|
||||
}
|
||||
@@ -465,7 +466,7 @@ public class BackupManager {
|
||||
checkServiceBinder();
|
||||
if (sService != null) {
|
||||
try {
|
||||
return sService.getCurrentTransportComponent();
|
||||
return sService.getCurrentTransportComponentForUser(mContext.getUserId());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "getCurrentTransportComponent() couldn't connect");
|
||||
}
|
||||
@@ -530,7 +531,8 @@ public class BackupManager {
|
||||
checkServiceBinder();
|
||||
if (sService != null) {
|
||||
try {
|
||||
sService.updateTransportAttributes(
|
||||
sService.updateTransportAttributesForUser(
|
||||
mContext.getUserId(),
|
||||
transportComponent,
|
||||
name,
|
||||
configurationIntent,
|
||||
@@ -590,7 +592,8 @@ public class BackupManager {
|
||||
try {
|
||||
SelectTransportListenerWrapper wrapper = listener == null ?
|
||||
null : new SelectTransportListenerWrapper(mContext, listener);
|
||||
sService.selectBackupTransportAsync(transport, wrapper);
|
||||
sService.selectBackupTransportAsyncForUser(
|
||||
mContext.getUserId(), transport, wrapper);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "selectBackupTransportAsync() couldn't connect");
|
||||
}
|
||||
@@ -637,7 +640,7 @@ public class BackupManager {
|
||||
checkServiceBinder();
|
||||
if (sService != null) {
|
||||
try {
|
||||
return sService.getAvailableRestoreToken(packageName);
|
||||
return sService.getAvailableRestoreTokenForUser(mContext.getUserId(), packageName);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "getAvailableRestoreToken() couldn't connect");
|
||||
}
|
||||
@@ -659,7 +662,7 @@ public class BackupManager {
|
||||
checkServiceBinder();
|
||||
if (sService != null) {
|
||||
try {
|
||||
return sService.isAppEligibleForBackup(packageName);
|
||||
return sService.isAppEligibleForBackupForUser(mContext.getUserId(), packageName);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "isAppEligibleForBackup(pkg) couldn't connect");
|
||||
}
|
||||
@@ -760,7 +763,7 @@ public class BackupManager {
|
||||
public Intent getConfigurationIntent(String transportName) {
|
||||
if (sService != null) {
|
||||
try {
|
||||
return sService.getConfigurationIntent(transportName);
|
||||
return sService.getConfigurationIntentForUser(mContext.getUserId(), transportName);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "getConfigurationIntent() couldn't connect");
|
||||
}
|
||||
@@ -781,7 +784,7 @@ public class BackupManager {
|
||||
public String getDestinationString(String transportName) {
|
||||
if (sService != null) {
|
||||
try {
|
||||
return sService.getDestinationString(transportName);
|
||||
return sService.getDestinationStringForUser(mContext.getUserId(), transportName);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "getDestinationString() couldn't connect");
|
||||
}
|
||||
@@ -802,7 +805,7 @@ public class BackupManager {
|
||||
public Intent getDataManagementIntent(String transportName) {
|
||||
if (sService != null) {
|
||||
try {
|
||||
return sService.getDataManagementIntent(transportName);
|
||||
return sService.getDataManagementIntentForUser(mContext.getUserId(), transportName);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "getDataManagementIntent() couldn't connect");
|
||||
}
|
||||
@@ -825,7 +828,7 @@ public class BackupManager {
|
||||
public String getDataManagementLabel(String transportName) {
|
||||
if (sService != null) {
|
||||
try {
|
||||
return sService.getDataManagementLabel(transportName);
|
||||
return sService.getDataManagementLabelForUser(mContext.getUserId(), transportName);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "getDataManagementLabel() couldn't connect");
|
||||
}
|
||||
|
||||
@@ -43,6 +43,15 @@ interface IBackupManager {
|
||||
* Any application can invoke this method for its own package, but
|
||||
* only callers who hold the android.permission.BACKUP permission
|
||||
* may invoke it for arbitrary packages.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the caller has made changes to its data.
|
||||
*/
|
||||
void dataChangedForUser(int userId, String packageName);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.dataChangedForUser} for the calling user id.
|
||||
*/
|
||||
void dataChanged(String packageName);
|
||||
|
||||
@@ -53,6 +62,15 @@ interface IBackupManager {
|
||||
* Any application can invoke this method for its own package, but
|
||||
* only callers who hold the android.permission.BACKUP permission
|
||||
* may invoke it for arbitrary packages.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which backup data should be erased.
|
||||
*/
|
||||
void clearBackupDataForUser(int userId, String transportName, String packageName);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.clearBackupDataForUser} for the calling user id.
|
||||
*/
|
||||
void clearBackupData(String transportName, String packageName);
|
||||
|
||||
@@ -62,24 +80,59 @@ interface IBackupManager {
|
||||
* operations.
|
||||
*
|
||||
* <p>Callers must hold the android.permission.BACKUP permission to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the given transports should be initialized.
|
||||
*/
|
||||
void initializeTransports(in String[] transportNames, IBackupObserver observer);
|
||||
void initializeTransportsForUser(int userId, in String[] transportNames,
|
||||
IBackupObserver observer);
|
||||
|
||||
/**
|
||||
* Notifies the Backup Manager Service that an agent has become available. This
|
||||
* method is only invoked by the Activity Manager.
|
||||
*
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which an agent has become available.
|
||||
*/
|
||||
void agentConnectedForUser(int userId, String packageName, IBinder agent);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.agentConnected} for the calling user id.
|
||||
*/
|
||||
void agentConnected(String packageName, IBinder agent);
|
||||
|
||||
/**
|
||||
* Notify the Backup Manager Service that an agent has unexpectedly gone away.
|
||||
* This method is only invoked by the Activity Manager.
|
||||
*
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which an agent has unexpectedly gone away.
|
||||
*/
|
||||
void agentDisconnectedForUser(int userId, String packageName);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.agentDisconnected} for the calling user id.
|
||||
*/
|
||||
void agentDisconnected(String packageName);
|
||||
|
||||
/**
|
||||
* Notify the Backup Manager Service that an application being installed will
|
||||
* need a data-restore pass. This method is only invoked by the Package Manager.
|
||||
*
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the application will need a data-restore pass.
|
||||
*/
|
||||
void restoreAtInstallForUser(int userId, String packageName, int token);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.restoreAtInstallForUser} for the calling user id.
|
||||
*/
|
||||
void restoreAtInstall(String packageName, int token);
|
||||
|
||||
@@ -112,10 +165,18 @@ interface IBackupManager {
|
||||
* is made generally available for launch.
|
||||
*
|
||||
* <p>Callers must hold the android.permission.BACKUP permission to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which automatic restore should be enabled/disabled.
|
||||
* @param doAutoRestore When true, enables the automatic app-data restore facility. When
|
||||
* false, this facility will be disabled.
|
||||
*/
|
||||
void setAutoRestoreForUser(int userId, boolean doAutoRestore);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.setAutoRestoreForUser} for the calling user id.
|
||||
*/
|
||||
void setAutoRestore(boolean doAutoRestore);
|
||||
|
||||
/**
|
||||
@@ -220,9 +281,13 @@ interface IBackupManager {
|
||||
* Perform a full-dataset backup of the given applications via the currently active
|
||||
* transport.
|
||||
*
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the full-dataset backup should be performed.
|
||||
* @param packageNames The package names of the apps whose data are to be backed up.
|
||||
*/
|
||||
void fullTransportBackup(in String[] packageNames);
|
||||
void fullTransportBackupForUser(int userId, in String[] packageNames);
|
||||
|
||||
/**
|
||||
* Restore device content from the data stream passed through the given socket. The
|
||||
@@ -250,6 +315,18 @@ interface IBackupManager {
|
||||
* backup dataset being used for restore.
|
||||
*
|
||||
* <p>Callers must hold the android.permission.BACKUP permission to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the requested backup/restore operation can proceed.
|
||||
*/
|
||||
void acknowledgeFullBackupOrRestoreForUser(int userId, int token, boolean allow,
|
||||
in String curPassword, in String encryptionPassword,
|
||||
IFullBackupRestoreObserver observer);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.acknowledgeFullBackupOrRestoreForUser} for the
|
||||
* calling user id.
|
||||
*/
|
||||
void acknowledgeFullBackupOrRestore(int token, boolean allow,
|
||||
in String curPassword, in String encryptionPassword,
|
||||
@@ -260,7 +337,10 @@ interface IBackupManager {
|
||||
* specified transport has not been bound at least once (for registration), this call will be
|
||||
* ignored. Only the host process of the transport can change its description, otherwise a
|
||||
* {@link SecurityException} will be thrown.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the attributes of the transport should be updated.
|
||||
* @param transportComponent The identity of the transport being described.
|
||||
* @param name A {@link String} with the new name for the transport. This is NOT for
|
||||
* identification. MUST NOT be {@code null}.
|
||||
@@ -279,13 +359,23 @@ interface IBackupManager {
|
||||
* @throws SecurityException If the UID of the calling process differs from the package UID of
|
||||
* {@code transportComponent} or if the caller does NOT have BACKUP permission.
|
||||
*/
|
||||
void updateTransportAttributes(in ComponentName transportComponent, in String name,
|
||||
void updateTransportAttributesForUser(int userId, in ComponentName transportComponent,
|
||||
in String name,
|
||||
in Intent configurationIntent, in String currentDestinationString,
|
||||
in Intent dataManagementIntent, in String dataManagementLabel);
|
||||
|
||||
/**
|
||||
* Identify the currently selected transport. Callers must hold the
|
||||
* android.permission.BACKUP permission to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the currently selected transport should be identified.
|
||||
*/
|
||||
String getCurrentTransportForUser(int userId);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.getCurrentTransportForUser} for the calling user id.
|
||||
*/
|
||||
String getCurrentTransport();
|
||||
|
||||
@@ -293,16 +383,35 @@ interface IBackupManager {
|
||||
* Returns the {@link ComponentName} of the host service of the selected transport or {@code
|
||||
* null} if no transport selected or if the transport selected is not registered. Callers must
|
||||
* hold the android.permission.BACKUP permission to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the currently selected transport should be identified.
|
||||
*/
|
||||
ComponentName getCurrentTransportComponent();
|
||||
ComponentName getCurrentTransportComponentForUser(int userId);
|
||||
|
||||
/**
|
||||
* Request a list of all available backup transports' names. Callers must
|
||||
* hold the android.permission.BACKUP permission to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which all available backup transports' names should be listed.
|
||||
*/
|
||||
String[] listAllTransportsForUser(int userId);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.listAllTransportsForUser} for the calling user id.
|
||||
*/
|
||||
String[] listAllTransports();
|
||||
|
||||
ComponentName[] listAllTransportComponents();
|
||||
/**
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which all available backup transports should be listed.
|
||||
*/
|
||||
ComponentName[] listAllTransportComponentsForUser(int userId);
|
||||
|
||||
/**
|
||||
* Retrieve the list of whitelisted transport components. Callers do </i>not</i> need
|
||||
@@ -315,13 +424,22 @@ interface IBackupManager {
|
||||
/**
|
||||
* Specify the current backup transport. Callers must hold the
|
||||
* android.permission.BACKUP permission to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the transport should be selected.
|
||||
* @param transport The name of the transport to select. This should be one
|
||||
* of {@link BackupManager.TRANSPORT_GOOGLE} or {@link BackupManager.TRANSPORT_ADB}.
|
||||
* @return The name of the previously selected transport. If the given transport
|
||||
* name is not one of the currently available transports, no change is made to
|
||||
* the current transport setting and the method returns null.
|
||||
*/
|
||||
String selectBackupTransportForUser(int userId, String transport);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.selectBackupTransportForUser} for the calling user
|
||||
* id.
|
||||
*/
|
||||
String selectBackupTransport(String transport);
|
||||
|
||||
/**
|
||||
@@ -330,43 +448,85 @@ interface IBackupManager {
|
||||
* which is in a separate process.
|
||||
*
|
||||
* <p>Callers must hold the android.permission.BACKUP permission to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the transport should be selected.
|
||||
* @param transport ComponentName of the service hosting the transport. This is different from
|
||||
* the transport's name that is returned by {@link BackupTransport#name()}.
|
||||
* @param listener A listener object to get a callback on the transport being selected.
|
||||
*/
|
||||
void selectBackupTransportAsync(in ComponentName transport, ISelectBackupTransportCallback listener);
|
||||
void selectBackupTransportAsyncForUser(int userId, in ComponentName transport,
|
||||
ISelectBackupTransportCallback listener);
|
||||
|
||||
/**
|
||||
* Get the configuration Intent, if any, from the given transport. Callers must
|
||||
* hold the android.permission.BACKUP permission in order to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the configuration Intent should be reported.
|
||||
* @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 getConfigurationIntentForUser(int userId, String transport);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.getConfigurationIntentForUser} for the calling user
|
||||
* id.
|
||||
*/
|
||||
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.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the transport destination string should be reported.
|
||||
* @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 getDestinationStringForUser(int userId, String transport);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.getDestinationStringForUser} for the calling user
|
||||
* id.
|
||||
*/
|
||||
String getDestinationString(String transport);
|
||||
|
||||
/**
|
||||
* Get the manage-data UI intent, if any, from the given transport. Callers must
|
||||
* hold the android.permission.BACKUP permission in order to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the manage-data UI intent should be reported.
|
||||
*/
|
||||
Intent getDataManagementIntentForUser(int userId, String transport);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.getDataManagementIntentForUser} for the calling user
|
||||
* id.
|
||||
*/
|
||||
Intent getDataManagementIntent(String transport);
|
||||
|
||||
/**
|
||||
* Get the manage-data menu label, if any, from the given transport. Callers must
|
||||
* hold the android.permission.BACKUP permission in order to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the manage-data menu label should be reported.
|
||||
*/
|
||||
String getDataManagementLabelForUser(int userId, String transport);
|
||||
|
||||
/**
|
||||
* {@link android.app.backup.IBackupManager.getDataManagementLabelForUser} for the calling user
|
||||
* id.
|
||||
*/
|
||||
String getDataManagementLabel(String transport);
|
||||
|
||||
@@ -381,7 +541,10 @@ interface IBackupManager {
|
||||
* package. In that case, the restore session returned is suitable for supporting
|
||||
* the BackupManager.requestRestore() functionality via RestoreSession.restorePackage()
|
||||
* without requiring the app to hold any special permission.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which a restore session should be begun.
|
||||
* @param packageName The name of the single package for which a restore will
|
||||
* be requested. May be null, in which case all packages in the restore
|
||||
* set can be restored.
|
||||
@@ -389,7 +552,7 @@ interface IBackupManager {
|
||||
* May be null, in which case the current active transport is used.
|
||||
* @return An interface to the restore session, or null on error.
|
||||
*/
|
||||
IRestoreSession beginRestoreSession(String packageName, String transportID);
|
||||
IRestoreSession beginRestoreSessionForUser(int userId, String packageName, String transportID);
|
||||
|
||||
/**
|
||||
* Notify the backup manager that a BackupAgent has completed the operation
|
||||
@@ -427,13 +590,16 @@ interface IBackupManager {
|
||||
* restored from if we were to install it right now.
|
||||
*
|
||||
* <p>Callers must hold the android.permission.BACKUP permission to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which this operation should be performed.
|
||||
* @param packageName The name of the package whose most-suitable dataset we
|
||||
* wish to look up
|
||||
* @return The dataset token from which a restore should be attempted, or zero if
|
||||
* no suitable data is available.
|
||||
*/
|
||||
long getAvailableRestoreToken(String packageName);
|
||||
long getAvailableRestoreTokenForUser(int userId, String packageName);
|
||||
|
||||
/**
|
||||
* Ask the framework whether this app is eligible for backup.
|
||||
@@ -442,21 +608,27 @@ interface IBackupManager {
|
||||
* {@link #filterAppsEligibleForBackup(String[])} to save resources.
|
||||
*
|
||||
* <p>Callers must hold the android.permission.BACKUP permission to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which this operation should be performed.
|
||||
* @param packageName The name of the package.
|
||||
* @return Whether this app is eligible for backup.
|
||||
*/
|
||||
boolean isAppEligibleForBackup(String packageName);
|
||||
boolean isAppEligibleForBackupForUser(int userId, String packageName);
|
||||
|
||||
/**
|
||||
* Filter the packages that are eligible for backup and return the result.
|
||||
*
|
||||
* <p>Callers must hold the android.permission.BACKUP permission to use this method.
|
||||
* If {@code userId} is different from the calling user id, then the caller must hold the
|
||||
* android.permission.INTERACT_ACROSS_USERS_FULL permission.
|
||||
*
|
||||
* @param userId User id for which the filter should be performed.
|
||||
* @param packages The list of packages to filter.
|
||||
* @return The packages eligible for backup.
|
||||
*/
|
||||
String[] filterAppsEligibleForBackup(in String[] packages);
|
||||
String[] filterAppsEligibleForBackupForUser(int userId, in String[] packages);
|
||||
|
||||
/**
|
||||
* Request an immediate backup, providing an observer to which results of the backup operation
|
||||
|
||||
@@ -284,7 +284,7 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dataChanged(String packageName) throws RemoteException {
|
||||
public void dataChangedForUser(int userId, String packageName) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
if (svc != null) {
|
||||
svc.dataChanged(packageName);
|
||||
@@ -292,8 +292,13 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeTransports(String[] transportNames, IBackupObserver observer)
|
||||
throws RemoteException {
|
||||
public void dataChanged(String packageName) throws RemoteException {
|
||||
dataChangedForUser(binderGetCallingUserId(), packageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeTransportsForUser(
|
||||
int userId, String[] transportNames, IBackupObserver observer) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
if (svc != null) {
|
||||
svc.initializeTransports(transportNames, observer);
|
||||
@@ -301,7 +306,7 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBackupData(String transportName, String packageName)
|
||||
public void clearBackupDataForUser(int userId, String transportName, String packageName)
|
||||
throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
if (svc != null) {
|
||||
@@ -310,7 +315,14 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void agentConnected(String packageName, IBinder agent) throws RemoteException {
|
||||
public void clearBackupData(String transportName, String packageName)
|
||||
throws RemoteException {
|
||||
clearBackupDataForUser(binderGetCallingUserId(), transportName, packageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void agentConnectedForUser(int userId, String packageName, IBinder agent)
|
||||
throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
if (svc != null) {
|
||||
svc.agentConnected(packageName, agent);
|
||||
@@ -318,7 +330,12 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void agentDisconnected(String packageName) throws RemoteException {
|
||||
public void agentConnected(String packageName, IBinder agent) throws RemoteException {
|
||||
agentConnectedForUser(binderGetCallingUserId(), packageName, agent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void agentDisconnectedForUser(int userId, String packageName) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
if (svc != null) {
|
||||
svc.agentDisconnected(packageName);
|
||||
@@ -326,13 +343,24 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreAtInstall(String packageName, int token) throws RemoteException {
|
||||
public void agentDisconnected(String packageName) throws RemoteException {
|
||||
agentDisconnectedForUser(binderGetCallingUserId(), packageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreAtInstallForUser(int userId, String packageName, int token)
|
||||
throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
if (svc != null) {
|
||||
svc.restoreAtInstall(packageName, token);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreAtInstall(String packageName, int token) throws RemoteException {
|
||||
restoreAtInstallForUser(binderGetCallingUserId(), packageName, token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackupEnabledForUser(@UserIdInt int userId, boolean isEnabled)
|
||||
throws RemoteException {
|
||||
@@ -348,13 +376,18 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoRestore(boolean doAutoRestore) throws RemoteException {
|
||||
public void setAutoRestoreForUser(int userId, boolean doAutoRestore) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
if (svc != null) {
|
||||
svc.setAutoRestore(doAutoRestore);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoRestore(boolean doAutoRestore) throws RemoteException {
|
||||
setAutoRestoreForUser(binderGetCallingUserId(), doAutoRestore);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackupProvisioned(boolean isProvisioned) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
@@ -411,7 +444,8 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fullTransportBackup(String[] packageNames) throws RemoteException {
|
||||
public void fullTransportBackupForUser(int userId, String[] packageNames)
|
||||
throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
if (svc != null) {
|
||||
svc.fullTransportBackup(packageNames);
|
||||
@@ -427,9 +461,14 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acknowledgeFullBackupOrRestore(int token, boolean allow, String curPassword,
|
||||
String encryptionPassword, IFullBackupRestoreObserver observer)
|
||||
throws RemoteException {
|
||||
public void acknowledgeFullBackupOrRestoreForUser(
|
||||
int userId,
|
||||
int token,
|
||||
boolean allow,
|
||||
String curPassword,
|
||||
String encryptionPassword,
|
||||
IFullBackupRestoreObserver observer)
|
||||
throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
if (svc != null) {
|
||||
svc.acknowledgeAdbBackupOrRestore(token, allow,
|
||||
@@ -438,30 +477,50 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentTransport() throws RemoteException {
|
||||
public void acknowledgeFullBackupOrRestore(int token, boolean allow, String curPassword,
|
||||
String encryptionPassword, IFullBackupRestoreObserver observer)
|
||||
throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
acknowledgeFullBackupOrRestoreForUser(
|
||||
binderGetCallingUserId(), token, allow, curPassword, encryptionPassword, observer);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCurrentTransportForUser(int userId) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.getCurrentTransport() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentTransport() throws RemoteException {
|
||||
return getCurrentTransportForUser(binderGetCallingUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link ComponentName} of the host service of the selected transport or
|
||||
* {@code null} if no transport selected or if the transport selected is not registered.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public ComponentName getCurrentTransportComponent() {
|
||||
public ComponentName getCurrentTransportComponentForUser(int userId) {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.getCurrentTransportComponent() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] listAllTransports() throws RemoteException {
|
||||
public String[] listAllTransportsForUser(int userId) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.listAllTransports() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentName[] listAllTransportComponents() throws RemoteException {
|
||||
public String[] listAllTransports() throws RemoteException {
|
||||
return listAllTransportsForUser(binderGetCallingUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentName[] listAllTransportComponentsForUser(int userId) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.listAllTransportComponents() : null;
|
||||
}
|
||||
@@ -473,7 +532,8 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTransportAttributes(
|
||||
public void updateTransportAttributesForUser(
|
||||
int userId,
|
||||
ComponentName transportComponent,
|
||||
String name,
|
||||
@Nullable Intent configurationIntent,
|
||||
@@ -493,13 +553,19 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String selectBackupTransport(String transport) throws RemoteException {
|
||||
public String selectBackupTransportForUser(int userId, String transport)
|
||||
throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.selectBackupTransport(transport) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectBackupTransportAsync(ComponentName transport,
|
||||
public String selectBackupTransport(String transport) throws RemoteException {
|
||||
return selectBackupTransportForUser(binderGetCallingUserId(), transport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectBackupTransportAsyncForUser(int userId, ComponentName transport,
|
||||
ISelectBackupTransportCallback listener) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
if (svc != null) {
|
||||
@@ -516,32 +582,58 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getConfigurationIntent(String transport) throws RemoteException {
|
||||
public Intent getConfigurationIntentForUser(int userId, String transport)
|
||||
throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.getConfigurationIntent(transport) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDestinationString(String transport) throws RemoteException {
|
||||
public Intent getConfigurationIntent(String transport)
|
||||
throws RemoteException {
|
||||
return getConfigurationIntentForUser(binderGetCallingUserId(), transport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDestinationStringForUser(int userId, String transport) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.getDestinationString(transport) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getDataManagementIntent(String transport) throws RemoteException {
|
||||
public String getDestinationString(String transport) throws RemoteException {
|
||||
return getDestinationStringForUser(binderGetCallingUserId(), transport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getDataManagementIntentForUser(int userId, String transport)
|
||||
throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.getDataManagementIntent(transport) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataManagementLabel(String transport) throws RemoteException {
|
||||
public Intent getDataManagementIntent(String transport)
|
||||
throws RemoteException {
|
||||
return getDataManagementIntentForUser(binderGetCallingUserId(), transport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataManagementLabelForUser(int userId, String transport)
|
||||
throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.getDataManagementLabel(transport) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRestoreSession beginRestoreSession(String packageName, String transportID)
|
||||
public String getDataManagementLabel(String transport)
|
||||
throws RemoteException {
|
||||
return getDataManagementLabelForUser(binderGetCallingUserId(), transport);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRestoreSession beginRestoreSessionForUser(
|
||||
int userId, String packageName, String transportID) throws RemoteException {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.beginRestoreSession(packageName, transportID) : null;
|
||||
}
|
||||
@@ -555,19 +647,19 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAvailableRestoreToken(String packageName) {
|
||||
public long getAvailableRestoreTokenForUser(int userId, String packageName) {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.getAvailableRestoreToken(packageName) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAppEligibleForBackup(String packageName) {
|
||||
public boolean isAppEligibleForBackupForUser(int userId, String packageName) {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.isAppEligibleForBackup(packageName) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] filterAppsEligibleForBackup(String[] packages) {
|
||||
public String[] filterAppsEligibleForBackupForUser(int userId, String[] packages) {
|
||||
BackupManagerService svc = mService;
|
||||
return (svc != null) ? svc.filterAppsEligibleForBackup(packages) : null;
|
||||
}
|
||||
|
||||
@@ -301,6 +301,15 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dataChangedForUser_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
mTrampoline.dataChangedForUser(mUserId, PACKAGE_NAME);
|
||||
|
||||
verify(mBackupManagerServiceMock).dataChanged(PACKAGE_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dataChanged_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
@@ -314,6 +323,15 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearBackupDataForUser_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
mTrampoline.clearBackupDataForUser(mUserId, TRANSPORT_NAME, PACKAGE_NAME);
|
||||
|
||||
verify(mBackupManagerServiceMock).clearBackupData(TRANSPORT_NAME, PACKAGE_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearBackupData_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
@@ -327,6 +345,15 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void agentConnectedForUser_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
mTrampoline.agentConnectedForUser(mUserId, PACKAGE_NAME, mAgentMock);
|
||||
|
||||
verify(mBackupManagerServiceMock).agentConnected(PACKAGE_NAME, mAgentMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void agentConnected_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
@@ -340,6 +367,15 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void agentDisconnectedForUser_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
mTrampoline.agentDisconnectedForUser(mUserId, PACKAGE_NAME);
|
||||
|
||||
verify(mBackupManagerServiceMock).agentDisconnected(PACKAGE_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void agentDisconnected_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
@@ -353,6 +389,15 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restoreAtInstallForUser_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
mTrampoline.restoreAtInstallForUser(mUserId, PACKAGE_NAME, 123);
|
||||
|
||||
verify(mBackupManagerServiceMock).restoreAtInstall(PACKAGE_NAME, 123);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restoreAtInstall_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
@@ -391,6 +436,15 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setAutoRestoreForUser_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
mTrampoline.setAutoRestoreForUser(mUserId, true);
|
||||
|
||||
verify(mBackupManagerServiceMock).setAutoRestore(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setAutoRestore_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
@@ -507,14 +561,14 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void fullTransportBackup_calledBeforeInitialize_ignored() throws RemoteException {
|
||||
mTrampoline.fullTransportBackup(PACKAGE_NAMES);
|
||||
mTrampoline.fullTransportBackupForUser(mUserId, PACKAGE_NAMES);
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fullTransportBackup_forwarded() throws RemoteException {
|
||||
public void fullTransportBackupForUser_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.fullTransportBackup(PACKAGE_NAMES);
|
||||
mTrampoline.fullTransportBackupForUser(mUserId, PACKAGE_NAMES);
|
||||
verify(mBackupManagerServiceMock).fullTransportBackup(PACKAGE_NAMES);
|
||||
}
|
||||
|
||||
@@ -539,6 +593,22 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acknowledgeFullBackupOrRestoreForUser_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
mTrampoline.acknowledgeFullBackupOrRestoreForUser(
|
||||
mUserId,
|
||||
123,
|
||||
true,
|
||||
CURRENT_PASSWORD,
|
||||
ENCRYPTION_PASSWORD,
|
||||
mFullBackupRestoreObserverMock);
|
||||
|
||||
verify(mBackupManagerServiceMock).acknowledgeAdbBackupOrRestore(123, true, CURRENT_PASSWORD,
|
||||
ENCRYPTION_PASSWORD, mFullBackupRestoreObserverMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acknowledgeFullBackupOrRestore_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
@@ -554,6 +624,16 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCurrentTransportForUser_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getCurrentTransport()).thenReturn(TRANSPORT_NAME);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
assertEquals(TRANSPORT_NAME, mTrampoline.getCurrentTransportForUser(mUserId));
|
||||
|
||||
verify(mBackupManagerServiceMock).getCurrentTransport();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCurrentTransport_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getCurrentTransport()).thenReturn(TRANSPORT_NAME);
|
||||
@@ -570,6 +650,16 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listAllTransportsForUser_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.listAllTransports()).thenReturn(TRANSPORTS);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
assertEquals(TRANSPORTS, mTrampoline.listAllTransportsForUser(mUserId));
|
||||
verify(mBackupManagerServiceMock).listAllTransports();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void listAllTransports_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.listAllTransports()).thenReturn(TRANSPORTS);
|
||||
@@ -580,18 +670,19 @@ public class TrampolineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listAllTransportComponents_calledBeforeInitialize_ignored() throws RemoteException {
|
||||
assertNull(mTrampoline.listAllTransportComponents());
|
||||
public void listAllTransportComponentsForUser_calledBeforeInitialize_ignored()
|
||||
throws RemoteException {
|
||||
assertNull(mTrampoline.listAllTransportComponentsForUser(mUserId));
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listAllTransportComponents_forwarded() throws RemoteException {
|
||||
public void listAllTransportComponentsForUser_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.listAllTransportComponents()).thenReturn(
|
||||
TRANSPORT_COMPONENTS);
|
||||
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertEquals(TRANSPORT_COMPONENTS, mTrampoline.listAllTransportComponents());
|
||||
|
||||
assertEquals(TRANSPORT_COMPONENTS, mTrampoline.listAllTransportComponentsForUser(mUserId));
|
||||
verify(mBackupManagerServiceMock).listAllTransportComponents();
|
||||
}
|
||||
|
||||
@@ -611,19 +702,34 @@ public class TrampolineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void describeTransport_calledBeforeInitialize_ignored() throws RemoteException {
|
||||
mTrampoline.updateTransportAttributes(TRANSPORT_COMPONENT_NAME, TRANSPORT_NAME, null,
|
||||
"Transport Destination", null, "Data Management");
|
||||
public void updateTransportAttributesForUser_calledBeforeInitialize_ignored()
|
||||
throws RemoteException {
|
||||
mTrampoline.updateTransportAttributesForUser(
|
||||
mUserId,
|
||||
TRANSPORT_COMPONENT_NAME,
|
||||
TRANSPORT_NAME,
|
||||
null,
|
||||
"Transport Destination",
|
||||
null,
|
||||
"Data Management");
|
||||
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void describeTransport_forwarded() throws RemoteException {
|
||||
public void updateTransportAttributesForUser_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getTransportWhitelist()).thenReturn(TRANSPORTS);
|
||||
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.updateTransportAttributes(TRANSPORT_COMPONENT_NAME, TRANSPORT_NAME, null,
|
||||
"Transport Destination", null, "Data Management");
|
||||
|
||||
mTrampoline.updateTransportAttributesForUser(
|
||||
mUserId,
|
||||
TRANSPORT_COMPONENT_NAME,
|
||||
TRANSPORT_NAME,
|
||||
null,
|
||||
"Transport Destination",
|
||||
null,
|
||||
"Data Management");
|
||||
|
||||
verify(mBackupManagerServiceMock).updateTransportAttributes(TRANSPORT_COMPONENT_NAME,
|
||||
TRANSPORT_NAME, null, "Transport Destination", null, "Data Management");
|
||||
}
|
||||
@@ -634,6 +740,15 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void selectBackupTransportForUser_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
mTrampoline.selectBackupTransportForUser(mUserId, TRANSPORT_NAME);
|
||||
|
||||
verify(mBackupManagerServiceMock).selectBackupTransport(TRANSPORT_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void selectBackupTransport_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
@@ -642,9 +757,12 @@ public class TrampolineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void selectBackupTransportAsync_calledBeforeInitialize_ignored() throws Exception {
|
||||
public void selectBackupTransportAsyncForUser_calledBeforeInitialize_ignored()
|
||||
throws Exception {
|
||||
LinkedBlockingQueue<Integer> q = new LinkedBlockingQueue();
|
||||
mTrampoline.selectBackupTransportAsync(
|
||||
|
||||
mTrampoline.selectBackupTransportAsyncForUser(
|
||||
mUserId,
|
||||
TRANSPORT_COMPONENT_NAME,
|
||||
new ISelectBackupTransportCallback() {
|
||||
@Override
|
||||
@@ -662,6 +780,7 @@ public class TrampolineTest {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
Integer errorCode = q.poll(5, TimeUnit.SECONDS);
|
||||
assertNotNull(errorCode);
|
||||
@@ -669,17 +788,19 @@ public class TrampolineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void selectBackupTransportAsync_calledBeforeInitialize_ignored_nullListener()
|
||||
public void selectBackupTransportAsyncForUser_calledBeforeInitialize_ignored_nullListener()
|
||||
throws Exception {
|
||||
mTrampoline.selectBackupTransportAsync(TRANSPORT_COMPONENT_NAME, null);
|
||||
mTrampoline.selectBackupTransportAsyncForUser(mUserId, TRANSPORT_COMPONENT_NAME, null);
|
||||
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
// No crash.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void selectBackupTransportAsync_calledBeforeInitialize_ignored_listenerThrowException()
|
||||
public void selectBackupTransportAsyncForUser_calledBeforeInitialize_ignored_listenerThrows()
|
||||
throws Exception {
|
||||
mTrampoline.selectBackupTransportAsync(
|
||||
mTrampoline.selectBackupTransportAsyncForUser(
|
||||
mUserId,
|
||||
TRANSPORT_COMPONENT_NAME,
|
||||
new ISelectBackupTransportCallback() {
|
||||
@Override
|
||||
@@ -697,14 +818,17 @@ public class TrampolineTest {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
// No crash.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void selectBackupTransportAsync_forwarded() throws RemoteException {
|
||||
public void selectBackupTransportAsyncForUser_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.selectBackupTransportAsync(TRANSPORT_COMPONENT_NAME, null);
|
||||
|
||||
mTrampoline.selectBackupTransportAsyncForUser(mUserId, TRANSPORT_COMPONENT_NAME, null);
|
||||
|
||||
verify(mBackupManagerServiceMock).selectBackupTransportAsync(TRANSPORT_COMPONENT_NAME,
|
||||
null);
|
||||
}
|
||||
@@ -715,6 +839,19 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfigurationIntentForUser_forwarded() throws RemoteException {
|
||||
Intent configurationIntentStub = new Intent();
|
||||
when(mBackupManagerServiceMock.getConfigurationIntent(TRANSPORT_NAME)).thenReturn(
|
||||
configurationIntentStub);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
assertEquals(
|
||||
configurationIntentStub,
|
||||
mTrampoline.getConfigurationIntentForUser(mUserId, TRANSPORT_NAME));
|
||||
verify(mBackupManagerServiceMock).getConfigurationIntent(TRANSPORT_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConfigurationIntent_forwarded() throws RemoteException {
|
||||
Intent configurationIntentStub = new Intent();
|
||||
@@ -732,6 +869,18 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDestinationStringForUser_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getDestinationString(TRANSPORT_NAME)).thenReturn(
|
||||
DESTINATION_STRING);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
assertEquals(
|
||||
DESTINATION_STRING,
|
||||
mTrampoline.getDestinationStringForUser(mUserId, TRANSPORT_NAME));
|
||||
verify(mBackupManagerServiceMock).getDestinationString(TRANSPORT_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDestinationString_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getDestinationString(TRANSPORT_NAME)).thenReturn(
|
||||
@@ -748,6 +897,19 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDataManagementIntentForUser_forwarded() throws RemoteException {
|
||||
Intent dataManagementIntent = new Intent();
|
||||
when(mBackupManagerServiceMock.getDataManagementIntent(TRANSPORT_NAME)).thenReturn(
|
||||
dataManagementIntent);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
assertEquals(
|
||||
dataManagementIntent,
|
||||
mTrampoline.getDataManagementIntentForUser(mUserId, TRANSPORT_NAME));
|
||||
verify(mBackupManagerServiceMock).getDataManagementIntent(TRANSPORT_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDataManagementIntent_forwarded() throws RemoteException {
|
||||
Intent dataManagementIntent = new Intent();
|
||||
@@ -765,6 +927,18 @@ public class TrampolineTest {
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDataManagementLabelForUser_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getDataManagementLabel(TRANSPORT_NAME)).thenReturn(
|
||||
DATA_MANAGEMENT_LABEL);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
assertEquals(
|
||||
DATA_MANAGEMENT_LABEL,
|
||||
mTrampoline.getDataManagementLabelForUser(mUserId, TRANSPORT_NAME));
|
||||
verify(mBackupManagerServiceMock).getDataManagementLabel(TRANSPORT_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDataManagementLabel_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getDataManagementLabel(TRANSPORT_NAME)).thenReturn(
|
||||
@@ -777,14 +951,16 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void beginRestoreSession_calledBeforeInitialize_ignored() throws RemoteException {
|
||||
mTrampoline.beginRestoreSession(PACKAGE_NAME, TRANSPORT_NAME);
|
||||
mTrampoline.beginRestoreSessionForUser(mUserId, PACKAGE_NAME, TRANSPORT_NAME);
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beginRestoreSession_forwarded() throws RemoteException {
|
||||
public void beginRestoreSessionForUser_forwarded() throws RemoteException {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.beginRestoreSession(PACKAGE_NAME, TRANSPORT_NAME);
|
||||
|
||||
mTrampoline.beginRestoreSessionForUser(mUserId, PACKAGE_NAME, TRANSPORT_NAME);
|
||||
|
||||
verify(mBackupManagerServiceMock).beginRestoreSession(PACKAGE_NAME, TRANSPORT_NAME);
|
||||
}
|
||||
|
||||
@@ -802,32 +978,34 @@ public class TrampolineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailableRestoreToken_calledBeforeInitialize_ignored() throws RemoteException {
|
||||
assertEquals(0, mTrampoline.getAvailableRestoreToken(PACKAGE_NAME));
|
||||
public void getAvailableRestoreTokenForUser_calledBeforeInitialize_ignored()
|
||||
throws RemoteException {
|
||||
assertEquals(0, mTrampoline.getAvailableRestoreTokenForUser(mUserId, PACKAGE_NAME));
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailableRestoreToken_forwarded() throws RemoteException {
|
||||
public void getAvailableRestoreTokenForUser_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getAvailableRestoreToken(PACKAGE_NAME)).thenReturn(123L);
|
||||
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertEquals(123, mTrampoline.getAvailableRestoreToken(PACKAGE_NAME));
|
||||
|
||||
assertEquals(123, mTrampoline.getAvailableRestoreTokenForUser(mUserId, PACKAGE_NAME));
|
||||
verify(mBackupManagerServiceMock).getAvailableRestoreToken(PACKAGE_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAppEligibleForBackup_calledBeforeInitialize_ignored() throws RemoteException {
|
||||
assertFalse(mTrampoline.isAppEligibleForBackup(PACKAGE_NAME));
|
||||
public void isAppEligibleForBackupForUser_calledBeforeInitialize_ignored()
|
||||
throws RemoteException {
|
||||
assertFalse(mTrampoline.isAppEligibleForBackupForUser(mUserId, PACKAGE_NAME));
|
||||
verifyNoMoreInteractions(mBackupManagerServiceMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAppEligibleForBackup_forwarded() throws RemoteException {
|
||||
public void isAppEligibleForBackupForUser_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.isAppEligibleForBackup(PACKAGE_NAME)).thenReturn(true);
|
||||
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertTrue(mTrampoline.isAppEligibleForBackup(PACKAGE_NAME));
|
||||
|
||||
assertTrue(mTrampoline.isAppEligibleForBackupForUser(mUserId, PACKAGE_NAME));
|
||||
verify(mBackupManagerServiceMock).isAppEligibleForBackup(PACKAGE_NAME);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user