diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0392bfc52b3..cf0e112a15f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8657,6 +8657,13 @@
When work profile is locked
+
+ Lock screen notification minimalism
+
+
+ Show fewer notifications on lock screen
+
Show only new notifications on lock screen
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index b673a0839b0..c88b7bace8a 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -136,8 +136,16 @@
/>
+
+
diff --git a/src/com/android/settings/notification/LockscreenNotificationMinimalismPreferenceController.java b/src/com/android/settings/notification/LockscreenNotificationMinimalismPreferenceController.java
new file mode 100644
index 00000000000..7b48ba7ff5a
--- /dev/null
+++ b/src/com/android/settings/notification/LockscreenNotificationMinimalismPreferenceController.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import static android.provider.Settings.Secure.LOCK_SCREEN_NOTIFICATION_MINIMALISM;
+import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.server.notification.Flags;
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+
+public class LockscreenNotificationMinimalismPreferenceController
+ extends TogglePreferenceController {
+
+ @VisibleForTesting
+ static final int ON = 1;
+ @VisibleForTesting
+ static final int OFF = 0;
+
+ public LockscreenNotificationMinimalismPreferenceController(
+ Context context,
+ String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Secure.getInt(mContext.getContentResolver(),
+ LOCK_SCREEN_NOTIFICATION_MINIMALISM, ON) == ON;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Secure.putInt(mContext.getContentResolver(),
+ LOCK_SCREEN_NOTIFICATION_MINIMALISM, isChecked ? ON : OFF);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (!Flags.notificationMinimalism()) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ int lockScreenNotif = Settings.Secure.getInt(mContext.getContentResolver(),
+ LOCK_SCREEN_SHOW_NOTIFICATIONS, 0);
+ if (lockScreenNotif == 0) {
+ return DISABLED_DEPENDENT_SETTING;
+ }
+ return AVAILABLE;
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_notifications;
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/LockscreenNotificationMinimalismPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/LockscreenNotificationMinimalismPreferenceControllerTest.java
new file mode 100644
index 00000000000..86dc06fc4d1
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/LockscreenNotificationMinimalismPreferenceControllerTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import static android.provider.Settings.Secure.LOCK_SCREEN_NOTIFICATION_MINIMALISM;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class LockscreenNotificationMinimalismPreferenceControllerTest {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private PreferenceScreen mScreen;
+
+ private LockscreenNotificationMinimalismPreferenceController mController;
+ private Preference mPreference;
+ static final int ON = 1;
+ static final int OFF = 0;
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ doReturn(mock(DevicePolicyManager.class)).when(mContext)
+ .getSystemService(Context.DEVICE_POLICY_SERVICE);
+ mController = new LockscreenNotificationMinimalismPreferenceController(mContext,
+ "key");
+ mPreference = new Preference(RuntimeEnvironment.application);
+ mPreference.setKey(mController.getPreferenceKey());
+ when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
+ }
+
+ @Test
+ @DisableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM)
+ public void display_featureFlagOff_shouldNotDisplay() {
+ mController.displayPreference(mScreen);
+ assertThat(mPreference.isVisible()).isFalse();
+ }
+
+ @Test
+ @EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM)
+ public void display_featureFlagOn_shouldDisplay() {
+ mController.displayPreference(mScreen);
+ assertThat(mPreference.isVisible()).isTrue();
+ }
+
+ @Test
+ @EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM)
+ public void isChecked_settingIsOff_shouldReturnFalse() {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ LOCK_SCREEN_NOTIFICATION_MINIMALISM, OFF);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ @EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_MINIMALISM)
+ public void isChecked_settingIsOn_shouldReturnTrue() {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ LOCK_SCREEN_NOTIFICATION_MINIMALISM, ON);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+}