Merge "Don't let IME move to recents activity during recents transition" into sc-v2-dev am: e7b6834733

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

Change-Id: I27be71407cd8ce288e52cf4d899f6f33c9cf8960
This commit is contained in:
Evan Rosky
2021-09-13 19:48:36 +00:00
committed by Automerger Merge Worker
7 changed files with 69 additions and 14 deletions

View File

@@ -1207,6 +1207,12 @@
"group": "WM_DEBUG_ORIENTATION",
"at": "com\/android\/server\/wm\/WindowManagerService.java"
},
"-779535710": {
"message": "Transition %d: Set %s as transient-launch",
"level": "VERBOSE",
"group": "WM_DEBUG_WINDOW_TRANSITIONS",
"at": "com\/android\/server\/wm\/Transition.java"
},
"-775004869": {
"message": "Not a match: %s",
"level": "DEBUG",

View File

@@ -30,7 +30,6 @@ import static android.app.ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION;
import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
@@ -1573,11 +1572,7 @@ class ActivityStarter {
newTransition.setRemoteTransition(remoteTransition);
}
mService.getTransitionController().collect(r);
// TODO(b/188669821): Remove when navbar reparenting moves to shell
if (r.getActivityType() == ACTIVITY_TYPE_HOME && r.getOptions() != null
&& r.getOptions().getTransientLaunch()) {
mService.getTransitionController().setIsLegacyRecents();
}
final boolean isTransient = r.getOptions() != null && r.getOptions().getTransientLaunch();
try {
mService.deferWindowLayout();
Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "startActivityInner");
@@ -1625,6 +1620,11 @@ class ActivityStarter {
// it as an existence change.
mService.getTransitionController().collectExistenceChange(r);
}
if (isTransient) {
// `r` isn't guaranteed to be the actual relevant activity, so we must wait
// until after we launched to identify the relevant activity.
mService.getTransitionController().setTransientLaunch(mLastStartActivityRecord);
}
if (newTransition != null) {
mService.getTransitionController().requestStartTransition(newTransition,
mTargetTask, remoteTransition);

View File

@@ -578,6 +578,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
* Specifies the count to determine whether to defer updating the IME target until ready.
*/
private int mDeferUpdateImeTargetCount;
private boolean mUpdateImeRequestedWhileDeferred;
private MagnificationSpec mMagnificationSpec;
@@ -3729,6 +3730,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
final WindowState curTarget = mImeLayeringTarget;
if (!canUpdateImeTarget()) {
if (DEBUG_INPUT_METHOD) Slog.w(TAG_WM, "Defer updating IME target");
mUpdateImeRequestedWhileDeferred = true;
return curTarget;
}
@@ -4991,6 +4993,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
* Increment the deferral count to determine whether to update the IME target.
*/
void deferUpdateImeTarget() {
if (mDeferUpdateImeTargetCount == 0) {
mUpdateImeRequestedWhileDeferred = false;
}
mDeferUpdateImeTargetCount++;
}
@@ -5004,7 +5009,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
}
mDeferUpdateImeTargetCount--;
if (mDeferUpdateImeTargetCount == 0) {
if (mDeferUpdateImeTargetCount == 0 && mUpdateImeRequestedWhileDeferred) {
computeImeTarget(true /* updateImeTarget */);
}
}

View File

@@ -148,6 +148,9 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
*/
private final ArraySet<WindowToken> mVisibleAtTransitionEndTokens = new ArraySet<>();
/** Set of transient activities (lifecycle initially tied to this transition). */
private ArraySet<ActivityRecord> mTransientLaunches = null;
/** Custom activity-level animation options and callbacks. */
private TransitionInfo.AnimationOptions mOverrideOptions;
private IRemoteCallback mClientAnimationStartCallback = null;
@@ -174,6 +177,20 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
mFlags |= flag;
}
/** Records an activity as transient-launch. This activity must be already collected. */
void setTransientLaunch(@NonNull ActivityRecord activity) {
if (mTransientLaunches == null) {
mTransientLaunches = new ArraySet<>();
}
mTransientLaunches.add(activity);
ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS, "Transition %d: Set %s as "
+ "transient-launch", mSyncId, activity);
}
boolean isTransientLaunch(@NonNull ActivityRecord activity) {
return mTransientLaunches != null && mTransientLaunches.contains(activity);
}
@VisibleForTesting
int getSyncId() {
return mSyncId;

View File

@@ -16,6 +16,7 @@
package com.android.server.wm;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_IS_RECENTS;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
@@ -185,6 +186,20 @@ class TransitionController {
return false;
}
/**
* @return {@code true} if {@param ar} is part of a transient-launch activity in an active
* transition.
*/
boolean isTransientLaunch(@NonNull ActivityRecord ar) {
if (mCollectingTransition != null && mCollectingTransition.isTransientLaunch(ar)) {
return true;
}
for (int i = mPlayingTransitions.size() - 1; i >= 0; --i) {
if (mPlayingTransitions.get(i).isTransientLaunch(ar)) return true;
}
return false;
}
@WindowManager.TransitionType
int getCollectingTransitionType() {
return mCollectingTransition != null ? mCollectingTransition.mType : TRANSIT_NONE;
@@ -331,13 +346,18 @@ class TransitionController {
}
/**
* Explicitly mark the collectingTransition as being part of recents gesture. Used for legacy
* behaviors.
* TODO(b/188669821): Remove once legacy recents behavior is moved to shell.
* Record that the launch of {@param activity} is transient (meaning its lifecycle is currently
* tied to the transition).
*/
void setIsLegacyRecents() {
void setTransientLaunch(@NonNull ActivityRecord activity) {
if (mCollectingTransition == null) return;
mCollectingTransition.addFlag(TRANSIT_FLAG_IS_RECENTS);
mCollectingTransition.setTransientLaunch(activity);
// TODO(b/188669821): Remove once legacy recents behavior is moved to shell.
// Also interpret HOME transient launch as recents
if (activity.getActivityType() == ACTIVITY_TYPE_HOME) {
mCollectingTransition.addFlag(TRANSIT_FLAG_IS_RECENTS);
}
}
void legacyDetachNavigationBarFromApp(@NonNull IBinder token) {

View File

@@ -7732,7 +7732,7 @@ public class WindowManagerService extends IWindowManager.Stub
final WindowState currentFocus = displayContent.mCurrentFocus;
if (currentFocus != null && currentFocus.mSession.mUid == uid
&& currentFocus.mSession.mPid == pid) {
return true;
return currentFocus.canBeImeTarget();
}
}
return false;

View File

@@ -1980,7 +1980,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
final ActivityRecord atoken = mActivityRecord;
return (mHasSurface || (!mRelayoutCalled && mViewVisibility == View.VISIBLE))
&& isVisibleByPolicy() && !isParentWindowHidden()
&& (atoken == null || atoken.mVisibleRequested)
&& (atoken == null || atoken.isVisible())
&& !mAnimatingExit && !mDestroying;
}
@@ -2706,6 +2706,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
}
}
// Don't allow transient-launch activities to take IME.
if (rootTask != null && mActivityRecord != null
&& mWmService.mAtmService.getTransitionController().isTransientLaunch(
mActivityRecord)) {
return false;
}
if (DEBUG_INPUT_METHOD) {
Slog.i(TAG_WM, "isVisibleOrAdding " + this + ": " + isVisibleOrAdding());
if (!isVisibleOrAdding()) {