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

Commit 29b76c64 authored by Kholoud Mohamed's avatar Kholoud Mohamed
Browse files

undeprecate getApplicationRestrictions

Keep getApplicationRestrictions which only returns restrictions set by
the DPC admin, apps wishing to retrieve app restrictions set by all
admins can call RestrictionsManager#getApplicationRestrictionsPerAdmin

Bug: 271108424
Test: N/A
Change-Id: I0aeb2afe9161bbe418598e8b53843a664766ae67
parent ecfc7bd0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -11404,7 +11404,7 @@ package android.content {
  public class RestrictionsManager {
    method public static android.os.Bundle convertRestrictionsToBundle(java.util.List<android.content.RestrictionEntry>);
    method public android.content.Intent createLocalApprovalIntent();
    method @Deprecated public android.os.Bundle getApplicationRestrictions();
    method public android.os.Bundle getApplicationRestrictions();
    method @NonNull @WorkerThread public java.util.List<android.os.Bundle> getApplicationRestrictionsPerAdmin();
    method public java.util.List<android.content.RestrictionEntry> getManifestRestrictions(String);
    method public boolean hasRestrictionsProvider();
@@ -33867,7 +33867,7 @@ package android.os {
  public class UserManager {
    method public static android.content.Intent createUserCreationIntent(@Nullable String, @Nullable String, @Nullable String, @Nullable android.os.PersistableBundle);
    method @Deprecated @WorkerThread public android.os.Bundle getApplicationRestrictions(String);
    method @WorkerThread public android.os.Bundle getApplicationRestrictions(String);
    method public long getSerialNumberForUser(android.os.UserHandle);
    method @RequiresPermission(anyOf={"android.permission.MANAGE_USERS", "android.permission.CREATE_USERS"}) public int getUserCount();
    method public long getUserCreationTime(android.os.UserHandle);
+9 −7
Original line number Diff line number Diff line
@@ -427,11 +427,12 @@ public class RestrictionsManager {
     * @return the application restrictions as a Bundle. Returns null if there
     * are no restrictions.
     *
     * @deprecated Use {@link #getApplicationRestrictionsPerAdmin} instead.
     * Starting from Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, it is
     * possible for there to be multiple managing agents on the device with the ability to set
     * restrictions. This API will only to return the restrictions set by device policy controllers
     * (DPCs)
     * <p>Starting from Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
     * it is possible for there to be multiple managing apps on the device with the ability to set
     * restrictions, e.g. a Device Policy Controller (DPC) and a Supervision admin.
     * This API will only return the restrictions set by the DPCs. To retrieve restrictions
     * set by all managing apps, use
     * {@link android.content.RestrictionsManager#getApplicationRestrictionsPerAdmin} instead.
     *
     * @see DevicePolicyManager
     */
@@ -453,8 +454,8 @@ public class RestrictionsManager {
     * stable between multiple calls.
     *
     * <p>Starting from Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
     * it is possible for there to be multiple managing agents on the device with the ability to set
     * restrictions, e.g. an Enterprise DPC and a Supervision admin.
     * it is possible for there to be multiple managing apps on the device with the ability to set
     * restrictions, e.g. an Enterprise Device Policy Controller (DPC) and a Supervision admin.
     *
     * <p>Each {@link Bundle} consists of key-value pairs, as defined by the application,
     * where the types of values may be:
@@ -471,6 +472,7 @@ public class RestrictionsManager {
     * package. Returns an empty {@link List} if there are no saved restrictions.
     *
     * @see UserManager#KEY_RESTRICTIONS_PENDING
     * @see DevicePolicyManager
     */
    @WorkerThread
    @UserHandleAware
+10 −8
Original line number Diff line number Diff line
@@ -5601,16 +5601,15 @@ public class UserManager {
     *
     * @see #KEY_RESTRICTIONS_PENDING
     *
     * @deprecated Use
     * <p>Starting from Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
     * it is possible for there to be multiple managing apps on the device with the ability to set
     * restrictions, e.g. an Enterprise Device Policy Controller (DPC) and a Supervision admin.
     * This API will only to return the restrictions set by the DPCs. To retrieve restrictions
     * set by all managing apps, use
     * {@link android.content.RestrictionsManager#getApplicationRestrictionsPerAdmin} instead.
     * Starting from Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, it is
     * possible for there to be multiple managing agents on the device with the ability to set
     * restrictions. This API will only to return the restrictions set by device policy controllers
     * (DPCs)
     *
     * @see DevicePolicyManager
     */
    @Deprecated
    @WorkerThread
    @UserHandleAware(enabledSinceTargetSdkVersion = Build.VERSION_CODES.TIRAMISU)
    public Bundle getApplicationRestrictions(String packageName) {
@@ -5623,12 +5622,15 @@ public class UserManager {
    }

    /**
     * @deprecated Use
     * <p>Starting from Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
     * it is possible for there to be multiple managing apps on the device with the ability to set
     * restrictions, e.g. an Enterprise Device Policy Controller (DPC) and a Supervision admin.
     * This API will only to return the restrictions set by the DPCs. To retrieve restrictions
     * set by all managing apps, use
     * {@link android.content.RestrictionsManager#getApplicationRestrictionsPerAdmin} instead.
     *
     * @hide
     */
    @Deprecated
    @WorkerThread
    public Bundle getApplicationRestrictions(String packageName, UserHandle user) {
        try {
+10 −6
Original line number Diff line number Diff line
@@ -5865,20 +5865,24 @@ public class UserManagerService extends IUserManager.Stub {
    }

    /**
     * @deprecated Use {@link
     * android.content.RestrictionsManager#getApplicationRestrictionsPerAdmin} instead.
     * <p>Starting from Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
     * it is possible for there to be multiple managing agents on the device with the ability to set
     * restrictions, e.g. an Enterprise DPC and a Supervision admin. This API will only to return
     * the restrictions set by the DPCs. To retrieve restrictions set by all agents, use
     * {@link android.content.RestrictionsManager#getApplicationRestrictionsPerAdmin} instead.
     */
    @Deprecated
    @Override
    public Bundle getApplicationRestrictions(String packageName) {
        return getApplicationRestrictionsForUser(packageName, UserHandle.getCallingUserId());
    }

    /**
     * @deprecated Use {@link
     * android.content.RestrictionsManager#getApplicationRestrictionsPerAdmin} instead.
     * <p>Starting from Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
     * it is possible for there to be multiple managing agents on the device with the ability to set
     * restrictions, e.g. an Enterprise DPC and a Supervision admin. This API will only to return
     * the restrictions set by the DPCs. To retrieve restrictions set by all agents, use
     * {@link android.content.RestrictionsManager#getApplicationRestrictionsPerAdmin} instead.
     */
    @Deprecated
    @Override
    public Bundle getApplicationRestrictionsForUser(String packageName, @UserIdInt int userId) {
        if (UserHandle.getCallingUserId() != userId