Merge "Fix graphical glitches on keyguard-unlock with PIP" into udc-dev

This commit is contained in:
Evan Rosky
2023-05-12 22:53:32 +00:00
committed by Android (Google) Code Review
2 changed files with 33 additions and 38 deletions

View File

@@ -235,11 +235,20 @@ public class TransitionUtil {
public static RemoteAnimationTarget newTarget(TransitionInfo.Change change, int order, public static RemoteAnimationTarget newTarget(TransitionInfo.Change change, int order,
TransitionInfo info, SurfaceControl.Transaction t, TransitionInfo info, SurfaceControl.Transaction t,
@Nullable ArrayMap<SurfaceControl, SurfaceControl> leashMap) { @Nullable ArrayMap<SurfaceControl, SurfaceControl> leashMap) {
return newTarget(change, order, false /* forceTranslucent */, info, t, leashMap);
}
/**
* Creates a new RemoteAnimationTarget from the provided change info
*/
public static RemoteAnimationTarget newTarget(TransitionInfo.Change change, int order,
boolean forceTranslucent, TransitionInfo info, SurfaceControl.Transaction t,
@Nullable ArrayMap<SurfaceControl, SurfaceControl> leashMap) {
final SurfaceControl leash = createLeash(info, change, order, t); final SurfaceControl leash = createLeash(info, change, order, t);
if (leashMap != null) { if (leashMap != null) {
leashMap.put(change.getLeash(), leash); leashMap.put(change.getLeash(), leash);
} }
return newTarget(change, order, leash); return newTarget(change, order, leash, forceTranslucent);
} }
/** /**
@@ -247,6 +256,14 @@ public class TransitionUtil {
*/ */
public static RemoteAnimationTarget newTarget(TransitionInfo.Change change, int order, public static RemoteAnimationTarget newTarget(TransitionInfo.Change change, int order,
SurfaceControl leash) { SurfaceControl leash) {
return newTarget(change, order, leash, false /* forceTranslucent */);
}
/**
* Creates a new RemoteAnimationTarget from the provided change and leash
*/
public static RemoteAnimationTarget newTarget(TransitionInfo.Change change, int order,
SurfaceControl leash, boolean forceTranslucent) {
if (isDividerBar(change)) { if (isDividerBar(change)) {
return getDividerTarget(change, leash); return getDividerTarget(change, leash);
} }
@@ -276,7 +293,7 @@ public class TransitionUtil {
// TODO: once we can properly sync transactions across process, // TODO: once we can properly sync transactions across process,
// then get rid of this leash. // then get rid of this leash.
leash, leash,
(change.getFlags() & TransitionInfo.FLAG_TRANSLUCENT) != 0, forceTranslucent || (change.getFlags() & TransitionInfo.FLAG_TRANSLUCENT) != 0,
null, null,
// TODO(shell-transitions): we need to send content insets? evaluate how its used. // TODO(shell-transitions): we need to send content insets? evaluate how its used.
new Rect(0, 0, 0, 0), new Rect(0, 0, 0, 0),

View File

@@ -42,8 +42,6 @@ import android.app.ActivityTaskManager;
import android.app.Service; import android.app.Service;
import android.app.WindowConfiguration; import android.app.WindowConfiguration;
import android.content.Intent; import android.content.Intent;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Binder; import android.os.Binder;
import android.os.Bundle; import android.os.Bundle;
import android.os.Debug; import android.os.Debug;
@@ -77,6 +75,7 @@ import com.android.systemui.SystemUIApplication;
import com.android.systemui.settings.DisplayTracker; import com.android.systemui.settings.DisplayTracker;
import com.android.wm.shell.transition.ShellTransitions; import com.android.wm.shell.transition.ShellTransitions;
import com.android.wm.shell.transition.Transitions; import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.util.TransitionUtil;
import java.util.ArrayList; import java.util.ArrayList;
@@ -105,7 +104,8 @@ public class KeyguardService extends Service {
} }
} }
private static RemoteAnimationTarget[] wrap(TransitionInfo info, boolean wallpapers) { private static RemoteAnimationTarget[] wrap(TransitionInfo info, boolean wallpapers,
SurfaceControl.Transaction t, ArrayMap<SurfaceControl, SurfaceControl> leashMap) {
final ArrayList<RemoteAnimationTarget> out = new ArrayList<>(); final ArrayList<RemoteAnimationTarget> out = new ArrayList<>();
for (int i = 0; i < info.getChanges().size(); i++) { for (int i = 0; i < info.getChanges().size(); i++) {
boolean changeIsWallpaper = boolean changeIsWallpaper =
@@ -115,32 +115,14 @@ public class KeyguardService extends Service {
final TransitionInfo.Change change = info.getChanges().get(i); final TransitionInfo.Change change = info.getChanges().get(i);
final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo(); final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo();
final int taskId = taskInfo != null ? change.getTaskInfo().taskId : -1; final int taskId = taskInfo != null ? change.getTaskInfo().taskId : -1;
boolean isNotInRecents;
WindowConfiguration windowConfiguration = null;
if (taskInfo != null) {
if (taskInfo.getConfiguration() != null) {
windowConfiguration =
change.getTaskInfo().getConfiguration().windowConfiguration;
}
isNotInRecents = !change.getTaskInfo().isRunning;
} else {
isNotInRecents = true;
}
Rect localBounds = new Rect(change.getEndAbsBounds());
localBounds.offsetTo(change.getEndRelOffset().x, change.getEndRelOffset().y);
final RemoteAnimationTarget target = new RemoteAnimationTarget( final RemoteAnimationTarget target = TransitionUtil.newTarget(change,
taskId, // wallpapers go into the "below" layer space
newModeToLegacyMode(change.getMode()),
change.getLeash(),
(change.getFlags() & TransitionInfo.FLAG_TRANSLUCENT) != 0
|| (change.getFlags() & TransitionInfo.FLAG_SHOW_WALLPAPER) != 0,
null /* clipRect */,
new Rect(0, 0, 0, 0) /* contentInsets */,
info.getChanges().size() - i, info.getChanges().size() - i,
new Point(), localBounds, new Rect(change.getEndAbsBounds()), // keyguard treats wallpaper as translucent
windowConfiguration, isNotInRecents, null /* startLeash */, (change.getFlags() & TransitionInfo.FLAG_SHOW_WALLPAPER) != 0,
change.getStartAbsBounds(), taskInfo, false /* allowEnterPip */); info, t, leashMap);
// Use hasAnimatingParent to mark the anything below root task // Use hasAnimatingParent to mark the anything below root task
if (taskId != -1 && change.getParent() != null) { if (taskId != -1 && change.getParent() != null) {
final TransitionInfo.Change parentChange = info.getChange(change.getParent()); final TransitionInfo.Change parentChange = info.getChange(change.getParent());
@@ -178,31 +160,27 @@ public class KeyguardService extends Service {
return new IRemoteTransition.Stub() { return new IRemoteTransition.Stub() {
final ArrayMap<IBinder, IRemoteTransitionFinishedCallback> mFinishCallbacks = final ArrayMap<IBinder, IRemoteTransitionFinishedCallback> mFinishCallbacks =
new ArrayMap<>(); new ArrayMap<>();
private final ArrayMap<SurfaceControl, SurfaceControl> mLeashMap = new ArrayMap<>();
@Override @Override
public void startAnimation(IBinder transition, TransitionInfo info, public void startAnimation(IBinder transition, TransitionInfo info,
SurfaceControl.Transaction t, IRemoteTransitionFinishedCallback finishCallback) SurfaceControl.Transaction t, IRemoteTransitionFinishedCallback finishCallback)
throws RemoteException { throws RemoteException {
Slog.d(TAG, "Starts IRemoteAnimationRunner: info=" + info); Slog.d(TAG, "Starts IRemoteAnimationRunner: info=" + info);
final RemoteAnimationTarget[] apps = wrap(info, false /* wallpapers */); final RemoteAnimationTarget[] apps =
final RemoteAnimationTarget[] wallpapers = wrap(info, true /* wallpapers */); wrap(info, false /* wallpapers */, t, mLeashMap);
final RemoteAnimationTarget[] wallpapers =
wrap(info, true /* wallpapers */, t, mLeashMap);
final RemoteAnimationTarget[] nonApps = new RemoteAnimationTarget[0]; final RemoteAnimationTarget[] nonApps = new RemoteAnimationTarget[0];
// Sets the alpha to 0 for the opening root task for fade in animation. And since // 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 // the fade in animation can only apply on the first opening app, so set alpha to 1
// for anything else. // for anything else.
boolean foundOpening = false;
for (RemoteAnimationTarget target : apps) { for (RemoteAnimationTarget target : apps) {
if (target.taskId != -1 if (target.taskId != -1
&& target.mode == RemoteAnimationTarget.MODE_OPENING && target.mode == RemoteAnimationTarget.MODE_OPENING
&& !target.hasAnimatingParent) { && !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); t.setAlpha(target.leash, 0.0f);
foundOpening = true;
} else { } else {
t.setAlpha(target.leash, 1.0f); t.setAlpha(target.leash, 1.0f);
} }