Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fcdfa01f authored by Annie Meng's avatar Annie Meng
Browse files

[Multi-user] Remove dir management for non-system users

Per-user CE directories are managed by vold so we don't need to
initialize or apply restorecon on them in our service.

Once the system user is migrated to the its CE directory, we can remove
the remaining restorecon and mkdirs logic.

Accompanies aosp/875352 and aosp/873133

Bug: 121197420
Test: 1) Boot device; check directories exist and labelled properly
for system user; perform backup successfully
2) Add secondary user; check directories exist and labelled properly;
perform backup succesfully

Change-Id: If848da4c9254db87b393fce6cfc4169785bfac51
parent 53cf5208
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -494,20 +494,18 @@ public class UserBackupManagerService {
                mUserId);

        mBaseStateDir = checkNotNull(baseStateDir, "baseStateDir cannot be null");
        // 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.restoreconRecursive(mBaseStateDir)) {
            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.
+7 −2
Original line number Diff line number Diff line
@@ -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,9 +687,13 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
                    ParcelFileDescriptor.open(
                            mNewStateFile, MODE_READ_WRITE | MODE_CREATE | MODE_TRUNCATE);

            // 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()");
            long quota = transport.getBackupQuota(packageName, /* isFullBackup */ false);