summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java7
2 files changed, 10 insertions, 5 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java
index 20474c842b51..deaf57999b21 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java
@@ -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,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
index 2bcd3fcfed17..10b726b90894 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerImpl.java
@@ -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;
}