Add a toggle for enabling/disabling sensitive lockscreen notifications for Private Space

This adds a toggle in the Private Space Settings page to control the
lockscreen sensitive notifications for the private profile.
Sensitive notifications for private profile will still be disabled if
sensitive notifications are disabled for the main user.

Demo link:https://drive.google.com/file/d/1--LNXziTRTMvfdsJZAh90SiNiPxWNcI8/view?usp=sharing

Bug: 317067050
Test: atest SettingsUnitTests:HidePrivateSpaceSensitiveNotificationsControllerTest

Change-Id: Ie7f18c1a940e5ffd64112a01c48ac9dee58cb1ab
This commit is contained in:
Olivier Nshimiye
2024-02-08 17:41:27 +00:00
parent 022a815033
commit baecaee2a5
6 changed files with 329 additions and 5 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settings.privatespace;
import static android.provider.Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS;
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK;
import static com.android.settings.privatespace.PrivateSpaceMaintainer.HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL;
@@ -139,6 +140,24 @@ public class PrivateSpaceMaintainerTest {
.isEqualTo(HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL);
}
/**
* Tests that {@link PrivateSpaceMaintainer#createPrivateSpace()} sets the PS sensitive
* notifications to hidden by default.
*/
@Test
public void createPrivateSpace_psDoesNotExist_setsDefaultPsSensitiveNotificationsValue() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
android.multiuser.Flags.FLAG_ENABLE_PS_SENSITIVE_NOTIFICATIONS_TOGGLE);
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
privateSpaceMaintainer.deletePrivateSpace();
privateSpaceMaintainer.createPrivateSpace();
assertThat(privateSpaceMaintainer.doesPrivateSpaceExist()).isTrue();
assertThat(getPsSensitiveNotificationsValue(privateSpaceMaintainer))
.isEqualTo(HidePrivateSpaceSensitiveNotificationsController.DISABLED);
}
/**
* Tests that {@link PrivateSpaceMaintainer#createPrivateSpace()} when PS exist does not reset
* hide PS Settings.
@@ -287,4 +306,11 @@ public class PrivateSpaceMaintainerTest {
0,
privateSpaceMaintainer.getPrivateProfileHandle().getIdentifier());
}
private int getPsSensitiveNotificationsValue(PrivateSpaceMaintainer privateSpaceMaintainer) {
return Settings.Secure.getIntForUser(mContentResolver,
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
HidePrivateSpaceSensitiveNotificationsController.ENABLED,
privateSpaceMaintainer.getPrivateProfileHandle().getIdentifier());
}
}