Merge "Remove blurs when adjusting brightness" into rvc-dev am: 137af5ad16 am: d369b905da
Change-Id: I74e4e09ed39a80ecfe09898ae7881a2eef74620a
This commit is contained in:
@@ -65,6 +65,7 @@ import com.android.systemui.statusbar.NavigationBarController;
|
||||
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
|
||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
||||
import com.android.systemui.statusbar.NotificationViewHierarchyManager;
|
||||
import com.android.systemui.statusbar.PulseExpansionHandler;
|
||||
import com.android.systemui.statusbar.SuperStatusBarViewFactory;
|
||||
@@ -225,6 +226,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
KeyguardIndicationController keyguardIndicationController,
|
||||
DismissCallbackRegistry dismissCallbackRegistry,
|
||||
StatusBarTouchableRegionManager statusBarTouchableRegionManager,
|
||||
Lazy<NotificationShadeDepthController> depthControllerLazy,
|
||||
/* Car Settings injected components. */
|
||||
CarNavigationBarController carNavigationBarController) {
|
||||
super(
|
||||
@@ -304,6 +306,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
|
||||
phoneStatusBarPolicy,
|
||||
keyguardIndicationController,
|
||||
dismissCallbackRegistry,
|
||||
depthControllerLazy,
|
||||
statusBarTouchableRegionManager);
|
||||
mUserSwitcherController = userSwitcherController;
|
||||
mScrimController = scrimController;
|
||||
|
||||
@@ -51,6 +51,7 @@ import com.android.systemui.statusbar.NavigationBarController;
|
||||
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
|
||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
||||
import com.android.systemui.statusbar.NotificationViewHierarchyManager;
|
||||
import com.android.systemui.statusbar.PulseExpansionHandler;
|
||||
import com.android.systemui.statusbar.SuperStatusBarViewFactory;
|
||||
@@ -200,6 +201,7 @@ public class CarStatusBarModule {
|
||||
KeyguardIndicationController keyguardIndicationController,
|
||||
DismissCallbackRegistry dismissCallbackRegistry,
|
||||
StatusBarTouchableRegionManager statusBarTouchableRegionManager,
|
||||
Lazy<NotificationShadeDepthController> notificationShadeDepthControllerLazy,
|
||||
CarNavigationBarController carNavigationBarController) {
|
||||
return new CarStatusBar(
|
||||
context,
|
||||
@@ -278,6 +280,7 @@ public class CarStatusBarModule {
|
||||
keyguardIndicationController,
|
||||
dismissCallbackRegistry,
|
||||
statusBarTouchableRegionManager,
|
||||
notificationShadeDepthControllerLazy,
|
||||
carNavigationBarController);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.android.systemui.statusbar.phone.PanelExpansionListener
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController
|
||||
import java.io.FileDescriptor
|
||||
import java.io.PrintWriter
|
||||
import java.lang.IllegalArgumentException
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlin.math.max
|
||||
@@ -74,6 +73,15 @@ class NotificationShadeDepthController @Inject constructor(
|
||||
@VisibleForTesting
|
||||
var globalActionsSpring = DepthAnimation()
|
||||
|
||||
@VisibleForTesting
|
||||
var brightnessMirrorSpring = DepthAnimation()
|
||||
var brightnessMirrorVisible: Boolean = false
|
||||
set(value) {
|
||||
field = value
|
||||
brightnessMirrorSpring.animateTo(if (value) blurUtils.blurRadiusOfRatio(1f)
|
||||
else 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Blur radius of the wake-up animation on this frame.
|
||||
*/
|
||||
@@ -91,7 +99,9 @@ class NotificationShadeDepthController @Inject constructor(
|
||||
val updateBlurCallback = Choreographer.FrameCallback {
|
||||
updateScheduled = false
|
||||
|
||||
val blur = max(max(shadeSpring.radius, wakeAndUnlockBlurRadius), globalActionsSpring.radius)
|
||||
var shadeRadius = max(shadeSpring.radius, wakeAndUnlockBlurRadius)
|
||||
shadeRadius = (shadeRadius * (1f - brightnessMirrorSpring.ratio)).toInt()
|
||||
val blur = max(shadeRadius, globalActionsSpring.radius)
|
||||
blurUtils.applyBlur(blurRoot?.viewRootImpl ?: root.viewRootImpl, blur)
|
||||
try {
|
||||
wallpaperManager.setWallpaperZoomOut(root.windowToken,
|
||||
@@ -148,6 +158,7 @@ class NotificationShadeDepthController @Inject constructor(
|
||||
if (isDozing) {
|
||||
shadeSpring.finishIfRunning()
|
||||
globalActionsSpring.finishIfRunning()
|
||||
brightnessMirrorSpring.finishIfRunning()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,6 +210,7 @@ class NotificationShadeDepthController @Inject constructor(
|
||||
it.increaseIndent()
|
||||
it.println("shadeRadius: ${shadeSpring.radius}")
|
||||
it.println("globalActionsRadius: ${globalActionsSpring.radius}")
|
||||
it.println("brightnessMirrorRadius: ${brightnessMirrorSpring.radius}")
|
||||
it.println("wakeAndUnlockBlur: $wakeAndUnlockBlurRadius")
|
||||
}
|
||||
}
|
||||
@@ -212,7 +224,12 @@ class NotificationShadeDepthController @Inject constructor(
|
||||
* Blur radius visible on the UI, in pixels.
|
||||
*/
|
||||
var radius = 0
|
||||
private set
|
||||
|
||||
/**
|
||||
* Depth ratio of the current blur radius.
|
||||
*/
|
||||
val ratio
|
||||
get() = blurUtils.ratioOfBlurRadius(radius)
|
||||
|
||||
/**
|
||||
* Radius that we're animating to.
|
||||
|
||||
@@ -176,6 +176,7 @@ import com.android.systemui.statusbar.NotificationLockscreenUserManager;
|
||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||
import com.android.systemui.statusbar.NotificationPresenter;
|
||||
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
||||
import com.android.systemui.statusbar.NotificationShelf;
|
||||
import com.android.systemui.statusbar.NotificationViewHierarchyManager;
|
||||
import com.android.systemui.statusbar.PulseExpansionHandler;
|
||||
@@ -589,6 +590,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
private ActivityLaunchAnimator mActivityLaunchAnimator;
|
||||
protected StatusBarNotificationPresenter mPresenter;
|
||||
private NotificationActivityStarter mNotificationActivityStarter;
|
||||
private Lazy<NotificationShadeDepthController> mNotificationShadeDepthControllerLazy;
|
||||
private final BubbleController mBubbleController;
|
||||
private final BubbleController.BubbleExpandListener mBubbleExpandListener;
|
||||
|
||||
@@ -679,6 +681,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
PhoneStatusBarPolicy phoneStatusBarPolicy,
|
||||
KeyguardIndicationController keyguardIndicationController,
|
||||
DismissCallbackRegistry dismissCallbackRegistry,
|
||||
Lazy<NotificationShadeDepthController> notificationShadeDepthControllerLazy,
|
||||
StatusBarTouchableRegionManager statusBarTouchableRegionManager) {
|
||||
super(context);
|
||||
mNotificationsController = notificationsController;
|
||||
@@ -735,6 +738,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
mScreenPinningRequest = screenPinningRequest;
|
||||
mDozeScrimController = dozeScrimController;
|
||||
mBiometricUnlockControllerLazy = biometricUnlockControllerLazy;
|
||||
mNotificationShadeDepthControllerLazy = notificationShadeDepthControllerLazy;
|
||||
mVolumeComponent = volumeComponent;
|
||||
mCommandQueue = commandQueue;
|
||||
mRecentsOptional = recentsOptional;
|
||||
@@ -1135,6 +1139,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
mBrightnessMirrorController = new BrightnessMirrorController(
|
||||
mNotificationShadeWindowView,
|
||||
mNotificationPanelViewController,
|
||||
mNotificationShadeDepthControllerLazy.get(),
|
||||
(visible) -> {
|
||||
mBrightnessMirrorVisible = visible;
|
||||
updateScrimController();
|
||||
|
||||
@@ -51,6 +51,7 @@ import com.android.systemui.statusbar.NavigationBarController;
|
||||
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
|
||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
||||
import com.android.systemui.statusbar.NotificationViewHierarchyManager;
|
||||
import com.android.systemui.statusbar.PulseExpansionHandler;
|
||||
import com.android.systemui.statusbar.SuperStatusBarViewFactory;
|
||||
@@ -197,6 +198,7 @@ public interface StatusBarPhoneModule {
|
||||
UserInfoControllerImpl userInfoControllerImpl,
|
||||
PhoneStatusBarPolicy phoneStatusBarPolicy,
|
||||
KeyguardIndicationController keyguardIndicationController,
|
||||
Lazy<NotificationShadeDepthController> notificationShadeDepthController,
|
||||
DismissCallbackRegistry dismissCallbackRegistry,
|
||||
StatusBarTouchableRegionManager statusBarTouchableRegionManager) {
|
||||
return new StatusBar(
|
||||
@@ -276,6 +278,7 @@ public interface StatusBarPhoneModule {
|
||||
phoneStatusBarPolicy,
|
||||
keyguardIndicationController,
|
||||
dismissCallbackRegistry,
|
||||
notificationShadeDepthController,
|
||||
statusBarTouchableRegionManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
||||
import com.android.systemui.statusbar.phone.NotificationPanelViewController;
|
||||
import com.android.systemui.statusbar.phone.NotificationShadeWindowView;
|
||||
|
||||
@@ -39,16 +40,19 @@ public class BrightnessMirrorController
|
||||
private final NotificationShadeWindowView mStatusBarWindow;
|
||||
private final Consumer<Boolean> mVisibilityCallback;
|
||||
private final NotificationPanelViewController mNotificationPanel;
|
||||
private final NotificationShadeDepthController mDepthController;
|
||||
private final ArraySet<BrightnessMirrorListener> mBrightnessMirrorListeners = new ArraySet<>();
|
||||
private final int[] mInt2Cache = new int[2];
|
||||
private View mBrightnessMirror;
|
||||
|
||||
public BrightnessMirrorController(NotificationShadeWindowView statusBarWindow,
|
||||
NotificationPanelViewController notificationPanelViewController,
|
||||
NotificationShadeDepthController notificationShadeDepthController,
|
||||
@NonNull Consumer<Boolean> visibilityCallback) {
|
||||
mStatusBarWindow = statusBarWindow;
|
||||
mBrightnessMirror = statusBarWindow.findViewById(R.id.brightness_mirror);
|
||||
mNotificationPanel = notificationPanelViewController;
|
||||
mDepthController = notificationShadeDepthController;
|
||||
mNotificationPanel.setPanelAlphaEndAction(() -> {
|
||||
mBrightnessMirror.setVisibility(View.INVISIBLE);
|
||||
});
|
||||
@@ -59,11 +63,13 @@ public class BrightnessMirrorController
|
||||
mBrightnessMirror.setVisibility(View.VISIBLE);
|
||||
mVisibilityCallback.accept(true);
|
||||
mNotificationPanel.setPanelAlpha(0, true /* animate */);
|
||||
mDepthController.setBrightnessMirrorVisible(true);
|
||||
}
|
||||
|
||||
public void hideMirror() {
|
||||
mVisibilityCallback.accept(false);
|
||||
mNotificationPanel.setPanelAlpha(255, true /* animate */);
|
||||
mDepthController.setBrightnessMirrorVisible(false);
|
||||
}
|
||||
|
||||
public void setLocation(View original) {
|
||||
|
||||
@@ -45,7 +45,6 @@ import org.mockito.Mockito.clearInvocations
|
||||
import org.mockito.Mockito.doThrow
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
@RunWith(AndroidTestingRunner::class)
|
||||
@RunWithLooper
|
||||
@@ -64,6 +63,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
|
||||
@Mock private lateinit var viewRootImpl: ViewRootImpl
|
||||
@Mock private lateinit var shadeSpring: NotificationShadeDepthController.DepthAnimation
|
||||
@Mock private lateinit var globalActionsSpring: NotificationShadeDepthController.DepthAnimation
|
||||
@Mock private lateinit var brightnessSpring: NotificationShadeDepthController.DepthAnimation
|
||||
@JvmField @Rule val mockitoRule = MockitoJUnit.rule()
|
||||
|
||||
private lateinit var statusBarStateListener: StatusBarStateController.StateListener
|
||||
@@ -83,6 +83,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
|
||||
keyguardStateController, choreographer, wallpaperManager,
|
||||
notificationShadeWindowController, dumpManager)
|
||||
notificationShadeDepthController.shadeSpring = shadeSpring
|
||||
notificationShadeDepthController.brightnessMirrorSpring = brightnessSpring
|
||||
notificationShadeDepthController.globalActionsSpring = globalActionsSpring
|
||||
notificationShadeDepthController.root = root
|
||||
|
||||
@@ -134,6 +135,30 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
|
||||
verify(wallpaperManager).setWallpaperZoomOut(any(), anyFloat())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun brightnessMirrorVisible_whenVisible() {
|
||||
notificationShadeDepthController.brightnessMirrorVisible = true
|
||||
verify(brightnessSpring).animateTo(eq(maxBlur), any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun brightnessMirrorVisible_whenHidden() {
|
||||
notificationShadeDepthController.brightnessMirrorVisible = false
|
||||
verify(brightnessSpring).animateTo(eq(0), any())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun brightnessMirror_hidesShadeBlur() {
|
||||
// Brightness mirror is fully visible
|
||||
`when`(brightnessSpring.ratio).thenReturn(1f)
|
||||
// And shade is blurred
|
||||
`when`(shadeSpring.radius).thenReturn(maxBlur)
|
||||
|
||||
notificationShadeDepthController.updateBlurCallback.doFrame(0)
|
||||
verify(notificationShadeWindowController).setBackgroundBlurRadius(0)
|
||||
verify(blurUtils).applyBlur(safeEq(viewRootImpl), eq(0))
|
||||
}
|
||||
|
||||
private fun <T : Any> safeEq(value: T): T {
|
||||
return eq(value) ?: value
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ import com.android.systemui.statusbar.NotificationListener;
|
||||
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
|
||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||
import com.android.systemui.statusbar.NotificationShadeDepthController;
|
||||
import com.android.systemui.statusbar.NotificationViewHierarchyManager;
|
||||
import com.android.systemui.statusbar.PulseExpansionHandler;
|
||||
import com.android.systemui.statusbar.RemoteInputController;
|
||||
@@ -249,6 +250,7 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
@Mock private ExtensionController mExtensionController;
|
||||
@Mock private UserInfoControllerImpl mUserInfoControllerImpl;
|
||||
@Mock private PhoneStatusBarPolicy mPhoneStatusBarPolicy;
|
||||
@Mock private Lazy<NotificationShadeDepthController> mNotificationShadeDepthControllerLazy;
|
||||
private ShadeController mShadeController;
|
||||
private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock());
|
||||
private InitController mInitController = new InitController();
|
||||
@@ -404,6 +406,7 @@ public class StatusBarTest extends SysuiTestCase {
|
||||
mPhoneStatusBarPolicy,
|
||||
mKeyguardIndicationController,
|
||||
mDismissCallbackRegistry,
|
||||
mNotificationShadeDepthControllerLazy,
|
||||
mStatusBarTouchableRegionManager);
|
||||
|
||||
when(mNotificationShadeWindowView.findViewById(R.id.lock_icon_container)).thenReturn(
|
||||
|
||||
Reference in New Issue
Block a user