Merge "Attemp to fix Launcher stay invisible after keyguard unlock." into tm-qpr-dev

This commit is contained in:
Evan Rosky
2022-06-23 17:08:33 +00:00
committed by Android (Google) Code Review
3 changed files with 68 additions and 16 deletions

View File

@@ -158,7 +158,7 @@ public class KeyguardService extends Service {
Rect localBounds = new Rect(change.getEndAbsBounds());
localBounds.offsetTo(change.getEndRelOffset().x, change.getEndRelOffset().y);
out.add(new RemoteAnimationTarget(
final RemoteAnimationTarget target = new RemoteAnimationTarget(
taskId,
newModeToLegacyMode(change.getMode()),
change.getLeash(),
@@ -169,7 +169,15 @@ public class KeyguardService extends Service {
info.getChanges().size() - i,
new Point(), localBounds, new Rect(change.getEndAbsBounds()),
windowConfiguration, isNotInRecents, null /* startLeash */,
change.getStartAbsBounds(), taskInfo, false /* allowEnterPip */));
change.getStartAbsBounds(), taskInfo, false /* allowEnterPip */);
// Use hasAnimatingParent to mark the anything below root task
if (taskId != -1 && change.getParent() != null) {
final TransitionInfo.Change parentChange = info.getChange(change.getParent());
if (parentChange != null && parentChange.getTaskInfo() != null) {
target.hasAnimatingParent = true;
}
}
out.add(target);
}
return out.toArray(new RemoteAnimationTarget[out.size()]);
}
@@ -190,6 +198,7 @@ public class KeyguardService extends Service {
}
}
// Wrap Keyguard going away animation
private static IRemoteTransition wrap(IRemoteAnimationRunner runner) {
return new IRemoteTransition.Stub() {
final ArrayMap<IBinder, IRemoteTransitionFinishedCallback> mFinishCallbacks =
@@ -204,9 +213,24 @@ public class KeyguardService extends Service {
final RemoteAnimationTarget[] wallpapers = wrap(info, true /* wallpapers */);
final RemoteAnimationTarget[] nonApps = new RemoteAnimationTarget[0];
// TODO: Remove this, and update alpha value in the IAnimationRunner.
for (TransitionInfo.Change change : info.getChanges()) {
t.setAlpha(change.getLeash(), 1.0f);
// Sets the alpha to 0 for the opening root task for fade in animation. And since
// the fade in animation can only apply on the first opening app, so set alpha to 1
// for anything else.
boolean foundOpening = false;
for (RemoteAnimationTarget target : apps) {
if (target.taskId != -1
&& target.mode == RemoteAnimationTarget.MODE_OPENING
&& !target.hasAnimatingParent) {
if (foundOpening) {
Log.w(TAG, "More than one opening target");
t.setAlpha(target.leash, 1.0f);
continue;
}
t.setAlpha(target.leash, 0.0f);
foundOpening = true;
} else {
t.setAlpha(target.leash, 1.0f);
}
}
t.apply();
synchronized (mFinishCallbacks) {

View File

@@ -26,6 +26,7 @@ import android.os.Handler
import android.os.RemoteException
import android.util.Log
import android.view.RemoteAnimationTarget
import android.view.SurfaceControl
import android.view.SyncRtSurfaceTransactionApplier
import android.view.View
import androidx.annotation.VisibleForTesting
@@ -293,6 +294,8 @@ class KeyguardUnlockAnimationController @Inject constructor(
private val handler = Handler()
private val tmpFloat = FloatArray(9)
init {
with(surfaceBehindAlphaAnimator) {
duration = SURFACE_BEHIND_SWIPE_FADE_DURATION_MS
@@ -723,13 +726,27 @@ class KeyguardUnlockAnimationController @Inject constructor(
if (keyguardStateController.isSnappingKeyguardBackAfterSwipe) amount
else surfaceBehindAlpha
applyParamsToSurface(
SyncRtSurfaceTransactionApplier.SurfaceParams.Builder(
surfaceBehindRemoteAnimationTarget!!.leash)
.withMatrix(surfaceBehindMatrix)
.withCornerRadius(roundedCornerRadius)
.withAlpha(animationAlpha)
.build())
// SyncRtSurfaceTransactionApplier cannot apply transaction when the target view is unable
// to draw
val sc: SurfaceControl? = surfaceBehindRemoteAnimationTarget?.leash
if (keyguardViewController.viewRootImpl.view?.visibility != View.VISIBLE &&
sc?.isValid == true) {
with(SurfaceControl.Transaction()) {
setMatrix(sc, surfaceBehindMatrix, tmpFloat)
setCornerRadius(sc, roundedCornerRadius)
setAlpha(sc, animationAlpha)
apply()
}
} else {
applyParamsToSurface(
SyncRtSurfaceTransactionApplier.SurfaceParams.Builder(
surfaceBehindRemoteAnimationTarget!!.leash)
.withMatrix(surfaceBehindMatrix)
.withCornerRadius(roundedCornerRadius)
.withAlpha(animationAlpha)
.build()
)
}
}
/**
@@ -744,8 +761,11 @@ class KeyguardUnlockAnimationController @Inject constructor(
handler.removeCallbacksAndMessages(null)
// Make sure we made the surface behind fully visible, just in case. It should already be
// fully visible. If the launcher is doing its own animation, let it continue without
// forcing it to 1f.
// fully visible. The exit animation is finished, and we should not hold the leash anymore,
// so forcing it to 1f.
surfaceBehindAlphaAnimator.cancel()
surfaceBehindEntryAnimator.cancel()
surfaceBehindAlpha = 1f
setSurfaceBehindAppearAmount(1f)
launcherUnlockController?.setUnlockAmount(1f, false /* forceIfAnimating */)
@@ -910,4 +930,4 @@ class KeyguardUnlockAnimationController @Inject constructor(
return context.resources.getIntArray(R.array.config_foldedDeviceStates).isNotEmpty()
}
}
}
}

View File

@@ -2503,10 +2503,18 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
mInteractionJankMonitor.begin(
createInteractionJankMonitorConf("DismissPanel"));
// Apply the opening animation on root task if exists
RemoteAnimationTarget aniTarget = apps[0];
for (RemoteAnimationTarget tmpTarget : apps) {
if (tmpTarget.taskId != -1 && !tmpTarget.hasAnimatingParent) {
aniTarget = tmpTarget;
break;
}
}
// Pass the surface and metadata to the unlock animation controller.
mKeyguardUnlockAnimationControllerLazy.get()
.notifyStartSurfaceBehindRemoteAnimation(
apps[0], startTime, mSurfaceBehindRemoteAnimationRequested);
aniTarget, startTime, mSurfaceBehindRemoteAnimationRequested);
} else {
mInteractionJankMonitor.begin(
createInteractionJankMonitorConf("RemoteAnimationDisabled"));