Loading services/backup/java/com/android/server/backup/BackupManagerService.java +13 −22 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import com.android.server.LocalServices; import com.android.server.SystemConfig; import com.android.server.SystemService; import com.android.server.backup.utils.RandomAccessFileUtils; import com.android.server.pm.UserManagerInternal; import java.io.File; import java.io.FileDescriptor; Loading Loading @@ -129,7 +130,7 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM } private final Context mContext; private final UserManager mUserManager; private final UserManagerInternal mUserManagerInternal; private final Object mLock = new Object(); Loading Loading @@ -179,14 +180,14 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM new HandlerThread(BACKUP_THREAD, Process.THREAD_PRIORITY_BACKGROUND); handlerThread.start(); mHandler = new Handler(handlerThread.getLooper()); mUserManager = UserManager.get(context); mUserManagerInternal = LocalServices.getService(UserManagerInternal.class); mUserServices = new SparseArray<>(); Set<ComponentName> transportWhitelist = SystemConfig.getInstance().getBackupTransportWhitelist(); mTransportWhitelist = (transportWhitelist == null) ? emptySet() : transportWhitelist; mContext.registerReceiver( mUserRemovedReceiver, new IntentFilter(Intent.ACTION_USER_REMOVED)); mDidMainUserExistAtBoot = getUserManager().getMainUser() != null; mDidMainUserExistAtBoot = mUserManagerInternal.getMainUserId() != UserHandle.USER_NULL; if (!mDidMainUserExistAtBoot) { // This might happen on the first boot if BMS starts before the main user is created. Slog.d(TAG, "Main user does not exist yet"); Loading Loading @@ -362,13 +363,13 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM } // Returns false if the user is not a full user. if (!getUserManager().getUserInfo(userId).isFull()) { if (!mUserManagerInternal.getUserInfo(userId).isFull()) { return false; } // Returns true for the main user. UserHandle mainUser = getUserManager().getMainUser(); if (mainUser != null && userId == mainUser.getIdentifier()) { int mainUserId = mUserManagerInternal.getMainUserId(); if (mainUserId != UserHandle.USER_NULL && userId == mainUserId) { return true; } Loading @@ -376,16 +377,6 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM return android.multiuser.Flags.backupActivatedForAllUsers(); } @VisibleForTesting protected Context getContext() { return mContext; } @VisibleForTesting protected UserManager getUserManager() { return mUserManager; } @VisibleForTesting protected void postToHandler(Runnable runnable) { mHandler.post(runnable); Loading Loading @@ -486,7 +477,7 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM private void enforcePermissionsOnUser(@UserIdInt int userId) throws SecurityException { boolean isRestrictedUser = userId == UserHandle.USER_SYSTEM || getUserManager().getUserInfo(userId).isManagedProfile(); || mUserManagerInternal.getUserInfo(userId).isManagedProfile(); if (isRestrictedUser) { int caller = binderGetCallingUid(); Loading Loading @@ -544,7 +535,7 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM // If the user is unlocked, we can start the backup service for it. Otherwise we // will start the service when the user is unlocked as part of its unlock callback. if (getUserManager().isUserUnlocked(userId)) { if (mUserManagerInternal.isUserUnlocked(userId)) { // Clear calling identity as initialization enforces the system identity but we // can be coming from shell. final long oldId = Binder.clearCallingIdentity(); Loading Loading @@ -1482,7 +1473,7 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM final int[] userIds; final long oldId = Binder.clearCallingIdentity(); try { userIds = getUserManager().getProfileIds(callingUserId, false); userIds = mUserManagerInternal.getProfileIds(callingUserId, false); } finally { Binder.restoreCallingIdentity(oldId); } Loading Loading @@ -1775,12 +1766,12 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM return; } UserHandle mainUser = getUserManager().getMainUser(); if (mainUser == null) { int mainUserId = mUserManagerInternal.getMainUserId(); if (mainUserId == UserHandle.USER_NULL) { return; } if (mainUser.getIdentifier() == UserHandle.USER_SYSTEM) { if (mainUserId == UserHandle.USER_SYSTEM) { return; } Loading services/robotests/backup/src/com/android/server/backup/BackupManagerServiceRoboTest.java +9 −8 Original line number Diff line number Diff line Loading @@ -49,18 +49,17 @@ import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.platform.test.annotations.Presubmit; import android.util.SparseArray; import com.android.server.LocalServices; import com.android.server.SystemService.TargetUser; import com.android.server.backup.testing.TransportData; import com.android.server.pm.UserManagerInternal; import com.android.server.testing.shadows.ShadowApplicationPackageManager; import com.android.server.testing.shadows.ShadowBinder; import com.android.server.testing.shadows.ShadowEnvironment; import com.android.server.testing.shadows.ShadowSystemServiceRegistry; import com.android.server.testing.shadows.ShadowUserManager; import org.junit.Before; import org.junit.Test; Loading @@ -70,7 +69,6 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.shadow.api.Shadow; import org.robolectric.shadows.ShadowContextWrapper; import java.io.File; Loading @@ -82,7 +80,6 @@ import java.io.IOException; shadows = { ShadowApplicationPackageManager.class, ShadowBinder.class, ShadowUserManager.class, ShadowEnvironment.class, ShadowSystemServiceRegistry.class }) Loading @@ -94,13 +91,14 @@ public class BackupManagerServiceRoboTest { private Context mContext; private ShadowContextWrapper mShadowContext; private ShadowUserManager mShadowUserManager; @UserIdInt private int mUserOneId; @UserIdInt private int mUserTwoId; @Mock private UserBackupManagerService mUserSystemService; @Mock private UserBackupManagerService mUserOneService; @Mock private BackupAgentConnectionManager mUserOneBackupAgentConnectionManager; @Mock private UserBackupManagerService mUserTwoService; @Mock private UserManagerInternal mUserManagerInternal; @Mock private UserInfo mUserInfoMock; /** Setup */ @Before Loading @@ -110,16 +108,19 @@ public class BackupManagerServiceRoboTest { Application application = RuntimeEnvironment.application; mContext = application; mShadowContext = shadowOf(application); mShadowUserManager = Shadow.extract(UserManager.get(application)); mUserOneId = UserHandle.USER_SYSTEM + 1; mUserTwoId = mUserOneId + 1; mShadowUserManager.addUser(mUserOneId, "mUserOneId", 0); mShadowUserManager.addUser(mUserTwoId, "mUserTwoId", 0); mShadowContext.grantPermissions(BACKUP); mShadowContext.grantPermissions(INTERACT_ACROSS_USERS_FULL); LocalServices.removeServiceForTest(UserManagerInternal.class); LocalServices.addService(UserManagerInternal.class, mUserManagerInternal); when(mUserManagerInternal.getUserInfo(mUserOneId)).thenReturn(mUserInfoMock); when(mUserManagerInternal.getUserInfo(mUserTwoId)).thenReturn(mUserInfoMock); when(mUserOneService.getBackupAgentConnectionManager()).thenReturn( mUserOneBackupAgentConnectionManager); Loading services/robotests/backup/src/com/android/server/backup/UserBackupManagerServiceTest.java +6 −2 Original line number Diff line number Diff line Loading @@ -54,17 +54,18 @@ import android.os.UserHandle; import android.platform.test.annotations.Presubmit; import android.provider.Settings; import com.android.server.LocalServices; import com.android.server.backup.testing.BackupManagerServiceTestUtils; import com.android.server.backup.testing.TransportData; import com.android.server.backup.testing.TransportTestUtils.TransportMock; import com.android.server.backup.transport.TransportNotRegisteredException; import com.android.server.pm.UserManagerInternal; import com.android.server.testing.shadows.ShadowApplicationPackageManager; import com.android.server.testing.shadows.ShadowBackupEligibilityRules; import com.android.server.testing.shadows.ShadowBinder; import com.android.server.testing.shadows.ShadowKeyValueBackupJob; import com.android.server.testing.shadows.ShadowKeyValueBackupTask; import com.android.server.testing.shadows.ShadowSystemServiceRegistry; import com.android.server.testing.shadows.ShadowUserManager; import org.junit.After; import org.junit.Before; Loading Loading @@ -99,7 +100,6 @@ import java.util.List; ShadowBackupEligibilityRules.class, ShadowApplicationPackageManager.class, ShadowSystemServiceRegistry.class, ShadowUserManager.class }) @Presubmit public class UserBackupManagerServiceTest { Loading @@ -109,6 +109,7 @@ public class UserBackupManagerServiceTest { private static final int USER_ID = 10; @Mock private TransportManager mTransportManager; @Mock private UserManagerInternal mUserManagerInternal; private HandlerThread mBackupThread; private ShadowLooper mShadowBackupLooper; private File mBaseStateDir; Loading Loading @@ -142,6 +143,9 @@ public class UserBackupManagerServiceTest { mContext = context; mShadowContext = shadowOf(context); LocalServices.removeServiceForTest(UserManagerInternal.class); LocalServices.addService(UserManagerInternal.class, mUserManagerInternal); File cacheDir = mContext.getCacheDir(); // Corresponds to /data/backup mBaseStateDir = new File(cacheDir, "base_state"); Loading services/robotests/backup/src/com/android/server/backup/internal/SetupObserverTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -25,15 +25,16 @@ import android.os.HandlerThread; import android.platform.test.annotations.Presubmit; import android.provider.Settings; import com.android.server.LocalServices; import com.android.server.backup.FullBackupJob; import com.android.server.backup.JobIdManager; import com.android.server.backup.KeyValueBackupJob; import com.android.server.backup.TransportManager; import com.android.server.backup.UserBackupManagerService; import com.android.server.backup.testing.BackupManagerServiceTestUtils; import com.android.server.pm.UserManagerInternal; import com.android.server.testing.shadows.ShadowApplicationPackageManager; import com.android.server.testing.shadows.ShadowSystemServiceRegistry; import com.android.server.testing.shadows.ShadowUserManager; import org.junit.Before; import org.junit.Test; Loading @@ -58,7 +59,6 @@ import java.io.File; ShadowApplicationPackageManager.class, ShadowJobScheduler.class, ShadowSystemServiceRegistry.class, ShadowUserManager.class }) @Presubmit public class SetupObserverTest { Loading @@ -66,6 +66,7 @@ public class SetupObserverTest { private static final int USER_ID = 10; @Mock private TransportManager mTransportManager; @Mock private UserManagerInternal mUserManagerInternal; private Context mContext; private UserBackupManagerService mUserBackupManagerService; Loading @@ -76,6 +77,8 @@ public class SetupObserverTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); LocalServices.removeServiceForTest(UserManagerInternal.class); LocalServices.addService(UserManagerInternal.class, mUserManagerInternal); mContext = RuntimeEnvironment.application; mHandlerThread = BackupManagerServiceTestUtils.startSilentBackupThread(TAG); mUserBackupManagerService = Loading services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -126,13 +126,13 @@ import com.android.server.backup.testing.TransportTestUtils; import com.android.server.backup.testing.TransportTestUtils.TransportMock; import com.android.server.backup.utils.BackupEligibilityRules; import com.android.server.backup.utils.BackupManagerMonitorEventSender; import com.android.server.pm.UserManagerInternal; import com.android.server.testing.shadows.FrameworkShadowLooper; import com.android.server.testing.shadows.ShadowApplicationPackageManager; import com.android.server.testing.shadows.ShadowBackupDataInput; import com.android.server.testing.shadows.ShadowBackupDataOutput; import com.android.server.testing.shadows.ShadowEventLog; import com.android.server.testing.shadows.ShadowSystemServiceRegistry; import com.android.server.testing.shadows.ShadowUserManager; import com.google.common.base.Charsets; import com.google.common.truth.IterableSubject; Loading Loading @@ -180,7 +180,6 @@ import java.util.stream.Stream; ShadowEventLog.class, ShadowQueuedWork.class, ShadowSystemServiceRegistry.class, ShadowUserManager.class }) @Presubmit public class KeyValueBackupTaskTest { Loading @@ -198,6 +197,7 @@ public class KeyValueBackupTaskTest { @Mock private OnTaskFinishedListener mListener; @Mock private PackageManagerInternal mPackageManagerInternal; @Mock private BackupAgentConnectionManager mBackupAgentConnectionManager; @Mock private UserManagerInternal mUserManagerInternal; private UserBackupManagerService mBackupManagerService; private TransportData mTransport; Loading Loading @@ -243,6 +243,9 @@ public class KeyValueBackupTaskTest { mWakeLock = spy(createBackupWakeLock(mApplication)); mBackupManager = spy(FakeIBackupManager.class); LocalServices.removeServiceForTest(UserManagerInternal.class); LocalServices.addService(UserManagerInternal.class, mUserManagerInternal); // Needed to be able to use a real BMS instead of a mock setUpBinderCallerAndApplicationAsSystem(mApplication); mBackupManagerService = Loading Loading
services/backup/java/com/android/server/backup/BackupManagerService.java +13 −22 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import com.android.server.LocalServices; import com.android.server.SystemConfig; import com.android.server.SystemService; import com.android.server.backup.utils.RandomAccessFileUtils; import com.android.server.pm.UserManagerInternal; import java.io.File; import java.io.FileDescriptor; Loading Loading @@ -129,7 +130,7 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM } private final Context mContext; private final UserManager mUserManager; private final UserManagerInternal mUserManagerInternal; private final Object mLock = new Object(); Loading Loading @@ -179,14 +180,14 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM new HandlerThread(BACKUP_THREAD, Process.THREAD_PRIORITY_BACKGROUND); handlerThread.start(); mHandler = new Handler(handlerThread.getLooper()); mUserManager = UserManager.get(context); mUserManagerInternal = LocalServices.getService(UserManagerInternal.class); mUserServices = new SparseArray<>(); Set<ComponentName> transportWhitelist = SystemConfig.getInstance().getBackupTransportWhitelist(); mTransportWhitelist = (transportWhitelist == null) ? emptySet() : transportWhitelist; mContext.registerReceiver( mUserRemovedReceiver, new IntentFilter(Intent.ACTION_USER_REMOVED)); mDidMainUserExistAtBoot = getUserManager().getMainUser() != null; mDidMainUserExistAtBoot = mUserManagerInternal.getMainUserId() != UserHandle.USER_NULL; if (!mDidMainUserExistAtBoot) { // This might happen on the first boot if BMS starts before the main user is created. Slog.d(TAG, "Main user does not exist yet"); Loading Loading @@ -362,13 +363,13 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM } // Returns false if the user is not a full user. if (!getUserManager().getUserInfo(userId).isFull()) { if (!mUserManagerInternal.getUserInfo(userId).isFull()) { return false; } // Returns true for the main user. UserHandle mainUser = getUserManager().getMainUser(); if (mainUser != null && userId == mainUser.getIdentifier()) { int mainUserId = mUserManagerInternal.getMainUserId(); if (mainUserId != UserHandle.USER_NULL && userId == mainUserId) { return true; } Loading @@ -376,16 +377,6 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM return android.multiuser.Flags.backupActivatedForAllUsers(); } @VisibleForTesting protected Context getContext() { return mContext; } @VisibleForTesting protected UserManager getUserManager() { return mUserManager; } @VisibleForTesting protected void postToHandler(Runnable runnable) { mHandler.post(runnable); Loading Loading @@ -486,7 +477,7 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM private void enforcePermissionsOnUser(@UserIdInt int userId) throws SecurityException { boolean isRestrictedUser = userId == UserHandle.USER_SYSTEM || getUserManager().getUserInfo(userId).isManagedProfile(); || mUserManagerInternal.getUserInfo(userId).isManagedProfile(); if (isRestrictedUser) { int caller = binderGetCallingUid(); Loading Loading @@ -544,7 +535,7 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM // If the user is unlocked, we can start the backup service for it. Otherwise we // will start the service when the user is unlocked as part of its unlock callback. if (getUserManager().isUserUnlocked(userId)) { if (mUserManagerInternal.isUserUnlocked(userId)) { // Clear calling identity as initialization enforces the system identity but we // can be coming from shell. final long oldId = Binder.clearCallingIdentity(); Loading Loading @@ -1482,7 +1473,7 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM final int[] userIds; final long oldId = Binder.clearCallingIdentity(); try { userIds = getUserManager().getProfileIds(callingUserId, false); userIds = mUserManagerInternal.getProfileIds(callingUserId, false); } finally { Binder.restoreCallingIdentity(oldId); } Loading Loading @@ -1775,12 +1766,12 @@ public class BackupManagerService extends IBackupManager.Stub implements BackupM return; } UserHandle mainUser = getUserManager().getMainUser(); if (mainUser == null) { int mainUserId = mUserManagerInternal.getMainUserId(); if (mainUserId == UserHandle.USER_NULL) { return; } if (mainUser.getIdentifier() == UserHandle.USER_SYSTEM) { if (mainUserId == UserHandle.USER_SYSTEM) { return; } Loading
services/robotests/backup/src/com/android/server/backup/BackupManagerServiceRoboTest.java +9 −8 Original line number Diff line number Diff line Loading @@ -49,18 +49,17 @@ import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.platform.test.annotations.Presubmit; import android.util.SparseArray; import com.android.server.LocalServices; import com.android.server.SystemService.TargetUser; import com.android.server.backup.testing.TransportData; import com.android.server.pm.UserManagerInternal; import com.android.server.testing.shadows.ShadowApplicationPackageManager; import com.android.server.testing.shadows.ShadowBinder; import com.android.server.testing.shadows.ShadowEnvironment; import com.android.server.testing.shadows.ShadowSystemServiceRegistry; import com.android.server.testing.shadows.ShadowUserManager; import org.junit.Before; import org.junit.Test; Loading @@ -70,7 +69,6 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.shadow.api.Shadow; import org.robolectric.shadows.ShadowContextWrapper; import java.io.File; Loading @@ -82,7 +80,6 @@ import java.io.IOException; shadows = { ShadowApplicationPackageManager.class, ShadowBinder.class, ShadowUserManager.class, ShadowEnvironment.class, ShadowSystemServiceRegistry.class }) Loading @@ -94,13 +91,14 @@ public class BackupManagerServiceRoboTest { private Context mContext; private ShadowContextWrapper mShadowContext; private ShadowUserManager mShadowUserManager; @UserIdInt private int mUserOneId; @UserIdInt private int mUserTwoId; @Mock private UserBackupManagerService mUserSystemService; @Mock private UserBackupManagerService mUserOneService; @Mock private BackupAgentConnectionManager mUserOneBackupAgentConnectionManager; @Mock private UserBackupManagerService mUserTwoService; @Mock private UserManagerInternal mUserManagerInternal; @Mock private UserInfo mUserInfoMock; /** Setup */ @Before Loading @@ -110,16 +108,19 @@ public class BackupManagerServiceRoboTest { Application application = RuntimeEnvironment.application; mContext = application; mShadowContext = shadowOf(application); mShadowUserManager = Shadow.extract(UserManager.get(application)); mUserOneId = UserHandle.USER_SYSTEM + 1; mUserTwoId = mUserOneId + 1; mShadowUserManager.addUser(mUserOneId, "mUserOneId", 0); mShadowUserManager.addUser(mUserTwoId, "mUserTwoId", 0); mShadowContext.grantPermissions(BACKUP); mShadowContext.grantPermissions(INTERACT_ACROSS_USERS_FULL); LocalServices.removeServiceForTest(UserManagerInternal.class); LocalServices.addService(UserManagerInternal.class, mUserManagerInternal); when(mUserManagerInternal.getUserInfo(mUserOneId)).thenReturn(mUserInfoMock); when(mUserManagerInternal.getUserInfo(mUserTwoId)).thenReturn(mUserInfoMock); when(mUserOneService.getBackupAgentConnectionManager()).thenReturn( mUserOneBackupAgentConnectionManager); Loading
services/robotests/backup/src/com/android/server/backup/UserBackupManagerServiceTest.java +6 −2 Original line number Diff line number Diff line Loading @@ -54,17 +54,18 @@ import android.os.UserHandle; import android.platform.test.annotations.Presubmit; import android.provider.Settings; import com.android.server.LocalServices; import com.android.server.backup.testing.BackupManagerServiceTestUtils; import com.android.server.backup.testing.TransportData; import com.android.server.backup.testing.TransportTestUtils.TransportMock; import com.android.server.backup.transport.TransportNotRegisteredException; import com.android.server.pm.UserManagerInternal; import com.android.server.testing.shadows.ShadowApplicationPackageManager; import com.android.server.testing.shadows.ShadowBackupEligibilityRules; import com.android.server.testing.shadows.ShadowBinder; import com.android.server.testing.shadows.ShadowKeyValueBackupJob; import com.android.server.testing.shadows.ShadowKeyValueBackupTask; import com.android.server.testing.shadows.ShadowSystemServiceRegistry; import com.android.server.testing.shadows.ShadowUserManager; import org.junit.After; import org.junit.Before; Loading Loading @@ -99,7 +100,6 @@ import java.util.List; ShadowBackupEligibilityRules.class, ShadowApplicationPackageManager.class, ShadowSystemServiceRegistry.class, ShadowUserManager.class }) @Presubmit public class UserBackupManagerServiceTest { Loading @@ -109,6 +109,7 @@ public class UserBackupManagerServiceTest { private static final int USER_ID = 10; @Mock private TransportManager mTransportManager; @Mock private UserManagerInternal mUserManagerInternal; private HandlerThread mBackupThread; private ShadowLooper mShadowBackupLooper; private File mBaseStateDir; Loading Loading @@ -142,6 +143,9 @@ public class UserBackupManagerServiceTest { mContext = context; mShadowContext = shadowOf(context); LocalServices.removeServiceForTest(UserManagerInternal.class); LocalServices.addService(UserManagerInternal.class, mUserManagerInternal); File cacheDir = mContext.getCacheDir(); // Corresponds to /data/backup mBaseStateDir = new File(cacheDir, "base_state"); Loading
services/robotests/backup/src/com/android/server/backup/internal/SetupObserverTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -25,15 +25,16 @@ import android.os.HandlerThread; import android.platform.test.annotations.Presubmit; import android.provider.Settings; import com.android.server.LocalServices; import com.android.server.backup.FullBackupJob; import com.android.server.backup.JobIdManager; import com.android.server.backup.KeyValueBackupJob; import com.android.server.backup.TransportManager; import com.android.server.backup.UserBackupManagerService; import com.android.server.backup.testing.BackupManagerServiceTestUtils; import com.android.server.pm.UserManagerInternal; import com.android.server.testing.shadows.ShadowApplicationPackageManager; import com.android.server.testing.shadows.ShadowSystemServiceRegistry; import com.android.server.testing.shadows.ShadowUserManager; import org.junit.Before; import org.junit.Test; Loading @@ -58,7 +59,6 @@ import java.io.File; ShadowApplicationPackageManager.class, ShadowJobScheduler.class, ShadowSystemServiceRegistry.class, ShadowUserManager.class }) @Presubmit public class SetupObserverTest { Loading @@ -66,6 +66,7 @@ public class SetupObserverTest { private static final int USER_ID = 10; @Mock private TransportManager mTransportManager; @Mock private UserManagerInternal mUserManagerInternal; private Context mContext; private UserBackupManagerService mUserBackupManagerService; Loading @@ -76,6 +77,8 @@ public class SetupObserverTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); LocalServices.removeServiceForTest(UserManagerInternal.class); LocalServices.addService(UserManagerInternal.class, mUserManagerInternal); mContext = RuntimeEnvironment.application; mHandlerThread = BackupManagerServiceTestUtils.startSilentBackupThread(TAG); mUserBackupManagerService = Loading
services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -126,13 +126,13 @@ import com.android.server.backup.testing.TransportTestUtils; import com.android.server.backup.testing.TransportTestUtils.TransportMock; import com.android.server.backup.utils.BackupEligibilityRules; import com.android.server.backup.utils.BackupManagerMonitorEventSender; import com.android.server.pm.UserManagerInternal; import com.android.server.testing.shadows.FrameworkShadowLooper; import com.android.server.testing.shadows.ShadowApplicationPackageManager; import com.android.server.testing.shadows.ShadowBackupDataInput; import com.android.server.testing.shadows.ShadowBackupDataOutput; import com.android.server.testing.shadows.ShadowEventLog; import com.android.server.testing.shadows.ShadowSystemServiceRegistry; import com.android.server.testing.shadows.ShadowUserManager; import com.google.common.base.Charsets; import com.google.common.truth.IterableSubject; Loading Loading @@ -180,7 +180,6 @@ import java.util.stream.Stream; ShadowEventLog.class, ShadowQueuedWork.class, ShadowSystemServiceRegistry.class, ShadowUserManager.class }) @Presubmit public class KeyValueBackupTaskTest { Loading @@ -198,6 +197,7 @@ public class KeyValueBackupTaskTest { @Mock private OnTaskFinishedListener mListener; @Mock private PackageManagerInternal mPackageManagerInternal; @Mock private BackupAgentConnectionManager mBackupAgentConnectionManager; @Mock private UserManagerInternal mUserManagerInternal; private UserBackupManagerService mBackupManagerService; private TransportData mTransport; Loading Loading @@ -243,6 +243,9 @@ public class KeyValueBackupTaskTest { mWakeLock = spy(createBackupWakeLock(mApplication)); mBackupManager = spy(FakeIBackupManager.class); LocalServices.removeServiceForTest(UserManagerInternal.class); LocalServices.addService(UserManagerInternal.class, mUserManagerInternal); // Needed to be able to use a real BMS instead of a mock setUpBinderCallerAndApplicationAsSystem(mApplication); mBackupManagerService = Loading