summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/backup/java/com/android/server/backup/UserBackupManagerService.java20
-rw-r--r--services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java9
2 files changed, 16 insertions, 13 deletions
diff --git a/services/backup/java/com/android/server/backup/UserBackupManagerService.java b/services/backup/java/com/android/server/backup/UserBackupManagerService.java
index e0e81ffb6b48..79f8a7e4e9ae 100644
--- a/services/backup/java/com/android/server/backup/UserBackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/UserBackupManagerService.java
@@ -494,20 +494,18 @@ public class UserBackupManagerService {
mUserId);
mBaseStateDir = checkNotNull(baseStateDir, "baseStateDir cannot be null");
- mBaseStateDir.mkdirs();
- if (!SELinux.restoreconRecursive(mBaseStateDir)) {
- Slog.w(TAG, "SELinux restorecon failed on " + mBaseStateDir);
+ // TODO (b/120424138): Remove once the system user is migrated to use the per-user CE
+ // directory. Per-user CE directories are managed by vold.
+ if (userId == UserHandle.USER_SYSTEM) {
+ mBaseStateDir.mkdirs();
+ if (!SELinux.restorecon(mBaseStateDir)) {
+ Slog.w(TAG, "SELinux restorecon failed on " + mBaseStateDir);
+ }
}
+ // TODO (b/120424138): The system user currently uses the cache which is managed by init.rc
+ // Initialization and restorecon is managed by vold for per-user CE directories.
mDataDir = checkNotNull(dataDir, "dataDir cannot be null");
- // TODO(b/120424138): Remove when the system user moves out of the cache dir. The cache dir
- // is managed by init.rc so we don't have to create it below.
- if (userId != UserHandle.USER_SYSTEM) {
- mDataDir.mkdirs();
- if (!SELinux.restoreconRecursive(mDataDir)) {
- Slog.w(TAG, "SELinux restorecon failed on " + mDataDir);
- }
- }
mBackupPasswordManager = new BackupPasswordManager(mContext, mBaseStateDir, mRng);
// Receivers for scheduled backups and transport initialization operations.
diff --git a/services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java b/services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java
index 862ca711e694..cfc129e11c6e 100644
--- a/services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java
+++ b/services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java
@@ -45,6 +45,7 @@ import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.RemoteException;
import android.os.SELinux;
+import android.os.UserHandle;
import android.os.WorkSource;
import com.android.internal.annotations.GuardedBy;
@@ -686,8 +687,12 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
ParcelFileDescriptor.open(
mNewStateFile, MODE_READ_WRITE | MODE_CREATE | MODE_TRUNCATE);
- if (!SELinux.restorecon(mBackupDataFile)) {
- mReporter.onRestoreconFailed(mBackupDataFile);
+ // TODO (b/120424138): Remove once the system user is migrated to use the per-user CE
+ // directory. Per-user CE directories are managed by vold.
+ if (mUserId == UserHandle.USER_SYSTEM) {
+ if (!SELinux.restorecon(mBackupDataFile)) {
+ mReporter.onRestoreconFailed(mBackupDataFile);
+ }
}
IBackupTransport transport = mTransportClient.connectOrThrow("KVBT.extractAgentData()");