Disable PS entry point and Activity when PS is not allowed.

In this change we disable:
1. Security Center Entry point
2. PrivateSpaceAuthenticationActivity

when private profile is not present and cannot be added.

Additionally, the intent exposing PrivateSpaceAuthenticationActivity
is also non-exported and changed to a better name.

Bug: 328578044
Test: Manual build and flash
Change-Id: I13d298316c6d719d0b06e4969989ea1da83dd4c6
This commit is contained in:
Himanshu Gupta
2024-03-21 14:14:02 +00:00
parent 9c50f2c61d
commit 5e451db395
5 changed files with 87 additions and 8 deletions

View File

@@ -44,11 +44,27 @@ public final class PrivateSpaceSafetySource {
return;
}
// Check the profile type - we don't want to show this for anything other than primary user.
UserManager userManager = context.getSystemService(UserManager.class);
if (userManager != null && !userManager.isMainUser()) {
Log.i(TAG, "setSafetySourceData not main user");
return;
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(context);
if (android.multiuser.Flags.enablePrivateSpaceFeatures()
&& android.multiuser.Flags.blockPrivateSpaceCreation()) {
// Do not add the entry point when
// -Private Profile is not present and
// -Private Profile cannot be added.
if (!privateSpaceMaintainer.doesPrivateSpaceExist()
&& userManager != null
&& !userManager.canAddPrivateProfile()) {
Log.i(TAG, "Private Space not allowed for user " + context.getUser());
return;
}
} else {
// Check the profile type - we don't want to show this for anything other than primary
// user.
if (userManager != null && !userManager.isMainUser()) {
Log.i(TAG, "setSafetySourceData not main user");
return;
}
}
if (!Flags.allowPrivateProfile()