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

Commit 11b651c2 authored by Bernardo Rufino's avatar Bernardo Rufino
Browse files

Move sInstance to Trampoline

Test: Trigger KV and Full-backup jobs
Test: adb shell bmgr backupnow <package>
Bug: 135661048
Change-Id: If569ad290f2f57a30e859367f3fac289cf23e85d
parent d1df67ef
Loading
Loading
Loading
Loading
+4 −14
Original line number Diff line number Diff line
@@ -74,16 +74,6 @@ public class BackupManagerService {
    @VisibleForTesting
    static final String DUMP_RUNNING_USERS_MESSAGE = "Backup Manager is running for users:";

    // The published binder is a singleton Trampoline object that calls through to the proper code.
    // This indirection lets us turn down the heavy implementation object on the fly without
    // disturbing binders that have been cached elsewhere in the system.
    private static Trampoline sInstance;

    static Trampoline getInstance() {
        // Always constructed during system bring up, so no need to lazy-init.
        return sInstance;
    }

    private final Context mContext;
    private final Trampoline mTrampoline;

@@ -895,22 +885,22 @@ public class BackupManagerService {
        @VisibleForTesting
        Lifecycle(Context context, Trampoline trampoline) {
            super(context);
            sInstance = trampoline;
            Trampoline.sInstance = trampoline;
        }

        @Override
        public void onStart() {
            publishService(Context.BACKUP_SERVICE, sInstance);
            publishService(Context.BACKUP_SERVICE, Trampoline.sInstance);
        }

        @Override
        public void onUnlockUser(int userId) {
            sInstance.onUnlockUser(userId);
            Trampoline.sInstance.onUnlockUser(userId);
        }

        @Override
        public void onStopUser(int userId) {
            sInstance.onStopUser(userId);
            Trampoline.sInstance.onStopUser(userId);
        }

        @VisibleForTesting
+2 −2
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ public class FullBackupJob extends JobService {
            mParamsForUser.put(userId, params);
        }

        Trampoline service = BackupManagerService.getInstance();
        Trampoline service = Trampoline.getInstance();
        return service.beginFullBackup(userId, this);
    }

@@ -105,7 +105,7 @@ public class FullBackupJob extends JobService {
            }
        }

        Trampoline service = BackupManagerService.getInstance();
        Trampoline service = Trampoline.getInstance();
        service.endFullBackup(userId);

        return false;
+1 −1
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ public class KeyValueBackupJob extends JobService {
        }

        // Time to run a key/value backup!
        Trampoline service = BackupManagerService.getInstance();
        Trampoline service = Trampoline.getInstance();
        try {
            service.backupNowForUser(userId);
        } catch (RemoteException e) {}
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.backup;

import static com.android.internal.util.Preconditions.checkNotNull;
import static com.android.server.backup.BackupManagerService.TAG;

import android.Manifest;
@@ -98,6 +99,12 @@ public class Trampoline extends IBackupManager.Stub {

    private static final String BACKUP_THREAD = "backup";

    static Trampoline sInstance;

    static Trampoline getInstance() {
        return checkNotNull(sInstance);
    }

    private final Context mContext;
    private final UserManager mUserManager;