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

@@ -45,6 +45,7 @@ import com.android.internal.annotations.GuardedBy;
import java.util.List;
// TODO(b/293569406): Update the javadoc when we have the setup flow in place to create PS
/** A class to help with the creation / deletion of Private Space */
public class PrivateSpaceMaintainer {
private static final String TAG = "PrivateSpaceMaintainer";
@@ -65,9 +66,9 @@ public class PrivateSpaceMaintainer {
public static final int PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL = PRIVATE_SPACE_AUTO_LOCK_NEVER;
public enum ErrorDeletingPrivateSpace {
DELETE_PS_ERROR_NONE,
DELETE_PS_ERROR_NO_PRIVATE_SPACE,
DELETE_PS_ERROR_INTERNAL
DELETE_PS_ERROR_NONE,
DELETE_PS_ERROR_NO_PRIVATE_SPACE,
DELETE_PS_ERROR_INTERNAL
}
/**
@@ -90,7 +91,7 @@ public class PrivateSpaceMaintainer {
if (mUserHandle == null) {
try {
mUserHandle = mUserManager.createProfile(
userName, USER_TYPE_PROFILE_PRIVATE, new ArraySet<>());
userName, USER_TYPE_PROFILE_PRIVATE, new ArraySet<>());
} catch (Exception e) {
Log.e(TAG, "Error creating private space", e);
return false;
@@ -117,7 +118,8 @@ public class PrivateSpaceMaintainer {
return true;
}
/** Returns the {@link ErrorDeletingPrivateSpace} enum representing the result of operation.
/**
* Returns the {@link ErrorDeletingPrivateSpace} enum representing the result of operation.
*
* <p> This method should be used ONLY by the delete-PS controller in the PS Settings page.
*/
@@ -212,6 +214,7 @@ public class PrivateSpaceMaintainer {
// TODO(b/307281644): Remove this method once new auth change is merged
/**
* Returns true if private space exists and a separate private profile lock is set
* otherwise false when the private space does not exit or exists but does not have a
@@ -290,9 +293,20 @@ public class PrivateSpaceMaintainer {
return false;
}
@GuardedBy("this")
private void resetPrivateSpaceSettings() {
setHidePrivateSpaceEntryPointSetting(HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL);
setPrivateSpaceAutoLockSetting(PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL);
setPrivateSpaceSensitiveNotificationsDefaultValue();
}
/** Sets private space sensitive notifications hidden on lockscreen by default */
@GuardedBy("this")
private void setPrivateSpaceSensitiveNotificationsDefaultValue() {
Settings.Secure.putIntForUser(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
HidePrivateSpaceSensitiveNotificationsController.DISABLED,
mUserHandle.getIdentifier());
}
/**