[Multi-user] Clean up backup service creation and disable
Part of prep to make BMS multi-user aware. Current disable logic: - Trampoline is a proxy to BMS that enforces system- and policy-imposed disabling of the backup service (user-configurable disabling is in BMS). - Backup service can be disabled by system property = permanent disable. - Backup service can be disabled by a privileged caller like Device Policy Manager = temporary disable. In multi-user context: - The system user is the main actor in creation and disabling of the backup service. - BMS is only created when the system user is unlocked -> system user will always be unlocked first and is always running. - Device Policy Manager acts on the system user and shuts down backup mechanism for the whole device -> disable for system user disables for all users. - Non-system users have no impact on the creation/disabling of the backup service. This CL: - Clean up and document the above logic. - Move synchronization on backup suppress file from 'this' to private lock. Bug: 118520567 Test: 1) atest TrampolineTest 2) atest DevicePolicyManagerTest 3) Manual: - Before unlocking system user > service not started - Unlock system user > service started Change-Id: I207858bcfd1e0b9de43291bec178066b59c3a7cb
This commit is contained in:
@@ -591,15 +591,15 @@ public class BackupManagerService {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Backup enable apparently not migrated");
|
||||
}
|
||||
final ContentResolver r = sInstance.mContext.getContentResolver();
|
||||
final int enableState = Settings.Secure.getIntForUser(r,
|
||||
ContentResolver resolver = sInstance.getContext().getContentResolver();
|
||||
int enableState = Settings.Secure.getIntForUser(resolver,
|
||||
Settings.Secure.BACKUP_ENABLED, -1, UserHandle.USER_SYSTEM);
|
||||
if (enableState >= 0) {
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "Migrating enable state " + (enableState != 0));
|
||||
}
|
||||
writeBackupEnableState(enableState != 0, UserHandle.USER_SYSTEM);
|
||||
Settings.Secure.putStringForUser(r,
|
||||
Settings.Secure.putStringForUser(resolver,
|
||||
Settings.Secure.BACKUP_ENABLED, null, UserHandle.USER_SYSTEM);
|
||||
} else {
|
||||
if (DEBUG) {
|
||||
@@ -2790,8 +2790,8 @@ public class BackupManagerService {
|
||||
Slog.e(TAG, "Unable to record backup enable state; reverting to disabled: "
|
||||
+ e.getMessage());
|
||||
|
||||
final ContentResolver r = sInstance.mContext.getContentResolver();
|
||||
Settings.Secure.putStringForUser(r,
|
||||
ContentResolver resolver = sInstance.getContext().getContentResolver();
|
||||
Settings.Secure.putStringForUser(resolver,
|
||||
Settings.Secure.BACKUP_ENABLED, null, userId);
|
||||
enableFile.delete();
|
||||
stage.delete();
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package com.android.server.backup;
|
||||
|
||||
import static com.android.server.backup.BackupManagerService.TAG;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.backup.BackupManager;
|
||||
import android.app.backup.IBackupManager;
|
||||
import android.app.backup.IBackupManagerMonitor;
|
||||
@@ -39,44 +42,52 @@ import android.os.SystemProperties;
|
||||
import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.util.DumpUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
|
||||
/**
|
||||
* A proxy to BackupManagerService implementation.
|
||||
*
|
||||
* This is an external interface to the BackupManagerService which is being accessed via published
|
||||
* binder (see BackupManagerService$Lifecycle). This lets us turn down the heavy implementation
|
||||
* object on the fly without disturbing binders that have been cached somewhere in the system.
|
||||
* <p>This is an external interface to the BackupManagerService which is being accessed via
|
||||
* published binder (see BackupManagerService$Lifecycle). This lets us turn down the heavy
|
||||
* implementation object on the fly without disturbing binders that have been cached somewhere in
|
||||
* the system.
|
||||
*
|
||||
* This is where it is decided whether backup subsystem is available. It can be disabled with the
|
||||
* following two methods:
|
||||
* <p>Trampoline determines whether the backup service is available. It can be disabled in the
|
||||
* following two ways:
|
||||
*
|
||||
* <ul>
|
||||
* <li> Temporarily - create a file named Trampoline.BACKUP_SUPPRESS_FILENAME, or
|
||||
* <li> Product level - set Trampoline.BACKUP_DISABLE_PROPERTY system property to true.
|
||||
* <li>Temporary - create the file {@link #BACKUP_SUPPRESS_FILENAME}, or
|
||||
* <li>Permanent - set the system property {@link #BACKUP_DISABLE_PROPERTY} to true.
|
||||
* </ul>
|
||||
*
|
||||
* Temporary disabling is controlled by {@link #setBackupServiceActive(int, boolean)} through
|
||||
* privileged callers (currently {@link DevicePolicyManager}). This is called on {@link
|
||||
* UserHandle#USER_SYSTEM} and disables backup for all users.
|
||||
*
|
||||
* <p>Creation of the backup service is done when {@link UserHandle#USER_SYSTEM} is unlocked. The
|
||||
* system user is unlocked before any other users.
|
||||
*/
|
||||
public class Trampoline extends IBackupManager.Stub {
|
||||
static final String TAG = "BackupManagerService";
|
||||
|
||||
// When this file is present, the backup service is inactive
|
||||
// When this file is present, the backup service is inactive.
|
||||
private static final String BACKUP_SUPPRESS_FILENAME = "backup-suppress";
|
||||
|
||||
// Product-level suppression of backup/restore
|
||||
// Product-level suppression of backup/restore.
|
||||
private static final String BACKUP_DISABLE_PROPERTY = "ro.backup.disable";
|
||||
|
||||
final Context mContext;
|
||||
private final File mSuppressFile; // existence testing & creating synchronized on 'this'
|
||||
private final boolean mGlobalDisable;
|
||||
private volatile BackupManagerService mService;
|
||||
private final Context mContext;
|
||||
|
||||
@GuardedBy("mStateLock")
|
||||
private final File mSuppressFile;
|
||||
|
||||
private final boolean mGlobalDisable;
|
||||
private final Object mStateLock = new Object();
|
||||
|
||||
private volatile BackupManagerService mService;
|
||||
private HandlerThread mHandlerThread;
|
||||
|
||||
public Trampoline(Context context) {
|
||||
@@ -99,78 +110,100 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
BACKUP_SUPPRESS_FILENAME);
|
||||
}
|
||||
|
||||
protected Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
protected BackupManagerService createBackupManagerService() {
|
||||
return BackupManagerService.create(mContext, this, mHandlerThread);
|
||||
}
|
||||
|
||||
// internal control API
|
||||
public void initialize(final int whichUser) {
|
||||
// Note that only the owner user is currently involved in backup/restore
|
||||
// TODO: http://b/22388012
|
||||
if (whichUser == UserHandle.USER_SYSTEM) {
|
||||
// Does this product support backup/restore at all?
|
||||
if (mGlobalDisable) {
|
||||
Slog.i(TAG, "Backup/restore not supported");
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Initialize {@link BackupManagerService} if the backup service is not disabled. Only the
|
||||
* system user can initialize the service.
|
||||
*/
|
||||
/* package */ void initializeService(int userId) {
|
||||
if (mGlobalDisable) {
|
||||
Slog.i(TAG, "Backup service not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (!mSuppressFile.exists()) {
|
||||
mService = createBackupManagerService();
|
||||
} else {
|
||||
Slog.i(TAG, "Backup inactive in user " + whichUser);
|
||||
}
|
||||
if (userId != UserHandle.USER_SYSTEM) {
|
||||
Slog.i(TAG, "Cannot initialize backup service for non-system user: " + userId);
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (mStateLock) {
|
||||
if (!mSuppressFile.exists()) {
|
||||
mService = createBackupManagerService();
|
||||
} else {
|
||||
Slog.i(TAG, "Backup service inactive");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from {@link BackupManagerService$Lifecycle} when the system user is unlocked. Attempts
|
||||
* to initialize {@link BackupManagerService} and set backup state for the system user.
|
||||
*
|
||||
* @see BackupManagerService#unlockSystemUser()
|
||||
*/
|
||||
void unlockSystemUser() {
|
||||
mHandlerThread = new HandlerThread("backup", Process.THREAD_PRIORITY_BACKGROUND);
|
||||
mHandlerThread.start();
|
||||
|
||||
Handler h = new Handler(mHandlerThread.getLooper());
|
||||
h.post(() -> {
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup init");
|
||||
initialize(UserHandle.USER_SYSTEM);
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
h.post(
|
||||
() -> {
|
||||
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup init");
|
||||
initializeService(UserHandle.USER_SYSTEM);
|
||||
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
|
||||
|
||||
BackupManagerService svc = mService;
|
||||
Slog.i(TAG, "Unlocking system user; mService=" + mService);
|
||||
if (svc != null) {
|
||||
svc.unlockSystemUser();
|
||||
}
|
||||
});
|
||||
BackupManagerService service = mService;
|
||||
if (service != null) {
|
||||
Slog.i(TAG, "Unlocking system user");
|
||||
service.unlockSystemUser();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setBackupServiceActive(final int userHandle, boolean makeActive) {
|
||||
// Only the DPM should be changing the active state of backup
|
||||
final int caller = binderGetCallingUid();
|
||||
if (caller != Process.SYSTEM_UID
|
||||
&& caller != Process.ROOT_UID) {
|
||||
/**
|
||||
* Only privileged callers should be changing the backup state. This method only acts on {@link
|
||||
* UserHandle#USER_SYSTEM} and is a no-op if passed non-system users. Deactivating backup in the
|
||||
* system user also deactivates backup in all users.
|
||||
*/
|
||||
public void setBackupServiceActive(int userId, boolean makeActive) {
|
||||
int caller = binderGetCallingUid();
|
||||
if (caller != Process.SYSTEM_UID && caller != Process.ROOT_UID) {
|
||||
throw new SecurityException("No permission to configure backup activity");
|
||||
}
|
||||
|
||||
if (mGlobalDisable) {
|
||||
Slog.i(TAG, "Backup/restore not supported");
|
||||
Slog.i(TAG, "Backup service not supported");
|
||||
return;
|
||||
}
|
||||
// TODO: http://b/22388012
|
||||
if (userHandle == UserHandle.USER_SYSTEM) {
|
||||
synchronized (this) {
|
||||
if (makeActive != isBackupServiceActive(userHandle)) {
|
||||
Slog.i(TAG, "Making backup "
|
||||
+ (makeActive ? "" : "in") + "active in user " + userHandle);
|
||||
if (makeActive) {
|
||||
mService = createBackupManagerService();
|
||||
mSuppressFile.delete();
|
||||
} else {
|
||||
mService = null;
|
||||
try {
|
||||
mSuppressFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
Slog.e(TAG, "Unable to persist backup service inactivity");
|
||||
}
|
||||
}
|
||||
|
||||
if (userId != UserHandle.USER_SYSTEM) {
|
||||
Slog.i(TAG, "Cannot set backup service activity for non-system user: " + userId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (makeActive == isBackupServiceActive(userId)) {
|
||||
Slog.i(TAG, "No change in backup service activity");
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (mStateLock) {
|
||||
Slog.i(TAG, "Making backup " + (makeActive ? "" : "in") + "active");
|
||||
if (makeActive) {
|
||||
mService = createBackupManagerService();
|
||||
mSuppressFile.delete();
|
||||
} else {
|
||||
mService = null;
|
||||
try {
|
||||
mSuppressFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
Slog.e(TAG, "Unable to persist backup service inactivity");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,14 +214,15 @@ public class Trampoline extends IBackupManager.Stub {
|
||||
/**
|
||||
* Querying activity state of backup service. Calling this method before initialize yields
|
||||
* undefined result.
|
||||
* @param userHandle The user in which the activity state of backup service is queried.
|
||||
*
|
||||
* @param userId The user in which the activity state of backup service is queried.
|
||||
* @return true if the service is active.
|
||||
*/
|
||||
@Override
|
||||
public boolean isBackupServiceActive(final int userHandle) {
|
||||
public boolean isBackupServiceActive(int userId) {
|
||||
// TODO: http://b/22388012
|
||||
if (userHandle == UserHandle.USER_SYSTEM) {
|
||||
synchronized (this) {
|
||||
if (userId == UserHandle.USER_SYSTEM) {
|
||||
synchronized (mStateLock) {
|
||||
return mService != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,8 +118,8 @@ public class TrampolineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_forUserSystem_successfullyInitialized() {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
public void initializeService_forUserSystem_successfullyInitialized() {
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
assertTrue(mTrampoline.isBackupServiceActive(UserHandle.USER_SYSTEM));
|
||||
}
|
||||
@@ -127,29 +127,29 @@ public class TrampolineTest {
|
||||
// The BackupManagerService can only be initialized by USER_SYSTEM, so we check that if any
|
||||
// other user trying to initialize it leaves it non-active.
|
||||
@Test
|
||||
public void initialize_forNonUserSystem_nonInitialized() {
|
||||
mTrampoline.initialize(NON_USER_SYSTEM);
|
||||
public void initializeService_forNonUserSystem_nonInitialized() {
|
||||
mTrampoline.initializeService(NON_USER_SYSTEM);
|
||||
|
||||
assertFalse(mTrampoline.isBackupServiceActive(NON_USER_SYSTEM));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initialize_globallyDisabled_nonInitialized() {
|
||||
public void initializeService_globallyDisabled_nonInitialized() {
|
||||
TrampolineTestable.sBackupDisabled = true;
|
||||
|
||||
TrampolineTestable trampoline = new TrampolineTestable(mContextMock);
|
||||
trampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
trampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
assertFalse(trampoline.isBackupServiceActive(UserHandle.USER_SYSTEM));
|
||||
}
|
||||
|
||||
// Verify that BackupManagerService is not initialized if suppress file exists.
|
||||
@Test
|
||||
public void initialize_suppressFileExists_nonInitialized() {
|
||||
public void initializeService_suppressFileExists_nonInitialized() {
|
||||
when(mSuppressFileMock.exists()).thenReturn(true);
|
||||
|
||||
TrampolineTestable trampoline = new TrampolineTestable(mContextMock);
|
||||
trampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
trampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
assertFalse(trampoline.isBackupServiceActive(UserHandle.USER_SYSTEM));
|
||||
}
|
||||
@@ -229,7 +229,7 @@ public class TrampolineTest {
|
||||
@Test
|
||||
public void setBackupServiceActive_makeNonActive_serviceDeletedAndSuppressFileCreated()
|
||||
throws IOException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertTrue(mTrampoline.isBackupServiceActive(UserHandle.USER_SYSTEM));
|
||||
|
||||
mTrampoline.setBackupServiceActive(UserHandle.USER_SYSTEM, false);
|
||||
@@ -243,7 +243,7 @@ public class TrampolineTest {
|
||||
setBackupServiceActive_makeNonActive_serviceDeletedAndSuppressFileCreated_ioExceptionHandled()
|
||||
throws IOException {
|
||||
when(mSuppressFileMock.createNewFile()).thenThrow(new IOException());
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertTrue(mTrampoline.isBackupServiceActive(UserHandle.USER_SYSTEM));
|
||||
|
||||
mTrampoline.setBackupServiceActive(UserHandle.USER_SYSTEM, false);
|
||||
@@ -269,7 +269,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void dataChanged_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.dataChanged(PACKAGE_NAME);
|
||||
verify(mBackupManagerServiceMock).dataChanged(PACKAGE_NAME);
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void clearBackupData_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.clearBackupData(TRANSPORT_NAME, PACKAGE_NAME);
|
||||
verify(mBackupManagerServiceMock).clearBackupData(TRANSPORT_NAME, PACKAGE_NAME);
|
||||
}
|
||||
@@ -295,7 +295,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void agentConnected_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.agentConnected(PACKAGE_NAME, mAgentMock);
|
||||
verify(mBackupManagerServiceMock).agentConnected(PACKAGE_NAME, mAgentMock);
|
||||
}
|
||||
@@ -308,7 +308,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void agentDisconnected_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.agentDisconnected(PACKAGE_NAME);
|
||||
verify(mBackupManagerServiceMock).agentDisconnected(PACKAGE_NAME);
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void restoreAtInstall_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.restoreAtInstall(PACKAGE_NAME, 123);
|
||||
verify(mBackupManagerServiceMock).restoreAtInstall(PACKAGE_NAME, 123);
|
||||
}
|
||||
@@ -334,7 +334,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void setBackupEnabled_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.setBackupEnabled(true);
|
||||
verify(mBackupManagerServiceMock).setBackupEnabled(true);
|
||||
}
|
||||
@@ -347,7 +347,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void setAutoRestore_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.setAutoRestore(true);
|
||||
verify(mBackupManagerServiceMock).setAutoRestore(true);
|
||||
}
|
||||
@@ -360,7 +360,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void setBackupProvisioned_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.setBackupProvisioned(true);
|
||||
verify(mBackupManagerServiceMock).setBackupProvisioned(true);
|
||||
}
|
||||
@@ -373,7 +373,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void isBackupEnabled_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.isBackupEnabled();
|
||||
verify(mBackupManagerServiceMock).isBackupEnabled();
|
||||
}
|
||||
@@ -386,7 +386,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void setBackupPassword_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.setBackupPassword(CURRENT_PASSWORD, NEW_PASSWORD);
|
||||
verify(mBackupManagerServiceMock).setBackupPassword(CURRENT_PASSWORD, NEW_PASSWORD);
|
||||
}
|
||||
@@ -399,7 +399,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void hasBackupPassword_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.hasBackupPassword();
|
||||
verify(mBackupManagerServiceMock).hasBackupPassword();
|
||||
}
|
||||
@@ -412,7 +412,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void backupNow_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.backupNow();
|
||||
verify(mBackupManagerServiceMock).backupNow();
|
||||
}
|
||||
@@ -427,7 +427,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void adbBackup_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.adbBackup(mParcelFileDescriptorMock, true, true, true, true, true, true, true,
|
||||
true,
|
||||
PACKAGE_NAMES);
|
||||
@@ -444,7 +444,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void fullTransportBackup_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.fullTransportBackup(PACKAGE_NAMES);
|
||||
verify(mBackupManagerServiceMock).fullTransportBackup(PACKAGE_NAMES);
|
||||
}
|
||||
@@ -457,7 +457,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void adbRestore_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.adbRestore(mParcelFileDescriptorMock);
|
||||
verify(mBackupManagerServiceMock).adbRestore(mParcelFileDescriptorMock);
|
||||
}
|
||||
@@ -472,7 +472,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void acknowledgeFullBackupOrRestore_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.acknowledgeFullBackupOrRestore(123, true, CURRENT_PASSWORD, ENCRYPTION_PASSWORD,
|
||||
mFullBackupRestoreObserverMock);
|
||||
verify(mBackupManagerServiceMock).acknowledgeAdbBackupOrRestore(123, true, CURRENT_PASSWORD,
|
||||
@@ -489,7 +489,7 @@ public class TrampolineTest {
|
||||
public void getCurrentTransport_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getCurrentTransport()).thenReturn(TRANSPORT_NAME);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
assertEquals(TRANSPORT_NAME, mTrampoline.getCurrentTransport());
|
||||
verify(mBackupManagerServiceMock).getCurrentTransport();
|
||||
@@ -505,7 +505,7 @@ public class TrampolineTest {
|
||||
public void listAllTransports_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.listAllTransports()).thenReturn(TRANSPORTS);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertEquals(TRANSPORTS, mTrampoline.listAllTransports());
|
||||
verify(mBackupManagerServiceMock).listAllTransports();
|
||||
}
|
||||
@@ -521,7 +521,7 @@ public class TrampolineTest {
|
||||
when(mBackupManagerServiceMock.listAllTransportComponents()).thenReturn(
|
||||
TRANSPORT_COMPONENTS);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertEquals(TRANSPORT_COMPONENTS, mTrampoline.listAllTransportComponents());
|
||||
verify(mBackupManagerServiceMock).listAllTransportComponents();
|
||||
}
|
||||
@@ -536,7 +536,7 @@ public class TrampolineTest {
|
||||
public void getTransportWhitelist_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getTransportWhitelist()).thenReturn(TRANSPORTS);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertEquals(TRANSPORTS, mTrampoline.getTransportWhitelist());
|
||||
verify(mBackupManagerServiceMock).getTransportWhitelist();
|
||||
}
|
||||
@@ -552,7 +552,7 @@ public class TrampolineTest {
|
||||
public void describeTransport_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getTransportWhitelist()).thenReturn(TRANSPORTS);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.updateTransportAttributes(TRANSPORT_COMPONENT_NAME, TRANSPORT_NAME, null,
|
||||
"Transport Destination", null, "Data Management");
|
||||
verify(mBackupManagerServiceMock).updateTransportAttributes(TRANSPORT_COMPONENT_NAME,
|
||||
@@ -567,7 +567,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void selectBackupTransport_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.selectBackupTransport(TRANSPORT_NAME);
|
||||
verify(mBackupManagerServiceMock).selectBackupTransport(TRANSPORT_NAME);
|
||||
}
|
||||
@@ -634,7 +634,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void selectBackupTransportAsync_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.selectBackupTransportAsync(TRANSPORT_COMPONENT_NAME, null);
|
||||
verify(mBackupManagerServiceMock).selectBackupTransportAsync(TRANSPORT_COMPONENT_NAME,
|
||||
null);
|
||||
@@ -652,7 +652,7 @@ public class TrampolineTest {
|
||||
when(mBackupManagerServiceMock.getConfigurationIntent(TRANSPORT_NAME)).thenReturn(
|
||||
configurationIntentStub);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertEquals(configurationIntentStub, mTrampoline.getConfigurationIntent(TRANSPORT_NAME));
|
||||
verify(mBackupManagerServiceMock).getConfigurationIntent(TRANSPORT_NAME);
|
||||
}
|
||||
@@ -668,7 +668,7 @@ public class TrampolineTest {
|
||||
when(mBackupManagerServiceMock.getDestinationString(TRANSPORT_NAME)).thenReturn(
|
||||
DESTINATION_STRING);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertEquals(DESTINATION_STRING, mTrampoline.getDestinationString(TRANSPORT_NAME));
|
||||
verify(mBackupManagerServiceMock).getDestinationString(TRANSPORT_NAME);
|
||||
}
|
||||
@@ -685,7 +685,7 @@ public class TrampolineTest {
|
||||
when(mBackupManagerServiceMock.getDataManagementIntent(TRANSPORT_NAME)).thenReturn(
|
||||
dataManagementIntent);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertEquals(dataManagementIntent, mTrampoline.getDataManagementIntent(TRANSPORT_NAME));
|
||||
verify(mBackupManagerServiceMock).getDataManagementIntent(TRANSPORT_NAME);
|
||||
}
|
||||
@@ -701,7 +701,7 @@ public class TrampolineTest {
|
||||
when(mBackupManagerServiceMock.getDataManagementLabel(TRANSPORT_NAME)).thenReturn(
|
||||
DATA_MANAGEMENT_LABEL);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertEquals(DATA_MANAGEMENT_LABEL, mTrampoline.getDataManagementLabel(TRANSPORT_NAME));
|
||||
verify(mBackupManagerServiceMock).getDataManagementLabel(TRANSPORT_NAME);
|
||||
}
|
||||
@@ -714,7 +714,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void beginRestoreSession_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.beginRestoreSession(PACKAGE_NAME, TRANSPORT_NAME);
|
||||
verify(mBackupManagerServiceMock).beginRestoreSession(PACKAGE_NAME, TRANSPORT_NAME);
|
||||
}
|
||||
@@ -727,7 +727,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void opComplete_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.opComplete(1, 2);
|
||||
verify(mBackupManagerServiceMock).opComplete(1, 2);
|
||||
}
|
||||
@@ -742,7 +742,7 @@ public class TrampolineTest {
|
||||
public void getAvailableRestoreToken_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.getAvailableRestoreToken(PACKAGE_NAME)).thenReturn(123L);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertEquals(123, mTrampoline.getAvailableRestoreToken(PACKAGE_NAME));
|
||||
verify(mBackupManagerServiceMock).getAvailableRestoreToken(PACKAGE_NAME);
|
||||
}
|
||||
@@ -757,7 +757,7 @@ public class TrampolineTest {
|
||||
public void isAppEligibleForBackup_forwarded() throws RemoteException {
|
||||
when(mBackupManagerServiceMock.isAppEligibleForBackup(PACKAGE_NAME)).thenReturn(true);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertTrue(mTrampoline.isAppEligibleForBackup(PACKAGE_NAME));
|
||||
verify(mBackupManagerServiceMock).isAppEligibleForBackup(PACKAGE_NAME);
|
||||
}
|
||||
@@ -774,7 +774,7 @@ public class TrampolineTest {
|
||||
when(mBackupManagerServiceMock.requestBackup(PACKAGE_NAMES, mBackupObserverMock,
|
||||
mBackupManagerMonitorMock, 123)).thenReturn(456);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertEquals(456, mTrampoline.requestBackup(PACKAGE_NAMES, mBackupObserverMock,
|
||||
mBackupManagerMonitorMock, 123));
|
||||
verify(mBackupManagerServiceMock).requestBackup(PACKAGE_NAMES, mBackupObserverMock,
|
||||
@@ -789,7 +789,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void cancelBackups_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.cancelBackups();
|
||||
verify(mBackupManagerServiceMock).cancelBackups();
|
||||
}
|
||||
@@ -805,7 +805,7 @@ public class TrampolineTest {
|
||||
FullBackupJob fullBackupJob = new FullBackupJob();
|
||||
when(mBackupManagerServiceMock.beginFullBackup(fullBackupJob)).thenReturn(true);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
assertTrue(mTrampoline.beginFullBackup(fullBackupJob));
|
||||
verify(mBackupManagerServiceMock).beginFullBackup(fullBackupJob);
|
||||
}
|
||||
@@ -818,7 +818,7 @@ public class TrampolineTest {
|
||||
|
||||
@Test
|
||||
public void endFullBackup_forwarded() throws RemoteException {
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.endFullBackup();
|
||||
verify(mBackupManagerServiceMock).endFullBackup();
|
||||
}
|
||||
@@ -829,7 +829,7 @@ public class TrampolineTest {
|
||||
android.Manifest.permission.DUMP)).thenReturn(
|
||||
PackageManager.PERMISSION_DENIED);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
mTrampoline.dump(mFileDescriptorStub, mPrintWriterMock, new String[0]);
|
||||
|
||||
@@ -853,7 +853,7 @@ public class TrampolineTest {
|
||||
android.Manifest.permission.DUMP)).thenReturn(
|
||||
PackageManager.PERMISSION_GRANTED);
|
||||
|
||||
mTrampoline.initialize(UserHandle.USER_SYSTEM);
|
||||
mTrampoline.initializeService(UserHandle.USER_SYSTEM);
|
||||
|
||||
mTrampoline.dump(mFileDescriptorStub, mPrintWriterMock, null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user