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

Commit 813716b1 authored by Annie Meng's avatar Annie Meng
Browse files

[Multi-user] Extract BackupManagerService to UserBackupManagerService

BMS is split into GlobalBMS and UserBMS.
UserBMS:
- Core backup/restore implementations and bookkeeping.
- Will be per user in a future CL (only one instance in this CL to limit
scope of changes).

GlobalBMS:
- System service definition, interaction with Trampoline, user-aware
operations.
- Will be renamed back to BMS in a future CL (so BMS history can follow
UserBMS in this CL).

*** Reviewers, please pay attention to the patchset breakdown to better
understand what is a rename/move vs. new changes ***

* Base -> Patchset 2: BMS splits into GlobalBMS and UserBMS (MOVE ONLY)

Patchset 1: Rename BMS -> UserBMS
Patchset 2: Move parts of UserBMS to GlobalBMS
No new functionality, only moving existing code.

* Patchset 2 -> Patchset 3: New functionality for GlobalBMS

- Switch references from BMS to GlobalBMS in Trampoline.java.
- Change the definition of the system service in SystemServer.java to
GlobalBMS.
- Instantiate one instance of UserBMS in GlobalBMS constructor.
- Add all IBackupManager methods, which for now just directly calls the
corresponding method in UserBMS.

* Patchset 3 -> Patchset 4: Migrate usages of BMS in code (RENAME ONLY)

Find and replace, no new functionality.

* Patchset 4 -> Patchset 5: Migrate usages of BMS in tests (RENAME ONLY)

Find and replace, no new functionality.

* Patchset 5 -> Patchset 6: New tests for GlobalBMS

Add tests for all the new IBackupManager methods added (just tests
straight redirection for now).

* Overall: View Patchset 2 -> [Latest Patchset] for new code.

TODO: Modify art-profile with rename

Bug: 118520567
Test: 1) atest RunFrameworksServicesRoboTests
2) atest $(find
frameworks/base/services/tests/servicestests/src/com/android/server/backup
-name '*Test.java')
3) atest GtsBackupHostTestCases
4) atest CtsBackupTestCases
5) atest CtsBackupHostTestCases
6) atest DeviceOwnerTest
7) 'Backup Now' in Settings
8) Cloud and d2d restore in SUW; deferred restore
9) All 'adb shell bmgr' flows
10) adb backup; adb restore
Change-Id: Ib5a5837375fe950bc7d33a5e31cca16b605541f9
parent de93099a
Loading
Loading
Loading
Loading
+9 −6
Original line number Original line Diff line number Diff line
@@ -16,12 +16,15 @@


package com.android.server.backup;
package com.android.server.backup;


import static com.android.server.backup.GlobalBackupManagerService.DEBUG_SCHEDULING;

import android.content.ContentResolver;
import android.content.ContentResolver;
import android.os.Handler;
import android.os.Handler;
import android.provider.Settings;
import android.provider.Settings;
import android.util.KeyValueListParser;
import android.util.KeyValueListParser;
import android.util.KeyValueSettingObserver;
import android.util.KeyValueSettingObserver;
import android.util.Slog;
import android.util.Slog;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;


@@ -137,7 +140,7 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver {


    public long getKvBackupAgentTimeoutMillis() {
    public long getKvBackupAgentTimeoutMillis() {
        synchronized (mLock) {
        synchronized (mLock) {
            if (BackupManagerService.DEBUG_SCHEDULING) {
            if (DEBUG_SCHEDULING) {
                Slog.v(TAG, "getKvBackupAgentTimeoutMillis(): " + mKvBackupAgentTimeoutMillis);
                Slog.v(TAG, "getKvBackupAgentTimeoutMillis(): " + mKvBackupAgentTimeoutMillis);
            }
            }
            return mKvBackupAgentTimeoutMillis;
            return mKvBackupAgentTimeoutMillis;
@@ -146,7 +149,7 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver {


    public long getFullBackupAgentTimeoutMillis() {
    public long getFullBackupAgentTimeoutMillis() {
        synchronized (mLock) {
        synchronized (mLock) {
            if (BackupManagerService.DEBUG_SCHEDULING) {
            if (DEBUG_SCHEDULING) {
                Slog.v(TAG, "getFullBackupAgentTimeoutMillis(): " + mFullBackupAgentTimeoutMillis);
                Slog.v(TAG, "getFullBackupAgentTimeoutMillis(): " + mFullBackupAgentTimeoutMillis);
            }
            }
            return mFullBackupAgentTimeoutMillis;
            return mFullBackupAgentTimeoutMillis;
@@ -155,7 +158,7 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver {


    public long getSharedBackupAgentTimeoutMillis() {
    public long getSharedBackupAgentTimeoutMillis() {
        synchronized (mLock) {
        synchronized (mLock) {
            if (BackupManagerService.DEBUG_SCHEDULING) {
            if (DEBUG_SCHEDULING) {
                Slog.v(
                Slog.v(
                        TAG,
                        TAG,
                        "getSharedBackupAgentTimeoutMillis(): " + mSharedBackupAgentTimeoutMillis);
                        "getSharedBackupAgentTimeoutMillis(): " + mSharedBackupAgentTimeoutMillis);
@@ -166,7 +169,7 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver {


    public long getRestoreAgentTimeoutMillis() {
    public long getRestoreAgentTimeoutMillis() {
        synchronized (mLock) {
        synchronized (mLock) {
            if (BackupManagerService.DEBUG_SCHEDULING) {
            if (DEBUG_SCHEDULING) {
                Slog.v(TAG, "getRestoreAgentTimeoutMillis(): " + mRestoreAgentTimeoutMillis);
                Slog.v(TAG, "getRestoreAgentTimeoutMillis(): " + mRestoreAgentTimeoutMillis);
            }
            }
            return mRestoreAgentTimeoutMillis;
            return mRestoreAgentTimeoutMillis;
@@ -175,7 +178,7 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver {


    public long getRestoreAgentFinishedTimeoutMillis() {
    public long getRestoreAgentFinishedTimeoutMillis() {
        synchronized (mLock) {
        synchronized (mLock) {
            if (BackupManagerService.DEBUG_SCHEDULING) {
            if (DEBUG_SCHEDULING) {
                Slog.v(
                Slog.v(
                        TAG,
                        TAG,
                        "getRestoreAgentFinishedTimeoutMillis(): "
                        "getRestoreAgentFinishedTimeoutMillis(): "
@@ -187,7 +190,7 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver {


    public long getQuotaExceededTimeoutMillis() {
    public long getQuotaExceededTimeoutMillis() {
        synchronized (mLock) {
        synchronized (mLock) {
            if (BackupManagerService.DEBUG_SCHEDULING) {
            if (DEBUG_SCHEDULING) {
                Slog.v(
                Slog.v(
                        TAG,
                        TAG,
                        "getQuotaExceededTimeoutMillis(): "
                        "getQuotaExceededTimeoutMillis(): "
+11 −8
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.server.backup;
package com.android.server.backup;


import static com.android.server.backup.GlobalBackupManagerService.DEBUG_SCHEDULING;

import android.app.AlarmManager;
import android.app.AlarmManager;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.os.Handler;
import android.os.Handler;
@@ -24,6 +26,7 @@ import android.text.TextUtils;
import android.util.KeyValueListParser;
import android.util.KeyValueListParser;
import android.util.KeyValueSettingObserver;
import android.util.KeyValueSettingObserver;
import android.util.Slog;
import android.util.Slog;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;


/**
/**
@@ -151,7 +154,7 @@ public class BackupManagerConstants extends KeyValueSettingObserver {
    // group the calls of these methods in a block syncrhonized on
    // group the calls of these methods in a block syncrhonized on
    // a reference of this object.
    // a reference of this object.
    public synchronized long getKeyValueBackupIntervalMilliseconds() {
    public synchronized long getKeyValueBackupIntervalMilliseconds() {
        if (BackupManagerService.DEBUG_SCHEDULING) {
        if (DEBUG_SCHEDULING) {
            Slog.v(
            Slog.v(
                    TAG,
                    TAG,
                    "getKeyValueBackupIntervalMilliseconds(...) returns "
                    "getKeyValueBackupIntervalMilliseconds(...) returns "
@@ -161,7 +164,7 @@ public class BackupManagerConstants extends KeyValueSettingObserver {
    }
    }


    public synchronized long getKeyValueBackupFuzzMilliseconds() {
    public synchronized long getKeyValueBackupFuzzMilliseconds() {
        if (BackupManagerService.DEBUG_SCHEDULING) {
        if (DEBUG_SCHEDULING) {
            Slog.v(
            Slog.v(
                    TAG,
                    TAG,
                    "getKeyValueBackupFuzzMilliseconds(...) returns "
                    "getKeyValueBackupFuzzMilliseconds(...) returns "
@@ -171,7 +174,7 @@ public class BackupManagerConstants extends KeyValueSettingObserver {
    }
    }


    public synchronized boolean getKeyValueBackupRequireCharging() {
    public synchronized boolean getKeyValueBackupRequireCharging() {
        if (BackupManagerService.DEBUG_SCHEDULING) {
        if (DEBUG_SCHEDULING) {
            Slog.v(
            Slog.v(
                    TAG,
                    TAG,
                    "getKeyValueBackupRequireCharging(...) returns "
                    "getKeyValueBackupRequireCharging(...) returns "
@@ -181,7 +184,7 @@ public class BackupManagerConstants extends KeyValueSettingObserver {
    }
    }


    public synchronized int getKeyValueBackupRequiredNetworkType() {
    public synchronized int getKeyValueBackupRequiredNetworkType() {
        if (BackupManagerService.DEBUG_SCHEDULING) {
        if (DEBUG_SCHEDULING) {
            Slog.v(
            Slog.v(
                    TAG,
                    TAG,
                    "getKeyValueBackupRequiredNetworkType(...) returns "
                    "getKeyValueBackupRequiredNetworkType(...) returns "
@@ -191,7 +194,7 @@ public class BackupManagerConstants extends KeyValueSettingObserver {
    }
    }


    public synchronized long getFullBackupIntervalMilliseconds() {
    public synchronized long getFullBackupIntervalMilliseconds() {
        if (BackupManagerService.DEBUG_SCHEDULING) {
        if (DEBUG_SCHEDULING) {
            Slog.v(
            Slog.v(
                    TAG,
                    TAG,
                    "getFullBackupIntervalMilliseconds(...) returns "
                    "getFullBackupIntervalMilliseconds(...) returns "
@@ -201,14 +204,14 @@ public class BackupManagerConstants extends KeyValueSettingObserver {
    }
    }


    public synchronized boolean getFullBackupRequireCharging() {
    public synchronized boolean getFullBackupRequireCharging() {
        if (BackupManagerService.DEBUG_SCHEDULING) {
        if (DEBUG_SCHEDULING) {
            Slog.v(TAG, "getFullBackupRequireCharging(...) returns " + mFullBackupRequireCharging);
            Slog.v(TAG, "getFullBackupRequireCharging(...) returns " + mFullBackupRequireCharging);
        }
        }
        return mFullBackupRequireCharging;
        return mFullBackupRequireCharging;
    }
    }


    public synchronized int getFullBackupRequiredNetworkType() {
    public synchronized int getFullBackupRequiredNetworkType() {
        if (BackupManagerService.DEBUG_SCHEDULING) {
        if (DEBUG_SCHEDULING) {
            Slog.v(
            Slog.v(
                    TAG,
                    TAG,
                    "getFullBackupRequiredNetworkType(...) returns "
                    "getFullBackupRequiredNetworkType(...) returns "
@@ -219,7 +222,7 @@ public class BackupManagerConstants extends KeyValueSettingObserver {


    /** Returns an array of package names that should be notified whenever a backup finishes. */
    /** Returns an array of package names that should be notified whenever a backup finishes. */
    public synchronized String[] getBackupFinishedNotificationReceivers() {
    public synchronized String[] getBackupFinishedNotificationReceivers() {
        if (BackupManagerService.DEBUG_SCHEDULING) {
        if (DEBUG_SCHEDULING) {
            Slog.v(
            Slog.v(
                    TAG,
                    TAG,
                    "getBackupFinishedNotificationReceivers(...) returns "
                    "getBackupFinishedNotificationReceivers(...) returns "
+1 −1
Original line number Original line Diff line number Diff line
@@ -16,7 +16,7 @@


package com.android.server.backup;
package com.android.server.backup;


import static com.android.server.backup.BackupManagerService.TAG;
import static com.android.server.backup.GlobalBackupManagerService.TAG;


import android.app.backup.BackupAgent;
import android.app.backup.BackupAgent;
import android.util.Slog;
import android.util.Slog;
+2 −2
Original line number Original line Diff line number Diff line
@@ -61,7 +61,7 @@ public class FullBackupJob extends JobService {
    @Override
    @Override
    public boolean onStartJob(JobParameters params) {
    public boolean onStartJob(JobParameters params) {
        mParams = params;
        mParams = params;
        Trampoline service = BackupManagerService.getInstance();
        Trampoline service = GlobalBackupManagerService.getInstance();
        return service.beginFullBackup(this);
        return service.beginFullBackup(this);
    }
    }


@@ -69,7 +69,7 @@ public class FullBackupJob extends JobService {
    public boolean onStopJob(JobParameters params) {
    public boolean onStopJob(JobParameters params) {
        if (mParams != null) {
        if (mParams != null) {
            mParams = null;
            mParams = null;
            Trampoline service = BackupManagerService.getInstance();
            Trampoline service = GlobalBackupManagerService.getInstance();
            service.endFullBackup();
            service.endFullBackup();
        }
        }
        return false;
        return false;
+633 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading