diff options
| author | 2020-07-06 16:52:52 +0000 | |
|---|---|---|
| committer | 2020-07-06 16:52:52 +0000 | |
| commit | b7d10233ed8f924f416fabf2dfa99c3efdbb3a7e (patch) | |
| tree | 4097f89531eabc47b5c03d1403efe35e6c50dd7a | |
| parent | fd0a609cbe2d69e989a78357abf64d949eac7871 (diff) | |
| parent | 94476498356308ac5b1015ab0e7dd263b6a41f32 (diff) | |
Merge "Add support for PO on corp owned device for QS disclosure dialog" into rvc-dev am: 5c201b0360 am: 09e6559d7e am: 9447649835
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12034935
Change-Id: I83e50f111e109e89ce7715630687f7c2d7774805
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java | 26 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java | 41 |
2 files changed, 58 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java index 51eca67e02f9..afc5be4e6c2f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java @@ -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); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java index ea5449b4448e..417b19f0cfc1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java @@ -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( + /* 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(true, null)); + mFooter.getManagementMessage( + /* isDeviceManaged= */ false, + /* organizationName= */ null, + /* isProfileOwnerOfOrganizationOwnedDevice= */ true, + /* workProfileOrganizationName= */ null)); } @Test |