Merge "Add support for PO on corp owned device for QS disclosure dialog" into rvc-dev

This commit is contained in:
Antoan Angelov
2020-07-06 16:10:06 +00:00
committed by Android (Google) Code Review
2 changed files with 58 additions and 9 deletions

View File

@@ -265,9 +265,13 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic
private void createDialog() {
final boolean isDeviceManaged = mSecurityController.isDeviceManaged();
boolean isProfileOwnerOfOrganizationOwnedDevice =
mSecurityController.isProfileOwnerOfOrganizationOwnedDevice();
final boolean hasWorkProfile = mSecurityController.hasWorkProfile();
final CharSequence deviceOwnerOrganization =
mSecurityController.getDeviceOwnerOrganizationName();
final CharSequence workProfileOrganizationName =
mSecurityController.getWorkProfileOrganizationName();
final boolean hasCACerts = mSecurityController.hasCACertInCurrentUser();
final boolean hasCACertsInWorkProfile = mSecurityController.hasCACertInWorkProfile();
final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled();
@@ -284,7 +288,8 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic
// device management section
CharSequence managementMessage = getManagementMessage(isDeviceManaged,
deviceOwnerOrganization);
deviceOwnerOrganization, isProfileOwnerOfOrganizationOwnedDevice,
workProfileOrganizationName);
if (managementMessage == null) {
dialogView.findViewById(R.id.device_management_disclosures).setVisibility(View.GONE);
} else {
@@ -292,7 +297,11 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic
TextView deviceManagementWarning =
(TextView) dialogView.findViewById(R.id.device_management_warning);
deviceManagementWarning.setText(managementMessage);
mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
// Don't show the policies button for profile owner of org owned device, because there
// is no policies settings screen for it
if (!isProfileOwnerOfOrganizationOwnedDevice) {
mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
}
}
// ca certificate section
@@ -382,11 +391,18 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic
}
protected CharSequence getManagementMessage(boolean isDeviceManaged,
CharSequence organizationName) {
if (!isDeviceManaged) return null;
if (organizationName != null)
CharSequence organizationName, boolean isProfileOwnerOfOrganizationOwnedDevice,
CharSequence workProfileOrganizationName) {
if (!isDeviceManaged && !isProfileOwnerOfOrganizationOwnedDevice) {
return null;
}
if (isDeviceManaged && organizationName != null) {
return mContext.getString(
R.string.monitoring_description_named_management, organizationName);
} else if (isProfileOwnerOfOrganizationOwnedDevice && workProfileOrganizationName != null) {
return mContext.getString(
R.string.monitoring_description_named_management, workProfileOrganizationName);
}
return mContext.getString(R.string.monitoring_description_management);
}

View File

@@ -367,13 +367,46 @@ public class QSSecurityFooterTest extends SysuiTestCase {
}
@Test
public void testGetManagementMessage() {
assertEquals(null, mFooter.getManagementMessage(false, MANAGING_ORGANIZATION));
public void testGetManagementMessage_noManagement() {
assertEquals(null, mFooter.getManagementMessage(
/* isDeviceManaged= */ false,
MANAGING_ORGANIZATION,
/* isProfileOwnerOfOrganizationOwnedDevice= */ false,
MANAGING_ORGANIZATION));
}
@Test
public void testGetManagementMessage_deviceOwner() {
assertEquals(mContext.getString(R.string.monitoring_description_named_management,
MANAGING_ORGANIZATION),
mFooter.getManagementMessage(true, MANAGING_ORGANIZATION));
mFooter.getManagementMessage(
/* isDeviceManaged= */ true,
MANAGING_ORGANIZATION,
/* isProfileOwnerOfOrganizationOwnedDevice= */ false,
/* workProfileOrganizationName= */ null));
assertEquals(mContext.getString(R.string.monitoring_description_management),
mFooter.getManagementMessage(true, null));
mFooter.getManagementMessage(
/* isDeviceManaged= */ true,
/* organizationName= */ null,
/* isProfileOwnerOfOrganizationOwnedDevice= */ false,
/* workProfileOrganizationName= */ null));
}
@Test
public void testGetManagementMessage_profileOwnerOfOrganizationOwnedDevice() {
assertEquals(mContext.getString(R.string.monitoring_description_named_management,
MANAGING_ORGANIZATION),
mFooter.getManagementMessage(
/* isDeviceManaged= */ false,
/* organizationName= */ null,
/* isProfileOwnerOfOrganizationOwnedDevice= */ true,
MANAGING_ORGANIZATION));
assertEquals(mContext.getString(R.string.monitoring_description_management),
mFooter.getManagementMessage(
/* isDeviceManaged= */ false,
/* organizationName= */ null,
/* isProfileOwnerOfOrganizationOwnedDevice= */ true,
/* workProfileOrganizationName= */ null));
}
@Test