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

Commit 506f07e7 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Remove keyguardPrivateNotifications flag

Test: TH
Flag: EXEMPT flag cleanup
Fixes: 409612016
Change-Id: I2004e39bdb7b6596208f8844c010eef997012c2e
parent ca5e23e9
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -136,13 +136,6 @@ flag {
  bug: "368817201"
}

flag {
  name: "keyguard_private_notifications"
  namespace: "systemui"
  description: "Fixes the behavior of KeyguardManager#setPrivateNotificationsAllowed()"
  bug: "309920145"
}

flag {
  name: "category_voicemail"
  is_exported: true
+0 −50
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.statusbar;

import static android.app.Flags.FLAG_KEYGUARD_PRIVATE_NOTIFICATIONS;
import static android.app.Notification.VISIBILITY_PRIVATE;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.app.NotificationManager.VISIBILITY_NO_OVERRIDE;
@@ -130,7 +129,6 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
    public static List<FlagsParameterization> getParams() {
        return FlagsParameterization.allCombinationsOf(
                FLAG_ALLOW_PRIVATE_PROFILE,
                FLAG_KEYGUARD_PRIVATE_NOTIFICATIONS,
                FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
    }

@@ -314,7 +312,6 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
    }

    @Test
    @EnableFlags(FLAG_KEYGUARD_PRIVATE_NOTIFICATIONS)
    public void testInit() {
        when(mKeyguardManager.getPrivateNotificationsAllowed()).thenReturn(false);
        mLockscreenUserManager = new TestNotificationLockscreenUserManager(mContext);
@@ -884,7 +881,6 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
    }

    @Test
    @EnableFlags(FLAG_KEYGUARD_PRIVATE_NOTIFICATIONS)
    public void testEarlyUserSwitch() {
        mLockscreenUserManager =
                new TestNotificationLockscreenUserManager(mContext);
@@ -895,7 +891,6 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
    }

    @Test
    @EnableFlags(FLAG_KEYGUARD_PRIVATE_NOTIFICATIONS)
    public void testKeyguardManager_noPrivateNotifications() {
        Mockito.clearInvocations(mDevicePolicyManager);
        // User allows notifications
@@ -1042,7 +1037,6 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
    }

    @Test
    @EnableFlags(FLAG_KEYGUARD_PRIVATE_NOTIFICATIONS)
    public void testShouldShowLockscreenNotifications_keyguardManagerNoPrivateNotifications_show() {
        // KeyguardManager does not allow notifications
        when(mKeyguardManager.getPrivateNotificationsAllowed()).thenReturn(false);
@@ -1063,50 +1057,6 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
        assertTrue(mLockscreenUserManager.userAllowsNotificationsInPublic(mCurrentUser.id));
    }

    @Test
    @DisableFlags(FLAG_KEYGUARD_PRIVATE_NOTIFICATIONS)
    public void testShouldShowLockscreenNotifications_keyguardManagerNoPrivateNotifications() {
        // KeyguardManager does not allow notifications
        when(mKeyguardManager.getPrivateNotificationsAllowed()).thenReturn(false);
        // User allows notifications
        mSettings.putIntForUser(LOCK_SCREEN_SHOW_NOTIFICATIONS, 1, mCurrentUser.id);
        changeSetting(LOCK_SCREEN_SHOW_NOTIFICATIONS);
        // DevicePolicy allows notifications
        when(mDevicePolicyManager.getKeyguardDisabledFeatures(null, mCurrentUser.id))
                .thenReturn(0);
        BroadcastReceiver.PendingResult pr = new BroadcastReceiver.PendingResult(
                0, null, null, 0, true, false, null, mCurrentUser.id, 0);
        mLockscreenUserManager.mAllUsersReceiver.setPendingResult(pr);
        mLockscreenUserManager.mAllUsersReceiver.onReceive(mContext,
                new Intent(ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED));

        assertFalse(mLockscreenUserManager.shouldShowLockscreenNotifications());
    }

    @Test
    @DisableFlags(FLAG_KEYGUARD_PRIVATE_NOTIFICATIONS)
    public void testUserAllowsNotificationsInPublic_keyguardManagerNoPrivateNotifications() {
        // DevicePolicy allows notifications
        when(mDevicePolicyManager.getKeyguardDisabledFeatures(null, mCurrentUser.id))
                .thenReturn(0);
        BroadcastReceiver.PendingResult pr = new BroadcastReceiver.PendingResult(
                0, null, null, 0, true, false, null, mCurrentUser.id, 0);
        mLockscreenUserManager.mAllUsersReceiver.setPendingResult(pr);
        mLockscreenUserManager.mAllUsersReceiver.onReceive(mContext,
                new Intent(ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED));

        // KeyguardManager does not allow notifications
        when(mKeyguardManager.getPrivateNotificationsAllowed()).thenReturn(false);

        // User allows notifications
        mSettings.putIntForUser(LOCK_SCREEN_SHOW_NOTIFICATIONS, 1, mCurrentUser.id);
        // We shouldn't need to call this method, but getPrivateNotificationsAllowed has no
        // callback, so it's only updated when the setting is
        changeSetting(LOCK_SCREEN_SHOW_NOTIFICATIONS);

        assertFalse(mLockscreenUserManager.userAllowsNotificationsInPublic(mCurrentUser.id));
    }

    @Test
    public void testUserAllowsNotificationsInPublic_settingsChange() {
        // User allows notifications
+7 −12
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui;

import static android.app.Flags.keyguardPrivateNotifications;
import static android.content.Intent.ACTION_PACKAGE_ADDED;
import static android.content.Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST;
import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
@@ -546,7 +545,6 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis
        @Override
        public void onReceive(Context context, Intent intent) {
            if (Objects.equals(intent.getAction(), Intent.ACTION_USER_UNLOCKED)) {
                if (keyguardPrivateNotifications()) {
                // Start the launcher connection to the launcher service
                // Connect if user hasn't connected yet
                if (getProxy() == null) {
@@ -554,7 +552,6 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis
                }
            }
        }
        }
    };

    private final BroadcastReceiver mLauncherStateChangedReceiver = new BroadcastReceiver() {
@@ -806,11 +803,9 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        mContext.registerReceiver(mLauncherStateChangedReceiver, filter);

        if (keyguardPrivateNotifications()) {
        mBroadcastDispatcher.registerReceiver(mUserEventReceiver,
                new IntentFilter(Intent.ACTION_USER_UNLOCKED),
                null /* executor */, UserHandle.ALL);
        }

        // Listen for status bar state changes
        statusBarWinController.registerCallback(mStatusBarWindowCallback);
+15 −53
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
 */
package com.android.systemui.statusbar;

import static android.app.Flags.keyguardPrivateNotifications;
import static android.app.StatusBarManager.ACTION_KEYGUARD_PRIVATE_NOTIFICATIONS_CHANGED;
import static android.app.StatusBarManager.EXTRA_KM_PRIVATE_NOTIFS_ALLOWED;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED;
@@ -241,14 +240,6 @@ public class NotificationLockscreenUserManagerImpl implements
                });
            } else if (profileAvailabilityActions(action)) {
                updateCurrentProfilesCache();
            } else if (Objects.equals(action, Intent.ACTION_USER_UNLOCKED)) {
                if (!keyguardPrivateNotifications()) {
                    // Start the overview connection to the launcher service
                    // Connect if user hasn't connected yet
                    if (mLauncherProxyServiceLazy.get().getProxy() == null) {
                        mLauncherProxyServiceLazy.get().startConnectionToCurrentUser();
                    }
                }
            } else if (Objects.equals(action, NOTIFICATION_UNLOCKED_BY_WORK_CHALLENGE_ACTION)) {
                final IntentSender intentSender = intent.getParcelableExtra(
                        Intent.EXTRA_INTENT);
@@ -382,9 +373,7 @@ public class NotificationLockscreenUserManagerImpl implements

        dumpManager.registerDumpable(this);

        if (keyguardPrivateNotifications()) {
        init();
        }

        // To avoid dependency injection cycle, finish constructing this object before using the
        // KeyguardInteractor. The CoroutineScope will only be null in tests.
@@ -417,10 +406,6 @@ public class NotificationLockscreenUserManagerImpl implements

    public void setUpWithPresenter(NotificationPresenter presenter) {
        mPresenter = presenter;

        if (!keyguardPrivateNotifications()) {
            init();
        }
    }

    private void init() {
@@ -498,11 +483,10 @@ public class NotificationLockscreenUserManagerImpl implements
        mBroadcastDispatcher.registerReceiver(mAllUsersReceiver,
                new IntentFilter(ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED),
                mBackgroundExecutor, UserHandle.ALL);
        if (keyguardPrivateNotifications()) {

        mBroadcastDispatcher.registerReceiver(mKeyguardReceiver,
                new IntentFilter(ACTION_KEYGUARD_PRIVATE_NOTIFICATIONS_CHANGED),
                mBackgroundExecutor, UserHandle.ALL);
        }

        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_USER_ADDED);
@@ -541,10 +525,8 @@ public class NotificationLockscreenUserManagerImpl implements
                false, mLockScreenUris, 0, UserHandle.of(userId));
        updateDpcSettings(userId);

        if (keyguardPrivateNotifications()) {
        updateGlobalKeyguardSettings();
    }
    }

    public boolean shouldShowLockscreenNotifications() {
        return mShowLockscreenNotifications;
@@ -571,12 +553,8 @@ public class NotificationLockscreenUserManagerImpl implements
        boolean show;
        boolean allowedByDpm;

        if (keyguardPrivateNotifications()) {
        show = mUsersUsersAllowingNotifications.get(mCurrentUserId);
        } else {
            show = mUsersUsersAllowingNotifications.get(mCurrentUserId)
                    && mKeyguardAllowingNotifications;
        }

        // If DPC never notified us about a user, that means they have no policy for the user,
        // and they allow the behavior
        allowedByDpm = mUsersDpcAllowingNotifications.get(mCurrentUserId, true);
@@ -610,12 +588,7 @@ public class NotificationLockscreenUserManagerImpl implements
                userId) != 0;
        mUsersUsersAllowingNotifications.put(userId, newAllowLockscreen);

        if (keyguardPrivateNotifications()) {
        return (newAllowLockscreen != originalAllowLockscreen);
        } else {
            boolean keyguardChanged = updateGlobalKeyguardSettings();
            return (newAllowLockscreen != originalAllowLockscreen) || keyguardChanged;
        }
    }

    @WorkerThread
@@ -674,14 +647,9 @@ public class NotificationLockscreenUserManagerImpl implements
            Log.i(TAG, "Asking for redact notifs dpm override too early", new Throwable());
            return false;
        }
        if (keyguardPrivateNotifications()) {
        return mUsersUsersAllowingPrivateNotifications.get(userHandle)
                && mUsersDpcAllowingPrivateNotifications.get(userHandle)
                && mKeyguardAllowingNotifications;
        } else {
            return mUsersUsersAllowingPrivateNotifications.get(userHandle)
                    && mUsersDpcAllowingPrivateNotifications.get(userHandle);
        }
    }

    /**
@@ -750,14 +718,8 @@ public class NotificationLockscreenUserManagerImpl implements
            Log.wtf(TAG, "Asking for show notifs dpm override too early", new Throwable());
            updateDpcSettings(userHandle);
        }
        if (keyguardPrivateNotifications()) {
        return mUsersUsersAllowingNotifications.get(userHandle)
                && mUsersDpcAllowingNotifications.get(userHandle);
        } else {
            return mUsersUsersAllowingNotifications.get(userHandle)
                    && mUsersDpcAllowingNotifications.get(userHandle)
                    && mKeyguardAllowingNotifications;
        }
    }

    /**
@@ -790,7 +752,7 @@ public class NotificationLockscreenUserManagerImpl implements
        if (notificationRequestsRedaction && isNotifRedacted) {
            return REDACTION_TYPE_PUBLIC;
        }
        if (keyguardPrivateNotifications() && !mKeyguardAllowingNotifications) {
        if (!mKeyguardAllowingNotifications) {
            return REDACTION_TYPE_PUBLIC;
        }

+5 −7
Original line number Diff line number Diff line
@@ -7213,13 +7213,11 @@ public class NotificationManagerService extends SystemService {
            }
            if (allow != mLockScreenAllowSecureNotifications) {
                mLockScreenAllowSecureNotifications = allow;
                if (android.app.Flags.keyguardPrivateNotifications()) {
                getContext().sendBroadcast(
                        new Intent(ACTION_KEYGUARD_PRIVATE_NOTIFICATIONS_CHANGED)
                                .putExtra(EXTRA_KM_PRIVATE_NOTIFS_ALLOWED,
                                        mLockScreenAllowSecureNotifications),
                        STATUS_BAR_SERVICE);
                }
                handleSavePolicyFile();
            }
Loading