diff options
3 files changed, 6 insertions, 55 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 1ddec17e49bb..0f54cb7bc35e 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -10476,10 +10476,6 @@ public class DevicePolicyManager { @WorkerThread public void setApplicationRestrictions(@Nullable ComponentName admin, String packageName, Bundle settings) { - if (!Flags.dmrhSetAppRestrictions()) { - throwIfParentInstance("setApplicationRestrictions"); - } - if (mService != null) { try { mService.setApplicationRestrictions(admin, mContext.getPackageName(), packageName, @@ -11884,9 +11880,6 @@ public class DevicePolicyManager { @WorkerThread public @NonNull Bundle getApplicationRestrictions( @Nullable ComponentName admin, String packageName) { - if (!Flags.dmrhSetAppRestrictions()) { - throwIfParentInstance("getApplicationRestrictions"); - } if (mService != null) { try { @@ -14231,21 +14224,11 @@ public class DevicePolicyManager { */ public @NonNull DevicePolicyManager getParentProfileInstance(@NonNull ComponentName admin) { throwIfParentInstance("getParentProfileInstance"); - try { - if (Flags.dmrhSetAppRestrictions()) { - UserManager um = mContext.getSystemService(UserManager.class); - if (!um.isManagedProfile()) { - throw new SecurityException("The current user does not have a parent profile."); - } - } else { - if (!mService.isManagedProfile(admin)) { - throw new SecurityException("The current user does not have a parent profile."); - } - } - return new DevicePolicyManager(mContext, mService, true); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); + UserManager um = mContext.getSystemService(UserManager.class); + if (!um.isManagedProfile()) { + throw new SecurityException("The current user does not have a parent profile."); } + return new DevicePolicyManager(mContext, mService, true); } /** diff --git a/core/java/android/app/admin/flags/flags.aconfig b/core/java/android/app/admin/flags/flags.aconfig index d9bd77fb3d54..540592ff0b90 100644 --- a/core/java/android/app/admin/flags/flags.aconfig +++ b/core/java/android/app/admin/flags/flags.aconfig @@ -210,16 +210,6 @@ flag { } flag { - name: "dmrh_set_app_restrictions" - namespace: "enterprise" - description: "Allow DMRH to set application restrictions (both on the profile and the parent)" - bug: "328758346" - metadata { - purpose: PURPOSE_BUGFIX - } -} - -flag { name: "always_persist_do" namespace: "enterprise" description: "Always write device_owners2.xml so that migration flags aren't lost" diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index fc619677bb56..2b7e9f902ccf 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -11858,7 +11858,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } setBackwardsCompatibleAppRestrictions( caller, packageName, restrictions, caller.getUserHandle()); - } else if (Flags.dmrhSetAppRestrictions()) { + } else { final boolean isRoleHolder; if (who != null) { // DO or PO @@ -11905,15 +11905,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { caller.getUserHandle()); }); } - } else { - Preconditions.checkCallAuthorization((caller.hasAdminComponent() - && (isProfileOwner(caller) || isDefaultDeviceOwner(caller))) - || (caller.hasPackage() && isCallerDelegate(caller, - DELEGATION_APP_RESTRICTIONS))); - mInjector.binderWithCleanCallingIdentity(() -> { - mUserManager.setApplicationRestrictions(packageName, restrictions, - caller.getUserHandle()); - }); } DevicePolicyEventLogger @@ -13244,7 +13235,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return Bundle.EMPTY; } return policies.get(enforcingAdmin).getValue(); - } else if (Flags.dmrhSetAppRestrictions()) { + } else { final boolean isRoleHolder; if (who != null) { // Caller is DO or PO. They cannot call this on parent @@ -13287,19 +13278,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return bundle != null ? bundle : Bundle.EMPTY; }); } - - } else { - Preconditions.checkCallAuthorization((caller.hasAdminComponent() - && (isProfileOwner(caller) || isDefaultDeviceOwner(caller))) - || (caller.hasPackage() && isCallerDelegate(caller, - DELEGATION_APP_RESTRICTIONS))); - return mInjector.binderWithCleanCallingIdentity(() -> { - Bundle bundle = mUserManager.getApplicationRestrictions(packageName, - caller.getUserHandle()); - // if no restrictions were saved, mUserManager.getApplicationRestrictions - // returns null, but DPM method should return an empty Bundle as per JavaDoc - return bundle != null ? bundle : Bundle.EMPTY; - }); } } |