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

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

[Multi-user] Create setting for multi-user backup service support

Whether the backup service supports multi-user is now configured in a
Global setting: backup_multi_user_enabled

This allows us to develop multi-user support hidden behind a flag. In a
future CL, we'll also gate the types of users we support.

Also create basic infrastructure for starting the service for a newly
unlocked user (currently a no-op).

Bug: 120212806
Test: 1) atest TrampolineTest
2) adb shell settings put global backup_multi_user_enabled 0;
   unlock system user -> verify service started;
   unlock user 10 -> verify service not started;
3) adb shell settings put global backup_multi_user_enabled 1;
   unlock system user -> verify service started;
   unlock user 10 -> verify service started;

Change-Id: I048e017cfa6148097cebe2eb2916d1b53c53d3b0
parent 348c8977
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -13794,6 +13794,14 @@ public final class Settings {
        public static final String BACKUP_AGENT_TIMEOUT_PARAMETERS =
                "backup_agent_timeout_parameters";
        /**
         * Whether the backup system service supports multiple users (0 = disabled, 1 = enabled). If
         * disabled, the service will only be active for the system user.
         *
         * @hide
         */
        public static final String BACKUP_MULTI_USER_ENABLED = "backup_multi_user_enabled";
        /**
         * Blacklist of GNSS satellites.
         *
+10 −2
Original line number Diff line number Diff line
@@ -109,7 +109,15 @@ message GlobalSettingsProto {
    }
    optional Autofill autofill = 140;

    optional SettingProto backup_agent_timeout_parameters = 18;
    reserved 18; // Used to be backup_agent_timeout_parameters

    message Backup {
        option (android.msg_privacy).dest = DEST_EXPLICIT;

        optional SettingProto backup_agent_timeout_parameters = 1;
        optional SettingProto backup_multi_user_enabled = 2;
    }
    optional Backup backup = 146;

    message Battery {
        option (android.msg_privacy).dest = DEST_EXPLICIT;
@@ -1007,5 +1015,5 @@ message GlobalSettingsProto {

    // Please insert fields in alphabetical order and group them into messages
    // if possible (to avoid reaching the method limit).
    // Next tag = 146;
    // Next tag = 147;
}
+2 −1
Original line number Diff line number Diff line
@@ -541,7 +541,8 @@ public class SettingsBackupTest {
                    Settings.Global.OVERRIDE_SETTINGS_PROVIDER_RESTORE_ANY_VERSION,
                    Settings.Global.CHAINED_BATTERY_ATTRIBUTION_ENABLED,
                    Settings.Global.HIDDEN_API_BLACKLIST_EXEMPTIONS,
                    Settings.Global.BACKUP_AGENT_TIMEOUT_PARAMETERS);
                    Settings.Global.BACKUP_AGENT_TIMEOUT_PARAMETERS,
                    Settings.Global.BACKUP_MULTI_USER_ENABLED);
    private static final Set<String> BACKUP_BLACKLISTED_SECURE_SETTINGS =
             newHashSet(
                 Settings.Secure.ACCESSIBILITY_SOFT_KEYBOARD_MODE,
+6 −1
Original line number Diff line number Diff line
@@ -208,9 +208,14 @@ class SettingsProtoDumpUtil {
                GlobalSettingsProto.Autofill.MAX_VISIBLE_DATASETS);
        p.end(autofillToken);

        final long backupToken = p.start(GlobalSettingsProto.BACKUP);
        dumpSetting(s, p,
                Settings.Global.BACKUP_AGENT_TIMEOUT_PARAMETERS,
                GlobalSettingsProto.BACKUP_AGENT_TIMEOUT_PARAMETERS);
                GlobalSettingsProto.Backup.BACKUP_AGENT_TIMEOUT_PARAMETERS);
        dumpSetting(s, p,
                Settings.Global.BACKUP_MULTI_USER_ENABLED,
                GlobalSettingsProto.Backup.BACKUP_MULTI_USER_ENABLED);
        p.end(backupToken);

        final long batteryToken = p.start(GlobalSettingsProto.BATTERY);
        dumpSetting(s, p,
+12 −1
Original line number Diff line number Diff line
@@ -184,6 +184,15 @@ public class BackupManagerService {
        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.
     */
    // TODO(b/120212806): Add UserBackupManagerService initialization logic.
    void startServiceForUser(int userId) {
        // Intentionally empty.
    }

    /*
     * The following methods are implementations of IBackupManager methods called from Trampoline.
     * They delegate to the appropriate per-user instance of UserBackupManagerService to perform the
@@ -626,7 +635,9 @@ public class BackupManagerService {
        @Override
        public void onUnlockUser(int userId) {
            if (userId == UserHandle.USER_SYSTEM) {
                sInstance.unlockSystemUser();
                sInstance.initializeServiceAndUnlockSystemUser();
            } else {
                sInstance.startServiceForUser(userId);
            }
        }
    }
Loading