Merge "Add policy transparency dialog to 'Remove work profile'" into rvc-dev

This commit is contained in:
Alex Johnston
2020-03-12 12:00:49 +00:00
committed by Android (Google) Code Review

View File

@@ -457,12 +457,20 @@ public class DeviceAdminAdd extends Activity {
private void showPolicyTransparencyDialogIfRequired() { private void showPolicyTransparencyDialogIfRequired() {
if (isManagedProfile(mDeviceAdmin) if (isManagedProfile(mDeviceAdmin)
&& mDeviceAdmin.getComponent().equals(mDPM.getProfileOwner())) { && mDeviceAdmin.getComponent().equals(mDPM.getProfileOwner())) {
if (hasBaseCantRemoveProfileRestriction()) { EnforcedAdmin enforcedAdmin;
// If DISALLOW_REMOVE_MANAGED_PROFILE is set by the system, there's no ComponentName adminComponent = mDPM.getProfileOwnerAsUser(getUserId());
// point showing a dialog saying it's disabled by an admin. if (adminComponent != null && mDPM.isOrganizationOwnedDeviceWithManagedProfile()) {
return; enforcedAdmin = new EnforcedAdmin(adminComponent,
UserManager.DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.of(getUserId()));
} else {
// Todo (b/151061366): Investigate this case to check if it is still viable.
if (hasBaseCantRemoveProfileRestriction()) {
// If DISALLOW_REMOVE_MANAGED_PROFILE is set by the system, there's no
// point showing a dialog saying it's disabled by an admin.
return;
}
enforcedAdmin = getAdminEnforcingCantRemoveProfile();
} }
EnforcedAdmin enforcedAdmin = getAdminEnforcingCantRemoveProfile();
if (enforcedAdmin != null) { if (enforcedAdmin != null) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent( RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
DeviceAdminAdd.this, DeviceAdminAdd.this,
@@ -640,7 +648,8 @@ public class DeviceAdminAdd extends Activity {
final EnforcedAdmin admin = getAdminEnforcingCantRemoveProfile(); final EnforcedAdmin admin = getAdminEnforcingCantRemoveProfile();
final boolean hasBaseRestriction = hasBaseCantRemoveProfileRestriction(); final boolean hasBaseRestriction = hasBaseCantRemoveProfileRestriction();
if (admin != null && !hasBaseRestriction) { if ((hasBaseRestriction && mDPM.isOrganizationOwnedDeviceWithManagedProfile())
|| (admin != null && !hasBaseRestriction)) {
findViewById(R.id.restricted_icon).setVisibility(View.VISIBLE); findViewById(R.id.restricted_icon).setVisibility(View.VISIBLE);
} }
mActionButton.setEnabled(admin == null && !hasBaseRestriction); mActionButton.setEnabled(admin == null && !hasBaseRestriction);