Merge changes from topic "aod-lockscreen-gx" into sc-dev

* changes:
  Add additional tests for AOD/unlocked animations.
  Use new GX overlay for new AOD/lockscreen transitions.
This commit is contained in:
Josh Tsuji
2021-02-16 17:32:47 +00:00
committed by Android (Google) Code Review
10 changed files with 119 additions and 15 deletions

View File

@@ -38,5 +38,8 @@
<!-- People Tile flag -->
<bool name="flag_conversations">false</bool>
<!-- The new animations to/from lockscreen and AOD! -->
<bool name="flag_lockscreen_animations">false</bool>
<bool name="flag_toast_style">false</bool>
</resources>

View File

@@ -67,6 +67,10 @@ public class FeatureFlags {
return mFlagReader.isEnabled(R.bool.flag_brightness_slider);
}
public boolean useNewLockscreenAnimations() {
return mFlagReader.isEnabled(R.bool.flag_lockscreen_animations);
}
public boolean isPeopleTileEnabled() {
return mFlagReader.isEnabled(R.bool.flag_conversations);
}

View File

@@ -11,14 +11,10 @@ import android.graphics.PorterDuffColorFilter
import android.graphics.PorterDuffXfermode
import android.graphics.RadialGradient
import android.graphics.Shader
import android.os.SystemProperties
import android.util.AttributeSet
import android.view.View
import com.android.systemui.Interpolators
val enableLightReveal =
SystemProperties.getBoolean("persist.sysui.show_new_screen_on_transitions", false)
/**
* Provides methods to modify the various properties of a [LightRevealScrim] to reveal between 0% to
* 100% of the view(s) underneath the scrim.

View File

@@ -29,6 +29,7 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.AlwaysOnDisplayPolicy;
import com.android.systemui.doze.DozeScreenState;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.tuner.TunerService;
@@ -54,6 +55,7 @@ public class DozeParameters implements TunerService.Tunable,
private final AlwaysOnDisplayPolicy mAlwaysOnPolicy;
private final Resources mResources;
private final BatteryController mBatteryController;
private final FeatureFlags mFeatureFlags;
private boolean mDozeAlwaysOn;
private boolean mControlScreenOffAnimation;
@@ -65,7 +67,8 @@ public class DozeParameters implements TunerService.Tunable,
AlwaysOnDisplayPolicy alwaysOnDisplayPolicy,
PowerManager powerManager,
BatteryController batteryController,
TunerService tunerService) {
TunerService tunerService,
FeatureFlags featureFlags) {
mResources = resources;
mAmbientDisplayConfiguration = ambientDisplayConfiguration;
mAlwaysOnPolicy = alwaysOnDisplayPolicy;
@@ -74,6 +77,7 @@ public class DozeParameters implements TunerService.Tunable,
mControlScreenOffAnimation = !getDisplayNeedsBlanking();
mPowerManager = powerManager;
mPowerManager.setDozeAfterScreenOff(!mControlScreenOffAnimation);
mFeatureFlags = featureFlags;
tunerService.addTunable(
this,
@@ -200,8 +204,7 @@ public class DozeParameters implements TunerService.Tunable,
* then abruptly showing AOD.
*/
public boolean shouldControlUnlockedScreenOff() {
return getAlwaysOn() && SystemProperties.getBoolean(
"persist.sysui.show_new_screen_on_transitions", false);
return getAlwaysOn() && mFeatureFlags.useNewLockscreenAnimations();
}
private boolean getBoolean(String propName, int resId) {

View File

@@ -35,7 +35,6 @@ import static com.android.systemui.charging.WirelessChargingLayout.UNKNOWN_BATTE
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASLEEP;
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_AWAKE;
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_WAKING;
import static com.android.systemui.statusbar.LightRevealScrimKt.getEnableLightReveal;
import static com.android.systemui.statusbar.NotificationLockscreenUserManager.PERMISSION_SELF;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT;
@@ -180,6 +179,7 @@ import com.android.systemui.statusbar.AutoHideUiElement;
import com.android.systemui.statusbar.BackDropView;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CrossFadeHelper;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.KeyboardShortcuts;
import com.android.systemui.statusbar.KeyguardIndicationController;
@@ -440,6 +440,7 @@ public class StatusBar extends SystemUI implements DemoMode,
private final KeyguardViewMediator mKeyguardViewMediator;
protected final NotificationInterruptStateProvider mNotificationInterruptStateProvider;
private final BrightnessSlider.Factory mBrightnessSliderFactory;
private final FeatureFlags mFeatureFlags;
private final List<ExpansionChangedListener> mExpansionChangedListeners;
@@ -762,7 +763,8 @@ public class StatusBar extends SystemUI implements DemoMode,
Lazy<NotificationShadeDepthController> notificationShadeDepthControllerLazy,
StatusBarTouchableRegionManager statusBarTouchableRegionManager,
NotificationIconAreaController notificationIconAreaController,
BrightnessSlider.Factory brightnessSliderFactory) {
BrightnessSlider.Factory brightnessSliderFactory,
FeatureFlags featureFlags) {
super(context);
mNotificationsController = notificationsController;
mLightBarController = lightBarController;
@@ -840,6 +842,7 @@ public class StatusBar extends SystemUI implements DemoMode,
mDemoModeController = demoModeController;
mNotificationIconAreaController = notificationIconAreaController;
mBrightnessSliderFactory = brightnessSliderFactory;
mFeatureFlags = featureFlags;
mExpansionChangedListeners = new ArrayList<>();
@@ -1181,9 +1184,11 @@ public class StatusBar extends SystemUI implements DemoMode,
mLightRevealScrim = mNotificationShadeWindowView.findViewById(R.id.light_reveal_scrim);
if (getEnableLightReveal()) {
if (mFeatureFlags.useNewLockscreenAnimations() && mDozeParameters.getAlwaysOn()) {
mLightRevealScrim.setVisibility(View.VISIBLE);
mLightRevealScrim.setRevealEffect(LiftReveal.INSTANCE);
} else {
mLightRevealScrim.setVisibility(View.GONE);
}
mNotificationPanelViewController.initDependencies(
@@ -3614,7 +3619,7 @@ public class StatusBar extends SystemUI implements DemoMode,
@Override
public void onDozeAmountChanged(float linear, float eased) {
if (getEnableLightReveal()) {
if (mFeatureFlags.useNewLockscreenAnimations()) {
mLightRevealScrim.setRevealAmount(1f - linear);
}
}

View File

@@ -47,6 +47,7 @@ import com.android.systemui.recents.ScreenPinningRequest;
import com.android.systemui.settings.brightness.BrightnessSlider;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationMediaManager;
@@ -200,7 +201,8 @@ public interface StatusBarPhoneModule {
DismissCallbackRegistry dismissCallbackRegistry,
StatusBarTouchableRegionManager statusBarTouchableRegionManager,
NotificationIconAreaController notificationIconAreaController,
BrightnessSlider.Factory brightnessSliderFactory) {
BrightnessSlider.Factory brightnessSliderFactory,
FeatureFlags featureFlags) {
return new StatusBar(
context,
notificationsController,
@@ -279,6 +281,7 @@ public interface StatusBarPhoneModule {
notificationShadeDepthController,
statusBarTouchableRegionManager,
notificationIconAreaController,
brightnessSliderFactory);
brightnessSliderFactory,
featureFlags);
}
}

View File

@@ -173,4 +173,30 @@ public class DozeUiTest extends SysuiTestCase {
mDozeUi.transitionTo(UNINITIALIZED, DOZE);
verify(mHost).setAnimateWakeup(eq(false));
}
@Test
public void controlScreenOffTrueWhenKeyguardNotShowingAndControlUnlockedScreenOff() {
when(mDozeParameters.getAlwaysOn()).thenReturn(true);
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true);
// Tell doze that keyguard is not visible.
mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(false /* showing */);
// Since we're controlling the unlocked screen off animation, verify that we've asked to
// control the screen off animation despite being unlocked.
verify(mDozeParameters).setControlScreenOffAnimation(true);
}
@Test
public void controlScreenOffFalseWhenKeyguardNotShowingAndControlUnlockedScreenOffFalse() {
when(mDozeParameters.getAlwaysOn()).thenReturn(true);
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(false);
// Tell doze that keyguard is not visible.
mDozeUi.getKeyguardCallback().onKeyguardVisibilityChanged(false /* showing */);
// Since we're not controlling the unlocked screen off animation, verify that we haven't
// asked to control the screen off animation since we're unlocked.
verify(mDozeParameters).setControlScreenOffAnimation(false);
}
}

View File

@@ -18,6 +18,8 @@ package com.android.systemui.keyguard;
import static android.view.WindowManagerPolicyConstants.OFF_BECAUSE_OF_USER;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -27,13 +29,17 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.admin.DevicePolicyManager;
import android.app.trust.TrustManager;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
import com.android.systemui.R;
import androidx.test.filters.SmallTest;
import com.android.internal.widget.LockPatternUtils;
@@ -45,6 +51,7 @@ import com.android.systemui.classifier.FalsingCollectorFake;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.LightRevealScrim;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.util.DeviceConfigProxy;
@@ -117,4 +124,20 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
mViewMediator.mViewMediatorCallback.keyguardGone();
verify(mStatusBarKeyguardViewManager).setKeyguardGoingAwayState(eq(false));
}
@Test
public void testIsAnimatingScreenOff() {
when(mDozeParameters.shouldControlUnlockedScreenOff()).thenReturn(true);
mViewMediator.onFinishedGoingToSleep(OFF_BECAUSE_OF_USER, false);
mViewMediator.setDozing(true);
// Mid-doze, we should be animating the screen off animation.
mViewMediator.onDozeAmountChanged(0.5f, 0.5f);
assertTrue(mViewMediator.isAnimatingScreenOff());
// Once we're 100% dozed, the screen off animation should be completed.
mViewMediator.onDozeAmountChanged(1f, 1f);
assertFalse(mViewMediator.isAnimatingScreenOff());
}
}

View File

@@ -18,6 +18,8 @@ package com.android.systemui.statusbar.phone;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.reset;
@@ -35,6 +37,7 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.doze.AlwaysOnDisplayPolicy;
import com.android.systemui.doze.DozeScreenState;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.tuner.TunerService;
@@ -57,6 +60,7 @@ public class DozeParametersTest extends SysuiTestCase {
@Mock private PowerManager mPowerManager;
@Mock private TunerService mTunerService;
@Mock private BatteryController mBatteryController;
@Mock private FeatureFlags mFeatureFlags;
@Before
public void setup() {
@@ -67,7 +71,8 @@ public class DozeParametersTest extends SysuiTestCase {
mAlwaysOnDisplayPolicy,
mPowerManager,
mBatteryController,
mTunerService
mTunerService,
mFeatureFlags
);
}
@Test
@@ -111,4 +116,37 @@ public class DozeParametersTest extends SysuiTestCase {
assertThat(mDozeParameters.getAlwaysOn()).isFalse();
}
@Test
public void testControlUnlockedScreenOffAnimation_dozeAfterScreenOff_false() {
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
mDozeParameters.onTuningChanged(Settings.Secure.DOZE_ALWAYS_ON, "1");
when(mFeatureFlags.useNewLockscreenAnimations()).thenReturn(true);
assertTrue(mDozeParameters.shouldControlUnlockedScreenOff());
// Trigger the setter for the current value.
mDozeParameters.setControlScreenOffAnimation(mDozeParameters.shouldControlScreenOff());
// We should have asked power manager not to doze after screen off no matter what, since
// we're animating and controlling screen off.
verify(mPowerManager).setDozeAfterScreenOff(eq(false));
}
@Test
public void testControlUnlockedScreenOffAnimationDisabled_dozeAfterScreenOff() {
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
mDozeParameters.onTuningChanged(Settings.Secure.DOZE_ALWAYS_ON, "1");
when(mFeatureFlags.useNewLockscreenAnimations()).thenReturn(false);
assertFalse(mDozeParameters.shouldControlUnlockedScreenOff());
// Trigger the setter for the current value.
mDozeParameters.setControlScreenOffAnimation(mDozeParameters.shouldControlScreenOff());
// We should have asked power manager to doze only if we're not controlling screen off
// normally.
verify(mPowerManager).setDozeAfterScreenOff(
eq(!mDozeParameters.shouldControlScreenOff()));
}
}

View File

@@ -97,6 +97,7 @@ import com.android.systemui.recents.ScreenPinningRequest;
import com.android.systemui.settings.brightness.BrightnessSlider;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
@@ -258,6 +259,7 @@ public class StatusBarTest extends SysuiTestCase {
@Mock private DemoModeController mDemoModeController;
@Mock private Lazy<NotificationShadeDepthController> mNotificationShadeDepthControllerLazy;
@Mock private BrightnessSlider.Factory mBrightnessSliderFactory;
@Mock private FeatureFlags mFeatureFlags;
private ShadeController mShadeController;
private FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock());
private InitController mInitController = new InitController();
@@ -418,7 +420,8 @@ public class StatusBarTest extends SysuiTestCase {
mNotificationShadeDepthControllerLazy,
mStatusBarTouchableRegionManager,
mNotificationIconAreaController,
mBrightnessSliderFactory);
mBrightnessSliderFactory,
mFeatureFlags);
when(mNotificationShadeWindowView.findViewById(R.id.lock_icon_container)).thenReturn(
mLockIconContainer);