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

Commit 5b8ca021 authored by Nate Myren's avatar Nate Myren
Browse files

Replace kgm call with local in shouldShowRedacted

There is no need to make a binder call to the KeyguardManager to
determine device locked state for every notification, when we already
have an observed stateflow for the KeyguardInteractor

Bug: 388207862
Test: atest NotificationLockscreenUserManagerTest
Flag: android.app.redact_sensitive_content_notifications_on_lockscreen
Change-Id: I0d822da880a34a18e79e8e9d6d5c26ffe3297210
parent 04a6b7ef
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -526,7 +526,7 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
        mLockscreenUserManager.mLastLockTime
                .set(mSensitiveNotifPostTime - TimeUnit.DAYS.toMillis(1));
        // Device is not currently locked
        when(mKeyguardManager.isDeviceLocked()).thenReturn(false);
        mLockscreenUserManager.mLocked.set(false);

        // Sensitive Content notifications are always redacted
        assertEquals(REDACTION_TYPE_NONE,
@@ -540,7 +540,7 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
        mSettings.putIntForUser(LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1,
                mCurrentUser.id);
        changeSetting(LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS);
        when(mKeyguardManager.isDeviceLocked()).thenReturn(true);
        mLockscreenUserManager.mLocked.set(true);
        // Device was locked after this notification arrived
        mLockscreenUserManager.mLastLockTime
                .set(mSensitiveNotifPostTime + TimeUnit.DAYS.toMillis(1));
@@ -560,7 +560,7 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
        // Device has been locked for 1 second before the notification came in, which is too short
        mLockscreenUserManager.mLastLockTime
                .set(mSensitiveNotifPostTime - TimeUnit.SECONDS.toMillis(1));
        when(mKeyguardManager.isDeviceLocked()).thenReturn(true);
        mLockscreenUserManager.mLocked.set(true);

        // Sensitive Content notifications are always redacted
        assertEquals(REDACTION_TYPE_NONE,
@@ -577,7 +577,7 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
        // Claim the device was last locked 1 day ago
        mLockscreenUserManager.mLastLockTime
                .set(mSensitiveNotifPostTime - TimeUnit.DAYS.toMillis(1));
        when(mKeyguardManager.isDeviceLocked()).thenReturn(true);
        mLockscreenUserManager.mLocked.set(true);

        // Sensitive Content notifications are always redacted
        assertEquals(REDACTION_TYPE_NONE,
+6 −1
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;

import javax.inject.Inject;
@@ -297,6 +298,9 @@ public class NotificationLockscreenUserManagerImpl implements
    // The last lock time. Uses currentTimeMillis
    @VisibleForTesting
    protected final AtomicLong mLastLockTime = new AtomicLong(-1);
    // Whether or not the device is locked
    @VisibleForTesting
    protected final AtomicBoolean mLocked = new AtomicBoolean(true);

    protected int mCurrentUserId = 0;

@@ -369,6 +373,7 @@ public class NotificationLockscreenUserManagerImpl implements
                        if (!unlocked) {
                            mLastLockTime.set(System.currentTimeMillis());
                        }
                        mLocked.set(!unlocked);
                    }));
        }
    }
@@ -737,7 +742,7 @@ public class NotificationLockscreenUserManagerImpl implements
            return false;
        }

        if (!mKeyguardManager.isDeviceLocked()) {
        if (!mLocked.get()) {
            return false;
        }