Merge "Merge "Reduce unnecessary operations in the setFocusedTask" into udc-dev am: 67e0a033a9 am: acf1d4d1ba"

This commit is contained in:
Automerger Merge Worker
2023-03-29 08:15:11 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 11 deletions

View File

@@ -2011,6 +2011,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
return;
}
if (r == mRootWindowContainer.getTopResumedActivity()) {
setLastResumedActivityUncheckLocked(r, "setFocusedTask-alreadyTop");
return;
}
final Transition transition = (getTransitionController().isCollecting()
|| !getTransitionController().isShellTransitionsEnabled()) ? null
: getTransitionController().createTransition(TRANSIT_TO_FRONT);
@@ -4788,11 +4792,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
// until we've committed to the gesture. The focus will be transferred at the end of
// the transition (if the transient launch is committed) or early if explicitly requested
// via `setFocused*`.
boolean focusedAppChanged = false;
if (!getTransitionController().isTransientCollect(r)) {
final Task prevFocusTask = r.mDisplayContent.mFocusedApp != null
? r.mDisplayContent.mFocusedApp.getTask() : null;
final boolean changed = r.mDisplayContent.setFocusedApp(r);
if (changed) {
focusedAppChanged = r.mDisplayContent.setFocusedApp(r);
if (focusedAppChanged) {
mWindowManager.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL,
true /*updateInputWindows*/);
}
@@ -4801,13 +4804,14 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
mTaskSupervisor.mRecentTasks.add(task);
}
applyUpdateLockStateLocked(r);
applyUpdateVrModeLocked(r);
if (focusedAppChanged) {
applyUpdateLockStateLocked(r);
}
if (mVrController.mVrService != null) {
applyUpdateVrModeLocked(r);
}
EventLogTags.writeWmSetResumedActivity(
r == null ? -1 : r.mUserId,
r == null ? "NULL" : r.shortComponentName,
reason);
EventLogTags.writeWmSetResumedActivity(r.mUserId, r.shortComponentName, reason);
}
final class SleepTokenAcquirerImpl implements ActivityTaskManagerInternal.SleepTokenAcquirer {

View File

@@ -126,6 +126,9 @@ final class VrController {
}
};
/** If it is null after system ready, then VR mode is not supported. */
VrManagerInternal mVrService;
/**
* Create new VrController instance.
*
@@ -141,6 +144,7 @@ final class VrController {
public void onSystemReady() {
VrManagerInternal vrManagerInternal = LocalServices.getService(VrManagerInternal.class);
if (vrManagerInternal != null) {
mVrService = vrManagerInternal;
vrManagerInternal.addPersistentVrModeStateListener(mPersistentVrModeListener);
}
}
@@ -181,7 +185,7 @@ final class VrController {
public boolean onVrModeChanged(ActivityRecord record) {
// This message means that the top focused activity enabled VR mode (or an activity
// that previously set this has become focused).
VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class);
final VrManagerInternal vrService = mVrService;
if (vrService == null) {
// VR mode isn't supported on this device.
return false;