From aeae9af5f5be0cd74e533401728e8baa3c6aa523 Mon Sep 17 00:00:00 2001 From: Jordan Demeulenaere Date: Fri, 30 Sep 2022 14:53:52 +0200 Subject: [PATCH] Fix security dialog bug This CL fixes a bug introduced by ag/19712818: when inflating the security dialog content, we should use the Quick Settings context (which is always using dark mode) and not the application context. Otherwise, if we are in light mode, then the color of the text is the same as the background and it looks like there is not content in the dialog. In dark mode, everything was looking fine because the text color from the application context would be light. Bug: 247961387 Test: Manual Change-Id: I0088206b8a3f5473f22d6f80e89a5dd07875c167 --- .../com/android/systemui/qs/QSSecurityFooterUtils.java | 10 +++++----- .../com/android/systemui/qs/QSSecurityFooterTest.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooterUtils.java b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooterUtils.java index bd75c75faa00b..ae6ed2008a77f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooterUtils.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooterUtils.java @@ -444,7 +444,7 @@ public class QSSecurityFooterUtils implements DialogInterface.OnClickListener { mShouldUseSettingsButton.set(false); mBgHandler.post(() -> { String settingsButtonText = getSettingsButton(); - final View dialogView = createDialogView(); + final View dialogView = createDialogView(quickSettingsContext); mMainHandler.post(() -> { mDialog = new SystemUIDialog(quickSettingsContext, 0); mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); @@ -469,14 +469,14 @@ public class QSSecurityFooterUtils implements DialogInterface.OnClickListener { } @VisibleForTesting - View createDialogView() { + View createDialogView(Context quickSettingsContext) { if (mSecurityController.isParentalControlsEnabled()) { return createParentalControlsDialogView(); } - return createOrganizationDialogView(); + return createOrganizationDialogView(quickSettingsContext); } - private View createOrganizationDialogView() { + private View createOrganizationDialogView(Context quickSettingsContext) { final boolean isDeviceManaged = mSecurityController.isDeviceManaged(); final boolean hasWorkProfile = mSecurityController.hasWorkProfile(); final CharSequence deviceOwnerOrganization = @@ -487,7 +487,7 @@ public class QSSecurityFooterUtils implements DialogInterface.OnClickListener { final String vpnName = mSecurityController.getPrimaryVpnName(); final String vpnNameWorkProfile = mSecurityController.getWorkProfileVpnName(); - View dialogView = LayoutInflater.from(mContext) + View dialogView = LayoutInflater.from(quickSettingsContext) .inflate(R.layout.quick_settings_footer_dialog, null, false); // device management section 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 233c267c3be07..1c686c66e31e4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java @@ -726,7 +726,7 @@ public class QSSecurityFooterTest extends SysuiTestCase { when(mSecurityController.isParentalControlsEnabled()).thenReturn(true); when(mSecurityController.getLabel(any())).thenReturn(PARENTAL_CONTROLS_LABEL); - View view = mFooterUtils.createDialogView(); + View view = mFooterUtils.createDialogView(getContext()); TextView textView = (TextView) view.findViewById(R.id.parental_controls_title); assertEquals(PARENTAL_CONTROLS_LABEL, textView.getText()); } @@ -749,7 +749,7 @@ public class QSSecurityFooterTest extends SysuiTestCase { when(mSecurityController.getDeviceOwnerType(DEVICE_OWNER_COMPONENT)) .thenReturn(DEVICE_OWNER_TYPE_FINANCED); - View view = mFooterUtils.createDialogView(); + View view = mFooterUtils.createDialogView(getContext()); TextView managementSubtitle = view.findViewById(R.id.device_management_subtitle); assertEquals(View.VISIBLE, managementSubtitle.getVisibility());