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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12034935

Change-Id: Idc343d7d907025ad9ed710aabb36688e9ca0ee89
This commit is contained in:
Antoan Angelov
2020-07-06 16:28:31 +00:00
committed by Automerger Merge Worker
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() { private void createDialog() {
final boolean isDeviceManaged = mSecurityController.isDeviceManaged(); final boolean isDeviceManaged = mSecurityController.isDeviceManaged();
boolean isProfileOwnerOfOrganizationOwnedDevice =
mSecurityController.isProfileOwnerOfOrganizationOwnedDevice();
final boolean hasWorkProfile = mSecurityController.hasWorkProfile(); final boolean hasWorkProfile = mSecurityController.hasWorkProfile();
final CharSequence deviceOwnerOrganization = final CharSequence deviceOwnerOrganization =
mSecurityController.getDeviceOwnerOrganizationName(); mSecurityController.getDeviceOwnerOrganizationName();
final CharSequence workProfileOrganizationName =
mSecurityController.getWorkProfileOrganizationName();
final boolean hasCACerts = mSecurityController.hasCACertInCurrentUser(); final boolean hasCACerts = mSecurityController.hasCACertInCurrentUser();
final boolean hasCACertsInWorkProfile = mSecurityController.hasCACertInWorkProfile(); final boolean hasCACertsInWorkProfile = mSecurityController.hasCACertInWorkProfile();
final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled(); final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled();
@@ -284,7 +288,8 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic
// device management section // device management section
CharSequence managementMessage = getManagementMessage(isDeviceManaged, CharSequence managementMessage = getManagementMessage(isDeviceManaged,
deviceOwnerOrganization); deviceOwnerOrganization, isProfileOwnerOfOrganizationOwnedDevice,
workProfileOrganizationName);
if (managementMessage == null) { if (managementMessage == null) {
dialogView.findViewById(R.id.device_management_disclosures).setVisibility(View.GONE); dialogView.findViewById(R.id.device_management_disclosures).setVisibility(View.GONE);
} else { } else {
@@ -292,7 +297,11 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic
TextView deviceManagementWarning = TextView deviceManagementWarning =
(TextView) dialogView.findViewById(R.id.device_management_warning); (TextView) dialogView.findViewById(R.id.device_management_warning);
deviceManagementWarning.setText(managementMessage); 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 // ca certificate section
@@ -382,11 +391,18 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic
} }
protected CharSequence getManagementMessage(boolean isDeviceManaged, protected CharSequence getManagementMessage(boolean isDeviceManaged,
CharSequence organizationName) { CharSequence organizationName, boolean isProfileOwnerOfOrganizationOwnedDevice,
if (!isDeviceManaged) return null; CharSequence workProfileOrganizationName) {
if (organizationName != null) if (!isDeviceManaged && !isProfileOwnerOfOrganizationOwnedDevice) {
return null;
}
if (isDeviceManaged && organizationName != null) {
return mContext.getString( return mContext.getString(
R.string.monitoring_description_named_management, organizationName); 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); return mContext.getString(R.string.monitoring_description_management);
} }

View File

@@ -367,13 +367,46 @@ public class QSSecurityFooterTest extends SysuiTestCase {
} }
@Test @Test
public void testGetManagementMessage() { public void testGetManagementMessage_noManagement() {
assertEquals(null, mFooter.getManagementMessage(false, MANAGING_ORGANIZATION)); 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, assertEquals(mContext.getString(R.string.monitoring_description_named_management,
MANAGING_ORGANIZATION), 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), 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 @Test