summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Olivier Nshimiye <onshimiye@google.com> 2024-02-07 17:57:06 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-02-07 17:57:06 +0000
commitfa1584783c5d25d8ed47ff3c6593273c75a352c5 (patch)
tree0879f4a6e97628a4e479c7d6a713d0dd7bad3e2d
parent9214d4fc5e10342b117959b3789c42ad91aef72f (diff)
parent258bf46cef3e5b275dfcac9bc83e1449f6e34f24 (diff)
Merge "Make the profileApiVisibility user property a hidden API" into main
-rw-r--r--core/api/system-current.txt4
-rw-r--r--core/java/android/content/pm/UserProperties.java49
-rw-r--r--core/java/android/content/pm/multiuser.aconfig8
-rw-r--r--services/core/java/com/android/server/pm/UserTypeFactory.java44
-rw-r--r--services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserPropertiesTest.java7
-rw-r--r--services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserTypeTest.java7
-rw-r--r--services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java13
7 files changed, 42 insertions, 90 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 515d01786b90..e998c2bc56bf 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -4249,7 +4249,6 @@ package android.content.pm {
public final class UserProperties implements android.os.Parcelable {
method public int describeContents();
method public int getCrossProfileContentSharingStrategy();
- method @FlaggedApi("android.multiuser.support_hiding_profiles") @NonNull public int getProfileApiVisibility();
method public int getShowInQuietMode();
method public int getShowInSharingSurfaces();
method public boolean isCredentialShareableWithParent();
@@ -4259,9 +4258,6 @@ package android.content.pm {
field public static final int CROSS_PROFILE_CONTENT_SHARING_DELEGATE_FROM_PARENT = 1; // 0x1
field public static final int CROSS_PROFILE_CONTENT_SHARING_NO_DELEGATION = 0; // 0x0
field public static final int CROSS_PROFILE_CONTENT_SHARING_UNKNOWN = -1; // 0xffffffff
- field @FlaggedApi("android.multiuser.support_hiding_profiles") public static final int PROFILE_API_VISIBILITY_HIDDEN = 1; // 0x1
- field @FlaggedApi("android.multiuser.support_hiding_profiles") public static final int PROFILE_API_VISIBILITY_UNKNOWN = -1; // 0xffffffff
- field @FlaggedApi("android.multiuser.support_hiding_profiles") public static final int PROFILE_API_VISIBILITY_VISIBLE = 0; // 0x0
field public static final int SHOW_IN_QUIET_MODE_DEFAULT = 2; // 0x2
field public static final int SHOW_IN_QUIET_MODE_HIDDEN = 1; // 0x1
field public static final int SHOW_IN_QUIET_MODE_PAUSED = 0; // 0x0
diff --git a/core/java/android/content/pm/UserProperties.java b/core/java/android/content/pm/UserProperties.java
index f54b2ac06929..d347a0e8ae63 100644
--- a/core/java/android/content/pm/UserProperties.java
+++ b/core/java/android/content/pm/UserProperties.java
@@ -16,9 +16,6 @@
package android.content.pm;
-import static android.multiuser.Flags.FLAG_SUPPORT_HIDING_PROFILES;
-
-import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -476,22 +473,26 @@ public final class UserProperties implements Parcelable {
)
public @interface ProfileApiVisibility {
}
- /*
- * The api visibility value for this profile user is undefined or unknown.
+
+ /**
+ * The api visibility value for this profile user is undefined or unknown.
+ *
+ * @hide
*/
- @FlaggedApi(FLAG_SUPPORT_HIDING_PROFILES)
public static final int PROFILE_API_VISIBILITY_UNKNOWN = -1;
/**
* Indicates that information about this profile user should be shown in API surfaces.
+ *
+ * @hide
*/
- @FlaggedApi(FLAG_SUPPORT_HIDING_PROFILES)
public static final int PROFILE_API_VISIBILITY_VISIBLE = 0;
/**
* Indicates that information about this profile should be not be visible in API surfaces.
+ *
+ * @hide
*/
- @FlaggedApi(FLAG_SUPPORT_HIDING_PROFILES)
public static final int PROFILE_API_VISIBILITY_HIDDEN = 1;
@@ -555,9 +556,7 @@ public final class UserProperties implements Parcelable {
setShowInQuietMode(orig.getShowInQuietMode());
setShowInSharingSurfaces(orig.getShowInSharingSurfaces());
setCrossProfileContentSharingStrategy(orig.getCrossProfileContentSharingStrategy());
- if (android.multiuser.Flags.supportHidingProfiles()) {
- setProfileApiVisibility(orig.getProfileApiVisibility());
- }
+ setProfileApiVisibility(orig.getProfileApiVisibility());
}
/**
@@ -1002,9 +1001,10 @@ public final class UserProperties implements Parcelable {
/**
* Returns the visibility of the profile user in API surfaces. Any information linked to the
* profile (userId, package names) should be hidden API surfaces if a user is marked as hidden.
+ *
+ * @hide
*/
@NonNull
- @FlaggedApi(FLAG_SUPPORT_HIDING_PROFILES)
public @ProfileApiVisibility int getProfileApiVisibility() {
if (isPresent(INDEX_PROFILE_API_VISIBILITY)) return mProfileApiVisibility;
if (mDefaultProperties != null) return mDefaultProperties.mProfileApiVisibility;
@@ -1012,7 +1012,6 @@ public final class UserProperties implements Parcelable {
}
/** @hide */
@NonNull
- @FlaggedApi(FLAG_SUPPORT_HIDING_PROFILES)
public void setProfileApiVisibility(@ProfileApiVisibility int profileApiVisibility) {
this.mProfileApiVisibility = profileApiVisibility;
setPresent(INDEX_PROFILE_API_VISIBILITY);
@@ -1053,9 +1052,6 @@ public final class UserProperties implements Parcelable {
@Override
public String toString() {
- String profileApiVisibility =
- android.multiuser.Flags.supportHidingProfiles() ? ", mProfileApiVisibility="
- + getProfileApiVisibility() : "";
// Please print in increasing order of PropertyIndex.
return "UserProperties{"
+ "mPropertiesPresent=" + Long.toBinaryString(mPropertiesPresent)
@@ -1079,7 +1075,7 @@ public final class UserProperties implements Parcelable {
+ ", mDeleteAppWithParent=" + getDeleteAppWithParent()
+ ", mAlwaysVisible=" + getAlwaysVisible()
+ ", mCrossProfileContentSharingStrategy=" + getCrossProfileContentSharingStrategy()
- + ", mProfileApiVisibility=" + profileApiVisibility
+ + ", mProfileApiVisibility=" + getProfileApiVisibility()
+ ", mItemsRestrictedOnHomeScreen=" + areItemsRestrictedOnHomeScreen()
+ "}";
}
@@ -1114,9 +1110,7 @@ public final class UserProperties implements Parcelable {
pw.println(prefix + " mAlwaysVisible=" + getAlwaysVisible());
pw.println(prefix + " mCrossProfileContentSharingStrategy="
+ getCrossProfileContentSharingStrategy());
- if (android.multiuser.Flags.supportHidingProfiles()) {
- pw.println(prefix + " mProfileApiVisibility=" + getProfileApiVisibility());
- }
+ pw.println(prefix + " mProfileApiVisibility=" + getProfileApiVisibility());
pw.println(prefix + " mItemsRestrictedOnHomeScreen=" + areItemsRestrictedOnHomeScreen());
}
@@ -1203,9 +1197,7 @@ public final class UserProperties implements Parcelable {
setCrossProfileContentSharingStrategy(parser.getAttributeInt(i));
break;
case ATTR_PROFILE_API_VISIBILITY:
- if (android.multiuser.Flags.supportHidingProfiles()) {
- setProfileApiVisibility(parser.getAttributeInt(i));
- }
+ setProfileApiVisibility(parser.getAttributeInt(i));
break;
case ITEMS_RESTRICTED_ON_HOME_SCREEN:
setItemsRestrictedOnHomeScreen(parser.getAttributeBoolean(i));
@@ -1293,10 +1285,8 @@ public final class UserProperties implements Parcelable {
mCrossProfileContentSharingStrategy);
}
if (isPresent(INDEX_PROFILE_API_VISIBILITY)) {
- if (android.multiuser.Flags.supportHidingProfiles()) {
- serializer.attributeInt(null, ATTR_PROFILE_API_VISIBILITY,
- mProfileApiVisibility);
- }
+ serializer.attributeInt(null, ATTR_PROFILE_API_VISIBILITY,
+ mProfileApiVisibility);
}
if (isPresent(INDEX_ITEMS_RESTRICTED_ON_HOME_SCREEN)) {
serializer.attributeBoolean(null, ITEMS_RESTRICTED_ON_HOME_SCREEN,
@@ -1566,7 +1556,6 @@ public final class UserProperties implements Parcelable {
* @hide
*/
@NonNull
- @FlaggedApi(FLAG_SUPPORT_HIDING_PROFILES)
public Builder setProfileApiVisibility(@ProfileApiVisibility int profileApiVisibility){
mProfileApiVisibility = profileApiVisibility;
return this;
@@ -1650,9 +1639,7 @@ public final class UserProperties implements Parcelable {
setDeleteAppWithParent(deleteAppWithParent);
setAlwaysVisible(alwaysVisible);
setCrossProfileContentSharingStrategy(crossProfileContentSharingStrategy);
- if (android.multiuser.Flags.supportHidingProfiles()) {
- setProfileApiVisibility(profileApiVisibility);
- }
+ setProfileApiVisibility(profileApiVisibility);
setItemsRestrictedOnHomeScreen(itemsRestrictedOnHomeScreen);
}
}
diff --git a/core/java/android/content/pm/multiuser.aconfig b/core/java/android/content/pm/multiuser.aconfig
index 1be15e2438ef..4b890faf527e 100644
--- a/core/java/android/content/pm/multiuser.aconfig
+++ b/core/java/android/content/pm/multiuser.aconfig
@@ -116,14 +116,6 @@ flag {
}
flag {
- name: "support_hiding_profiles"
- namespace: "profile_experiences"
- description: "Allow the use of a hide_profile property to hide some profiles behind a permission"
- bug: "316362775"
- is_fixed_read_only: true
-}
-
-flag {
name: "enable_permission_to_access_hidden_profiles"
namespace: "profile_experiences"
description: "Add permission to access API hidden users data via system APIs"
diff --git a/services/core/java/com/android/server/pm/UserTypeFactory.java b/services/core/java/com/android/server/pm/UserTypeFactory.java
index b7203045543e..067a012ed373 100644
--- a/services/core/java/com/android/server/pm/UserTypeFactory.java
+++ b/services/core/java/com/android/server/pm/UserTypeFactory.java
@@ -288,29 +288,6 @@ public final class UserTypeFactory {
* configuration.
*/
private static UserTypeDetails.Builder getDefaultTypeProfilePrivate() {
- UserProperties.Builder userPropertiesBuilder = new UserProperties.Builder()
- .setStartWithParent(true)
- .setCredentialShareableWithParent(true)
- .setAuthAlwaysRequiredToDisableQuietMode(true)
- .setAllowStoppingUserWithDelayedLocking(true)
- .setMediaSharedWithParent(false)
- .setShowInLauncher(UserProperties.SHOW_IN_LAUNCHER_SEPARATE)
- .setShowInSettings(UserProperties.SHOW_IN_SETTINGS_SEPARATE)
- .setShowInQuietMode(
- UserProperties.SHOW_IN_QUIET_MODE_HIDDEN)
- .setShowInSharingSurfaces(
- UserProperties.SHOW_IN_SHARING_SURFACES_SEPARATE)
- .setCrossProfileIntentFilterAccessControl(
- UserProperties.CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_SYSTEM)
- .setInheritDevicePolicy(UserProperties.INHERIT_DEVICE_POLICY_FROM_PARENT)
- .setCrossProfileContentSharingStrategy(
- UserProperties.CROSS_PROFILE_CONTENT_SHARING_DELEGATE_FROM_PARENT)
- .setItemsRestrictedOnHomeScreen(true);
- if (android.multiuser.Flags.supportHidingProfiles()) {
- userPropertiesBuilder.setProfileApiVisibility(
- UserProperties.PROFILE_API_VISIBILITY_HIDDEN);
- }
-
return new UserTypeDetails.Builder()
.setName(USER_TYPE_PROFILE_PRIVATE)
.setBaseType(FLAG_PROFILE)
@@ -329,7 +306,26 @@ public final class UserTypeFactory {
.setDarkThemeBadgeColors(
R.color.white)
.setDefaultRestrictions(getDefaultProfileRestrictions())
- .setDefaultUserProperties(userPropertiesBuilder);
+ .setDefaultUserProperties(new UserProperties.Builder()
+ .setStartWithParent(true)
+ .setCredentialShareableWithParent(true)
+ .setAuthAlwaysRequiredToDisableQuietMode(true)
+ .setAllowStoppingUserWithDelayedLocking(true)
+ .setMediaSharedWithParent(false)
+ .setShowInLauncher(UserProperties.SHOW_IN_LAUNCHER_SEPARATE)
+ .setShowInSettings(UserProperties.SHOW_IN_SETTINGS_SEPARATE)
+ .setShowInQuietMode(
+ UserProperties.SHOW_IN_QUIET_MODE_HIDDEN)
+ .setShowInSharingSurfaces(
+ UserProperties.SHOW_IN_SHARING_SURFACES_SEPARATE)
+ .setCrossProfileIntentFilterAccessControl(
+ UserProperties.CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_SYSTEM)
+ .setInheritDevicePolicy(UserProperties.INHERIT_DEVICE_POLICY_FROM_PARENT)
+ .setCrossProfileContentSharingStrategy(
+ UserProperties.CROSS_PROFILE_CONTENT_SHARING_DELEGATE_FROM_PARENT)
+ .setProfileApiVisibility(
+ UserProperties.PROFILE_API_VISIBILITY_HIDDEN)
+ .setItemsRestrictedOnHomeScreen(true));
}
/**
diff --git a/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserPropertiesTest.java b/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserPropertiesTest.java
index 3778a32b34c3..f1d3ba9db489 100644
--- a/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserPropertiesTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserPropertiesTest.java
@@ -23,7 +23,6 @@ import static org.testng.Assert.assertThrows;
import android.content.pm.UserProperties;
import android.os.Parcel;
import android.platform.test.annotations.Presubmit;
-import android.platform.test.flag.junit.SetFlagsRule;
import android.util.Xml;
import androidx.test.filters.MediumTest;
@@ -32,7 +31,6 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.modules.utils.TypedXmlPullParser;
import com.android.modules.utils.TypedXmlSerializer;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -54,13 +52,10 @@ import java.util.function.Supplier;
@RunWith(AndroidJUnit4.class)
@MediumTest
public class UserManagerServiceUserPropertiesTest {
- @Rule
- public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
/** Test that UserProperties can properly read the xml information that it writes. */
@Test
public void testWriteReadXml() throws Exception {
- mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SUPPORT_HIDING_PROFILES);
final UserProperties defaultProps = new UserProperties.Builder()
.setShowInLauncher(21)
.setStartWithParent(false)
@@ -123,7 +118,6 @@ public class UserManagerServiceUserPropertiesTest {
/** Tests parcelling an object in which all properties are present. */
@Test
public void testParcelUnparcel() throws Exception {
- mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SUPPORT_HIDING_PROFILES);
final UserProperties originalProps = new UserProperties.Builder()
.setShowInLauncher(2145)
.build();
@@ -134,7 +128,6 @@ public class UserManagerServiceUserPropertiesTest {
/** Tests copying a UserProperties object varying permissions. */
@Test
public void testCopyLacksPermissions() throws Exception {
- mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SUPPORT_HIDING_PROFILES);
final UserProperties defaultProps = new UserProperties.Builder()
.setShowInLauncher(2145)
.setStartWithParent(true)
diff --git a/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserTypeTest.java b/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserTypeTest.java
index 6cdbc7428f7e..3047bcf4b146 100644
--- a/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserTypeTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserTypeTest.java
@@ -41,7 +41,6 @@ import android.content.res.XmlResourceParser;
import android.os.Bundle;
import android.os.UserManager;
import android.platform.test.annotations.Presubmit;
-import android.platform.test.flag.junit.SetFlagsRule;
import android.util.ArrayMap;
import androidx.test.InstrumentationRegistry;
@@ -51,7 +50,6 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.frameworks.servicestests.R;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -73,11 +71,8 @@ public class UserManagerServiceUserTypeTest {
public void setup() {
mResources = InstrumentationRegistry.getTargetContext().getResources();
}
- @Rule
- public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Test
public void testUserTypeBuilder_createUserType() {
- mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SUPPORT_HIDING_PROFILES);
final Bundle restrictions = makeRestrictionsBundle("r1", "r2");
final Bundle systemSettings = makeSettingsBundle("s1", "s2");
final Bundle secureSettings = makeSettingsBundle("secure_s1", "secure_s2");
@@ -207,7 +202,6 @@ public class UserManagerServiceUserTypeTest {
@Test
public void testUserTypeBuilder_defaults() {
- mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SUPPORT_HIDING_PROFILES);
UserTypeDetails type = new UserTypeDetails.Builder()
.setName("name") // Required (no default allowed)
.setBaseType(FLAG_FULL) // Required (no default allowed)
@@ -321,7 +315,6 @@ public class UserManagerServiceUserTypeTest {
/** Tests {@link UserTypeFactory#customizeBuilders} for a reasonable xml file. */
@Test
public void testUserTypeFactoryCustomize_profile() throws Exception {
- mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SUPPORT_HIDING_PROFILES);
final String userTypeAosp1 = "android.test.1"; // Profile user that is not customized
final String userTypeAosp2 = "android.test.2"; // Profile user that is customized
final String userTypeOem1 = "custom.test.1"; // Custom-defined profile
diff --git a/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java
index 9323b482d5e2..df2069efb0ce 100644
--- a/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java
@@ -39,7 +39,6 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.platform.test.annotations.Postsubmit;
import android.platform.test.annotations.RequiresFlagsEnabled;
-import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
@@ -56,7 +55,6 @@ import com.google.common.collect.Range;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -99,8 +97,6 @@ public final class UserManagerTest {
private UserSwitchWaiter mUserSwitchWaiter;
private UserRemovalWaiter mUserRemovalWaiter;
private int mOriginalCurrentUserId;
- @Rule
- public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Before
public void setUp() throws Exception {
@@ -172,7 +168,6 @@ public final class UserManagerTest {
@Test
public void testCloneUser() throws Exception {
- mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SUPPORT_HIDING_PROFILES);
assumeCloneEnabled();
UserHandle mainUser = mUserManager.getMainUser();
assumeTrue("Main user is null", mainUser != null);
@@ -229,7 +224,8 @@ public final class UserManagerTest {
.isEqualTo(cloneUserProperties.getCrossProfileContentSharingStrategy());
assertThrows(SecurityException.class, cloneUserProperties::getDeleteAppWithParent);
assertThrows(SecurityException.class, cloneUserProperties::getAlwaysVisible);
- assertThrows(SecurityException.class, cloneUserProperties::getProfileApiVisibility);
+ assertThat(typeProps.getProfileApiVisibility()).isEqualTo(
+ cloneUserProperties.getProfileApiVisibility());
compareDrawables(mUserManager.getUserBadge(),
Resources.getSystem().getDrawable(userTypeDetails.getBadgePlain()));
@@ -311,7 +307,6 @@ public final class UserManagerTest {
@Test
public void testPrivateProfile() throws Exception {
- mSetFlagsRule.enableFlags(android.multiuser.Flags.FLAG_SUPPORT_HIDING_PROFILES);
UserHandle mainUser = mUserManager.getMainUser();
assumeTrue("Main user is null", mainUser != null);
// Get the default properties for private profile user type.
@@ -353,8 +348,8 @@ public final class UserManagerTest {
assertThrows(SecurityException.class, privateProfileUserProperties::getDeleteAppWithParent);
assertThrows(SecurityException.class,
privateProfileUserProperties::getAllowStoppingUserWithDelayedLocking);
- assertThrows(SecurityException.class,
- privateProfileUserProperties::getProfileApiVisibility);
+ assertThat(typeProps.getProfileApiVisibility()).isEqualTo(
+ privateProfileUserProperties.getProfileApiVisibility());
assertThrows(SecurityException.class,
privateProfileUserProperties::areItemsRestrictedOnHomeScreen);
compareDrawables(mUserManager.getUserBadge(),