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

Commit e5050980 authored by Annie Meng's avatar Annie Meng Committed by Android (Google) Code Review
Browse files

Merge "[Multi-user] Clean up backup enabled initialization"

parents 01a6fc95 6e95fc95
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import android.os.Binder;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.Trace;
import android.os.UserHandle;
import android.util.Slog;
@@ -139,13 +138,7 @@ public class BackupManagerService {
        mServiceUsers.put(userId, userBackupManagerService);

        Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backup enable");
        try {
            // TODO(b/121198604): Make enable file per-user and clean up indirection.
            mTrampoline.setBackupEnabledForUser(
                    userId, UserBackupManagerFilePersistedSettings.readBackupEnableState(userId));
        } catch (RemoteException e) {
            // Can't happen, it's a local object.
        }
        userBackupManagerService.initializeBackupEnableState();
        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
    }

+5 −0
Original line number Diff line number Diff line
@@ -556,6 +556,11 @@ public class UserBackupManagerService {
        mWakelock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "*backup*");
    }

    void initializeBackupEnableState() {
        boolean isEnabled = UserBackupManagerFilePersistedSettings.readBackupEnableState(mUserId);
        setBackupEnabled(isEnabled);
    }

    /** Cleans up state when the user of this service is stopped. */
    void tearDownService() {
        mUserBackupThread.quit();
+1 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.backup;

import static android.Manifest.permission.BACKUP;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;

import static com.android.server.backup.testing.BackupManagerServiceTestUtils.startBackupThread;
@@ -27,7 +28,6 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.robolectric.Shadows.shadowOf;
import static org.testng.Assert.expectThrows;

@@ -201,7 +201,7 @@ public class BackupManagerServiceTest {
        backupManagerService.stopServiceForUser(mUserOneId);

        verify(mUserOneService).tearDownService();
        verifyNoMoreInteractions(mUserTwoService);
        verify(mUserTwoService, never()).tearDownService();
    }

    /** Test that the service unregisters users when stopped. */
@@ -1542,6 +1542,7 @@ public class BackupManagerServiceTest {
    }

    private BackupManagerService createService() {
        mShadowContext.grantPermissions(BACKUP);
        return new BackupManagerService(
                mContext, new Trampoline(mContext), startBackupThread(null));
    }
+1 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.