diff options
author | Bernardo Rufino <brufino@google.com> | 2019-08-14 18:30:27 +0100 |
---|---|---|
committer | Bernardo Rufino <brufino@google.com> | 2019-08-15 10:25:45 +0100 |
commit | 7dedc861b6baabc2e533d09a653d3657fe322e57 (patch) | |
tree | b446d103c7d05d96b6d6e842934a5f0a44c32bd0 /services/backup/java | |
parent | 0c8b84e4a337769d9251f4276147bb7b05c369f6 (diff) |
Move settings operations to Trampoline
From BMS.
Test: atest BackupManagerServiceTest TrampolineRoboTest TrampolineTest
Bug: 135661048
Change-Id: I47e8072898555fd881ffa7b3d546e858fad01c6d
Diffstat (limited to 'services/backup/java')
-rw-r--r-- | services/backup/java/com/android/server/backup/BackupManagerService.java | 34 | ||||
-rw-r--r-- | services/backup/java/com/android/server/backup/Trampoline.java | 36 |
2 files changed, 33 insertions, 37 deletions
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java index 695fccc84c0a..bce7f7cf07d3 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -99,40 +99,6 @@ public class BackupManagerService { // TODO (b/118520567): Stop hardcoding system user when we pass in user id as a parameter // --------------------------------------------- - // SETTINGS OPERATIONS - // --------------------------------------------- - - /** Enable/disable the backup service. This is user-configurable via backup settings. */ - public void setBackupEnabled(@UserIdInt int userId, boolean enable) { - UserBackupManagerService userBackupManagerService = - getServiceForUserIfCallerHasPermission(userId, "setBackupEnabled()"); - - if (userBackupManagerService != null) { - userBackupManagerService.setBackupEnabled(enable); - } - } - - /** Enable/disable automatic restore of app data at install time. */ - public void setAutoRestore(@UserIdInt int userId, boolean autoRestore) { - UserBackupManagerService userBackupManagerService = - getServiceForUserIfCallerHasPermission(userId, "setAutoRestore()"); - - if (userBackupManagerService != null) { - userBackupManagerService.setAutoRestore(autoRestore); - } - } - - /** - * Return {@code true} if the backup mechanism is currently enabled, else returns {@code false}. - */ - public boolean isBackupEnabled(@UserIdInt int userId) { - UserBackupManagerService userBackupManagerService = - getServiceForUserIfCallerHasPermission(userId, "isBackupEnabled()"); - - return userBackupManagerService != null && userBackupManagerService.isBackupEnabled(); - } - - // --------------------------------------------- // BACKUP OPERATIONS // --------------------------------------------- diff --git a/services/backup/java/com/android/server/backup/Trampoline.java b/services/backup/java/com/android/server/backup/Trampoline.java index b522c87d6cbe..cdcc6ee4609f 100644 --- a/services/backup/java/com/android/server/backup/Trampoline.java +++ b/services/backup/java/com/android/server/backup/Trampoline.java @@ -644,7 +644,7 @@ public class Trampoline extends IBackupManager.Stub { public void setBackupEnabledForUser(@UserIdInt int userId, boolean isEnabled) throws RemoteException { if (isUserReadyForBackup(userId)) { - mService.setBackupEnabled(userId, isEnabled); + setBackupEnabled(userId, isEnabled); } } @@ -653,10 +653,20 @@ public class Trampoline extends IBackupManager.Stub { setBackupEnabledForUser(binderGetCallingUserId(), isEnabled); } + /** Enable/disable the backup service. This is user-configurable via backup settings. */ + public void setBackupEnabled(@UserIdInt int userId, boolean enable) { + UserBackupManagerService userBackupManagerService = + getServiceForUserIfCallerHasPermission(userId, "setBackupEnabled()"); + + if (userBackupManagerService != null) { + userBackupManagerService.setBackupEnabled(enable); + } + } + @Override public void setAutoRestoreForUser(int userId, boolean doAutoRestore) throws RemoteException { if (isUserReadyForBackup(userId)) { - mService.setAutoRestore(userId, doAutoRestore); + setAutoRestore(userId, doAutoRestore); } } @@ -665,9 +675,19 @@ public class Trampoline extends IBackupManager.Stub { setAutoRestoreForUser(binderGetCallingUserId(), doAutoRestore); } + /** Enable/disable automatic restore of app data at install time. */ + public void setAutoRestore(@UserIdInt int userId, boolean autoRestore) { + UserBackupManagerService userBackupManagerService = + getServiceForUserIfCallerHasPermission(userId, "setAutoRestore()"); + + if (userBackupManagerService != null) { + userBackupManagerService.setAutoRestore(autoRestore); + } + } + @Override public boolean isBackupEnabledForUser(@UserIdInt int userId) throws RemoteException { - return isUserReadyForBackup(userId) && mService.isBackupEnabled(userId); + return isUserReadyForBackup(userId) && isBackupEnabled(userId); } @Override @@ -675,6 +695,16 @@ public class Trampoline extends IBackupManager.Stub { return isBackupEnabledForUser(binderGetCallingUserId()); } + /** + * Return {@code true} if the backup mechanism is currently enabled, else returns {@code false}. + */ + public boolean isBackupEnabled(@UserIdInt int userId) { + UserBackupManagerService userBackupManagerService = + getServiceForUserIfCallerHasPermission(userId, "isBackupEnabled()"); + + return userBackupManagerService != null && userBackupManagerService.isBackupEnabled(); + } + @Override public boolean setBackupPassword(String currentPw, String newPw) throws RemoteException { int userId = binderGetCallingUserId(); |