summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/backup/java/com/android/server/backup/BackupManagerService.java168
-rw-r--r--services/backup/java/com/android/server/backup/Trampoline.java56
-rw-r--r--services/backup/java/com/android/server/backup/UserBackupManagerService.java22
-rw-r--r--services/robotests/backup/src/com/android/server/backup/BackupManagerServiceTest.java366
-rw-r--r--services/tests/servicestests/src/com/android/server/backup/TrampolineTest.java179
5 files changed, 439 insertions, 352 deletions
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java
index fd2043769dd1..a9f4e46395f3 100644
--- a/services/backup/java/com/android/server/backup/BackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/BackupManagerService.java
@@ -117,7 +117,7 @@ public class BackupManagerService {
* @param userId User id on which the backup operation is being requested.
* @param message A message to include in the exception if it is thrown.
*/
- private void enforceCallingPermissionOnUserId(int userId, String message) {
+ private void enforceCallingPermissionOnUserId(@UserIdInt int userId, String message) {
if (Binder.getCallingUserHandle().getIdentifier() != userId) {
mContext.enforceCallingOrSelfPermission(
Manifest.permission.INTERACT_ACROSS_USERS_FULL, message);
@@ -170,9 +170,14 @@ public class BackupManagerService {
* @param userId The id of the user to retrieve its instance of {@link
* UserBackupManagerService}.
* @param caller A {@link String} identifying the caller for logging purposes.
+ * @throws SecurityException if {@code userId} is different from the calling user id and the
+ * caller does NOT have the android.permission.INTERACT_ACROSS_USERS_FULL permission.
*/
@Nullable
- private UserBackupManagerService getServiceForUser(@UserIdInt int userId, String caller) {
+ @VisibleForTesting
+ UserBackupManagerService getServiceForUserIfCallerHasPermission(
+ @UserIdInt int userId, String caller) {
+ enforceCallingPermissionOnUserId(userId, caller);
UserBackupManagerService userBackupManagerService = mServiceUsers.get(userId);
if (userBackupManagerService == null) {
Slog.w(TAG, "Called " + caller + " for unknown user: " + userId);
@@ -196,9 +201,9 @@ public class BackupManagerService {
* backup for their app {@code packageName}. Only used for apps participating in key-value
* backup.
*/
- public void dataChanged(String packageName) {
+ public void dataChanged(@UserIdInt int userId, String packageName) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "dataChanged()");
+ getServiceForUserIfCallerHasPermission(userId, "dataChanged()");
if (userBackupManagerService != null) {
userBackupManagerService.dataChanged(packageName);
@@ -209,9 +214,9 @@ public class BackupManagerService {
* Callback: a requested backup agent has been instantiated. This should only be called from the
* {@link ActivityManager}.
*/
- public void agentConnected(String packageName, IBinder agentBinder) {
+ public void agentConnected(@UserIdInt int userId, String packageName, IBinder agentBinder) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "agentConnected()");
+ getServiceForUserIfCallerHasPermission(userId, "agentConnected()");
if (userBackupManagerService != null) {
userBackupManagerService.agentConnected(packageName, agentBinder);
@@ -222,9 +227,9 @@ public class BackupManagerService {
* Callback: a backup agent has failed to come up, or has unexpectedly quit. This should only be
* called from the {@link ActivityManager}.
*/
- public void agentDisconnected(String packageName) {
+ public void agentDisconnected(@UserIdInt int userId, String packageName) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "agentDisconnected()");
+ getServiceForUserIfCallerHasPermission(userId, "agentDisconnected()");
if (userBackupManagerService != null) {
userBackupManagerService.agentDisconnected(packageName);
@@ -235,9 +240,9 @@ public class BackupManagerService {
* Used by a currently-active backup agent to notify the service that it has completed its given
* outstanding asynchronous backup/restore operation.
*/
- public void opComplete(int token, long result) {
+ public void opComplete(@UserIdInt int userId, int token, long result) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "opComplete()");
+ getServiceForUserIfCallerHasPermission(userId, "opComplete()");
if (userBackupManagerService != null) {
userBackupManagerService.opComplete(token, result);
@@ -249,9 +254,10 @@ public class BackupManagerService {
// ---------------------------------------------
/** Run an initialize operation for the given transports {@code transportNames}. */
- public void initializeTransports(String[] transportNames, IBackupObserver observer) {
+ public void initializeTransports(
+ @UserIdInt int userId, String[] transportNames, IBackupObserver observer) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "initializeTransports()");
+ getServiceForUserIfCallerHasPermission(userId, "initializeTransports()");
if (userBackupManagerService != null) {
userBackupManagerService.initializeTransports(transportNames, observer);
@@ -262,9 +268,9 @@ public class BackupManagerService {
* Clear the given package {@code packageName}'s backup data from the transport {@code
* transportName}.
*/
- public void clearBackupData(String transportName, String packageName) {
+ public void clearBackupData(@UserIdInt int userId, String transportName, String packageName) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "clearBackupData()");
+ getServiceForUserIfCallerHasPermission(userId, "clearBackupData()");
if (userBackupManagerService != null) {
userBackupManagerService.clearBackupData(transportName, packageName);
@@ -273,9 +279,9 @@ public class BackupManagerService {
/** Return the name of the currently active transport. */
@Nullable
- public String getCurrentTransport() {
+ public String getCurrentTransport(@UserIdInt int userId) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "getCurrentTransport()");
+ getServiceForUserIfCallerHasPermission(userId, "getCurrentTransport()");
return userBackupManagerService == null
? null
@@ -287,9 +293,9 @@ public class BackupManagerService {
* null} if no transport selected or if the transport selected is not registered.
*/
@Nullable
- public ComponentName getCurrentTransportComponent() {
+ public ComponentName getCurrentTransportComponent(@UserIdInt int userId) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "getCurrentTransportComponent()");
+ getServiceForUserIfCallerHasPermission(userId, "getCurrentTransportComponent()");
return userBackupManagerService == null
? null
@@ -298,9 +304,9 @@ public class BackupManagerService {
/** Report all known, available backup transports by name. */
@Nullable
- public String[] listAllTransports() {
+ public String[] listAllTransports(@UserIdInt int userId) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "listAllTransports()");
+ getServiceForUserIfCallerHasPermission(userId, "listAllTransports()");
return userBackupManagerService == null
? null
@@ -309,9 +315,9 @@ public class BackupManagerService {
/** Report all known, available backup transports by {@link ComponentName}. */
@Nullable
- public ComponentName[] listAllTransportComponents() {
+ public ComponentName[] listAllTransportComponents(@UserIdInt int userId) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "listAllTransportComponents()");
+ getServiceForUserIfCallerHasPermission(userId, "listAllTransportComponents()");
return userBackupManagerService == null
? null
@@ -321,12 +327,14 @@ public class BackupManagerService {
/** Report all system whitelisted transports. */
@Nullable
public String[] getTransportWhitelist() {
- UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "getTransportWhitelist()");
-
- return userBackupManagerService == null
- ? null
- : userBackupManagerService.getTransportWhitelist();
+ // No permission check, intentionally.
+ String[] whitelistedTransports = new String[mTransportWhitelist.size()];
+ int i = 0;
+ for (ComponentName component : mTransportWhitelist) {
+ whitelistedTransports[i] = component.flattenToShortString();
+ i++;
+ }
+ return whitelistedTransports;
}
/**
@@ -353,6 +361,7 @@ public class BackupManagerService {
* {@code transportComponent} or if the caller does NOT have BACKUP permission.
*/
public void updateTransportAttributes(
+ @UserIdInt int userId,
ComponentName transportComponent,
String name,
@Nullable Intent configurationIntent,
@@ -360,7 +369,7 @@ public class BackupManagerService {
@Nullable Intent dataManagementIntent,
String dataManagementLabel) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "updateTransportAttributes()");
+ getServiceForUserIfCallerHasPermission(userId, "updateTransportAttributes()");
if (userBackupManagerService != null) {
userBackupManagerService.updateTransportAttributes(
@@ -381,9 +390,9 @@ public class BackupManagerService {
*/
@Deprecated
@Nullable
- public String selectBackupTransport(String transportName) {
+ public String selectBackupTransport(@UserIdInt int userId, String transportName) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "selectBackupTransport()");
+ getServiceForUserIfCallerHasPermission(userId, "selectBackupTransport()");
return userBackupManagerService == null
? null
@@ -395,9 +404,11 @@ public class BackupManagerService {
* with the result upon completion.
*/
public void selectBackupTransportAsync(
- ComponentName transportComponent, ISelectBackupTransportCallback listener) {
+ @UserIdInt int userId,
+ ComponentName transportComponent,
+ ISelectBackupTransportCallback listener) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "selectBackupTransportAsync()");
+ getServiceForUserIfCallerHasPermission(userId, "selectBackupTransportAsync()");
if (userBackupManagerService != null) {
userBackupManagerService.selectBackupTransportAsync(transportComponent, listener);
@@ -410,9 +421,9 @@ public class BackupManagerService {
* returns {@code null}.
*/
@Nullable
- public Intent getConfigurationIntent(String transportName) {
+ public Intent getConfigurationIntent(@UserIdInt int userId, String transportName) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "getConfigurationIntent()");
+ getServiceForUserIfCallerHasPermission(userId, "getConfigurationIntent()");
return userBackupManagerService == null
? null
@@ -429,9 +440,9 @@ public class BackupManagerService {
* @return The current destination string or null if the transport is not registered.
*/
@Nullable
- public String getDestinationString(String transportName) {
+ public String getDestinationString(@UserIdInt int userId, String transportName) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "getDestinationString()");
+ getServiceForUserIfCallerHasPermission(userId, "getDestinationString()");
return userBackupManagerService == null
? null
@@ -440,9 +451,9 @@ public class BackupManagerService {
/** Supply the manage-data intent for the given transport. */
@Nullable
- public Intent getDataManagementIntent(String transportName) {
+ public Intent getDataManagementIntent(@UserIdInt int userId, String transportName) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "getDataManagementIntent()");
+ getServiceForUserIfCallerHasPermission(userId, "getDataManagementIntent()");
return userBackupManagerService == null
? null
@@ -454,9 +465,9 @@ public class BackupManagerService {
* transport.
*/
@Nullable
- public String getDataManagementLabel(String transportName) {
+ public String getDataManagementLabel(@UserIdInt int userId, String transportName) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "getDataManagementLabel()");
+ getServiceForUserIfCallerHasPermission(userId, "getDataManagementLabel()");
return userBackupManagerService == null
? null
@@ -469,9 +480,8 @@ public class BackupManagerService {
/** Enable/disable the backup service. This is user-configurable via backup settings. */
public void setBackupEnabled(@UserIdInt int userId, boolean enable) {
- enforceCallingPermissionOnUserId(userId, "setBackupEnabled");
UserBackupManagerService userBackupManagerService =
- getServiceForUser(userId, "setBackupEnabled()");
+ getServiceForUserIfCallerHasPermission(userId, "setBackupEnabled()");
if (userBackupManagerService != null) {
userBackupManagerService.setBackupEnabled(enable);
@@ -479,32 +489,21 @@ public class BackupManagerService {
}
/** Enable/disable automatic restore of app data at install time. */
- public void setAutoRestore(boolean autoRestore) {
+ public void setAutoRestore(@UserIdInt int userId, boolean autoRestore) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "setAutoRestore()");
+ getServiceForUserIfCallerHasPermission(userId, "setAutoRestore()");
if (userBackupManagerService != null) {
userBackupManagerService.setAutoRestore(autoRestore);
}
}
- /** Mark the backup service as having been provisioned (device has gone through SUW). */
- public void setBackupProvisioned(boolean provisioned) {
- UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "setBackupProvisioned()");
-
- if (userBackupManagerService != null) {
- userBackupManagerService.setBackupProvisioned(provisioned);
- }
- }
-
/**
* Return {@code true} if the backup mechanism is currently enabled, else returns {@code false}.
*/
public boolean isBackupEnabled(@UserIdInt int userId) {
- enforceCallingPermissionOnUserId(userId, "isBackupEnabled");
UserBackupManagerService userBackupManagerService =
- getServiceForUser(userId, "isBackupEnabled()");
+ getServiceForUserIfCallerHasPermission(userId, "isBackupEnabled()");
return userBackupManagerService != null && userBackupManagerService.isBackupEnabled();
}
@@ -514,9 +513,9 @@ public class BackupManagerService {
// ---------------------------------------------
/** Checks if the given package {@code packageName} is eligible for backup. */
- public boolean isAppEligibleForBackup(String packageName) {
+ public boolean isAppEligibleForBackup(@UserIdInt int userId, String packageName) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "isAppEligibleForBackup()");
+ getServiceForUserIfCallerHasPermission(userId, "isAppEligibleForBackup()");
return userBackupManagerService != null
&& userBackupManagerService.isAppEligibleForBackup(packageName);
@@ -526,9 +525,9 @@ public class BackupManagerService {
* Returns from the inputted packages {@code packages}, the ones that are eligible for backup.
*/
@Nullable
- public String[] filterAppsEligibleForBackup(String[] packages) {
+ public String[] filterAppsEligibleForBackup(@UserIdInt int userId, String[] packages) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "filterAppsEligibleForBackup()");
+ getServiceForUserIfCallerHasPermission(userId, "filterAppsEligibleForBackup()");
return userBackupManagerService == null
? null
@@ -540,9 +539,8 @@ public class BackupManagerService {
* they have pending updates.
*/
public void backupNow(@UserIdInt int userId) {
- enforceCallingPermissionOnUserId(userId, "backupNow");
UserBackupManagerService userBackupManagerService =
- getServiceForUser(userId, "backupNow()");
+ getServiceForUserIfCallerHasPermission(userId, "backupNow()");
if (userBackupManagerService != null) {
userBackupManagerService.backupNow();
@@ -559,9 +557,8 @@ public class BackupManagerService {
IBackupObserver observer,
IBackupManagerMonitor monitor,
int flags) {
- enforceCallingPermissionOnUserId(userId, "requestBackup");
UserBackupManagerService userBackupManagerService =
- getServiceForUser(userId, "requestBackup()");
+ getServiceForUserIfCallerHasPermission(userId, "requestBackup()");
return userBackupManagerService == null
? BackupManager.ERROR_BACKUP_NOT_ALLOWED
@@ -570,9 +567,8 @@ public class BackupManagerService {
/** Cancel all running backup operations. */
public void cancelBackups(@UserIdInt int userId) {
- enforceCallingPermissionOnUserId(userId, "cancelBackups");
UserBackupManagerService userBackupManagerService =
- getServiceForUser(userId, "cancelBackups()");
+ getServiceForUserIfCallerHasPermission(userId, "cancelBackups()");
if (userBackupManagerService != null) {
userBackupManagerService.cancelBackups();
@@ -589,7 +585,7 @@ public class BackupManagerService {
*/
public boolean beginFullBackup(FullBackupJob scheduledJob) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "beginFullBackup()");
+ getServiceForUserIfCallerHasPermission(UserHandle.USER_SYSTEM, "beginFullBackup()");
return userBackupManagerService != null
&& userBackupManagerService.beginFullBackup(scheduledJob);
@@ -601,7 +597,7 @@ public class BackupManagerService {
*/
public void endFullBackup() {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "endFullBackup()");
+ getServiceForUserIfCallerHasPermission(UserHandle.USER_SYSTEM, "endFullBackup()");
if (userBackupManagerService != null) {
userBackupManagerService.endFullBackup();
@@ -611,9 +607,9 @@ public class BackupManagerService {
/**
* Run a full backup pass for the given packages {@code packageNames}. Used by 'adb shell bmgr'.
*/
- public void fullTransportBackup(String[] packageNames) {
+ public void fullTransportBackup(@UserIdInt int userId, String[] packageNames) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "fullTransportBackup()");
+ getServiceForUserIfCallerHasPermission(userId, "fullTransportBackup()");
if (userBackupManagerService != null) {
userBackupManagerService.fullTransportBackup(packageNames);
@@ -628,9 +624,9 @@ public class BackupManagerService {
* Used to run a restore pass for an application that is being installed. This should only be
* called from the {@link PackageManager}.
*/
- public void restoreAtInstall(String packageName, int token) {
+ public void restoreAtInstall(@UserIdInt int userId, String packageName, int token) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "restoreAtInstall()");
+ getServiceForUserIfCallerHasPermission(userId, "restoreAtInstall()");
if (userBackupManagerService != null) {
userBackupManagerService.restoreAtInstall(packageName, token);
@@ -642,9 +638,10 @@ public class BackupManagerService {
* {@code transportName}.
*/
@Nullable
- public IRestoreSession beginRestoreSession(String packageName, String transportName) {
+ public IRestoreSession beginRestoreSession(
+ @UserIdInt int userId, String packageName, String transportName) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "beginRestoreSession()");
+ getServiceForUserIfCallerHasPermission(userId, "beginRestoreSession()");
return userBackupManagerService == null
? null
@@ -655,9 +652,9 @@ public class BackupManagerService {
* Get the restore-set token for the best-available restore set for this {@code packageName}:
* the active set if possible, else the ancestral one. Returns zero if none available.
*/
- public long getAvailableRestoreToken(String packageName) {
+ public long getAvailableRestoreToken(@UserIdInt int userId, String packageName) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "getAvailableRestoreToken()");
+ getServiceForUserIfCallerHasPermission(userId, "getAvailableRestoreToken()");
return userBackupManagerService == null
? 0
@@ -671,7 +668,8 @@ public class BackupManagerService {
/** Sets the backup password used when running adb backup. */
public boolean setBackupPassword(String currentPassword, String newPassword) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "setBackupPassword()");
+ getServiceForUserIfCallerHasPermission(
+ UserHandle.USER_SYSTEM, "setBackupPassword()");
return userBackupManagerService != null
&& userBackupManagerService.setBackupPassword(currentPassword, newPassword);
@@ -680,7 +678,8 @@ public class BackupManagerService {
/** Returns {@code true} if adb backup was run with a password, else returns {@code false}. */
public boolean hasBackupPassword() {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "hasBackupPassword()");
+ getServiceForUserIfCallerHasPermission(
+ UserHandle.USER_SYSTEM, "hasBackupPassword()");
return userBackupManagerService != null && userBackupManagerService.hasBackupPassword();
}
@@ -703,9 +702,8 @@ public class BackupManagerService {
boolean doCompress,
boolean doKeyValue,
String[] packageNames) {
- enforceCallingPermissionOnUserId(userId, "adbBackup");
UserBackupManagerService userBackupManagerService =
- getServiceForUser(userId, "adbBackup()");
+ getServiceForUserIfCallerHasPermission(userId, "adbBackup()");
if (userBackupManagerService != null) {
userBackupManagerService.adbBackup(
@@ -728,9 +726,8 @@ public class BackupManagerService {
* requires on-screen confirmation by the user.
*/
public void adbRestore(@UserIdInt int userId, ParcelFileDescriptor fd) {
- enforceCallingPermissionOnUserId(userId, "setBackupEnabled");
UserBackupManagerService userBackupManagerService =
- getServiceForUser(userId, "adbRestore()");
+ getServiceForUserIfCallerHasPermission(userId, "adbRestore()");
if (userBackupManagerService != null) {
userBackupManagerService.adbRestore(fd);
@@ -742,13 +739,14 @@ public class BackupManagerService {
* to require a user-facing disclosure about the operation.
*/
public void acknowledgeAdbBackupOrRestore(
+ @UserIdInt int userId,
int token,
boolean allow,
String currentPassword,
String encryptionPassword,
IFullBackupRestoreObserver observer) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "acknowledgeAdbBackupOrRestore()");
+ getServiceForUserIfCallerHasPermission(userId, "acknowledgeAdbBackupOrRestore()");
if (userBackupManagerService != null) {
userBackupManagerService.acknowledgeAdbBackupOrRestore(
@@ -763,7 +761,7 @@ public class BackupManagerService {
/** Prints service state for 'dumpsys backup'. */
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
UserBackupManagerService userBackupManagerService =
- getServiceForUser(UserHandle.USER_SYSTEM, "dump()");
+ getServiceForUserIfCallerHasPermission(UserHandle.USER_SYSTEM, "dump()");
if (userBackupManagerService != null) {
userBackupManagerService.dump(fd, pw, args);
diff --git a/services/backup/java/com/android/server/backup/Trampoline.java b/services/backup/java/com/android/server/backup/Trampoline.java
index eb10a04586bf..d40368025c0c 100644
--- a/services/backup/java/com/android/server/backup/Trampoline.java
+++ b/services/backup/java/com/android/server/backup/Trampoline.java
@@ -287,7 +287,7 @@ public class Trampoline extends IBackupManager.Stub {
public void dataChangedForUser(int userId, String packageName) throws RemoteException {
BackupManagerService svc = mService;
if (svc != null) {
- svc.dataChanged(packageName);
+ svc.dataChanged(userId, packageName);
}
}
@@ -301,7 +301,7 @@ public class Trampoline extends IBackupManager.Stub {
int userId, String[] transportNames, IBackupObserver observer) throws RemoteException {
BackupManagerService svc = mService;
if (svc != null) {
- svc.initializeTransports(transportNames, observer);
+ svc.initializeTransports(userId, transportNames, observer);
}
}
@@ -310,7 +310,7 @@ public class Trampoline extends IBackupManager.Stub {
throws RemoteException {
BackupManagerService svc = mService;
if (svc != null) {
- svc.clearBackupData(transportName, packageName);
+ svc.clearBackupData(userId, transportName, packageName);
}
}
@@ -325,7 +325,7 @@ public class Trampoline extends IBackupManager.Stub {
throws RemoteException {
BackupManagerService svc = mService;
if (svc != null) {
- svc.agentConnected(packageName, agent);
+ svc.agentConnected(userId, packageName, agent);
}
}
@@ -338,7 +338,7 @@ public class Trampoline extends IBackupManager.Stub {
public void agentDisconnectedForUser(int userId, String packageName) throws RemoteException {
BackupManagerService svc = mService;
if (svc != null) {
- svc.agentDisconnected(packageName);
+ svc.agentDisconnected(userId, packageName);
}
}
@@ -352,7 +352,7 @@ public class Trampoline extends IBackupManager.Stub {
throws RemoteException {
BackupManagerService svc = mService;
if (svc != null) {
- svc.restoreAtInstall(packageName, token);
+ svc.restoreAtInstall(userId, packageName, token);
}
}
@@ -379,7 +379,7 @@ public class Trampoline extends IBackupManager.Stub {
public void setAutoRestoreForUser(int userId, boolean doAutoRestore) throws RemoteException {
BackupManagerService svc = mService;
if (svc != null) {
- svc.setAutoRestore(doAutoRestore);
+ svc.setAutoRestore(userId, doAutoRestore);
}
}
@@ -390,10 +390,9 @@ public class Trampoline extends IBackupManager.Stub {
@Override
public void setBackupProvisioned(boolean isProvisioned) throws RemoteException {
- BackupManagerService svc = mService;
- if (svc != null) {
- svc.setBackupProvisioned(isProvisioned);
- }
+ /*
+ * This is now a no-op; provisioning is simply the device's own setup state.
+ */
}
@Override
@@ -448,7 +447,7 @@ public class Trampoline extends IBackupManager.Stub {
throws RemoteException {
BackupManagerService svc = mService;
if (svc != null) {
- svc.fullTransportBackup(packageNames);
+ svc.fullTransportBackup(userId, packageNames);
}
}
@@ -471,7 +470,7 @@ public class Trampoline extends IBackupManager.Stub {
throws RemoteException {
BackupManagerService svc = mService;
if (svc != null) {
- svc.acknowledgeAdbBackupOrRestore(token, allow,
+ svc.acknowledgeAdbBackupOrRestore(userId, token, allow,
curPassword, encryptionPassword, observer);
}
}
@@ -489,7 +488,7 @@ public class Trampoline extends IBackupManager.Stub {
@Override
public String getCurrentTransportForUser(int userId) throws RemoteException {
BackupManagerService svc = mService;
- return (svc != null) ? svc.getCurrentTransport() : null;
+ return (svc != null) ? svc.getCurrentTransport(userId) : null;
}
@Override
@@ -505,13 +504,13 @@ public class Trampoline extends IBackupManager.Stub {
@Nullable
public ComponentName getCurrentTransportComponentForUser(int userId) {
BackupManagerService svc = mService;
- return (svc != null) ? svc.getCurrentTransportComponent() : null;
+ return (svc != null) ? svc.getCurrentTransportComponent(userId) : null;
}
@Override
public String[] listAllTransportsForUser(int userId) throws RemoteException {
BackupManagerService svc = mService;
- return (svc != null) ? svc.listAllTransports() : null;
+ return (svc != null) ? svc.listAllTransports(userId) : null;
}
@Override
@@ -522,7 +521,7 @@ public class Trampoline extends IBackupManager.Stub {
@Override
public ComponentName[] listAllTransportComponentsForUser(int userId) throws RemoteException {
BackupManagerService svc = mService;
- return (svc != null) ? svc.listAllTransportComponents() : null;
+ return (svc != null) ? svc.listAllTransportComponents(userId) : null;
}
@Override
@@ -543,6 +542,7 @@ public class Trampoline extends IBackupManager.Stub {
BackupManagerService svc = mService;
if (svc != null) {
svc.updateTransportAttributes(
+ userId,
transportComponent,
name,
configurationIntent,
@@ -556,7 +556,7 @@ public class Trampoline extends IBackupManager.Stub {
public String selectBackupTransportForUser(int userId, String transport)
throws RemoteException {
BackupManagerService svc = mService;
- return (svc != null) ? svc.selectBackupTransport(transport) : null;
+ return (svc != null) ? svc.selectBackupTransport(userId, transport) : null;
}
@Override
@@ -569,7 +569,7 @@ public class Trampoline extends IBackupManager.Stub {
ISelectBackupTransportCallback listener) throws RemoteException {
BackupManagerService svc = mService;
if (svc != null) {
- svc.selectBackupTransportAsync(transport, listener);
+ svc.selectBackupTransportAsync(userId, transport, listener);
} else {
if (listener != null) {
try {
@@ -585,7 +585,7 @@ public class Trampoline extends IBackupManager.Stub {
public Intent getConfigurationIntentForUser(int userId, String transport)
throws RemoteException {
BackupManagerService svc = mService;
- return (svc != null) ? svc.getConfigurationIntent(transport) : null;
+ return (svc != null) ? svc.getConfigurationIntent(userId, transport) : null;
}
@Override
@@ -597,7 +597,7 @@ public class Trampoline extends IBackupManager.Stub {
@Override
public String getDestinationStringForUser(int userId, String transport) throws RemoteException {
BackupManagerService svc = mService;
- return (svc != null) ? svc.getDestinationString(transport) : null;
+ return (svc != null) ? svc.getDestinationString(userId, transport) : null;
}
@Override
@@ -609,7 +609,7 @@ public class Trampoline extends IBackupManager.Stub {
public Intent getDataManagementIntentForUser(int userId, String transport)
throws RemoteException {
BackupManagerService svc = mService;
- return (svc != null) ? svc.getDataManagementIntent(transport) : null;
+ return (svc != null) ? svc.getDataManagementIntent(userId, transport) : null;
}
@Override
@@ -622,7 +622,7 @@ public class Trampoline extends IBackupManager.Stub {
public String getDataManagementLabelForUser(int userId, String transport)
throws RemoteException {
BackupManagerService svc = mService;
- return (svc != null) ? svc.getDataManagementLabel(transport) : null;
+ return (svc != null) ? svc.getDataManagementLabel(userId, transport) : null;
}
@Override
@@ -635,33 +635,33 @@ public class Trampoline extends IBackupManager.Stub {
public IRestoreSession beginRestoreSessionForUser(
int userId, String packageName, String transportID) throws RemoteException {
BackupManagerService svc = mService;
- return (svc != null) ? svc.beginRestoreSession(packageName, transportID) : null;
+ return (svc != null) ? svc.beginRestoreSession(userId, packageName, transportID) : null;
}
@Override
public void opComplete(int token, long result) throws RemoteException {
BackupManagerService svc = mService;
if (svc != null) {
- svc.opComplete(token, result);
+ svc.opComplete(binderGetCallingUserId(), token, result);
}
}
@Override
public long getAvailableRestoreTokenForUser(int userId, String packageName) {
BackupManagerService svc = mService;
- return (svc != null) ? svc.getAvailableRestoreToken(packageName) : 0;
+ return (svc != null) ? svc.getAvailableRestoreToken(userId, packageName) : 0;
}
@Override
public boolean isAppEligibleForBackupForUser(int userId, String packageName) {
BackupManagerService svc = mService;
- return (svc != null) ? svc.isAppEligibleForBackup(packageName) : false;
+ return (svc != null) ? svc.isAppEligibleForBackup(userId, packageName) : false;
}
@Override
public String[] filterAppsEligibleForBackupForUser(int userId, String[] packages) {
BackupManagerService svc = mService;
- return (svc != null) ? svc.filterAppsEligibleForBackup(packages) : null;
+ return (svc != null) ? svc.filterAppsEligibleForBackup(userId, packages) : null;
}
@Override
diff --git a/services/backup/java/com/android/server/backup/UserBackupManagerService.java b/services/backup/java/com/android/server/backup/UserBackupManagerService.java
index d35740482059..2e414438c6ff 100644
--- a/services/backup/java/com/android/server/backup/UserBackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/UserBackupManagerService.java
@@ -2811,15 +2811,6 @@ public class UserBackupManagerService {
}
}
- /** Mark the backup service as having been provisioned. */
- public void setBackupProvisioned(boolean available) {
- mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
- "setBackupProvisioned");
- /*
- * This is now a no-op; provisioning is simply the device's own setup state.
- */
- }
-
/** Report whether the backup mechanism is currently enabled. */
public boolean isBackupEnabled() {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
@@ -2869,19 +2860,6 @@ public class UserBackupManagerService {
return mTransportManager.getRegisteredTransportComponents();
}
- /** Report all system whitelisted transports. */
- public String[] getTransportWhitelist() {
- // No permission check, intentionally.
- Set<ComponentName> whitelistedComponents = mTransportManager.getTransportWhitelist();
- String[] whitelistedTransports = new String[whitelistedComponents.size()];
- int i = 0;
- for (ComponentName component : whitelistedComponents) {
- whitelistedTransports[i] = component.flattenToShortString();
- i++;
- }
- return whitelistedTransports;
- }
-
/**
* Update the attributes of the transport identified by {@code transportComponent}. If the
* specified transport has not been bound at least once (for registration), this call will be
diff --git a/services/robotests/backup/src/com/android/server/backup/BackupManagerServiceTest.java b/services/robotests/backup/src/com/android/server/backup/BackupManagerServiceTest.java
index 83f66c5258b2..b253e0ae0a40 100644
--- a/services/robotests/backup/src/com/android/server/backup/BackupManagerServiceTest.java
+++ b/services/robotests/backup/src/com/android/server/backup/BackupManagerServiceTest.java
@@ -23,6 +23,7 @@ import static com.android.server.backup.testing.TransportData.backupTransport;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -86,9 +87,7 @@ public class BackupManagerServiceTest {
mContext = application;
mShadowContext = shadowOf(application);
- // TODO(b/120212806): Hardcoding system user for now since most methods in BMS don't yet
- // take an user parameter (and instead hardcode the system user).
- mUserOneId = UserHandle.USER_SYSTEM;
+ mUserOneId = UserHandle.USER_SYSTEM + 1;
mUserTwoId = mUserOneId + 1;
}
@@ -176,9 +175,52 @@ public class BackupManagerServiceTest {
assertThat(serviceUsers.get(mUserOneId)).isEqualTo(mUserOneService);
}
- // TODO(b/120212806): When BMS methods take in a user parameter, modify unknown user tests to
- // check that that we don't call the method on another registered user. Currently these tests
- // have no registered users since we hardcode the system user in BMS.
+ /**
+ * Test that the backup services throws a {@link SecurityException} if the caller does not have
+ * INTERACT_ACROSS_USERS_FULL permission and passes a different user id.
+ */
+ @Test
+ public void testGetServiceForUser_withoutPermission_throwsSecurityExceptionForNonCallingUser() {
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
+
+ expectThrows(
+ SecurityException.class,
+ () ->
+ backupManagerService.getServiceForUserIfCallerHasPermission(
+ mUserOneId, "test"));
+ }
+
+ /**
+ * Test that the backup services does not throw a {@link SecurityException} if the caller has
+ * INTERACT_ACROSS_USERS_FULL permission and passes a different user id.
+ */
+ @Test
+ public void testGetServiceForUserIfCallerHasPermission_withPermission_worksForNonCallingUser() {
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ true);
+
+ assertEquals(
+ mUserOneService,
+ backupManagerService.getServiceForUserIfCallerHasPermission(mUserOneId, "test"));
+ }
+
+ /**
+ * Test that the backup services does not throw a {@link SecurityException} if the caller does
+ * not have INTERACT_ACROSS_USERS_FULL permission and passes in the calling user id.
+ */
+ @Test
+ public void testGetServiceForUserIfCallerHasPermission_withoutPermission_worksForCallingUser() {
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
+
+ assertEquals(
+ mUserOneService,
+ backupManagerService.getServiceForUserIfCallerHasPermission(mUserOneId, "test"));
+ }
// ---------------------------------------------
// Backup agent tests
@@ -189,8 +231,9 @@ public class BackupManagerServiceTest {
public void testDataChanged_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.dataChanged(TEST_PACKAGE);
+ backupManagerService.dataChanged(mUserOneId, TEST_PACKAGE);
verify(mUserOneService).dataChanged(TEST_PACKAGE);
}
@@ -198,9 +241,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testDataChanged_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.dataChanged(TEST_PACKAGE);
+ backupManagerService.dataChanged(mUserTwoId, TEST_PACKAGE);
verify(mUserOneService, never()).dataChanged(TEST_PACKAGE);
}
@@ -210,9 +255,10 @@ public class BackupManagerServiceTest {
public void testAgentConnected_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
IBinder agentBinder = mock(IBinder.class);
- backupManagerService.agentConnected(TEST_PACKAGE, agentBinder);
+ backupManagerService.agentConnected(mUserOneId, TEST_PACKAGE, agentBinder);
verify(mUserOneService).agentConnected(TEST_PACKAGE, agentBinder);
}
@@ -220,10 +266,12 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testAgentConnected_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
IBinder agentBinder = mock(IBinder.class);
- backupManagerService.agentConnected(TEST_PACKAGE, agentBinder);
+ backupManagerService.agentConnected(mUserTwoId, TEST_PACKAGE, agentBinder);
verify(mUserOneService, never()).agentConnected(TEST_PACKAGE, agentBinder);
}
@@ -233,8 +281,9 @@ public class BackupManagerServiceTest {
public void testAgentDisconnected_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.agentDisconnected(TEST_PACKAGE);
+ backupManagerService.agentDisconnected(mUserOneId, TEST_PACKAGE);
verify(mUserOneService).agentDisconnected(TEST_PACKAGE);
}
@@ -242,9 +291,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testAgentDisconnected_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.agentDisconnected(TEST_PACKAGE);
+ backupManagerService.agentDisconnected(mUserTwoId, TEST_PACKAGE);
verify(mUserOneService, never()).agentDisconnected(TEST_PACKAGE);
}
@@ -254,8 +305,9 @@ public class BackupManagerServiceTest {
public void testOpComplete_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.opComplete(/* token */ 0, /* result */ 0L);
+ backupManagerService.opComplete(mUserOneId, /* token */ 0, /* result */ 0L);
verify(mUserOneService).opComplete(/* token */ 0, /* result */ 0L);
}
@@ -263,9 +315,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testOpComplete_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.opComplete(/* token */ 0, /* result */ 0L);
+ backupManagerService.opComplete(mUserTwoId, /* token */ 0, /* result */ 0L);
verify(mUserOneService, never()).opComplete(/* token */ 0, /* result */ 0L);
}
@@ -279,9 +333,10 @@ public class BackupManagerServiceTest {
public void testInitializeTransports_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
String[] transports = {TEST_TRANSPORT};
- backupManagerService.initializeTransports(transports, /* observer */ null);
+ backupManagerService.initializeTransports(mUserOneId, transports, /* observer */ null);
verify(mUserOneService).initializeTransports(transports, /* observer */ null);
}
@@ -289,10 +344,12 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testInitializeTransports_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
String[] transports = {TEST_TRANSPORT};
- backupManagerService.initializeTransports(transports, /* observer */ null);
+ backupManagerService.initializeTransports(mUserTwoId, transports, /* observer */ null);
verify(mUserOneService, never()).initializeTransports(transports, /* observer */ null);
}
@@ -302,8 +359,9 @@ public class BackupManagerServiceTest {
public void testClearBackupData_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.clearBackupData(TEST_TRANSPORT, TEST_PACKAGE);
+ backupManagerService.clearBackupData(mUserOneId, TEST_TRANSPORT, TEST_PACKAGE);
verify(mUserOneService).clearBackupData(TEST_TRANSPORT, TEST_PACKAGE);
}
@@ -311,9 +369,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testClearBackupData_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.clearBackupData(TEST_TRANSPORT, TEST_PACKAGE);
+ backupManagerService.clearBackupData(mUserTwoId, TEST_TRANSPORT, TEST_PACKAGE);
verify(mUserOneService, never()).clearBackupData(TEST_TRANSPORT, TEST_PACKAGE);
}
@@ -323,8 +383,9 @@ public class BackupManagerServiceTest {
public void testGetCurrentTransport_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.getCurrentTransport();
+ backupManagerService.getCurrentTransport(mUserOneId);
verify(mUserOneService).getCurrentTransport();
}
@@ -332,9 +393,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testGetCurrentTransport_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.getCurrentTransport();
+ backupManagerService.getCurrentTransport(mUserTwoId);
verify(mUserOneService, never()).getCurrentTransport();
}
@@ -345,8 +408,9 @@ public class BackupManagerServiceTest {
throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.getCurrentTransportComponent();
+ backupManagerService.getCurrentTransportComponent(mUserOneId);
verify(mUserOneService).getCurrentTransportComponent();
}
@@ -355,9 +419,11 @@ public class BackupManagerServiceTest {
@Test
public void testGetCurrentTransportComponent_onUnknownUser_doesNotPropagateCall()
throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.getCurrentTransportComponent();
+ backupManagerService.getCurrentTransportComponent(mUserTwoId);
verify(mUserOneService, never()).getCurrentTransportComponent();
}
@@ -367,8 +433,9 @@ public class BackupManagerServiceTest {
public void testListAllTransports_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.listAllTransports();
+ backupManagerService.listAllTransports(mUserOneId);
verify(mUserOneService).listAllTransports();
}
@@ -376,9 +443,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testListAllTransports_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.listAllTransports();
+ backupManagerService.listAllTransports(mUserTwoId);
verify(mUserOneService, never()).listAllTransports();
}
@@ -389,8 +458,9 @@ public class BackupManagerServiceTest {
throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.listAllTransportComponents();
+ backupManagerService.listAllTransportComponents(mUserOneId);
verify(mUserOneService).listAllTransportComponents();
}
@@ -399,32 +469,13 @@ public class BackupManagerServiceTest {
@Test
public void testListAllTransportComponents_onUnknownUser_doesNotPropagateCall()
throws Exception {
- BackupManagerService backupManagerService = createService();
-
- backupManagerService.listAllTransportComponents();
-
- verify(mUserOneService, never()).listAllTransportComponents();
- }
-
- /** Test that the backup service routes methods correctly to the user that requests it. */
- @Test
- public void testGetTransportWhitelist_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.getTransportWhitelist();
-
- verify(mUserOneService).getTransportWhitelist();
- }
-
- /** Test that the backup service does not route methods for non-registered users. */
- @Test
- public void testGetTransportWhitelist_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
-
- backupManagerService.getTransportWhitelist();
+ backupManagerService.listAllTransportComponents(mUserTwoId);
- verify(mUserOneService, never()).getTransportWhitelist();
+ verify(mUserOneService, never()).listAllTransportComponents();
}
/** Test that the backup service routes methods correctly to the user that requests it. */
@@ -433,11 +484,13 @@ public class BackupManagerServiceTest {
throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
TransportData transport = backupTransport();
Intent configurationIntent = new Intent();
Intent dataManagementIntent = new Intent();
backupManagerService.updateTransportAttributes(
+ mUserOneId,
transport.getTransportComponent(),
transport.transportName,
configurationIntent,
@@ -459,12 +512,15 @@ public class BackupManagerServiceTest {
@Test
public void testUpdateTransportAttributes_onUnknownUser_doesNotPropagateCall()
throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
TransportData transport = backupTransport();
Intent configurationIntent = new Intent();
Intent dataManagementIntent = new Intent();
backupManagerService.updateTransportAttributes(
+ mUserTwoId,
transport.getTransportComponent(),
transport.transportName,
configurationIntent,
@@ -487,8 +543,9 @@ public class BackupManagerServiceTest {
public void testSelectBackupTransport_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.selectBackupTransport(TEST_TRANSPORT);
+ backupManagerService.selectBackupTransport(mUserOneId, TEST_TRANSPORT);
verify(mUserOneService).selectBackupTransport(TEST_TRANSPORT);
}
@@ -496,9 +553,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testSelectBackupTransport_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.selectBackupTransport(TEST_TRANSPORT);
+ backupManagerService.selectBackupTransport(mUserTwoId, TEST_TRANSPORT);
verify(mUserOneService, never()).selectBackupTransport(TEST_TRANSPORT);
}
@@ -508,11 +567,12 @@ public class BackupManagerServiceTest {
public void testSelectTransportAsync_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
TransportData transport = backupTransport();
ISelectBackupTransportCallback callback = mock(ISelectBackupTransportCallback.class);
backupManagerService.selectBackupTransportAsync(
- transport.getTransportComponent(), callback);
+ mUserOneId, transport.getTransportComponent(), callback);
verify(mUserOneService)
.selectBackupTransportAsync(transport.getTransportComponent(), callback);
@@ -522,12 +582,14 @@ public class BackupManagerServiceTest {
@Test
public void testSelectBackupTransportAsync_onUnknownUser_doesNotPropagateCall()
throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
TransportData transport = backupTransport();
ISelectBackupTransportCallback callback = mock(ISelectBackupTransportCallback.class);
backupManagerService.selectBackupTransportAsync(
- transport.getTransportComponent(), callback);
+ mUserTwoId, transport.getTransportComponent(), callback);
verify(mUserOneService, never())
.selectBackupTransportAsync(transport.getTransportComponent(), callback);
@@ -538,8 +600,9 @@ public class BackupManagerServiceTest {
public void testGetConfigurationIntent_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.getConfigurationIntent(TEST_TRANSPORT);
+ backupManagerService.getConfigurationIntent(mUserOneId, TEST_TRANSPORT);
verify(mUserOneService).getConfigurationIntent(TEST_TRANSPORT);
}
@@ -547,9 +610,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testGetConfigurationIntent_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.getConfigurationIntent(TEST_TRANSPORT);
+ backupManagerService.getConfigurationIntent(mUserTwoId, TEST_TRANSPORT);
verify(mUserOneService, never()).getConfigurationIntent(TEST_TRANSPORT);
}
@@ -559,8 +624,9 @@ public class BackupManagerServiceTest {
public void testGetDestinationString_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.getDestinationString(TEST_TRANSPORT);
+ backupManagerService.getDestinationString(mUserOneId, TEST_TRANSPORT);
verify(mUserOneService).getDestinationString(TEST_TRANSPORT);
}
@@ -568,9 +634,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testGetDestinationString_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.getDestinationString(TEST_TRANSPORT);
+ backupManagerService.getDestinationString(mUserTwoId, TEST_TRANSPORT);
verify(mUserOneService, never()).getDestinationString(TEST_TRANSPORT);
}
@@ -580,8 +648,9 @@ public class BackupManagerServiceTest {
public void testGetDataManagementIntent_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.getDataManagementIntent(TEST_TRANSPORT);
+ backupManagerService.getDataManagementIntent(mUserOneId, TEST_TRANSPORT);
verify(mUserOneService).getDataManagementIntent(TEST_TRANSPORT);
}
@@ -589,9 +658,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testGetDataManagementIntent_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.getDataManagementIntent(TEST_TRANSPORT);
+ backupManagerService.getDataManagementIntent(mUserTwoId, TEST_TRANSPORT);
verify(mUserOneService, never()).getDataManagementIntent(TEST_TRANSPORT);
}
@@ -601,8 +672,9 @@ public class BackupManagerServiceTest {
public void testGetDataManagementLabel_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.getDataManagementLabel(TEST_TRANSPORT);
+ backupManagerService.getDataManagementLabel(mUserOneId, TEST_TRANSPORT);
verify(mUserOneService).getDataManagementLabel(TEST_TRANSPORT);
}
@@ -610,9 +682,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testGetDataManagementLabel_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.getDataManagementLabel(TEST_TRANSPORT);
+ backupManagerService.getDataManagementLabel(mUserTwoId, TEST_TRANSPORT);
verify(mUserOneService, never()).getDataManagementLabel(TEST_TRANSPORT);
}
@@ -620,7 +694,6 @@ public class BackupManagerServiceTest {
// ---------------------------------------------
// Settings tests
// ---------------------------------------------
-
/**
* Test that the backup services throws a {@link SecurityException} if the caller does not have
* INTERACT_ACROSS_USERS_FULL permission and passes a different user id.
@@ -681,8 +754,9 @@ public class BackupManagerServiceTest {
public void testSetAutoRestore_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.setAutoRestore(true);
+ backupManagerService.setAutoRestore(mUserOneId, true);
verify(mUserOneService).setAutoRestore(true);
}
@@ -690,62 +764,13 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testSetAutoRestore_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
-
- backupManagerService.setAutoRestore(true);
-
- verify(mUserOneService, never()).setAutoRestore(true);
- }
-
- /** Test that the backup service routes methods correctly to the user that requests it. */
- @Test
- public void testSetBackupProvisioned_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.setBackupProvisioned(true);
-
- verify(mUserOneService).setBackupProvisioned(true);
- }
-
- /** Test that the backup service does not route methods for non-registered users. */
- @Test
- public void testSetBackupProvisioned_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
-
- backupManagerService.setBackupProvisioned(true);
-
- verify(mUserOneService, never()).setBackupProvisioned(true);
- }
-
- /**
- * Test that the backup services throws a {@link SecurityException} if the caller does not have
- * INTERACT_ACROSS_USERS_FULL permission and passes a different user id.
- */
- @Test
- public void testIsBackupEnabled_withoutPermission_throwsSecurityExceptionForNonCallingUser() {
- BackupManagerService backupManagerService =
- createServiceAndRegisterUser(mUserOneId, mUserOneService);
- setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
-
- expectThrows(
- SecurityException.class, () -> backupManagerService.isBackupEnabled(mUserTwoId));
- }
-
- /**
- * Test that the backup service does not throw a {@link SecurityException} if the caller has
- * INTERACT_ACROSS_USERS_FULL permission and passes a different user id.
- */
- @Test
- public void testIsBackupEnabled_withPermission_propagatesForNonCallingUser() {
- BackupManagerService backupManagerService =
- createServiceAndRegisterUser(mUserOneId, mUserOneService);
- backupManagerService.startServiceForUser(mUserTwoId, mUserTwoService);
- setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ true);
-
- backupManagerService.isBackupEnabled(mUserTwoId);
+ backupManagerService.setAutoRestore(mUserTwoId, true);
- verify(mUserTwoService).isBackupEnabled();
+ verify(mUserOneService, never()).setAutoRestore(true);
}
/** Test that the backup service routes methods correctly to the user that requests it. */
@@ -781,8 +806,9 @@ public class BackupManagerServiceTest {
public void testIsAppEligibleForBackup_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.isAppEligibleForBackup(TEST_PACKAGE);
+ backupManagerService.isAppEligibleForBackup(mUserOneId, TEST_PACKAGE);
verify(mUserOneService).isAppEligibleForBackup(TEST_PACKAGE);
}
@@ -790,9 +816,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testIsAppEligibleForBackup_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.isAppEligibleForBackup(TEST_PACKAGE);
+ backupManagerService.isAppEligibleForBackup(mUserTwoId, TEST_PACKAGE);
verify(mUserOneService, never()).isAppEligibleForBackup(TEST_PACKAGE);
}
@@ -803,9 +831,10 @@ public class BackupManagerServiceTest {
throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
String[] packages = {TEST_PACKAGE};
- backupManagerService.filterAppsEligibleForBackup(packages);
+ backupManagerService.filterAppsEligibleForBackup(mUserOneId, packages);
verify(mUserOneService).filterAppsEligibleForBackup(packages);
}
@@ -814,10 +843,12 @@ public class BackupManagerServiceTest {
@Test
public void testFilterAppsEligibleForBackup_onUnknownUser_doesNotPropagateCall()
throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
String[] packages = {TEST_PACKAGE};
- backupManagerService.filterAppsEligibleForBackup(packages);
+ backupManagerService.filterAppsEligibleForBackup(mUserTwoId, packages);
verify(mUserOneService, never()).filterAppsEligibleForBackup(packages);
}
@@ -1001,7 +1032,7 @@ public class BackupManagerServiceTest {
@Test
public void testBeginFullBackup_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
- createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ createServiceAndRegisterUser(UserHandle.USER_SYSTEM, mUserOneService);
FullBackupJob job = new FullBackupJob();
backupManagerService.beginFullBackup(job);
@@ -1024,7 +1055,7 @@ public class BackupManagerServiceTest {
@Test
public void testEndFullBackup_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
- createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ createServiceAndRegisterUser(UserHandle.USER_SYSTEM, mUserOneService);
backupManagerService.endFullBackup();
@@ -1046,9 +1077,10 @@ public class BackupManagerServiceTest {
public void testFullTransportBackup_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
String[] packages = {TEST_PACKAGE};
- backupManagerService.fullTransportBackup(packages);
+ backupManagerService.fullTransportBackup(mUserOneId, packages);
verify(mUserOneService).fullTransportBackup(packages);
}
@@ -1056,10 +1088,12 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testFullTransportBackup_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
String[] packages = {TEST_PACKAGE};
- backupManagerService.fullTransportBackup(packages);
+ backupManagerService.fullTransportBackup(mUserTwoId, packages);
verify(mUserOneService, never()).fullTransportBackup(packages);
}
@@ -1073,8 +1107,9 @@ public class BackupManagerServiceTest {
public void testRestoreAtInstall_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.restoreAtInstall(TEST_PACKAGE, /* token */ 0);
+ backupManagerService.restoreAtInstall(mUserOneId, TEST_PACKAGE, /* token */ 0);
verify(mUserOneService).restoreAtInstall(TEST_PACKAGE, /* token */ 0);
}
@@ -1082,9 +1117,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testRestoreAtInstall_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.restoreAtInstall(TEST_PACKAGE, /* token */ 0);
+ backupManagerService.restoreAtInstall(mUserTwoId, TEST_PACKAGE, /* token */ 0);
verify(mUserOneService, never()).restoreAtInstall(TEST_PACKAGE, /* token */ 0);
}
@@ -1094,8 +1131,9 @@ public class BackupManagerServiceTest {
public void testBeginRestoreSession_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.beginRestoreSession(TEST_PACKAGE, TEST_TRANSPORT);
+ backupManagerService.beginRestoreSession(mUserOneId, TEST_PACKAGE, TEST_TRANSPORT);
verify(mUserOneService).beginRestoreSession(TEST_PACKAGE, TEST_TRANSPORT);
}
@@ -1103,9 +1141,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testBeginRestoreSession_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.beginRestoreSession(TEST_PACKAGE, TEST_TRANSPORT);
+ backupManagerService.beginRestoreSession(mUserTwoId, TEST_PACKAGE, TEST_TRANSPORT);
verify(mUserOneService, never()).beginRestoreSession(TEST_PACKAGE, TEST_TRANSPORT);
}
@@ -1116,8 +1156,9 @@ public class BackupManagerServiceTest {
throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
- backupManagerService.getAvailableRestoreToken(TEST_PACKAGE);
+ backupManagerService.getAvailableRestoreToken(mUserOneId, TEST_PACKAGE);
verify(mUserOneService).getAvailableRestoreToken(TEST_PACKAGE);
}
@@ -1125,9 +1166,11 @@ public class BackupManagerServiceTest {
/** Test that the backup service does not route methods for non-registered users. */
@Test
public void testGetAvailableRestoreToken_onUnknownUser_doesNotPropagateCall() throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
- backupManagerService.getAvailableRestoreToken(TEST_PACKAGE);
+ backupManagerService.getAvailableRestoreToken(mUserTwoId, TEST_PACKAGE);
verify(mUserOneService, never()).getAvailableRestoreToken(TEST_PACKAGE);
}
@@ -1140,7 +1183,7 @@ public class BackupManagerServiceTest {
@Test
public void testSetBackupPassword_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
- createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ createServiceAndRegisterUser(UserHandle.USER_SYSTEM, mUserOneService);
backupManagerService.setBackupPassword("currentPassword", "newPassword");
@@ -1161,7 +1204,7 @@ public class BackupManagerServiceTest {
@Test
public void testHasBackupPassword_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
- createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ createServiceAndRegisterUser(UserHandle.USER_SYSTEM, mUserOneService);
backupManagerService.hasBackupPassword();
@@ -1377,10 +1420,16 @@ public class BackupManagerServiceTest {
throws Exception {
BackupManagerService backupManagerService =
createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserOneId, /* shouldGrantPermission */ false);
IFullBackupRestoreObserver observer = mock(IFullBackupRestoreObserver.class);
backupManagerService.acknowledgeAdbBackupOrRestore(
- /* token */ 0, /* allow */ true, "currentPassword", "encryptionPassword", observer);
+ mUserOneId,
+ /* token */ 0,
+ /* allow */ true,
+ "currentPassword",
+ "encryptionPassword",
+ observer);
verify(mUserOneService)
.acknowledgeAdbBackupOrRestore(
@@ -1395,11 +1444,18 @@ public class BackupManagerServiceTest {
@Test
public void testAcknowledgeAdbBackupOrRestore_onUnknownUser_doesNotPropagateCall()
throws Exception {
- BackupManagerService backupManagerService = createService();
+ BackupManagerService backupManagerService =
+ createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ setCallerAndGrantInteractUserPermission(mUserTwoId, /* shouldGrantPermission */ false);
IFullBackupRestoreObserver observer = mock(IFullBackupRestoreObserver.class);
backupManagerService.acknowledgeAdbBackupOrRestore(
- /* token */ 0, /* allow */ true, "currentPassword", "encryptionPassword", observer);
+ mUserTwoId,
+ /* token */ 0,
+ /* allow */ true,
+ "currentPassword",
+ "encryptionPassword",
+ observer);
verify(mUserOneService, never())
.acknowledgeAdbBackupOrRestore(
@@ -1418,7 +1474,7 @@ public class BackupManagerServiceTest {
@Test
public void testDump_onRegisteredUser_callsMethodForUser() throws Exception {
BackupManagerService backupManagerService =
- createServiceAndRegisterUser(mUserOneId, mUserOneService);
+ createServiceAndRegisterUser(UserHandle.USER_SYSTEM, mUserOneService);
File testFile = new File(mContext.getFilesDir(), "test");
testFile.createNewFile();
FileDescriptor fileDescriptor = new FileDescriptor();
diff --git a/services/tests/servicestests/src/com/android/server/backup/TrampolineTest.java b/services/tests/servicestests/src/com/android/server/backup/TrampolineTest.java
index 5615dff6c607..0851cf3bc4c0 100644
--- a/services/tests/servicestests/src/com/android/server/backup/TrampolineTest.java
+++ b/services/tests/servicestests/src/com/android/server/backup/TrampolineTest.java
@@ -307,14 +307,17 @@ public class TrampolineTest {
mTrampoline.dataChangedForUser(mUserId, PACKAGE_NAME);
- verify(mBackupManagerServiceMock).dataChanged(PACKAGE_NAME);
+ verify(mBackupManagerServiceMock).dataChanged(mUserId, PACKAGE_NAME);
}
@Test
public void dataChanged_forwarded() throws RemoteException {
+ TrampolineTestable.sCallingUserId = mUserId;
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
mTrampoline.dataChanged(PACKAGE_NAME);
- verify(mBackupManagerServiceMock).dataChanged(PACKAGE_NAME);
+
+ verify(mBackupManagerServiceMock).dataChanged(mUserId, PACKAGE_NAME);
}
@Test
@@ -329,14 +332,17 @@ public class TrampolineTest {
mTrampoline.clearBackupDataForUser(mUserId, TRANSPORT_NAME, PACKAGE_NAME);
- verify(mBackupManagerServiceMock).clearBackupData(TRANSPORT_NAME, PACKAGE_NAME);
+ verify(mBackupManagerServiceMock).clearBackupData(mUserId, TRANSPORT_NAME, PACKAGE_NAME);
}
@Test
public void clearBackupData_forwarded() throws RemoteException {
+ TrampolineTestable.sCallingUserId = mUserId;
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
mTrampoline.clearBackupData(TRANSPORT_NAME, PACKAGE_NAME);
- verify(mBackupManagerServiceMock).clearBackupData(TRANSPORT_NAME, PACKAGE_NAME);
+
+ verify(mBackupManagerServiceMock).clearBackupData(mUserId, TRANSPORT_NAME, PACKAGE_NAME);
}
@Test
@@ -351,14 +357,17 @@ public class TrampolineTest {
mTrampoline.agentConnectedForUser(mUserId, PACKAGE_NAME, mAgentMock);
- verify(mBackupManagerServiceMock).agentConnected(PACKAGE_NAME, mAgentMock);
+ verify(mBackupManagerServiceMock).agentConnected(mUserId, PACKAGE_NAME, mAgentMock);
}
@Test
public void agentConnected_forwarded() throws RemoteException {
+ TrampolineTestable.sCallingUserId = mUserId;
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
mTrampoline.agentConnected(PACKAGE_NAME, mAgentMock);
- verify(mBackupManagerServiceMock).agentConnected(PACKAGE_NAME, mAgentMock);
+
+ verify(mBackupManagerServiceMock).agentConnected(mUserId, PACKAGE_NAME, mAgentMock);
}
@Test
@@ -373,14 +382,17 @@ public class TrampolineTest {
mTrampoline.agentDisconnectedForUser(mUserId, PACKAGE_NAME);
- verify(mBackupManagerServiceMock).agentDisconnected(PACKAGE_NAME);
+ verify(mBackupManagerServiceMock).agentDisconnected(mUserId, PACKAGE_NAME);
}
@Test
public void agentDisconnected_forwarded() throws RemoteException {
+ TrampolineTestable.sCallingUserId = mUserId;
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
mTrampoline.agentDisconnected(PACKAGE_NAME);
- verify(mBackupManagerServiceMock).agentDisconnected(PACKAGE_NAME);
+
+ verify(mBackupManagerServiceMock).agentDisconnected(mUserId, PACKAGE_NAME);
}
@Test
@@ -395,14 +407,17 @@ public class TrampolineTest {
mTrampoline.restoreAtInstallForUser(mUserId, PACKAGE_NAME, 123);
- verify(mBackupManagerServiceMock).restoreAtInstall(PACKAGE_NAME, 123);
+ verify(mBackupManagerServiceMock).restoreAtInstall(mUserId, PACKAGE_NAME, 123);
}
@Test
public void restoreAtInstall_forwarded() throws RemoteException {
+ TrampolineTestable.sCallingUserId = mUserId;
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
mTrampoline.restoreAtInstall(PACKAGE_NAME, 123);
- verify(mBackupManagerServiceMock).restoreAtInstall(PACKAGE_NAME, 123);
+
+ verify(mBackupManagerServiceMock).restoreAtInstall(mUserId, PACKAGE_NAME, 123);
}
@Test
@@ -442,14 +457,17 @@ public class TrampolineTest {
mTrampoline.setAutoRestoreForUser(mUserId, true);
- verify(mBackupManagerServiceMock).setAutoRestore(true);
+ verify(mBackupManagerServiceMock).setAutoRestore(mUserId, true);
}
@Test
public void setAutoRestore_forwarded() throws RemoteException {
+ TrampolineTestable.sCallingUserId = mUserId;
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
mTrampoline.setAutoRestore(true);
- verify(mBackupManagerServiceMock).setAutoRestore(true);
+
+ verify(mBackupManagerServiceMock).setAutoRestore(mUserId, true);
}
@Test
@@ -462,7 +480,7 @@ public class TrampolineTest {
public void setBackupProvisioned_forwarded() throws RemoteException {
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
mTrampoline.setBackupProvisioned(true);
- verify(mBackupManagerServiceMock).setBackupProvisioned(true);
+ verifyNoMoreInteractions(mBackupManagerServiceMock);
}
@Test
@@ -568,8 +586,10 @@ public class TrampolineTest {
@Test
public void fullTransportBackupForUser_forwarded() throws RemoteException {
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
mTrampoline.fullTransportBackupForUser(mUserId, PACKAGE_NAMES);
- verify(mBackupManagerServiceMock).fullTransportBackup(PACKAGE_NAMES);
+
+ verify(mBackupManagerServiceMock).fullTransportBackup(mUserId, PACKAGE_NAMES);
}
@Test
@@ -605,17 +625,32 @@ public class TrampolineTest {
ENCRYPTION_PASSWORD,
mFullBackupRestoreObserverMock);
- verify(mBackupManagerServiceMock).acknowledgeAdbBackupOrRestore(123, true, CURRENT_PASSWORD,
- ENCRYPTION_PASSWORD, mFullBackupRestoreObserverMock);
+ verify(mBackupManagerServiceMock)
+ .acknowledgeAdbBackupOrRestore(
+ mUserId,
+ 123,
+ true,
+ CURRENT_PASSWORD,
+ ENCRYPTION_PASSWORD,
+ mFullBackupRestoreObserverMock);
}
@Test
public void acknowledgeFullBackupOrRestore_forwarded() throws RemoteException {
+ TrampolineTestable.sCallingUserId = mUserId;
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
mTrampoline.acknowledgeFullBackupOrRestore(123, true, CURRENT_PASSWORD, ENCRYPTION_PASSWORD,
mFullBackupRestoreObserverMock);
- verify(mBackupManagerServiceMock).acknowledgeAdbBackupOrRestore(123, true, CURRENT_PASSWORD,
- ENCRYPTION_PASSWORD, mFullBackupRestoreObserverMock);
+
+ verify(mBackupManagerServiceMock)
+ .acknowledgeAdbBackupOrRestore(
+ mUserId,
+ 123,
+ true,
+ CURRENT_PASSWORD,
+ ENCRYPTION_PASSWORD,
+ mFullBackupRestoreObserverMock);
}
@Test
@@ -626,22 +661,21 @@ public class TrampolineTest {
@Test
public void getCurrentTransportForUser_forwarded() throws RemoteException {
- when(mBackupManagerServiceMock.getCurrentTransport()).thenReturn(TRANSPORT_NAME);
+ when(mBackupManagerServiceMock.getCurrentTransport(mUserId)).thenReturn(TRANSPORT_NAME);
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
assertEquals(TRANSPORT_NAME, mTrampoline.getCurrentTransportForUser(mUserId));
-
- verify(mBackupManagerServiceMock).getCurrentTransport();
+ verify(mBackupManagerServiceMock).getCurrentTransport(mUserId);
}
@Test
public void getCurrentTransport_forwarded() throws RemoteException {
- when(mBackupManagerServiceMock.getCurrentTransport()).thenReturn(TRANSPORT_NAME);
-
+ TrampolineTestable.sCallingUserId = mUserId;
+ when(mBackupManagerServiceMock.getCurrentTransport(mUserId)).thenReturn(TRANSPORT_NAME);
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
assertEquals(TRANSPORT_NAME, mTrampoline.getCurrentTransport());
- verify(mBackupManagerServiceMock).getCurrentTransport();
+ verify(mBackupManagerServiceMock).getCurrentTransport(mUserId);
}
@Test
@@ -652,21 +686,22 @@ public class TrampolineTest {
@Test
public void listAllTransportsForUser_forwarded() throws RemoteException {
- when(mBackupManagerServiceMock.listAllTransports()).thenReturn(TRANSPORTS);
+ when(mBackupManagerServiceMock.listAllTransports(mUserId)).thenReturn(TRANSPORTS);
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
assertEquals(TRANSPORTS, mTrampoline.listAllTransportsForUser(mUserId));
- verify(mBackupManagerServiceMock).listAllTransports();
+ verify(mBackupManagerServiceMock).listAllTransports(mUserId);
}
@Test
public void listAllTransports_forwarded() throws RemoteException {
- when(mBackupManagerServiceMock.listAllTransports()).thenReturn(TRANSPORTS);
-
+ TrampolineTestable.sCallingUserId = mUserId;
+ when(mBackupManagerServiceMock.listAllTransports(mUserId)).thenReturn(TRANSPORTS);
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
assertEquals(TRANSPORTS, mTrampoline.listAllTransports());
- verify(mBackupManagerServiceMock).listAllTransports();
+ verify(mBackupManagerServiceMock).listAllTransports(mUserId);
}
@Test
@@ -678,12 +713,12 @@ public class TrampolineTest {
@Test
public void listAllTransportComponentsForUser_forwarded() throws RemoteException {
- when(mBackupManagerServiceMock.listAllTransportComponents()).thenReturn(
+ when(mBackupManagerServiceMock.listAllTransportComponents(mUserId)).thenReturn(
TRANSPORT_COMPONENTS);
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
assertEquals(TRANSPORT_COMPONENTS, mTrampoline.listAllTransportComponentsForUser(mUserId));
- verify(mBackupManagerServiceMock).listAllTransportComponents();
+ verify(mBackupManagerServiceMock).listAllTransportComponents(mUserId);
}
@Test
@@ -730,8 +765,15 @@ public class TrampolineTest {
null,
"Data Management");
- verify(mBackupManagerServiceMock).updateTransportAttributes(TRANSPORT_COMPONENT_NAME,
- TRANSPORT_NAME, null, "Transport Destination", null, "Data Management");
+ verify(mBackupManagerServiceMock)
+ .updateTransportAttributes(
+ mUserId,
+ TRANSPORT_COMPONENT_NAME,
+ TRANSPORT_NAME,
+ null,
+ "Transport Destination",
+ null,
+ "Data Management");
}
@Test
@@ -746,14 +788,17 @@ public class TrampolineTest {
mTrampoline.selectBackupTransportForUser(mUserId, TRANSPORT_NAME);
- verify(mBackupManagerServiceMock).selectBackupTransport(TRANSPORT_NAME);
+ verify(mBackupManagerServiceMock).selectBackupTransport(mUserId, TRANSPORT_NAME);
}
@Test
public void selectBackupTransport_forwarded() throws RemoteException {
+ TrampolineTestable.sCallingUserId = mUserId;
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
mTrampoline.selectBackupTransport(TRANSPORT_NAME);
- verify(mBackupManagerServiceMock).selectBackupTransport(TRANSPORT_NAME);
+
+ verify(mBackupManagerServiceMock).selectBackupTransport(mUserId, TRANSPORT_NAME);
}
@Test
@@ -829,8 +874,8 @@ public class TrampolineTest {
mTrampoline.selectBackupTransportAsyncForUser(mUserId, TRANSPORT_COMPONENT_NAME, null);
- verify(mBackupManagerServiceMock).selectBackupTransportAsync(TRANSPORT_COMPONENT_NAME,
- null);
+ verify(mBackupManagerServiceMock)
+ .selectBackupTransportAsync(mUserId, TRANSPORT_COMPONENT_NAME, null);
}
@Test
@@ -842,25 +887,26 @@ public class TrampolineTest {
@Test
public void getConfigurationIntentForUser_forwarded() throws RemoteException {
Intent configurationIntentStub = new Intent();
- when(mBackupManagerServiceMock.getConfigurationIntent(TRANSPORT_NAME)).thenReturn(
+ when(mBackupManagerServiceMock.getConfigurationIntent(mUserId, TRANSPORT_NAME)).thenReturn(
configurationIntentStub);
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
assertEquals(
configurationIntentStub,
mTrampoline.getConfigurationIntentForUser(mUserId, TRANSPORT_NAME));
- verify(mBackupManagerServiceMock).getConfigurationIntent(TRANSPORT_NAME);
+ verify(mBackupManagerServiceMock).getConfigurationIntent(mUserId, TRANSPORT_NAME);
}
@Test
public void getConfigurationIntent_forwarded() throws RemoteException {
+ TrampolineTestable.sCallingUserId = mUserId;
Intent configurationIntentStub = new Intent();
- when(mBackupManagerServiceMock.getConfigurationIntent(TRANSPORT_NAME)).thenReturn(
+ when(mBackupManagerServiceMock.getConfigurationIntent(mUserId, TRANSPORT_NAME)).thenReturn(
configurationIntentStub);
-
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
assertEquals(configurationIntentStub, mTrampoline.getConfigurationIntent(TRANSPORT_NAME));
- verify(mBackupManagerServiceMock).getConfigurationIntent(TRANSPORT_NAME);
+ verify(mBackupManagerServiceMock).getConfigurationIntent(mUserId, TRANSPORT_NAME);
}
@Test
@@ -871,24 +917,25 @@ public class TrampolineTest {
@Test
public void getDestinationStringForUser_forwarded() throws RemoteException {
- when(mBackupManagerServiceMock.getDestinationString(TRANSPORT_NAME)).thenReturn(
+ when(mBackupManagerServiceMock.getDestinationString(mUserId, TRANSPORT_NAME)).thenReturn(
DESTINATION_STRING);
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
assertEquals(
DESTINATION_STRING,
mTrampoline.getDestinationStringForUser(mUserId, TRANSPORT_NAME));
- verify(mBackupManagerServiceMock).getDestinationString(TRANSPORT_NAME);
+ verify(mBackupManagerServiceMock).getDestinationString(mUserId, TRANSPORT_NAME);
}
@Test
public void getDestinationString_forwarded() throws RemoteException {
- when(mBackupManagerServiceMock.getDestinationString(TRANSPORT_NAME)).thenReturn(
+ TrampolineTestable.sCallingUserId = mUserId;
+ when(mBackupManagerServiceMock.getDestinationString(mUserId, TRANSPORT_NAME)).thenReturn(
DESTINATION_STRING);
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
assertEquals(DESTINATION_STRING, mTrampoline.getDestinationString(TRANSPORT_NAME));
- verify(mBackupManagerServiceMock).getDestinationString(TRANSPORT_NAME);
+ verify(mBackupManagerServiceMock).getDestinationString(mUserId, TRANSPORT_NAME);
}
@Test
@@ -900,25 +947,26 @@ public class TrampolineTest {
@Test
public void getDataManagementIntentForUser_forwarded() throws RemoteException {
Intent dataManagementIntent = new Intent();
- when(mBackupManagerServiceMock.getDataManagementIntent(TRANSPORT_NAME)).thenReturn(
+ when(mBackupManagerServiceMock.getDataManagementIntent(mUserId, TRANSPORT_NAME)).thenReturn(
dataManagementIntent);
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
assertEquals(
dataManagementIntent,
mTrampoline.getDataManagementIntentForUser(mUserId, TRANSPORT_NAME));
- verify(mBackupManagerServiceMock).getDataManagementIntent(TRANSPORT_NAME);
+ verify(mBackupManagerServiceMock).getDataManagementIntent(mUserId, TRANSPORT_NAME);
}
@Test
public void getDataManagementIntent_forwarded() throws RemoteException {
+ TrampolineTestable.sCallingUserId = mUserId;
Intent dataManagementIntent = new Intent();
- when(mBackupManagerServiceMock.getDataManagementIntent(TRANSPORT_NAME)).thenReturn(
+ when(mBackupManagerServiceMock.getDataManagementIntent(mUserId, TRANSPORT_NAME)).thenReturn(
dataManagementIntent);
-
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
assertEquals(dataManagementIntent, mTrampoline.getDataManagementIntent(TRANSPORT_NAME));
- verify(mBackupManagerServiceMock).getDataManagementIntent(TRANSPORT_NAME);
+ verify(mBackupManagerServiceMock).getDataManagementIntent(mUserId, TRANSPORT_NAME);
}
@Test
@@ -929,24 +977,25 @@ public class TrampolineTest {
@Test
public void getDataManagementLabelForUser_forwarded() throws RemoteException {
- when(mBackupManagerServiceMock.getDataManagementLabel(TRANSPORT_NAME)).thenReturn(
+ when(mBackupManagerServiceMock.getDataManagementLabel(mUserId, 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);
+ verify(mBackupManagerServiceMock).getDataManagementLabel(mUserId, TRANSPORT_NAME);
}
@Test
public void getDataManagementLabel_forwarded() throws RemoteException {
- when(mBackupManagerServiceMock.getDataManagementLabel(TRANSPORT_NAME)).thenReturn(
+ TrampolineTestable.sCallingUserId = mUserId;
+ when(mBackupManagerServiceMock.getDataManagementLabel(mUserId, TRANSPORT_NAME)).thenReturn(
DATA_MANAGEMENT_LABEL);
-
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
assertEquals(DATA_MANAGEMENT_LABEL, mTrampoline.getDataManagementLabel(TRANSPORT_NAME));
- verify(mBackupManagerServiceMock).getDataManagementLabel(TRANSPORT_NAME);
+ verify(mBackupManagerServiceMock).getDataManagementLabel(mUserId, TRANSPORT_NAME);
}
@Test
@@ -961,7 +1010,8 @@ public class TrampolineTest {
mTrampoline.beginRestoreSessionForUser(mUserId, PACKAGE_NAME, TRANSPORT_NAME);
- verify(mBackupManagerServiceMock).beginRestoreSession(PACKAGE_NAME, TRANSPORT_NAME);
+ verify(mBackupManagerServiceMock)
+ .beginRestoreSession(mUserId, PACKAGE_NAME, TRANSPORT_NAME);
}
@Test
@@ -972,9 +1022,12 @@ public class TrampolineTest {
@Test
public void opComplete_forwarded() throws RemoteException {
+ TrampolineTestable.sCallingUserId = mUserId;
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
+
mTrampoline.opComplete(1, 2);
- verify(mBackupManagerServiceMock).opComplete(1, 2);
+
+ verify(mBackupManagerServiceMock).opComplete(mUserId, 1, 2);
}
@Test
@@ -986,11 +1039,12 @@ public class TrampolineTest {
@Test
public void getAvailableRestoreTokenForUser_forwarded() throws RemoteException {
- when(mBackupManagerServiceMock.getAvailableRestoreToken(PACKAGE_NAME)).thenReturn(123L);
+ when(mBackupManagerServiceMock.getAvailableRestoreToken(mUserId, PACKAGE_NAME))
+ .thenReturn(123L);
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
assertEquals(123, mTrampoline.getAvailableRestoreTokenForUser(mUserId, PACKAGE_NAME));
- verify(mBackupManagerServiceMock).getAvailableRestoreToken(PACKAGE_NAME);
+ verify(mBackupManagerServiceMock).getAvailableRestoreToken(mUserId, PACKAGE_NAME);
}
@Test
@@ -1002,11 +1056,12 @@ public class TrampolineTest {
@Test
public void isAppEligibleForBackupForUser_forwarded() throws RemoteException {
- when(mBackupManagerServiceMock.isAppEligibleForBackup(PACKAGE_NAME)).thenReturn(true);
+ when(mBackupManagerServiceMock.isAppEligibleForBackup(mUserId, PACKAGE_NAME))
+ .thenReturn(true);
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
assertTrue(mTrampoline.isAppEligibleForBackupForUser(mUserId, PACKAGE_NAME));
- verify(mBackupManagerServiceMock).isAppEligibleForBackup(PACKAGE_NAME);
+ verify(mBackupManagerServiceMock).isAppEligibleForBackup(mUserId, PACKAGE_NAME);
}
@Test