Remove IPC from critical path
Lock screen settings should be cached to avoid hitting an IPC with ContentProviders. Test: manually change lock screen privacy settings Test: atest NotificationLockscreenUserManagerTest Bug: 224779945 Change-Id: I6ae410a3c46b65cb15b0eacefa19ae272939f1b2
This commit is contained in:
@@ -60,6 +60,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.Co
|
||||
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
|
||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
import com.android.systemui.util.settings.SecureSettings;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
@@ -84,6 +85,7 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
|
||||
private final DeviceProvisionedController mDeviceProvisionedController;
|
||||
private final KeyguardStateController mKeyguardStateController;
|
||||
private final SecureSettings mSecureSettings;
|
||||
private final Object mLock = new Object();
|
||||
|
||||
// Lazy
|
||||
@@ -187,6 +189,7 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
protected NotificationPresenter mPresenter;
|
||||
protected ContentObserver mLockscreenSettingsObserver;
|
||||
protected ContentObserver mSettingsObserver;
|
||||
private boolean mHideSilentNotificationsOnLockscreen;
|
||||
|
||||
private NotificationEntryManager getEntryManager() {
|
||||
if (mEntryManager == null) {
|
||||
@@ -208,6 +211,7 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
@Main Handler mainHandler,
|
||||
DeviceProvisionedController deviceProvisionedController,
|
||||
KeyguardStateController keyguardStateController,
|
||||
SecureSettings secureSettings,
|
||||
DumpManager dumpManager) {
|
||||
mContext = context;
|
||||
mMainHandler = mainHandler;
|
||||
@@ -222,6 +226,7 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
mKeyguardManager = keyguardManager;
|
||||
mBroadcastDispatcher = broadcastDispatcher;
|
||||
mDeviceProvisionedController = deviceProvisionedController;
|
||||
mSecureSettings = secureSettings;
|
||||
mKeyguardStateController = keyguardStateController;
|
||||
|
||||
dumpManager.registerDumpable(this);
|
||||
@@ -256,12 +261,18 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
};
|
||||
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS), false,
|
||||
mSecureSettings.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS), false,
|
||||
mLockscreenSettingsObserver,
|
||||
UserHandle.USER_ALL);
|
||||
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS),
|
||||
mSecureSettings.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS),
|
||||
true,
|
||||
mLockscreenSettingsObserver,
|
||||
UserHandle.USER_ALL);
|
||||
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
mSecureSettings.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS),
|
||||
true,
|
||||
mLockscreenSettingsObserver,
|
||||
UserHandle.USER_ALL);
|
||||
@@ -272,7 +283,7 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
|
||||
if (ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT) {
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT),
|
||||
mSecureSettings.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT),
|
||||
false,
|
||||
mSettingsObserver,
|
||||
UserHandle.USER_ALL);
|
||||
@@ -366,7 +377,7 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
}
|
||||
}
|
||||
boolean exceedsPriorityThreshold;
|
||||
if (hideSilentNotificationsOnLockscreen()) {
|
||||
if (mHideSilentNotificationsOnLockscreen) {
|
||||
exceedsPriorityThreshold =
|
||||
entry.getBucket() == BUCKET_MEDIA_CONTROLS
|
||||
|| (entry.getBucket() != BUCKET_SILENT
|
||||
@@ -377,11 +388,6 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
return mShowLockscreenNotifications && exceedsPriorityThreshold;
|
||||
}
|
||||
|
||||
private boolean hideSilentNotificationsOnLockscreen() {
|
||||
return whitelistIpcs(() -> Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1) == 0);
|
||||
}
|
||||
|
||||
private void setShowLockscreenNotifications(boolean show) {
|
||||
mShowLockscreenNotifications = show;
|
||||
}
|
||||
@@ -391,7 +397,7 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
}
|
||||
|
||||
protected void updateLockscreenNotificationSetting() {
|
||||
final boolean show = Settings.Secure.getIntForUser(mContext.getContentResolver(),
|
||||
final boolean show = mSecureSettings.getIntForUser(
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
|
||||
1,
|
||||
mCurrentUserId) != 0;
|
||||
@@ -400,10 +406,13 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
final boolean allowedByDpm = (dpmFlags
|
||||
& DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS) == 0;
|
||||
|
||||
mHideSilentNotificationsOnLockscreen = mSecureSettings.getIntForUser(
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1, mCurrentUserId) == 0;
|
||||
|
||||
setShowLockscreenNotifications(show && allowedByDpm);
|
||||
|
||||
if (ENABLE_LOCK_SCREEN_ALLOW_REMOTE_INPUT) {
|
||||
final boolean remoteInput = Settings.Secure.getIntForUser(mContext.getContentResolver(),
|
||||
final boolean remoteInput = mSecureSettings.getIntForUser(
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT,
|
||||
0,
|
||||
mCurrentUserId) != 0;
|
||||
@@ -426,8 +435,7 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
}
|
||||
|
||||
if (mUsersAllowingPrivateNotifications.indexOfKey(userHandle) < 0) {
|
||||
final boolean allowedByUser = 0 != Settings.Secure.getIntForUser(
|
||||
mContext.getContentResolver(),
|
||||
final boolean allowedByUser = 0 != mSecureSettings.getIntForUser(
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, userHandle);
|
||||
final boolean allowedByDpm = adminAllowsKeyguardFeature(userHandle,
|
||||
DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
|
||||
@@ -492,8 +500,7 @@ public class NotificationLockscreenUserManagerImpl implements
|
||||
}
|
||||
|
||||
if (mUsersAllowingNotifications.indexOfKey(userHandle) < 0) {
|
||||
final boolean allowedByUser = 0 != Settings.Secure.getIntForUser(
|
||||
mContext.getContentResolver(),
|
||||
final boolean allowedByUser = 0 != mSecureSettings.getIntForUser(
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0, userHandle);
|
||||
final boolean allowedByDpm = adminAllowsKeyguardFeature(userHandle,
|
||||
DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
|
||||
|
||||
@@ -66,6 +66,7 @@ import com.android.systemui.statusbar.notification.collection.notifcollection.Co
|
||||
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
|
||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
import com.android.systemui.util.settings.FakeSettings;
|
||||
|
||||
import com.google.android.collect.Lists;
|
||||
|
||||
@@ -109,6 +110,7 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
private UserInfo mCurrentUser;
|
||||
private UserInfo mSecondaryUser;
|
||||
private UserInfo mWorkUser;
|
||||
private FakeSettings mSettings;
|
||||
private TestNotificationLockscreenUserManager mLockscreenUserManager;
|
||||
private NotificationEntry mCurrentUserNotif;
|
||||
private NotificationEntry mSecondaryUserNotif;
|
||||
@@ -120,6 +122,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager);
|
||||
|
||||
int currentUserId = ActivityManager.getCurrentUser();
|
||||
mSettings = new FakeSettings();
|
||||
mSettings.setUserId(ActivityManager.getCurrentUser());
|
||||
mCurrentUser = new UserInfo(currentUserId, "", 0);
|
||||
mSecondaryUser = new UserInfo(currentUserId + 1, "", 0);
|
||||
mWorkUser = new UserInfo(currentUserId + 2, "" /* name */, null /* iconPath */, 0,
|
||||
@@ -157,48 +161,45 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testLockScreenShowNotificationsFalse() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
assertFalse(mLockscreenUserManager.shouldShowLockscreenNotifications());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLockScreenShowNotificationsTrue() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
assertTrue(mLockscreenUserManager.shouldShowLockscreenNotifications());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLockScreenAllowPrivateNotificationsTrue() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
assertTrue(mLockscreenUserManager.userAllowsPrivateNotificationsInPublic(mCurrentUser.id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLockScreenAllowPrivateNotificationsFalse() {
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, mCurrentUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0,
|
||||
mCurrentUser.id);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
assertFalse(mLockscreenUserManager.userAllowsPrivateNotificationsInPublic(mCurrentUser.id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLockScreenAllowsWorkPrivateNotificationsFalse() {
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, mWorkUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0,
|
||||
mWorkUser.id);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
assertFalse(mLockscreenUserManager.userAllowsPrivateNotificationsInPublic(mWorkUser.id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLockScreenAllowsWorkPrivateNotificationsTrue() {
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mWorkUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1,
|
||||
mWorkUser.id);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
assertTrue(mLockscreenUserManager.userAllowsPrivateNotificationsInPublic(mWorkUser.id));
|
||||
}
|
||||
@@ -206,8 +207,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testCurrentUserPrivateNotificationsNotRedacted() {
|
||||
// GIVEN current user doesn't allow private notifications to show
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, mCurrentUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0,
|
||||
mCurrentUser.id);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
|
||||
// THEN current user's notification is redacted
|
||||
@@ -217,8 +218,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testCurrentUserPrivateNotificationsRedacted() {
|
||||
// GIVEN current user allows private notifications to show
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mCurrentUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1,
|
||||
mCurrentUser.id);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
|
||||
// THEN current user's notification isn't redacted
|
||||
@@ -228,8 +229,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testWorkPrivateNotificationsRedacted() {
|
||||
// GIVEN work profile doesn't private notifications to show
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, mWorkUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0,
|
||||
mWorkUser.id);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
|
||||
// THEN work profile notification is redacted
|
||||
@@ -239,8 +240,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testWorkPrivateNotificationsNotRedacted() {
|
||||
// GIVEN work profile allows private notifications to show
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mWorkUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1,
|
||||
mWorkUser.id);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
|
||||
// THEN work profile notification isn't redacted
|
||||
@@ -250,12 +251,11 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testWorkPrivateNotificationsNotRedacted_otherUsersRedacted() {
|
||||
// GIVEN work profile allows private notifications to show but the other users don't
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mWorkUser.id);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, mCurrentUser.id);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0,
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1,
|
||||
mWorkUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0,
|
||||
mCurrentUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0,
|
||||
mSecondaryUser.id);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
|
||||
@@ -270,12 +270,11 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testWorkProfileRedacted_otherUsersNotRedacted() {
|
||||
// GIVEN work profile doesn't allow private notifications to show but the other users do
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, mWorkUser.id);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, mCurrentUser.id);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1,
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0,
|
||||
mWorkUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1,
|
||||
mCurrentUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1,
|
||||
mSecondaryUser.id);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
|
||||
@@ -291,10 +290,9 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
public void testSecondaryUserNotRedacted_currentUserRedacted() {
|
||||
// GIVEN secondary profile allows private notifications to show but the current user
|
||||
// doesn't allow private notifications to show
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0, mCurrentUser.id);
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1,
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0,
|
||||
mCurrentUser.id);
|
||||
mSettings.putIntForUser(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1,
|
||||
mSecondaryUser.id);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
|
||||
@@ -328,10 +326,9 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testShowSilentNotifications_settingSaysShow() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
|
||||
NotificationEntry entry = new NotificationEntryBuilder()
|
||||
.setImportance(IMPORTANCE_LOW)
|
||||
@@ -343,10 +340,9 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testShowSilentNotifications_settingSaysHide() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
|
||||
final Notification notification = mock(Notification.class);
|
||||
when(notification.isForegroundService()).thenReturn(true);
|
||||
@@ -360,10 +356,9 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testShowSilentNotificationsPeopleBucket_settingSaysHide() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
|
||||
final Notification notification = mock(Notification.class);
|
||||
when(notification.isForegroundService()).thenReturn(true);
|
||||
@@ -377,10 +372,9 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void testShowSilentNotificationsMediaBucket_settingSaysHide() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
|
||||
final Notification notification = mock(Notification.class);
|
||||
when(notification.isForegroundService()).thenReturn(true);
|
||||
@@ -396,8 +390,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testKeyguardNotificationSuppressors() {
|
||||
// GIVEN a notification that should be shown on the lockscreen
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
mSettings.putInt(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
|
||||
mLockscreenUserManager.getLockscreenSettingsObserverForTest().onChange(false);
|
||||
final NotificationEntry entry = new NotificationEntryBuilder()
|
||||
.setImportance(IMPORTANCE_HIGH)
|
||||
.build();
|
||||
@@ -433,6 +427,7 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
||||
Handler.createAsync(Looper.myLooper()),
|
||||
mDeviceProvisionedController,
|
||||
mKeyguardStateController,
|
||||
mSettings,
|
||||
mock(DumpManager.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.systemui.util.settings;
|
||||
|
||||
import android.annotation.UserIdInt;
|
||||
import android.content.ContentResolver;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
@@ -34,6 +35,8 @@ public class FakeSettings implements SecureSettings, GlobalSettings, SystemSetti
|
||||
private final Map<String, List<ContentObserver>> mContentObserversAllUsers = new HashMap<>();
|
||||
|
||||
public static final Uri CONTENT_URI = Uri.parse("content://settings/fake");
|
||||
@UserIdInt
|
||||
private int mUserId = UserHandle.USER_CURRENT;
|
||||
|
||||
public FakeSettings() {
|
||||
}
|
||||
@@ -85,9 +88,13 @@ public class FakeSettings implements SecureSettings, GlobalSettings, SystemSetti
|
||||
return Uri.withAppendedPath(CONTENT_URI, name);
|
||||
}
|
||||
|
||||
public void setUserId(@UserIdInt int userId) {
|
||||
mUserId = userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUserId() {
|
||||
return UserHandle.USER_CURRENT;
|
||||
return mUserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user