Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa158478 authored by Olivier Nshimiye's avatar Olivier Nshimiye Committed by Android (Google) Code Review
Browse files

Merge "Make the profileApiVisibility user property a hidden API" into main

parents 9214d4fc 258bf46c
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -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
+18 −31
Original line number Diff line number Diff line
@@ -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.
     *
     * @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,10 +556,8 @@ public final class UserProperties implements Parcelable {
        setShowInQuietMode(orig.getShowInQuietMode());
        setShowInSharingSurfaces(orig.getShowInSharingSurfaces());
        setCrossProfileContentSharingStrategy(orig.getCrossProfileContentSharingStrategy());
        if (android.multiuser.Flags.supportHidingProfiles()) {
        setProfileApiVisibility(orig.getProfileApiVisibility());
    }
    }

    /**
     * Indicates that the given property is being stored explicitly in this object.
@@ -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 + "    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));
                    }
                    break;
                case ITEMS_RESTRICTED_ON_HOME_SCREEN:
                    setItemsRestrictedOnHomeScreen(parser.getAttributeBoolean(i));
@@ -1293,11 +1285,9 @@ 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);
        }
        }
        if (isPresent(INDEX_ITEMS_RESTRICTED_ON_HOME_SCREEN)) {
            serializer.attributeBoolean(null, ITEMS_RESTRICTED_ON_HOME_SCREEN,
                    mItemsRestrictedOnHomeScreen);
@@ -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);
        }
        setItemsRestrictedOnHomeScreen(itemsRestrictedOnHomeScreen);
    }
}
+0 −8
Original line number Diff line number Diff line
@@ -115,14 +115,6 @@ flag {
    bug: "286418785"
}

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"
+20 −24
Original line number Diff line number Diff line
@@ -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));
    }

    /**
+0 −7
Original line number Diff line number Diff line
@@ -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)
Loading