Merge "Remove dependency on WindowManager-Shell in the animation lib" into sc-dev am: e7701b84d3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15278139

Change-Id: I91873fd64feef60ce4d364f3289d9ac6d50e39d4
This commit is contained in:
Jordan Demeulenaere
2021-07-15 13:55:43 +00:00
committed by Automerger Merge Worker
4 changed files with 31 additions and 28 deletions

View File

@@ -36,7 +36,6 @@ android_library {
static_libs: [ static_libs: [
"PluginCoreLib", "PluginCoreLib",
"WindowManager-Shell",
], ],
manifest: "AndroidManifest.xml", manifest: "AndroidManifest.xml",

View File

@@ -7,6 +7,7 @@ import android.app.ActivityManager
import android.app.ActivityTaskManager import android.app.ActivityTaskManager
import android.app.AppGlobals import android.app.AppGlobals
import android.app.PendingIntent import android.app.PendingIntent
import android.app.TaskInfo
import android.content.Context import android.content.Context
import android.graphics.Matrix import android.graphics.Matrix
import android.graphics.PorterDuff import android.graphics.PorterDuff
@@ -30,8 +31,6 @@ import android.view.animation.AnimationUtils
import android.view.animation.PathInterpolator import android.view.animation.PathInterpolator
import com.android.internal.annotations.VisibleForTesting import com.android.internal.annotations.VisibleForTesting
import com.android.internal.policy.ScreenDecorationsUtils import com.android.internal.policy.ScreenDecorationsUtils
import com.android.wm.shell.startingsurface.SplashscreenContentDrawer
import com.android.wm.shell.startingsurface.StartingSurface
import kotlin.math.roundToInt import kotlin.math.roundToInt
private const val TAG = "ActivityLaunchAnimator" private const val TAG = "ActivityLaunchAnimator"
@@ -41,8 +40,7 @@ private const val TAG = "ActivityLaunchAnimator"
* nicely into the starting window. * nicely into the starting window.
*/ */
class ActivityLaunchAnimator( class ActivityLaunchAnimator(
private val keyguardHandler: KeyguardHandler, private val callback: Callback,
private val startingSurface: StartingSurface?,
context: Context context: Context
) { ) {
companion object { companion object {
@@ -120,7 +118,7 @@ class ActivityLaunchAnimator(
Log.d(TAG, "Starting intent with a launch animation") Log.d(TAG, "Starting intent with a launch animation")
val runner = Runner(controller) val runner = Runner(controller)
val isOnKeyguard = keyguardHandler.isOnKeyguard() val isOnKeyguard = callback.isOnKeyguard()
// Pass the RemoteAnimationAdapter to the intent starter only if we are not on the keyguard. // Pass the RemoteAnimationAdapter to the intent starter only if we are not on the keyguard.
val animationAdapter = if (!isOnKeyguard) { val animationAdapter = if (!isOnKeyguard) {
@@ -163,7 +161,7 @@ class ActivityLaunchAnimator(
// Hide the keyguard using the launch animation instead of the default unlock animation. // Hide the keyguard using the launch animation instead of the default unlock animation.
if (isOnKeyguard) { if (isOnKeyguard) {
keyguardHandler.hideKeyguardWithAnimation(runner) callback.hideKeyguardWithAnimation(runner)
} }
} }
} }
@@ -212,7 +210,7 @@ class ActivityLaunchAnimator(
fun startPendingIntent(animationAdapter: RemoteAnimationAdapter?): Int fun startPendingIntent(animationAdapter: RemoteAnimationAdapter?): Int
} }
interface KeyguardHandler { interface Callback {
/** Whether we are currently on the keyguard or not. */ /** Whether we are currently on the keyguard or not. */
fun isOnKeyguard(): Boolean fun isOnKeyguard(): Boolean
@@ -221,6 +219,9 @@ class ActivityLaunchAnimator(
/** Enable/disable window blur so they don't overlap with the window launch animation **/ /** Enable/disable window blur so they don't overlap with the window launch animation **/
fun setBlursDisabledForAppLaunch(disabled: Boolean) fun setBlursDisabledForAppLaunch(disabled: Boolean)
/* Get the background color of [task]. */
fun getBackgroundColor(task: TaskInfo): Int
} }
/** /**
@@ -484,12 +485,7 @@ class ActivityLaunchAnimator(
// which is usually the same color of the app background. We first fade in this layer // which is usually the same color of the app background. We first fade in this layer
// to hide the expanding view, then we fade it out with SRC mode to draw a hole in the // to hide the expanding view, then we fade it out with SRC mode to draw a hole in the
// launch container and reveal the opening window. // launch container and reveal the opening window.
val windowBackgroundColor = if (startingSurface != null) { val windowBackgroundColor = callback.getBackgroundColor(window.taskInfo)
startingSurface.getBackgroundColor(window.taskInfo)
} else {
Log.w(TAG, "No starting surface, defaulting to SystemBGColor")
SplashscreenContentDrawer.getSystemBGColor()
}
val windowBackgroundLayer = GradientDrawable().apply { val windowBackgroundLayer = GradientDrawable().apply {
setColor(windowBackgroundColor) setColor(windowBackgroundColor)
alpha = 0 alpha = 0
@@ -505,7 +501,7 @@ class ActivityLaunchAnimator(
animator.addListener(object : AnimatorListenerAdapter() { animator.addListener(object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator?, isReverse: Boolean) { override fun onAnimationStart(animation: Animator?, isReverse: Boolean) {
Log.d(TAG, "Animation started") Log.d(TAG, "Animation started")
keyguardHandler.setBlursDisabledForAppLaunch(true) callback.setBlursDisabledForAppLaunch(true)
controller.onLaunchAnimationStart(isExpandingFullyAbove) controller.onLaunchAnimationStart(isExpandingFullyAbove)
// Add the drawable to the launch container overlay. Overlays always draw // Add the drawable to the launch container overlay. Overlays always draw
@@ -516,7 +512,7 @@ class ActivityLaunchAnimator(
override fun onAnimationEnd(animation: Animator?) { override fun onAnimationEnd(animation: Animator?) {
Log.d(TAG, "Animation ended") Log.d(TAG, "Animation ended")
keyguardHandler.setBlursDisabledForAppLaunch(false) callback.setBlursDisabledForAppLaunch(false)
iCallback?.invoke() iCallback?.invoke()
controller.onLaunchAnimationEnd(isExpandingFullyAbove) controller.onLaunchAnimationEnd(isExpandingFullyAbove)
launchContainerOverlay.remove(windowBackgroundLayer) launchContainerOverlay.remove(windowBackgroundLayer)

View File

@@ -55,6 +55,7 @@ import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.StatusBarManager; import android.app.StatusBarManager;
import android.app.TaskInfo;
import android.app.UiModeManager; import android.app.UiModeManager;
import android.app.WallpaperInfo; import android.app.WallpaperInfo;
import android.app.WallpaperManager; import android.app.WallpaperManager;
@@ -247,6 +248,7 @@ import com.android.systemui.volume.VolumeComponent;
import com.android.systemui.wmshell.BubblesManager; import com.android.systemui.wmshell.BubblesManager;
import com.android.wm.shell.bubbles.Bubbles; import com.android.wm.shell.bubbles.Bubbles;
import com.android.wm.shell.legacysplitscreen.LegacySplitScreen; import com.android.wm.shell.legacysplitscreen.LegacySplitScreen;
import com.android.wm.shell.startingsurface.SplashscreenContentDrawer;
import com.android.wm.shell.startingsurface.StartingSurface; import com.android.wm.shell.startingsurface.StartingSurface;
import java.io.FileDescriptor; import java.io.FileDescriptor;
@@ -269,7 +271,7 @@ public class StatusBar extends SystemUI implements DemoMode,
ColorExtractor.OnColorsChangedListener, ConfigurationListener, ColorExtractor.OnColorsChangedListener, ConfigurationListener,
StatusBarStateController.StateListener, StatusBarStateController.StateListener,
LifecycleOwner, BatteryController.BatteryStateChangeCallback, LifecycleOwner, BatteryController.BatteryStateChangeCallback,
ActivityLaunchAnimator.KeyguardHandler { ActivityLaunchAnimator.Callback {
public static final boolean MULTIUSER_DEBUG = false; public static final boolean MULTIUSER_DEBUG = false;
protected static final int MSG_HIDE_RECENT_APPS = 1020; protected static final int MSG_HIDE_RECENT_APPS = 1020;
@@ -1421,9 +1423,7 @@ public class StatusBar extends SystemUI implements DemoMode,
private void setUpPresenter() { private void setUpPresenter() {
// Set up the initial notification state. // Set up the initial notification state.
mActivityLaunchAnimator = new ActivityLaunchAnimator(this, mActivityLaunchAnimator = new ActivityLaunchAnimator(this, mContext);
mStartingSurfaceOptional.orElse(null),
mContext);
mNotificationAnimationProvider = new NotificationLaunchAnimatorControllerProvider( mNotificationAnimationProvider = new NotificationLaunchAnimatorControllerProvider(
mNotificationShadeWindowViewController, mNotificationShadeWindowViewController,
mStackScrollerController.getNotificationListContainer(), mStackScrollerController.getNotificationListContainer(),
@@ -2123,6 +2123,16 @@ public class StatusBar extends SystemUI implements DemoMode,
mKeyguardViewMediator.setBlursDisabledForAppLaunch(disabled); mKeyguardViewMediator.setBlursDisabledForAppLaunch(disabled);
} }
@Override
public int getBackgroundColor(TaskInfo task) {
if (!mStartingSurfaceOptional.isPresent()) {
Log.w(TAG, "No starting surface, defaulting to SystemBGColor");
return SplashscreenContentDrawer.getSystemBGColor();
}
return mStartingSurfaceOptional.get().getBackgroundColor(task);
}
public boolean isDeviceInVrMode() { public boolean isDeviceInVrMode() {
return mPresenter.isDeviceInVrMode(); return mPresenter.isDeviceInVrMode();
} }

View File

@@ -22,7 +22,6 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase
import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.eq import com.android.systemui.util.mockito.eq
import com.android.wm.shell.startingsurface.StartingSurface
import junit.framework.Assert.assertFalse import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertNotNull import junit.framework.Assert.assertNotNull
import junit.framework.Assert.assertNull import junit.framework.Assert.assertNull
@@ -47,10 +46,9 @@ import org.mockito.junit.MockitoJUnit
@RunWithLooper @RunWithLooper
class ActivityLaunchAnimatorTest : SysuiTestCase() { class ActivityLaunchAnimatorTest : SysuiTestCase() {
private val launchContainer = LinearLayout(mContext) private val launchContainer = LinearLayout(mContext)
@Mock lateinit var keyguardHandler: ActivityLaunchAnimator.KeyguardHandler @Mock lateinit var callback: ActivityLaunchAnimator.Callback
@Spy private val controller = TestLaunchAnimatorController(launchContainer) @Spy private val controller = TestLaunchAnimatorController(launchContainer)
@Mock lateinit var iCallback: IRemoteAnimationFinishedCallback @Mock lateinit var iCallback: IRemoteAnimationFinishedCallback
@Mock lateinit var startingSurface: StartingSurface
@Mock lateinit var failHandler: Log.TerribleFailureHandler @Mock lateinit var failHandler: Log.TerribleFailureHandler
private lateinit var activityLaunchAnimator: ActivityLaunchAnimator private lateinit var activityLaunchAnimator: ActivityLaunchAnimator
@@ -58,7 +56,7 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
@Before @Before
fun setup() { fun setup() {
activityLaunchAnimator = ActivityLaunchAnimator(keyguardHandler, startingSurface, mContext) activityLaunchAnimator = ActivityLaunchAnimator(callback, mContext)
} }
private fun startIntentWithAnimation( private fun startIntentWithAnimation(
@@ -121,8 +119,8 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
@Test @Test
fun animatesIfActivityIsAlreadyOpenAndIsOnKeyguard() { fun animatesIfActivityIsAlreadyOpenAndIsOnKeyguard() {
`when`(keyguardHandler.isOnKeyguard()).thenReturn(true) `when`(callback.isOnKeyguard()).thenReturn(true)
val animator = ActivityLaunchAnimator(keyguardHandler, startingSurface, context) val animator = ActivityLaunchAnimator(callback, context)
val willAnimateCaptor = ArgumentCaptor.forClass(Boolean::class.java) val willAnimateCaptor = ArgumentCaptor.forClass(Boolean::class.java)
var animationAdapter: RemoteAnimationAdapter? = null var animationAdapter: RemoteAnimationAdapter? = null
@@ -134,7 +132,7 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
waitForIdleSync() waitForIdleSync()
verify(controller).onIntentStarted(willAnimateCaptor.capture()) verify(controller).onIntentStarted(willAnimateCaptor.capture())
verify(keyguardHandler).hideKeyguardWithAnimation(any()) verify(callback).hideKeyguardWithAnimation(any())
assertTrue(willAnimateCaptor.value) assertTrue(willAnimateCaptor.value)
assertNull(animationAdapter) assertNull(animationAdapter)
@@ -176,7 +174,7 @@ class ActivityLaunchAnimatorTest : SysuiTestCase() {
val runner = activityLaunchAnimator.createRunner(controller) val runner = activityLaunchAnimator.createRunner(controller)
runner.onAnimationStart(0, arrayOf(fakeWindow()), emptyArray(), emptyArray(), iCallback) runner.onAnimationStart(0, arrayOf(fakeWindow()), emptyArray(), emptyArray(), iCallback)
waitForIdleSync() waitForIdleSync()
verify(keyguardHandler).setBlursDisabledForAppLaunch(eq(true)) verify(callback).setBlursDisabledForAppLaunch(eq(true))
verify(controller).onLaunchAnimationStart(anyBoolean()) verify(controller).onLaunchAnimationStart(anyBoolean())
} }