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

Commit 3a71dcc7 authored by Adam Bookatz's avatar Adam Bookatz Committed by Android (Google) Code Review
Browse files

Merge "UserProperties is @SystemApi & migrate 2 old props"

parents d226c6a3 e6f09f5f
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -12881,16 +12881,6 @@ package android.content.pm {
    field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.SigningInfo> CREATOR;
  }
  public final class UserProperties implements android.os.Parcelable {
    method public int describeContents();
    method public int getShowInLauncher();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.UserProperties> CREATOR;
    field public static final int SHOW_IN_LAUNCHER_NO = 2; // 0x2
    field public static final int SHOW_IN_LAUNCHER_SEPARATE = 1; // 0x1
    field public static final int SHOW_IN_LAUNCHER_WITH_PARENT = 0; // 0x0
  }
  public final class VersionedPackage implements android.os.Parcelable {
    ctor public VersionedPackage(@NonNull String, int);
    ctor public VersionedPackage(@NonNull String, long);
@@ -33225,7 +33215,6 @@ package android.os {
    method public android.os.UserHandle getUserForSerialNumber(long);
    method @NonNull @RequiresPermission(anyOf={"android.permission.MANAGE_USERS", "android.permission.CREATE_USERS", "android.permission.QUERY_USERS", android.Manifest.permission.GET_ACCOUNTS_PRIVILEGED}) public String getUserName();
    method public java.util.List<android.os.UserHandle> getUserProfiles();
    method @NonNull @RequiresPermission(anyOf={"android.permission.MANAGE_USERS", "android.permission.QUERY_USERS", "android.permission.INTERACT_ACROSS_USERS"}, conditional=true) public android.content.pm.UserProperties getUserProperties(@NonNull android.os.UserHandle);
    method public android.os.Bundle getUserRestrictions();
    method @RequiresPermission(anyOf={"android.permission.MANAGE_USERS", "android.permission.INTERACT_ACROSS_USERS"}, conditional=true) public android.os.Bundle getUserRestrictions(android.os.UserHandle);
    method public boolean hasUserRestriction(String);
+11 −2
Original line number Diff line number Diff line
@@ -3908,6 +3908,14 @@ package android.content.pm {
    method @NonNull public android.content.pm.SuspendDialogInfo.Builder setTitle(@NonNull String);
  }
  public final class UserProperties implements android.os.Parcelable {
    method public int describeContents();
    method public boolean getIsCredentialSharableWithParent();
    method public boolean getIsMediaSharedWithParent();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.UserProperties> CREATOR;
  }
}
package android.content.pm.dex {
@@ -10415,6 +10423,7 @@ package android.os {
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public long[] getSerialNumbersOfUsers(boolean);
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public java.util.List<android.os.UserHandle> getUserHandles(boolean);
    method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.GET_ACCOUNTS_PRIVILEGED}) public android.graphics.Bitmap getUserIcon();
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.QUERY_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional=true) public android.content.pm.UserProperties getUserProperties(@NonNull android.os.UserHandle);
    method @Deprecated @android.os.UserManager.UserRestrictionSource @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.QUERY_USERS}) public int getUserRestrictionSource(String, android.os.UserHandle);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.QUERY_USERS}) public java.util.List<android.os.UserManager.EnforcingUser> getUserRestrictionSources(String, android.os.UserHandle);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}) public int getUserSwitchability();
@@ -10423,11 +10432,11 @@ package android.os {
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional=true) public boolean hasUserRestrictionForUser(@NonNull String, @NonNull android.os.UserHandle);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public boolean isAdminUser();
    method public boolean isCloneProfile();
    method public boolean isCredentialSharableWithParent();
    method @Deprecated public boolean isCredentialSharableWithParent();
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public boolean isGuestUser();
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public boolean isMainUser();
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.QUERY_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional=true) public boolean isManagedProfile(int);
    method public boolean isMediaSharedWithParent();
    method @Deprecated public boolean isMediaSharedWithParent();
    method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS, android.Manifest.permission.QUERY_USERS}) public boolean isPrimaryUser();
    method public static boolean isRemoveResultSuccessful(int);
    method public boolean isRestrictedProfile();
+7 −0
Original line number Diff line number Diff line
@@ -946,6 +946,13 @@ package android.content.pm {
    field public String userType;
  }

  public final class UserProperties implements android.os.Parcelable {
    method public int getShowInLauncher();
    field public static final int SHOW_IN_LAUNCHER_NO = 2; // 0x2
    field public static final int SHOW_IN_LAUNCHER_SEPARATE = 1; // 0x1
    field public static final int SHOW_IN_LAUNCHER_WITH_PARENT = 0; // 0x0
  }

}

package android.content.res {
+100 −4
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.content.pm;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Slog;
@@ -36,7 +38,10 @@ import java.lang.annotation.RetentionPolicy;

/**
 * Class holding the properties of a user that derive mostly from its user type.
 *
 * @hide
 */
@SystemApi
public final class UserProperties implements Parcelable {
    private static final String LOG_TAG = UserProperties.class.getSimpleName();

@@ -52,6 +57,10 @@ public final class UserProperties implements Parcelable {
            "crossProfileIntentFilterAccessControl";
    private static final String ATTR_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY =
            "crossProfileIntentResolutionStrategy";
    private static final String ATTR_MEDIA_SHARED_WITH_PARENT =
            "mediaSharedWithParent";
    private static final String ATTR_CREDENTIAL_SHARABLE_WITH_PARENT =
            "credentialSharableWithParent";

    /** Index values of each property (to indicate whether they are present in this object). */
    @IntDef(prefix = "INDEX_", value = {
@@ -62,7 +71,9 @@ public final class UserProperties implements Parcelable {
            INDEX_USE_PARENTS_CONTACTS,
            INDEX_UPDATE_CROSS_PROFILE_INTENT_FILTERS_ON_OTA,
            INDEX_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL,
            INDEX_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY
            INDEX_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY,
            INDEX_MEDIA_SHARED_WITH_PARENT,
            INDEX_CREDENTIAL_SHARABLE_WITH_PARENT
    })
    @Retention(RetentionPolicy.SOURCE)
    private @interface PropertyIndex {
@@ -75,6 +86,8 @@ public final class UserProperties implements Parcelable {
    private static final int INDEX_UPDATE_CROSS_PROFILE_INTENT_FILTERS_ON_OTA = 5;
    private static final int INDEX_CROSS_PROFILE_INTENT_FILTER_ACCESS_CONTROL = 6;
    private static final int INDEX_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY = 7;
    private static final int INDEX_MEDIA_SHARED_WITH_PARENT = 8;
    private static final int INDEX_CREDENTIAL_SHARABLE_WITH_PARENT = 9;
    /** A bit set, mapping each PropertyIndex to whether it is present (1) or absent (0). */
    private long mPropertiesPresent = 0;

@@ -95,16 +108,22 @@ public final class UserProperties implements Parcelable {
     * Suggests that the launcher should show this user's apps in the main tab.
     * That is, either this user is a full user, so its apps should be presented accordingly, or, if
     * this user is a profile, then its apps should be shown alongside its parent's apps.
     * @hide
     */
    @TestApi
    public static final int SHOW_IN_LAUNCHER_WITH_PARENT = 0;
    /**
     * Suggests that the launcher should show this user's apps, but separately from the apps of this
     * user's parent.
     * @hide
     */
    @TestApi
    public static final int SHOW_IN_LAUNCHER_SEPARATE = 1;
    /**
     * Suggests that the launcher should not show this user.
     * @hide
     */
    @TestApi
    public static final int SHOW_IN_LAUNCHER_NO = 2;

    /**
@@ -304,6 +323,8 @@ public final class UserProperties implements Parcelable {
        }
        // Add items that have no permission requirements at all.
        setShowInLauncher(orig.getShowInLauncher());
        setIsMediaSharedWithParent(orig.getIsMediaSharedWithParent());
        setIsCredentialSharableWithParent(orig.getIsCredentialSharableWithParent());
    }

    /**
@@ -337,7 +358,9 @@ public final class UserProperties implements Parcelable {
     *    and {@link #SHOW_IN_LAUNCHER_NO}.
     *
     * @return whether, and how, a profile should be shown in the Launcher.
     * @hide
     */
    @TestApi
    public @ShowInLauncher int getShowInLauncher() {
        if (isPresent(INDEX_SHOW_IN_LAUNCHER)) return mShowInLauncher;
        if (mDefaultProperties != null) return mDefaultProperties.mShowInLauncher;
@@ -463,13 +486,45 @@ public final class UserProperties implements Parcelable {
        throw new SecurityException("You don't have permission to query "
                + "updateCrossProfileIntentFiltersOnOTA");
    }

    /** @hide */
    public void setUpdateCrossProfileIntentFiltersOnOTA(boolean val) {
        this.mUpdateCrossProfileIntentFiltersOnOTA = val;
        setPresent(INDEX_UPDATE_CROSS_PROFILE_INTENT_FILTERS_ON_OTA);
    }

    /**
     * Returns whether a profile shares media with its parent user.
     * This only applies for users that have parents (i.e. for profiles).
     */
    public boolean getIsMediaSharedWithParent() {
        if (isPresent(INDEX_MEDIA_SHARED_WITH_PARENT)) return mMediaSharedWithParent;
        if (mDefaultProperties != null) return mDefaultProperties.mMediaSharedWithParent;
        throw new SecurityException("You don't have permission to query isMediaSharedWithParent");
    }
    /** @hide */
    public void setIsMediaSharedWithParent(boolean val) {
        this.mMediaSharedWithParent = val;
        setPresent(INDEX_MEDIA_SHARED_WITH_PARENT);
    }
    private boolean mMediaSharedWithParent;

    /**
     * Returns whether a profile can have shared lockscreen credential with its parent user.
     * This only applies for users that have parents (i.e. for profiles).
     */
    public boolean getIsCredentialSharableWithParent() {
        if (isPresent(INDEX_CREDENTIAL_SHARABLE_WITH_PARENT)) return mCredentialSharableWithParent;
        if (mDefaultProperties != null) return mDefaultProperties.mCredentialSharableWithParent;
        throw new SecurityException(
                "You don't have permission to query isCredentialSharableWithParent");
    }
    /** @hide */
    public void setIsCredentialSharableWithParent(boolean val) {
        this.mCredentialSharableWithParent = val;
        setPresent(INDEX_CREDENTIAL_SHARABLE_WITH_PARENT);
    }
    private boolean mCredentialSharableWithParent;

    /*
     Indicate if {@link com.android.server.pm.CrossProfileIntentFilter}s need to be updated during
     OTA update between user-parent
@@ -550,6 +605,8 @@ public final class UserProperties implements Parcelable {
                + getCrossProfileIntentFilterAccessControl()
                + ", mCrossProfileIntentResolutionStrategy="
                + getCrossProfileIntentResolutionStrategy()
                + ", mMediaSharedWithParent=" + getIsMediaSharedWithParent()
                + ", mCredentialSharableWithParent=" + getIsCredentialSharableWithParent()
                + "}";
    }

@@ -572,6 +629,9 @@ public final class UserProperties implements Parcelable {
                + getCrossProfileIntentFilterAccessControl());
        pw.println(prefix + "    mCrossProfileIntentResolutionStrategy="
                + getCrossProfileIntentResolutionStrategy());
        pw.println(prefix + "    mMediaSharedWithParent=" + getIsMediaSharedWithParent());
        pw.println(prefix + "    mCredentialSharableWithParent="
                + getIsCredentialSharableWithParent());
    }

    /**
@@ -629,6 +689,12 @@ public final class UserProperties implements Parcelable {
                case ATTR_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY:
                    setCrossProfileIntentResolutionStrategy(parser.getAttributeInt(i));
                    break;
                case ATTR_MEDIA_SHARED_WITH_PARENT:
                    setIsMediaSharedWithParent(parser.getAttributeBoolean(i));
                    break;
                case ATTR_CREDENTIAL_SHARABLE_WITH_PARENT:
                    setIsCredentialSharableWithParent(parser.getAttributeBoolean(i));
                    break;
                default:
                    Slog.w(LOG_TAG, "Skipping unknown property " + attributeName);
            }
@@ -676,6 +742,14 @@ public final class UserProperties implements Parcelable {
            serializer.attributeInt(null, ATTR_CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY,
                    mCrossProfileIntentResolutionStrategy);
        }
        if (isPresent(INDEX_MEDIA_SHARED_WITH_PARENT)) {
            serializer.attributeBoolean(null, ATTR_MEDIA_SHARED_WITH_PARENT,
                    mMediaSharedWithParent);
        }
        if (isPresent(INDEX_CREDENTIAL_SHARABLE_WITH_PARENT)) {
            serializer.attributeBoolean(null, ATTR_CREDENTIAL_SHARABLE_WITH_PARENT,
                    mCredentialSharableWithParent);
        }
    }

    // For use only with an object that has already had any permission-lacking fields stripped out.
@@ -690,6 +764,8 @@ public final class UserProperties implements Parcelable {
        dest.writeBoolean(mUpdateCrossProfileIntentFiltersOnOTA);
        dest.writeInt(mCrossProfileIntentFilterAccessControl);
        dest.writeInt(mCrossProfileIntentResolutionStrategy);
        dest.writeBoolean(mMediaSharedWithParent);
        dest.writeBoolean(mCredentialSharableWithParent);
    }

    /**
@@ -708,6 +784,8 @@ public final class UserProperties implements Parcelable {
        mUpdateCrossProfileIntentFiltersOnOTA = source.readBoolean();
        mCrossProfileIntentFilterAccessControl = source.readInt();
        mCrossProfileIntentResolutionStrategy = source.readInt();
        mMediaSharedWithParent = source.readBoolean();
        mCredentialSharableWithParent = source.readBoolean();
    }

    @Override
@@ -743,6 +821,8 @@ public final class UserProperties implements Parcelable {
                CROSS_PROFILE_INTENT_FILTER_ACCESS_LEVEL_ALL;
        private @CrossProfileIntentResolutionStrategy int mCrossProfileIntentResolutionStrategy =
                CROSS_PROFILE_INTENT_RESOLUTION_STRATEGY_DEFAULT;
        private boolean mMediaSharedWithParent = false;
        private boolean mCredentialSharableWithParent = false;

        public Builder setShowInLauncher(@ShowInLauncher int showInLauncher) {
            mShowInLauncher = showInLauncher;
@@ -794,6 +874,16 @@ public final class UserProperties implements Parcelable {
            return this;
        }

        public Builder setIsMediaSharedWithParent(boolean mediaSharedWithParent) {
            mMediaSharedWithParent = mediaSharedWithParent;
            return this;
        }

        public Builder setIsCredentialSharableWithParent(boolean credentialSharableWithParent) {
            mCredentialSharableWithParent = credentialSharableWithParent;
            return this;
        }

        /** Builds a UserProperties object with *all* values populated. */
        public UserProperties build() {
            return new UserProperties(
@@ -804,7 +894,9 @@ public final class UserProperties implements Parcelable {
                    mUseParentsContacts,
                    mUpdateCrossProfileIntentFiltersOnOTA,
                    mCrossProfileIntentFilterAccessControl,
                    mCrossProfileIntentResolutionStrategy);
                    mCrossProfileIntentResolutionStrategy,
                    mMediaSharedWithParent,
                    mCredentialSharableWithParent);
        }
    } // end Builder

@@ -816,7 +908,9 @@ public final class UserProperties implements Parcelable {
            @InheritDevicePolicy int inheritDevicePolicy,
            boolean useParentsContacts, boolean updateCrossProfileIntentFiltersOnOTA,
            @CrossProfileIntentFilterAccessControlLevel int crossProfileIntentFilterAccessControl,
            @CrossProfileIntentResolutionStrategy int crossProfileIntentResolutionStrategy) {
            @CrossProfileIntentResolutionStrategy int crossProfileIntentResolutionStrategy,
            boolean mediaSharedWithParent,
            boolean credentialSharableWithParent) {

        mDefaultProperties = null;
        setShowInLauncher(showInLauncher);
@@ -827,5 +921,7 @@ public final class UserProperties implements Parcelable {
        setUpdateCrossProfileIntentFiltersOnOTA(updateCrossProfileIntentFiltersOnOTA);
        setCrossProfileIntentFilterAccessControl(crossProfileIntentFilterAccessControl);
        setCrossProfileIntentResolutionStrategy(crossProfileIntentResolutionStrategy);
        setIsMediaSharedWithParent(mediaSharedWithParent);
        setIsCredentialSharableWithParent(credentialSharableWithParent);
    }
}
+0 −2
Original line number Diff line number Diff line
@@ -116,8 +116,6 @@ interface IUserManager {
    boolean someUserHasSeedAccount(in String accountName, in String accountType);
    boolean someUserHasAccount(in String accountName, in String accountType);
    String getProfileType(int userId);
    boolean isMediaSharedWithParent(int userId);
    boolean isCredentialSharableWithParent(int userId);
    boolean isDemoUser(int userId);
    boolean isPreCreated(int userId);
    UserInfo createProfileForUserEvenWhenDisallowedWithThrow(in String name, in String userType, int flags,
Loading