Skip moving the focused Task to top if it is already on top
The Task was moved to front while making an Activity to be the focused app. In that case, the resumed activity will be reset to the top-most resumed activity in the Task. However, the top-most resumed activity in the Task should not always be the current focused activity when activity embedded. This CL skips unnecessary task movement and making the target activity to be focused if the task is already on top and focused. Bug: 236565088 Test: atest TaskFragmentTest Change-Id: I6cbea10bdfa422e9d51c051595ed592843f5ba79
This commit is contained in:
@@ -475,12 +475,6 @@
|
||||
"group": "WM_DEBUG_ADD_REMOVE",
|
||||
"at": "com\/android\/server\/wm\/ResetTargetTaskHelper.java"
|
||||
},
|
||||
"-1635750891": {
|
||||
"message": "Received remote change for Display[%d], applied: [%dx%d, rot = %d]",
|
||||
"level": "VERBOSE",
|
||||
"group": "WM_DEBUG_CONFIGURATION",
|
||||
"at": "com\/android\/server\/wm\/RemoteDisplayChangeController.java"
|
||||
},
|
||||
"-1633115609": {
|
||||
"message": "Key dispatch not paused for screen off",
|
||||
"level": "VERBOSE",
|
||||
@@ -2599,6 +2593,12 @@
|
||||
"group": "WM_DEBUG_STATES",
|
||||
"at": "com\/android\/server\/wm\/TaskFragment.java"
|
||||
},
|
||||
"385237117": {
|
||||
"message": "moveFocusableActivityToTop: already on top and focused, activity=%s",
|
||||
"level": "DEBUG",
|
||||
"group": "WM_DEBUG_FOCUS",
|
||||
"at": "com\/android\/server\/wm\/ActivityRecord.java"
|
||||
},
|
||||
"385595355": {
|
||||
"message": "Starting animation on %s: type=%d, anim=%s",
|
||||
"level": "VERBOSE",
|
||||
@@ -3403,6 +3403,12 @@
|
||||
"group": "WM_DEBUG_BOOT",
|
||||
"at": "com\/android\/server\/wm\/WindowManagerService.java"
|
||||
},
|
||||
"1239439010": {
|
||||
"message": "moveFocusableActivityToTop: set focused, activity=%s",
|
||||
"level": "DEBUG",
|
||||
"group": "WM_DEBUG_FOCUS",
|
||||
"at": "com\/android\/server\/wm\/ActivityRecord.java"
|
||||
},
|
||||
"1252594551": {
|
||||
"message": "Window types in WindowContext and LayoutParams.type should match! Type from LayoutParams is %d, but type from WindowContext is %d",
|
||||
"level": "WARN",
|
||||
@@ -3877,12 +3883,6 @@
|
||||
"group": "WM_DEBUG_ORIENTATION",
|
||||
"at": "com\/android\/server\/wm\/WindowStateAnimator.java"
|
||||
},
|
||||
"1764619787": {
|
||||
"message": "Remote change for Display[%d]: timeout reached",
|
||||
"level": "VERBOSE",
|
||||
"group": "WM_DEBUG_CONFIGURATION",
|
||||
"at": "com\/android\/server\/wm\/RemoteDisplayChangeController.java"
|
||||
},
|
||||
"1774661765": {
|
||||
"message": "Devices still not ready after waiting %d milliseconds before attempting to detect safe mode.",
|
||||
"level": "WARN",
|
||||
@@ -3991,12 +3991,6 @@
|
||||
"group": "WM_DEBUG_STARTING_WINDOW",
|
||||
"at": "com\/android\/server\/wm\/ActivityRecord.java"
|
||||
},
|
||||
"1856211951": {
|
||||
"message": "moveFocusableActivityToTop: already on top, activity=%s",
|
||||
"level": "DEBUG",
|
||||
"group": "WM_DEBUG_FOCUS",
|
||||
"at": "com\/android\/server\/wm\/ActivityRecord.java"
|
||||
},
|
||||
"1856783490": {
|
||||
"message": "resumeTopActivity: Restarting %s",
|
||||
"level": "DEBUG",
|
||||
|
||||
@@ -3207,12 +3207,29 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mRootWindowContainer.getTopResumedActivity() == this
|
||||
&& getDisplayContent().mFocusedApp == this) {
|
||||
ProtoLog.d(WM_DEBUG_FOCUS, "moveFocusableActivityToTop: already on top, "
|
||||
+ "activity=%s", this);
|
||||
return !isState(RESUMED);
|
||||
// If this activity already positions on the top focused task, moving the task to front
|
||||
// is not needed. But we still need to ensure this activity is focused because the
|
||||
// current focused activity could be another activity in the same Task if activities are
|
||||
// displayed on adjacent TaskFragments.
|
||||
final ActivityRecord currentFocusedApp = mDisplayContent.mFocusedApp;
|
||||
if (currentFocusedApp != null && currentFocusedApp.task == task) {
|
||||
final Task topFocusableTask = mDisplayContent.getTask(
|
||||
(t) -> t.isLeafTask() && t.isFocusable(), true /* traverseTopToBottom */);
|
||||
if (task == topFocusableTask) {
|
||||
if (currentFocusedApp == this) {
|
||||
ProtoLog.d(WM_DEBUG_FOCUS, "moveFocusableActivityToTop: already on top "
|
||||
+ "and focused, activity=%s", this);
|
||||
} else {
|
||||
ProtoLog.d(WM_DEBUG_FOCUS, "moveFocusableActivityToTop: set focused, "
|
||||
+ "activity=%s", this);
|
||||
mDisplayContent.setFocusedApp(this);
|
||||
mAtmService.mWindowManager.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL,
|
||||
true /* updateInputWindows */);
|
||||
}
|
||||
return !isState(RESUMED);
|
||||
}
|
||||
}
|
||||
|
||||
ProtoLog.d(WM_DEBUG_FOCUS, "moveFocusableActivityToTop: activity=%s", this);
|
||||
|
||||
rootTask.moveToFront(reason, task);
|
||||
|
||||
@@ -475,5 +475,13 @@ public class TaskFragmentTest extends WindowTestsBase {
|
||||
assertFalse(activity0.isLetterboxedForFixedOrientationAndAspectRatio());
|
||||
assertFalse(activity1.isLetterboxedForFixedOrientationAndAspectRatio());
|
||||
assertEquals(SCREEN_ORIENTATION_UNSET, task.getOrientation());
|
||||
|
||||
tf0.setResumedActivity(activity0, "test");
|
||||
tf1.setResumedActivity(activity1, "test");
|
||||
mDisplayContent.mFocusedApp = activity1;
|
||||
|
||||
// Making the activity0 be the focused activity and ensure the focused app is updated.
|
||||
activity0.moveFocusableActivityToTop("test");
|
||||
assertEquals(activity0, mDisplayContent.mFocusedApp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user