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

Commit 4cce29b2 authored by Yasin Kilicdere's avatar Yasin Kilicdere Committed by Automerger Merge Worker
Browse files

Merge "Load the notifications of the target user before unfreezing the screen"...

Merge "Load the notifications of the target user before unfreezing the screen" into udc-dev am: 61ead8cc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22300803



Change-Id: Ib1fa0c89738b447d3fcfc446027bf3aaaa1ad9b4
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 0a255061 61ead8cc
Loading
Loading
Loading
Loading
+24 −4
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar;

import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED;

import static com.android.systemui.DejankUtils.whitelistIpcs;

import android.app.KeyguardManager;
@@ -47,6 +48,8 @@ import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.recents.OverviewProxyService;
@@ -59,14 +62,14 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.ListenerSet;
import com.android.systemui.util.settings.SecureSettings;

import dagger.Lazy;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import dagger.Lazy;

/**
 * Handles keeping track of the current user, profiles, and various things related to hiding
 * contents, redacting notifications, and the lockscreen.
@@ -99,7 +102,7 @@ public class NotificationLockscreenUserManagerImpl implements
    private final BroadcastDispatcher mBroadcastDispatcher;
    private final NotificationClickNotifier mClickNotifier;
    private final Lazy<OverviewProxyService> mOverviewProxyServiceLazy;

    private final FeatureFlags mFeatureFlags;
    private boolean mShowLockscreenNotifications;
    private boolean mAllowLockscreenRemoteInput;
    private LockPatternUtils mLockPatternUtils;
@@ -174,6 +177,21 @@ public class NotificationLockscreenUserManagerImpl implements
            new UserTracker.Callback() {
                @Override
                public void onUserChanged(int newUser, @NonNull Context userContext) {
                    if (!mFeatureFlags.isEnabled(
                            Flags.LOAD_NOTIFICATIONS_BEFORE_THE_USER_SWITCH_IS_COMPLETE)) {
                        handleUserChange(newUser);
                    }
                }

                @Override
                public void onUserChanging(int newUser, @NonNull Context userContext) {
                    if (mFeatureFlags.isEnabled(
                            Flags.LOAD_NOTIFICATIONS_BEFORE_THE_USER_SWITCH_IS_COMPLETE)) {
                        handleUserChange(newUser);
                    }
                }

                private void handleUserChange(int newUser) {
                    mCurrentUserId = newUser;
                    updateCurrentProfilesCache();

@@ -216,7 +234,8 @@ public class NotificationLockscreenUserManagerImpl implements
            KeyguardStateController keyguardStateController,
            SecureSettings secureSettings,
            DumpManager dumpManager,
            LockPatternUtils lockPatternUtils) {
            LockPatternUtils lockPatternUtils,
            FeatureFlags featureFlags) {
        mContext = context;
        mMainHandler = mainHandler;
        mDevicePolicyManager = devicePolicyManager;
@@ -234,6 +253,7 @@ public class NotificationLockscreenUserManagerImpl implements
        mDeviceProvisionedController = deviceProvisionedController;
        mSecureSettings = secureSettings;
        mKeyguardStateController = keyguardStateController;
        mFeatureFlags = featureFlags;

        dumpManager.registerDumpable(this);
    }
+14 −1
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ import com.android.systemui.Dependency;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FakeFeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.settings.UserTracker;
@@ -110,6 +112,7 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
    private NotificationEntry mCurrentUserNotif;
    private NotificationEntry mSecondaryUserNotif;
    private NotificationEntry mWorkProfileNotif;
    private final FakeFeatureFlags mFakeFeatureFlags = new FakeFeatureFlags();

    @Before
    public void setUp() {
@@ -290,8 +293,17 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
        assertTrue(mLockscreenUserManager.needsRedaction(mSecondaryUserNotif));
    }

    @Test
    public void testUserSwitchedCallsOnUserSwitching() {
        mFakeFeatureFlags.set(Flags.LOAD_NOTIFICATIONS_BEFORE_THE_USER_SWITCH_IS_COMPLETE, true);
        mLockscreenUserManager.getUserTrackerCallbackForTest().onUserChanging(mSecondaryUser.id,
                mContext);
        verify(mPresenter, times(1)).onUserSwitched(mSecondaryUser.id);
    }

    @Test
    public void testUserSwitchedCallsOnUserSwitched() {
        mFakeFeatureFlags.set(Flags.LOAD_NOTIFICATIONS_BEFORE_THE_USER_SWITCH_IS_COMPLETE, false);
        mLockscreenUserManager.getUserTrackerCallbackForTest().onUserChanged(mSecondaryUser.id,
                mContext);
        verify(mPresenter, times(1)).onUserSwitched(mSecondaryUser.id);
@@ -356,7 +368,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
                    mKeyguardStateController,
                    mSettings,
                    mock(DumpManager.class),
                    mock(LockPatternUtils.class));
                    mock(LockPatternUtils.class),
                    mFakeFeatureFlags);
        }

        public BroadcastReceiver getBaseBroadcastReceiverForTest() {