Loading services/backup/java/com/android/server/backup/BackupManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ public class BackupManagerService { protected void startServiceForUser(int userId) { UserBackupManagerService userBackupManagerService = UserBackupManagerService.createAndInitializeService( mContext, mTrampoline, mBackupThread, mTransportWhitelist); userId, mContext, mTrampoline, mBackupThread, mTransportWhitelist); startServiceForUser(userId, userBackupManagerService); } Loading services/backup/java/com/android/server/backup/UserBackupManagerService.java +9 −3 Original line number Diff line number Diff line Loading @@ -251,6 +251,7 @@ public class UserBackupManagerService { private static final long BUSY_BACKOFF_MIN_MILLIS = 1000 * 60 * 60; // one hour private static final int BUSY_BACKOFF_FUZZ = 1000 * 60 * 60 * 2; // two hours private final @UserIdInt int mUserId; private final BackupAgentTimeoutParameters mAgentTimeoutParameters; private final TransportManager mTransportManager; Loading Loading @@ -372,10 +373,11 @@ public class UserBackupManagerService { * Creates an instance of {@link UserBackupManagerService} and initializes state for it. This * includes setting up the directories where we keep our bookkeeping and transport management. * * @see #createAndInitializeService(Context, Trampoline, HandlerThread, File, File, * @see #createAndInitializeService(int, Context, Trampoline, HandlerThread, File, File, * TransportManager) */ static UserBackupManagerService createAndInitializeService( @UserIdInt int userId, Context context, Trampoline trampoline, HandlerThread backupThread, Loading @@ -399,12 +401,13 @@ public class UserBackupManagerService { File dataDir = new File(Environment.getDownloadCacheDirectory(), BACKUP_STAGING_DIR); return createAndInitializeService( context, trampoline, backupThread, baseStateDir, dataDir, transportManager); userId, context, trampoline, backupThread, baseStateDir, dataDir, transportManager); } /** * Creates an instance of {@link UserBackupManagerService}. * * @param userId The user which this service is for. * @param context The system server context. * @param trampoline A reference to the proxy to {@link BackupManagerService}. * @param backupThread The thread running backup/restore operations for the user. Loading @@ -415,6 +418,7 @@ public class UserBackupManagerService { */ @VisibleForTesting public static UserBackupManagerService createAndInitializeService( @UserIdInt int userId, Context context, Trampoline trampoline, HandlerThread backupThread, Loading @@ -422,16 +426,18 @@ public class UserBackupManagerService { File dataDir, TransportManager transportManager) { return new UserBackupManagerService( context, trampoline, backupThread, baseStateDir, dataDir, transportManager); userId, context, trampoline, backupThread, baseStateDir, dataDir, transportManager); } private UserBackupManagerService( @UserIdInt int userId, Context context, Trampoline parent, HandlerThread backupThread, File baseStateDir, File dataDir, TransportManager transportManager) { mUserId = userId; mContext = checkNotNull(context, "context cannot be null"); mPackageManager = context.getPackageManager(); mPackageManagerBinder = AppGlobals.getPackageManager(); Loading services/robotests/backup/src/com/android/server/backup/UserBackupManagerServiceTest.java +14 −5 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ public class UserBackupManagerServiceTest { private static final String TAG = "BMSTest"; private static final String PACKAGE_1 = "some.package.1"; private static final String PACKAGE_2 = "some.package.2"; private static final int USER_ID = 10; @Mock private TransportManager mTransportManager; private HandlerThread mBackupThread; Loading Loading @@ -979,6 +980,7 @@ public class UserBackupManagerServiceTest { mShadowContext.grantPermissions(android.Manifest.permission.BACKUP); UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), mBackupThread, Loading @@ -1000,6 +1002,7 @@ public class UserBackupManagerServiceTest { mShadowContext.grantPermissions(android.Manifest.permission.BACKUP); UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), mBackupThread, Loading @@ -1022,6 +1025,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, /* context */ null, new Trampoline(mContext), mBackupThread, Loading @@ -1041,6 +1045,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, mContext, /* trampoline */ null, mBackupThread, Loading @@ -1060,6 +1065,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), /* backupThread */ null, Loading @@ -1079,6 +1085,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), mBackupThread, Loading @@ -1089,8 +1096,8 @@ public class UserBackupManagerServiceTest { /** * Test checking non-null argument on {@link * UserBackupManagerService#createAndInitializeService(Context, Trampoline, HandlerThread, File, * File, TransportManager)}. * UserBackupManagerService#createAndInitializeService(int, Context, Trampoline, HandlerThread, * File, File, TransportManager)}. */ @Test public void testCreateAndInitializeService_withNullDataDir_throws() { Loading @@ -1098,6 +1105,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), mBackupThread, Loading @@ -1108,8 +1116,8 @@ public class UserBackupManagerServiceTest { /** * Test checking non-null argument on {@link * UserBackupManagerService#createAndInitializeService(Context, Trampoline, HandlerThread, File, * File, TransportManager)}. * UserBackupManagerService#createAndInitializeService(int, Context, Trampoline, HandlerThread, * File, File, TransportManager)}. */ @Test public void testCreateAndInitializeService_withNullTransportManager_throws() { Loading @@ -1117,6 +1125,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), mBackupThread, Loading @@ -1127,7 +1136,7 @@ public class UserBackupManagerServiceTest { private UserBackupManagerService createUserBackupManagerServiceAndRunTasks() { return BackupManagerServiceTestUtils.createUserBackupManagerServiceAndRunTasks( mContext, mBackupThread, mBaseStateDir, mDataDir, mTransportManager); USER_ID, mContext, mBackupThread, mBaseStateDir, mDataDir, mTransportManager); } private void setUpPowerManager(UserBackupManagerService backupManagerService) { Loading services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -169,6 +169,7 @@ public class KeyValueBackupTaskTest { private static final PackageData PACKAGE_2 = keyValuePackage(2); private static final String BACKUP_AGENT_SHARED_PREFS_SYNCHRONIZER_CLASS = "android.app.backup.BackupAgent$SharedPrefsSynchronizer"; private static final int USER_ID = 10; @Mock private TransportManager mTransportManager; @Mock private DataChangedJournal mOldJournal; Loading Loading @@ -224,7 +225,7 @@ public class KeyValueBackupTaskTest { setUpBinderCallerAndApplicationAsSystem(mApplication); mBackupManagerService = spy(createUserBackupManagerServiceAndRunTasks( mContext, mBaseStateDir, mDataDir, mTransportManager)); USER_ID, mContext, mBaseStateDir, mDataDir, mTransportManager)); setUpBackupManagerServiceBasics( mBackupManagerService, mApplication, Loading services/robotests/backup/src/com/android/server/backup/testing/BackupManagerServiceTestUtils.java +9 −3 Original line number Diff line number Diff line Loading @@ -58,13 +58,17 @@ public class BackupManagerServiceTestUtils { * <p>If the class-under-test is going to execute methods as the system, it's a good idea to * also call {@link #setUpBinderCallerAndApplicationAsSystem(Application)} before this method. * * @see #createUserBackupManagerServiceAndRunTasks(Context, HandlerThread, File, File, * @see #createUserBackupManagerServiceAndRunTasks(int, Context, HandlerThread, File, File, * TransportManager) */ public static UserBackupManagerService createUserBackupManagerServiceAndRunTasks( Context context, File baseStateDir, File dataDir, TransportManager transportManager) { int userId, Context context, File baseStateDir, File dataDir, TransportManager transportManager) { return createUserBackupManagerServiceAndRunTasks( context, startBackupThread(null), baseStateDir, dataDir, transportManager); userId, context, startBackupThread(null), baseStateDir, dataDir, transportManager); } /** Loading @@ -75,6 +79,7 @@ public class BackupManagerServiceTestUtils { * also call {@link #setUpBinderCallerAndApplicationAsSystem(Application)} before this method. */ public static UserBackupManagerService createUserBackupManagerServiceAndRunTasks( int userId, Context context, HandlerThread backupThread, File baseStateDir, Loading @@ -82,6 +87,7 @@ public class BackupManagerServiceTestUtils { TransportManager transportManager) { UserBackupManagerService backupManagerService = UserBackupManagerService.createAndInitializeService( userId, context, new Trampoline(context), backupThread, Loading Loading
services/backup/java/com/android/server/backup/BackupManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ public class BackupManagerService { protected void startServiceForUser(int userId) { UserBackupManagerService userBackupManagerService = UserBackupManagerService.createAndInitializeService( mContext, mTrampoline, mBackupThread, mTransportWhitelist); userId, mContext, mTrampoline, mBackupThread, mTransportWhitelist); startServiceForUser(userId, userBackupManagerService); } Loading
services/backup/java/com/android/server/backup/UserBackupManagerService.java +9 −3 Original line number Diff line number Diff line Loading @@ -251,6 +251,7 @@ public class UserBackupManagerService { private static final long BUSY_BACKOFF_MIN_MILLIS = 1000 * 60 * 60; // one hour private static final int BUSY_BACKOFF_FUZZ = 1000 * 60 * 60 * 2; // two hours private final @UserIdInt int mUserId; private final BackupAgentTimeoutParameters mAgentTimeoutParameters; private final TransportManager mTransportManager; Loading Loading @@ -372,10 +373,11 @@ public class UserBackupManagerService { * Creates an instance of {@link UserBackupManagerService} and initializes state for it. This * includes setting up the directories where we keep our bookkeeping and transport management. * * @see #createAndInitializeService(Context, Trampoline, HandlerThread, File, File, * @see #createAndInitializeService(int, Context, Trampoline, HandlerThread, File, File, * TransportManager) */ static UserBackupManagerService createAndInitializeService( @UserIdInt int userId, Context context, Trampoline trampoline, HandlerThread backupThread, Loading @@ -399,12 +401,13 @@ public class UserBackupManagerService { File dataDir = new File(Environment.getDownloadCacheDirectory(), BACKUP_STAGING_DIR); return createAndInitializeService( context, trampoline, backupThread, baseStateDir, dataDir, transportManager); userId, context, trampoline, backupThread, baseStateDir, dataDir, transportManager); } /** * Creates an instance of {@link UserBackupManagerService}. * * @param userId The user which this service is for. * @param context The system server context. * @param trampoline A reference to the proxy to {@link BackupManagerService}. * @param backupThread The thread running backup/restore operations for the user. Loading @@ -415,6 +418,7 @@ public class UserBackupManagerService { */ @VisibleForTesting public static UserBackupManagerService createAndInitializeService( @UserIdInt int userId, Context context, Trampoline trampoline, HandlerThread backupThread, Loading @@ -422,16 +426,18 @@ public class UserBackupManagerService { File dataDir, TransportManager transportManager) { return new UserBackupManagerService( context, trampoline, backupThread, baseStateDir, dataDir, transportManager); userId, context, trampoline, backupThread, baseStateDir, dataDir, transportManager); } private UserBackupManagerService( @UserIdInt int userId, Context context, Trampoline parent, HandlerThread backupThread, File baseStateDir, File dataDir, TransportManager transportManager) { mUserId = userId; mContext = checkNotNull(context, "context cannot be null"); mPackageManager = context.getPackageManager(); mPackageManagerBinder = AppGlobals.getPackageManager(); Loading
services/robotests/backup/src/com/android/server/backup/UserBackupManagerServiceTest.java +14 −5 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ public class UserBackupManagerServiceTest { private static final String TAG = "BMSTest"; private static final String PACKAGE_1 = "some.package.1"; private static final String PACKAGE_2 = "some.package.2"; private static final int USER_ID = 10; @Mock private TransportManager mTransportManager; private HandlerThread mBackupThread; Loading Loading @@ -979,6 +980,7 @@ public class UserBackupManagerServiceTest { mShadowContext.grantPermissions(android.Manifest.permission.BACKUP); UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), mBackupThread, Loading @@ -1000,6 +1002,7 @@ public class UserBackupManagerServiceTest { mShadowContext.grantPermissions(android.Manifest.permission.BACKUP); UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), mBackupThread, Loading @@ -1022,6 +1025,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, /* context */ null, new Trampoline(mContext), mBackupThread, Loading @@ -1041,6 +1045,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, mContext, /* trampoline */ null, mBackupThread, Loading @@ -1060,6 +1065,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), /* backupThread */ null, Loading @@ -1079,6 +1085,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), mBackupThread, Loading @@ -1089,8 +1096,8 @@ public class UserBackupManagerServiceTest { /** * Test checking non-null argument on {@link * UserBackupManagerService#createAndInitializeService(Context, Trampoline, HandlerThread, File, * File, TransportManager)}. * UserBackupManagerService#createAndInitializeService(int, Context, Trampoline, HandlerThread, * File, File, TransportManager)}. */ @Test public void testCreateAndInitializeService_withNullDataDir_throws() { Loading @@ -1098,6 +1105,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), mBackupThread, Loading @@ -1108,8 +1116,8 @@ public class UserBackupManagerServiceTest { /** * Test checking non-null argument on {@link * UserBackupManagerService#createAndInitializeService(Context, Trampoline, HandlerThread, File, * File, TransportManager)}. * UserBackupManagerService#createAndInitializeService(int, Context, Trampoline, HandlerThread, * File, File, TransportManager)}. */ @Test public void testCreateAndInitializeService_withNullTransportManager_throws() { Loading @@ -1117,6 +1125,7 @@ public class UserBackupManagerServiceTest { NullPointerException.class, () -> UserBackupManagerService.createAndInitializeService( USER_ID, mContext, new Trampoline(mContext), mBackupThread, Loading @@ -1127,7 +1136,7 @@ public class UserBackupManagerServiceTest { private UserBackupManagerService createUserBackupManagerServiceAndRunTasks() { return BackupManagerServiceTestUtils.createUserBackupManagerServiceAndRunTasks( mContext, mBackupThread, mBaseStateDir, mDataDir, mTransportManager); USER_ID, mContext, mBackupThread, mBaseStateDir, mDataDir, mTransportManager); } private void setUpPowerManager(UserBackupManagerService backupManagerService) { Loading
services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -169,6 +169,7 @@ public class KeyValueBackupTaskTest { private static final PackageData PACKAGE_2 = keyValuePackage(2); private static final String BACKUP_AGENT_SHARED_PREFS_SYNCHRONIZER_CLASS = "android.app.backup.BackupAgent$SharedPrefsSynchronizer"; private static final int USER_ID = 10; @Mock private TransportManager mTransportManager; @Mock private DataChangedJournal mOldJournal; Loading Loading @@ -224,7 +225,7 @@ public class KeyValueBackupTaskTest { setUpBinderCallerAndApplicationAsSystem(mApplication); mBackupManagerService = spy(createUserBackupManagerServiceAndRunTasks( mContext, mBaseStateDir, mDataDir, mTransportManager)); USER_ID, mContext, mBaseStateDir, mDataDir, mTransportManager)); setUpBackupManagerServiceBasics( mBackupManagerService, mApplication, Loading
services/robotests/backup/src/com/android/server/backup/testing/BackupManagerServiceTestUtils.java +9 −3 Original line number Diff line number Diff line Loading @@ -58,13 +58,17 @@ public class BackupManagerServiceTestUtils { * <p>If the class-under-test is going to execute methods as the system, it's a good idea to * also call {@link #setUpBinderCallerAndApplicationAsSystem(Application)} before this method. * * @see #createUserBackupManagerServiceAndRunTasks(Context, HandlerThread, File, File, * @see #createUserBackupManagerServiceAndRunTasks(int, Context, HandlerThread, File, File, * TransportManager) */ public static UserBackupManagerService createUserBackupManagerServiceAndRunTasks( Context context, File baseStateDir, File dataDir, TransportManager transportManager) { int userId, Context context, File baseStateDir, File dataDir, TransportManager transportManager) { return createUserBackupManagerServiceAndRunTasks( context, startBackupThread(null), baseStateDir, dataDir, transportManager); userId, context, startBackupThread(null), baseStateDir, dataDir, transportManager); } /** Loading @@ -75,6 +79,7 @@ public class BackupManagerServiceTestUtils { * also call {@link #setUpBinderCallerAndApplicationAsSystem(Application)} before this method. */ public static UserBackupManagerService createUserBackupManagerServiceAndRunTasks( int userId, Context context, HandlerThread backupThread, File baseStateDir, Loading @@ -82,6 +87,7 @@ public class BackupManagerServiceTestUtils { TransportManager transportManager) { UserBackupManagerService backupManagerService = UserBackupManagerService.createAndInitializeService( userId, context, new Trampoline(context), backupThread, Loading