Support launcher animations in new transition system

Hook up the shell-transitions RemoteTransition to
launcher.

Bug: 169035082
Test: Launch an app from a launcher icon and observe
Change-Id: Ie327c11bbc59f19fb969f159f8380c10e4a84e50
This commit is contained in:
[1;3C 2020-11-30 13:32:22 -08:00 committed by Winson Chung
parent 4380743251
commit d9abb1767d
8 changed files with 101 additions and 5 deletions

View File

@ -45,9 +45,10 @@
# BUG(70852369): Surpress additional warnings after changing from Proguard to R8 # BUG(70852369): Surpress additional warnings after changing from Proguard to R8
-dontwarn android.app.** -dontwarn android.app.**
-dontwarn android.view.**
-dontwarn android.os.**
-dontwarn android.graphics.** -dontwarn android.graphics.**
-dontwarn android.os.**
-dontwarn android.view.**
-dontwarn android.window.**
# Ignore warnings for hidden utility classes referenced from the shared lib # Ignore warnings for hidden utility classes referenced from the shared lib
-dontwarn com.android.internal.util.** -dontwarn com.android.internal.util.**

View File

@ -75,6 +75,7 @@ import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.views.FloatingIconView; import com.android.launcher3.views.FloatingIconView;
import com.android.quickstep.RemoteAnimationTargets; import com.android.quickstep.RemoteAnimationTargets;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.util.MultiValueUpdateListener; import com.android.quickstep.util.MultiValueUpdateListener;
import com.android.quickstep.util.RemoteAnimationProvider; import com.android.quickstep.util.RemoteAnimationProvider;
import com.android.quickstep.util.StaggeredWorkspaceAnim; import com.android.quickstep.util.StaggeredWorkspaceAnim;
@ -87,6 +88,7 @@ import com.android.systemui.shared.system.RemoteAnimationAdapterCompat;
import com.android.systemui.shared.system.RemoteAnimationDefinitionCompat; import com.android.systemui.shared.system.RemoteAnimationDefinitionCompat;
import com.android.systemui.shared.system.RemoteAnimationRunnerCompat; import com.android.systemui.shared.system.RemoteAnimationRunnerCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat; import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import com.android.systemui.shared.system.RemoteTransitionCompat;
import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams;
import com.android.systemui.shared.system.WindowManagerWrapper; import com.android.systemui.shared.system.WindowManagerWrapper;
@ -163,6 +165,9 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans
private WrappedAnimationRunnerImpl mAppLaunchRunner; private WrappedAnimationRunnerImpl mAppLaunchRunner;
private WrappedAnimationRunnerImpl mKeyguardGoingAwayRunner; private WrappedAnimationRunnerImpl mKeyguardGoingAwayRunner;
private WrappedAnimationRunnerImpl mWallpaperOpenTransitionRunner;
private RemoteTransitionCompat mLauncherOpenTransition;
private final AnimatorListenerAdapter mForceInvisibleListener = new AnimatorListenerAdapter() { private final AnimatorListenerAdapter mForceInvisibleListener = new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationStart(Animator animation) { public void onAnimationStart(Animator animation) {
@ -582,10 +587,11 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans
.withCornerRadius(mWindowRadius.value) .withCornerRadius(mWindowRadius.value)
.withShadowRadius(mShadowRadius.value); .withShadowRadius(mShadowRadius.value);
} else { } else {
tmpPos.set(target.position.x, target.position.y);
if (target.localBounds != null) { if (target.localBounds != null) {
final Rect localBounds = target.localBounds; final Rect localBounds = target.localBounds;
tmpPos.set(target.localBounds.left, target.localBounds.top); tmpPos.set(target.localBounds.left, target.localBounds.top);
} else {
tmpPos.set(target.position.x, target.position.y);
} }
matrix.setTranslate(tmpPos.x, tmpPos.y); matrix.setTranslate(tmpPos.x, tmpPos.y);
@ -656,6 +662,24 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans
} }
} }
/**
* Registers remote animations used when closing apps to home screen.
*/
@Override
public void registerRemoteTransitions() {
if (SEPARATE_RECENTS_ACTIVITY.get()) {
return;
}
if (hasControlRemoteAppTransitionPermission()) {
mWallpaperOpenTransitionRunner = createWallpaperOpenRunner(false /* fromUnlock */);
mLauncherOpenTransition = RemoteAnimationAdapterCompat.buildRemoteTransition(
new WrappedLauncherAnimationRunner<>(mWallpaperOpenTransitionRunner,
false /* startAtFrontOfQueue */));
mLauncherOpenTransition.addHomeOpenCheck();
SystemUiProxy.INSTANCE.getNoCreate().registerRemoteTransition(mLauncherOpenTransition);
}
}
/** /**
* Unregisters all remote animations. * Unregisters all remote animations.
*/ */
@ -675,6 +699,20 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans
} }
} }
@Override
public void unregisterRemoteTransitions() {
if (SEPARATE_RECENTS_ACTIVITY.get()) {
return;
}
if (hasControlRemoteAppTransitionPermission()) {
if (mLauncherOpenTransition == null) return;
SystemUiProxy.INSTANCE.getNoCreate().unregisterRemoteTransition(
mLauncherOpenTransition);
mLauncherOpenTransition = null;
mWallpaperOpenTransitionRunner = null;
}
}
private boolean launcherIsATargetWithMode(RemoteAnimationTargetCompat[] targets, int mode) { private boolean launcherIsATargetWithMode(RemoteAnimationTargetCompat[] targets, int mode) {
return taskIsATargetWithMode(targets, mLauncher.getTaskId(), mode); return taskIsATargetWithMode(targets, mLauncher.getTaskId(), mode);
} }
@ -742,9 +780,10 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans
RemoteAnimationTargetCompat target = appTargets[i]; RemoteAnimationTargetCompat target = appTargets[i];
SurfaceParams.Builder builder = new SurfaceParams.Builder(target.leash); SurfaceParams.Builder builder = new SurfaceParams.Builder(target.leash);
tmpPos.set(target.position.x, target.position.y);
if (target.localBounds != null) { if (target.localBounds != null) {
tmpPos.set(target.localBounds.left, target.localBounds.top); tmpPos.set(target.localBounds.left, target.localBounds.top);
} else {
tmpPos.set(target.position.x, target.position.y);
} }
if (target.mode == MODE_CLOSING) { if (target.mode == MODE_CLOSING) {

View File

@ -396,4 +396,9 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
pa.addFloat(recentsView, FULLSCREEN_PROGRESS, 1, 0, LINEAR); pa.addFloat(recentsView, FULLSCREEN_PROGRESS, 1, 0, LINEAR);
} }
} }
/** Called when OverviewService is bound to this process */
void onOverviewServiceBound() {
// Do nothing
}
} }

View File

@ -270,4 +270,11 @@ public final class LauncherActivityInterface extends
+ res.getDimensionPixelSize(R.dimen.overview_actions_height); + res.getDimensionPixelSize(R.dimen.overview_actions_height);
return actionsHeight; return actionsHeight;
} }
@Override
void onOverviewServiceBound() {
final BaseQuickstepLauncher activity = getCreatedActivity();
if (activity == null) return;
activity.getAppTransitionManager().registerRemoteTransitions();
}
} }

View File

@ -35,6 +35,7 @@ import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.systemui.shared.recents.IPinnedStackAnimationListener; import com.android.systemui.shared.recents.IPinnedStackAnimationListener;
import com.android.systemui.shared.recents.ISystemUiProxy; import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.RemoteTransitionCompat;
/** /**
* Holds the reference to SystemUI. * Holds the reference to SystemUI.
@ -408,4 +409,26 @@ public class SystemUiProxy implements ISystemUiProxy {
} }
} }
} }
@Override
public void registerRemoteTransition(RemoteTransitionCompat remoteTransition) {
if (mSystemUiProxy != null) {
try {
mSystemUiProxy.registerRemoteTransition(remoteTransition);
} catch (RemoteException e) {
Log.w(TAG, "Failed call registerRemoteTransition");
}
}
}
@Override
public void unregisterRemoteTransition(RemoteTransitionCompat remoteTransition) {
if (mSystemUiProxy != null) {
try {
mSystemUiProxy.unregisterRemoteTransition(remoteTransition);
} catch (RemoteException e) {
Log.w(TAG, "Failed call registerRemoteTransition");
}
}
}
} }

View File

@ -136,6 +136,12 @@ public class TouchInteractionService extends Service implements PluginListener<O
SystemUiProxy.INSTANCE.get(TouchInteractionService.this).setProxy(proxy); SystemUiProxy.INSTANCE.get(TouchInteractionService.this).setProxy(proxy);
TouchInteractionService.this.initInputMonitor(); TouchInteractionService.this.initInputMonitor();
preloadOverview(true /* fromInit */); preloadOverview(true /* fromInit */);
mDeviceState.runOnUserUnlocked(() -> {
final BaseActivityInterface ai =
mOverviewComponentObserver.getActivityInterface();
if (ai == null) return;
ai.onOverviewServiceBound();
});
}); });
sIsInitialized = true; sIsInitialized = true;
} }

View File

@ -1596,6 +1596,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
mOverlayManager.onActivityDestroyed(this); mOverlayManager.onActivityDestroyed(this);
mAppTransitionManager.unregisterRemoteAnimations(); mAppTransitionManager.unregisterRemoteAnimations();
mAppTransitionManager.unregisterRemoteTransitions();
mUserChangedCallbackCloseable.close(); mUserChangedCallbackCloseable.close();
mLifecycleRegistry.setCurrentState(Lifecycle.State.DESTROYED); mLifecycleRegistry.setCurrentState(Lifecycle.State.DESTROYED);
mLiveSearchManager.stop(); mLiveSearchManager.stop();

View File

@ -67,4 +67,18 @@ public class LauncherAppTransitionManager implements ResourceBasedOverride {
public void unregisterRemoteAnimations() { public void unregisterRemoteAnimations() {
// Do nothing // Do nothing
} }
/**
* Registers remote transitions for certain system transitions.
*/
public void registerRemoteTransitions() {
// Do nothing
}
/**
* Unregisters all remote transitions.
*/
public void unregisterRemoteTransitions() {
// Do nothing
}
} }