Loading services/backup/java/com/android/server/backup/BackupManagerService.java +13 −19 Original line number Diff line number Diff line Loading @@ -124,20 +124,6 @@ public class BackupManagerService { } } /** * Called through Trampoline from {@link Lifecycle#onUnlockUser(int)}. We run the heavy work on * a background thread to keep the unlock time down. */ public void unlockSystemUser() { Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup enable"); try { sInstance.setBackupEnabled(readBackupEnableState(UserHandle.USER_SYSTEM)); } catch (RemoteException e) { // can't happen; it's a local object } Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } /** * Starts the backup service for user {@code userId} by creating a new instance of {@link * UserBackupManagerService} and registering it with this service. Loading @@ -152,10 +138,19 @@ public class BackupManagerService { /** * Starts the backup service for user {@code userId} by registering its instance of {@link * UserBackupManagerService} with this service. * UserBackupManagerService} with this service and setting enabled state. */ void startServiceForUser(int userId, UserBackupManagerService userBackupManagerService) { mServiceUsers.put(userId, userBackupManagerService); Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup enable"); try { // TODO(b/121198604): Make enable file per-user and clean up indirection. mTrampoline.setBackupEnabledForUser(userId, readBackupEnableState(userId)); } catch (RemoteException e) { // Can't happen, it's a local object. } Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } SparseArray<UserBackupManagerService> getServiceUsers() { Loading Loading @@ -821,10 +816,9 @@ public class BackupManagerService { @Override public void onUnlockUser(int userId) { if (userId == UserHandle.USER_SYSTEM) { sInstance.initializeServiceAndUnlockSystemUser(); } else { sInstance.unlockUser(userId); sInstance.initializeService(); } sInstance.unlockUser(userId); } } } services/backup/java/com/android/server/backup/Trampoline.java +19 −42 Original line number Diff line number Diff line Loading @@ -150,20 +150,19 @@ public class Trampoline extends IBackupManager.Stub { } /** * Initialize {@link BackupManagerService} if the backup service is not disabled. Only the * system user can initialize the service. * Called from {@link BackupManagerService.Lifecycle} when the system user is unlocked. Attempts * to initialize {@link BackupManagerService}. Offloads work onto the handler thread {@link * #mHandlerThread} to keep unlock time low. */ /* package */ void initializeService(int userId) { void initializeService() { postToHandler( () -> { Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup init"); if (mGlobalDisable) { Slog.i(TAG, "Backup service not supported"); return; } 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(); Loading @@ -171,40 +170,18 @@ public class Trampoline extends IBackupManager.Stub { 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. */ void initializeServiceAndUnlockSystemUser() { postToHandler( () -> { // Initialize the backup service. Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup init"); initializeService(UserHandle.USER_SYSTEM); Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); // Start the service for the system user. BackupManagerService service = mService; if (service != null) { Slog.i(TAG, "Starting service for system user"); service.startServiceForUser(UserHandle.USER_SYSTEM); Slog.i(TAG, "Unlocking system user"); service.unlockSystemUser(); } }); } /** * Called from {@link BackupManagerService.Lifecycle} when a non-system user {@code userId} is * unlocked. Starts the backup service for this user if the service supports multi-user. * Offloads work onto the handler thread {@link #mHandlerThread} to keep unlock time low. * Called from {@link BackupManagerService.Lifecycle} when a user {@code userId} is unlocked. * Starts the backup service for this user if it's the system user or if the service supports * multi-user. Offloads work onto the handler thread {@link #mHandlerThread} to keep unlock time * low. */ // TODO(b/120212806): Consolidate service start for system and non-system users when system // user-only logic is removed. void unlockUser(int userId) { if (!isMultiUserEnabled()) { if (userId != UserHandle.USER_SYSTEM && !isMultiUserEnabled()) { Slog.i(TAG, "Multi-user disabled, cannot start service for user: " + userId); return; } Loading Loading
services/backup/java/com/android/server/backup/BackupManagerService.java +13 −19 Original line number Diff line number Diff line Loading @@ -124,20 +124,6 @@ public class BackupManagerService { } } /** * Called through Trampoline from {@link Lifecycle#onUnlockUser(int)}. We run the heavy work on * a background thread to keep the unlock time down. */ public void unlockSystemUser() { Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup enable"); try { sInstance.setBackupEnabled(readBackupEnableState(UserHandle.USER_SYSTEM)); } catch (RemoteException e) { // can't happen; it's a local object } Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } /** * Starts the backup service for user {@code userId} by creating a new instance of {@link * UserBackupManagerService} and registering it with this service. Loading @@ -152,10 +138,19 @@ public class BackupManagerService { /** * Starts the backup service for user {@code userId} by registering its instance of {@link * UserBackupManagerService} with this service. * UserBackupManagerService} with this service and setting enabled state. */ void startServiceForUser(int userId, UserBackupManagerService userBackupManagerService) { mServiceUsers.put(userId, userBackupManagerService); Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup enable"); try { // TODO(b/121198604): Make enable file per-user and clean up indirection. mTrampoline.setBackupEnabledForUser(userId, readBackupEnableState(userId)); } catch (RemoteException e) { // Can't happen, it's a local object. } Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); } SparseArray<UserBackupManagerService> getServiceUsers() { Loading Loading @@ -821,10 +816,9 @@ public class BackupManagerService { @Override public void onUnlockUser(int userId) { if (userId == UserHandle.USER_SYSTEM) { sInstance.initializeServiceAndUnlockSystemUser(); } else { sInstance.unlockUser(userId); sInstance.initializeService(); } sInstance.unlockUser(userId); } } }
services/backup/java/com/android/server/backup/Trampoline.java +19 −42 Original line number Diff line number Diff line Loading @@ -150,20 +150,19 @@ public class Trampoline extends IBackupManager.Stub { } /** * Initialize {@link BackupManagerService} if the backup service is not disabled. Only the * system user can initialize the service. * Called from {@link BackupManagerService.Lifecycle} when the system user is unlocked. Attempts * to initialize {@link BackupManagerService}. Offloads work onto the handler thread {@link * #mHandlerThread} to keep unlock time low. */ /* package */ void initializeService(int userId) { void initializeService() { postToHandler( () -> { Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup init"); if (mGlobalDisable) { Slog.i(TAG, "Backup service not supported"); return; } 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(); Loading @@ -171,40 +170,18 @@ public class Trampoline extends IBackupManager.Stub { 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. */ void initializeServiceAndUnlockSystemUser() { postToHandler( () -> { // Initialize the backup service. Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup init"); initializeService(UserHandle.USER_SYSTEM); Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); // Start the service for the system user. BackupManagerService service = mService; if (service != null) { Slog.i(TAG, "Starting service for system user"); service.startServiceForUser(UserHandle.USER_SYSTEM); Slog.i(TAG, "Unlocking system user"); service.unlockSystemUser(); } }); } /** * Called from {@link BackupManagerService.Lifecycle} when a non-system user {@code userId} is * unlocked. Starts the backup service for this user if the service supports multi-user. * Offloads work onto the handler thread {@link #mHandlerThread} to keep unlock time low. * Called from {@link BackupManagerService.Lifecycle} when a user {@code userId} is unlocked. * Starts the backup service for this user if it's the system user or if the service supports * multi-user. Offloads work onto the handler thread {@link #mHandlerThread} to keep unlock time * low. */ // TODO(b/120212806): Consolidate service start for system and non-system users when system // user-only logic is removed. void unlockUser(int userId) { if (!isMultiUserEnabled()) { if (userId != UserHandle.USER_SYSTEM && !isMultiUserEnabled()) { Slog.i(TAG, "Multi-user disabled, cannot start service for user: " + userId); return; } Loading