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

Commit e7367568 authored by Bernardo Rufino's avatar Bernardo Rufino Committed by Android (Google) Code Review
Browse files

Merge "Move sInstance to Trampoline"

parents c422b02f 11b651c2
Loading
Loading
Loading
Loading
+4 −14
Original line number Original line Diff line number Diff line
@@ -74,16 +74,6 @@ public class BackupManagerService {
    @VisibleForTesting
    @VisibleForTesting
    static final String DUMP_RUNNING_USERS_MESSAGE = "Backup Manager is running for users:";
    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 Context mContext;
    private final Trampoline mTrampoline;
    private final Trampoline mTrampoline;


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


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


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


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


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


        Trampoline service = BackupManagerService.getInstance();
        Trampoline service = Trampoline.getInstance();
        return service.beginFullBackup(userId, this);
        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);
        service.endFullBackup(userId);


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


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


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


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


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


    private static final String BACKUP_THREAD = "backup";
    private static final String BACKUP_THREAD = "backup";


    static Trampoline sInstance;

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

    private final Context mContext;
    private final Context mContext;
    private final UserManager mUserManager;
    private final UserManager mUserManager;