summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Behnam Heydarshahi <bhnm@google.com> 2024-09-27 22:21:08 +0000
committer Behnam Heydarshahi <bhnm@google.com> 2024-10-03 15:15:42 +0000
commit955da7239e6ec26b86a6e8469641a1931e4b99b0 (patch)
tree2377ba4e18609db63a1abf66abe432ba1d7f08fa
parent6d2364451564e0f3f837b72d7d0ba6c5b9cc7277 (diff)
Make shutdown text visible when wallpaper is white
The shutdown background was black. The wallpaper was white but hidden. The shutdown text was trying to match wallpaper, so black was chosen, which caused the text to be invisible. This CL solves that issue by setting text color to global_actions_shutdown_ui_text. Also this CL removes the code to blur the background because its alpha has been set to 1 for a while now. Bug: 193831592 Flag: EXEMPT resource only update Test: atest ShutdownUiTest Change-Id: I375beec37c26ce534cb4a5b9752acf5e40082aac
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/globalactions/ShutdownUiTest.java32
-rw-r--r--packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUi.java39
2 files changed, 39 insertions, 32 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/globalactions/ShutdownUiTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/globalactions/ShutdownUiTest.java
index 73509e2da520..acc17e73ac69 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/globalactions/ShutdownUiTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/globalactions/ShutdownUiTest.java
@@ -19,20 +19,25 @@ package com.android.systemui.globalactions;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.content.res.Resources;
import android.nearby.NearbyManager;
import android.net.platform.flags.Flags;
import android.os.PowerManager;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
+import android.testing.TestableLooper;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.internal.R;
import com.android.systemui.SysuiTestCase;
-import com.android.systemui.statusbar.BlurUtils;
import org.junit.Before;
import org.junit.Test;
@@ -46,14 +51,13 @@ public class ShutdownUiTest extends SysuiTestCase {
ShutdownUi mShutdownUi;
@Mock
- BlurUtils mBlurUtils;
- @Mock
NearbyManager mNearbyManager;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- mShutdownUi = new ShutdownUi(getContext(), mBlurUtils, mNearbyManager);
+ mContext = spy(mContext);
+ mShutdownUi = new ShutdownUi(mContext, mNearbyManager);
}
@Test
@@ -140,4 +144,24 @@ public class ShutdownUiTest extends SysuiTestCase {
assertEquals(actualLayout, expectedLayout);
}
+ /**
+ * Main looper required here because showShutdown UI creates a dialog which instantiates a
+ * handler that needs to be on the main thread.
+ */
+ @TestableLooper.RunWithLooper(setAsMainLooper = true)
+ @Test
+ public void showShutdownUi_loadsShutdownTextColorAndAlpha() {
+ this.allowTestableLooperAsMainThread();
+
+ Resources mockResources = spy(mContext.getResources());
+ when(mContext.getResources()).thenReturn(mockResources);
+
+ mShutdownUi.showShutdownUi(false, "test");
+
+ verify(mockResources).getFloat(
+ eq(com.android.systemui.res.R.dimen.shutdown_scrim_behind_alpha));
+ verify(mockResources).getColor(
+ eq(com.android.systemui.res.R.color.global_actions_shutdown_ui_text),
+ any());
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUi.java b/packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUi.java
index ccd69ca55f0c..4599afa66407 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUi.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/ShutdownUi.java
@@ -36,10 +36,7 @@ import android.widget.TextView;
import androidx.annotation.VisibleForTesting;
import com.android.internal.R;
-import com.android.settingslib.Utils;
import com.android.systemui.scrim.ScrimDrawable;
-import com.android.systemui.statusbar.BlurUtils;
-import com.android.systemui.statusbar.phone.ScrimController;
import javax.inject.Inject;
@@ -49,13 +46,11 @@ import javax.inject.Inject;
public class ShutdownUi {
private Context mContext;
- private BlurUtils mBlurUtils;
private NearbyManager mNearbyManager;
@Inject
- public ShutdownUi(Context context, BlurUtils blurUtils, NearbyManager nearbyManager) {
+ public ShutdownUi(Context context, NearbyManager nearbyManager) {
mContext = context;
- mBlurUtils = blurUtils;
mNearbyManager = nearbyManager;
}
@@ -63,25 +58,17 @@ public class ShutdownUi {
* Display the shutdown UI.
* @param isReboot Whether the device will be rebooting after this shutdown.
* @param reason Cause for the shutdown.
+ * @return Shutdown dialog.
*/
- public void showShutdownUi(boolean isReboot, String reason) {
+ public Dialog showShutdownUi(boolean isReboot, String reason) {
ScrimDrawable background = new ScrimDrawable();
final Dialog d = new Dialog(mContext,
com.android.systemui.res.R.style.Theme_SystemUI_Dialog_GlobalActions);
- d.setOnShowListener(dialog -> {
- if (mBlurUtils.supportsBlursOnWindows()) {
- int backgroundAlpha = (int) (ScrimController.BUSY_SCRIM_ALPHA * 255);
- background.setAlpha(backgroundAlpha);
- mBlurUtils.applyBlur(d.getWindow().getDecorView().getViewRootImpl(),
- (int) mBlurUtils.blurRadiusOfRatio(1), backgroundAlpha == 255);
- } else {
- float backgroundAlpha = mContext.getResources().getFloat(
- com.android.systemui.res.R.dimen.shutdown_scrim_behind_alpha);
- background.setAlpha((int) (backgroundAlpha * 255));
- }
- });
+ float backgroundAlpha = mContext.getResources().getFloat(
+ com.android.systemui.res.R.dimen.shutdown_scrim_behind_alpha);
+ background.setAlpha((int) (backgroundAlpha * 255));
// Window initialization
Window window = d.getWindow();
@@ -110,14 +97,9 @@ public class ShutdownUi {
d.setContentView(getShutdownDialogContent(isReboot));
d.setCancelable(false);
- int color;
- if (mBlurUtils.supportsBlursOnWindows()) {
- color = Utils.getColorAttrDefaultColor(mContext,
- com.android.systemui.res.R.attr.wallpaperTextColor);
- } else {
- color = mContext.getResources().getColor(
- com.android.systemui.res.R.color.global_actions_shutdown_ui_text);
- }
+ int color = mContext.getResources().getColor(
+ com.android.systemui.res.R.color.global_actions_shutdown_ui_text,
+ mContext.getTheme());
ProgressBar bar = d.findViewById(R.id.progress);
bar.getIndeterminateDrawable().setTint(color);
@@ -136,6 +118,8 @@ public class ShutdownUi {
}
d.show();
+
+ return d;
}
/**
@@ -162,7 +146,6 @@ public class ShutdownUi {
}
}
-
@StringRes
@VisibleForTesting int getRebootMessage(boolean isReboot, @Nullable String reason) {
if (reason != null && reason.startsWith(PowerManager.REBOOT_RECOVERY_UPDATE)) {