diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooterUtils.java b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooterUtils.java index 67bc769985975..068b9ea6bdb80 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooterUtils.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooterUtils.java @@ -247,7 +247,7 @@ public class QSSecurityFooterUtils implements DialogInterface.OnClickListener { Icon icon; ContentDescription contentDescription = null; - if (isParentalControlsEnabled) { + if (isParentalControlsEnabled && securityModel.getDeviceAdminIcon() != null) { icon = new Icon.Loaded(securityModel.getDeviceAdminIcon(), contentDescription); } else if (vpnName != null || vpnNameWorkProfile != null) { if (securityModel.isVpnBranded()) { 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 5e9c1aaad3091..906c20b1d0321 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java @@ -703,28 +703,32 @@ public class QSSecurityFooterTest extends SysuiTestCase { public void testParentalControls() { // Make sure the security footer is visible, so that the images are updated. when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true); - when(mSecurityController.isParentalControlsEnabled()).thenReturn(true); + // We use the default icon when there is no admin icon. + when(mSecurityController.getIcon(any())).thenReturn(null); + mFooter.refreshState(); + TestableLooper.get(this).processAllMessages(); + assertEquals(mContext.getString(R.string.quick_settings_disclosure_parental_controls), + mFooterText.getText()); + assertEquals(DEFAULT_ICON_ID, mPrimaryFooterIcon.getLastImageResource()); + Drawable testDrawable = new VectorDrawable(); when(mSecurityController.getIcon(any())).thenReturn(testDrawable); assertNotNull(mSecurityController.getIcon(null)); mFooter.refreshState(); - TestableLooper.get(this).processAllMessages(); assertEquals(mContext.getString(R.string.quick_settings_disclosure_parental_controls), mFooterText.getText()); assertEquals(View.VISIBLE, mPrimaryFooterIcon.getVisibility()); - assertEquals(testDrawable, mPrimaryFooterIcon.getDrawable()); // Ensure the primary icon is back to default after parental controls are gone when(mSecurityController.isParentalControlsEnabled()).thenReturn(false); mFooter.refreshState(); TestableLooper.get(this).processAllMessages(); - assertEquals(DEFAULT_ICON_ID, mPrimaryFooterIcon.getLastImageResource()); }