Merge "Move #moveFocusableActivityToTop() to ActivityRecord"
This commit is contained in:
@@ -1087,7 +1087,7 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
|
||||
if (top == null) {
|
||||
return false;
|
||||
}
|
||||
mSupervisor.moveFocusableActivityToTop(top, reason);
|
||||
top.moveFocusableActivityToTop(reason);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,11 +84,13 @@ import static android.os.Process.SYSTEM_UID;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_LEFT;
|
||||
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_CONFIGURATION;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_FOCUS;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_SAVED_STATE;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_STATES;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_SWITCH;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_VISIBILITY;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_CONFIGURATION;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_FOCUS;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_SAVED_STATE;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_STATES;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_SWITCH;
|
||||
@@ -215,6 +217,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
|
||||
private static final String TAG_STATES = TAG + POSTFIX_STATES;
|
||||
private static final String TAG_SWITCH = TAG + POSTFIX_SWITCH;
|
||||
private static final String TAG_VISIBILITY = TAG + POSTFIX_VISIBILITY;
|
||||
private static final String TAG_FOCUS = TAG + POSTFIX_FOCUS;
|
||||
// TODO(b/67864419): Remove once recents component is overridden
|
||||
private static final String LEGACY_RECENTS_PACKAGE_NAME = "com.android.systemui.recents";
|
||||
|
||||
@@ -1348,6 +1351,42 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
|
||||
return (info.flags & FLAG_ALWAYS_FOCUSABLE) != 0;
|
||||
}
|
||||
|
||||
/** Move activity with its stack to front and make the stack focused. */
|
||||
boolean moveFocusableActivityToTop(String reason) {
|
||||
if (!isFocusable()) {
|
||||
if (DEBUG_FOCUS) {
|
||||
Slog.d(TAG_FOCUS, "moveActivityStackToFront: unfocusable activity=" + this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
final TaskRecord task = getTask();
|
||||
final ActivityStack stack = getStack();
|
||||
if (stack == null) {
|
||||
Slog.w(TAG, "moveActivityStackToFront: invalid task or stack: activity="
|
||||
+ this + " task=" + task);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mStackSupervisor.getTopResumedActivity() == this) {
|
||||
if (DEBUG_FOCUS) {
|
||||
Slog.d(TAG_FOCUS, "moveActivityStackToFront: already on top, activity=" + this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DEBUG_FOCUS) {
|
||||
Slog.d(TAG_FOCUS, "moveActivityStackToFront: activity=" + this);
|
||||
}
|
||||
|
||||
stack.moveToFront(reason, task);
|
||||
// Report top activity change to tracking services and WM
|
||||
if (mStackSupervisor.getTopResumedActivity() == this) {
|
||||
// TODO(b/111361570): Support multiple focused apps in WM
|
||||
service.setResumedActivityUncheckLocked(this, reason);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the activity contains windows that have
|
||||
|
||||
@@ -3450,8 +3450,10 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
|
||||
final String myReason = reason + " adjustFocus";
|
||||
|
||||
if (next == r) {
|
||||
mStackSupervisor.moveFocusableActivityToTop(mStackSupervisor.topRunningActivityLocked(),
|
||||
myReason);
|
||||
final ActivityRecord top = mStackSupervisor.topRunningActivityLocked();
|
||||
if (top != null) {
|
||||
top.moveFocusableActivityToTop(myReason);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4662,7 +4664,9 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
|
||||
|
||||
// Set focus to the top running activity of this stack.
|
||||
final ActivityRecord r = topRunningActivityLocked();
|
||||
mStackSupervisor.moveFocusableActivityToTop(r, reason);
|
||||
if (r != null) {
|
||||
r.moveFocusableActivityToTop(reason);
|
||||
}
|
||||
|
||||
if (DEBUG_TRANSITION) Slog.v(TAG_TRANSITION, "Prepare to front transition: task=" + tr);
|
||||
if (noAnimation) {
|
||||
|
||||
@@ -55,7 +55,6 @@ import static android.view.Display.TYPE_VIRTUAL;
|
||||
import static android.view.WindowManager.TRANSIT_DOCK_TASK_FROM_RECENTS;
|
||||
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ALL;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_FOCUS;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_IDLE;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_PAUSE;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_RECENTS;
|
||||
@@ -64,7 +63,6 @@ import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_STACK;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_STATES;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_SWITCH;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_TASKS;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_FOCUS;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_IDLE;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_PAUSE;
|
||||
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_RECENTS;
|
||||
@@ -201,7 +199,6 @@ import java.util.Set;
|
||||
public class ActivityStackSupervisor extends ConfigurationContainer implements DisplayListener,
|
||||
RecentTasks.Callbacks, RootWindowContainerListener {
|
||||
private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityStackSupervisor" : TAG_AM;
|
||||
private static final String TAG_FOCUS = TAG + POSTFIX_FOCUS;
|
||||
private static final String TAG_IDLE = TAG + POSTFIX_IDLE;
|
||||
private static final String TAG_PAUSE = TAG + POSTFIX_PAUSE;
|
||||
private static final String TAG_RECENTS = TAG + POSTFIX_RECENTS;
|
||||
@@ -785,7 +782,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
|
||||
|
||||
// Only resume home activity if isn't finishing.
|
||||
if (r != null && !r.finishing) {
|
||||
moveFocusableActivityToTop(r, myReason);
|
||||
r.moveFocusableActivityToTop(myReason);
|
||||
return resumeFocusedStacksTopActivitiesLocked(r.getStack(), prev, null);
|
||||
}
|
||||
return mService.startHomeActivityLocked(mCurrentUser, myReason, displayId);
|
||||
@@ -3361,41 +3358,6 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
|
||||
mService.getTaskChangeNotificationController().notifyActivityPinned(r);
|
||||
}
|
||||
|
||||
/** Move activity with its stack to front and make the stack focused. */
|
||||
// TODO(b/111363427): Move this method to ActivityRecord.
|
||||
boolean moveFocusableActivityToTop(ActivityRecord r, String reason) {
|
||||
if (r == null || !r.isFocusable()) {
|
||||
if (DEBUG_FOCUS) Slog.d(TAG_FOCUS,
|
||||
"moveActivityStackToFront: unfocusable r=" + r);
|
||||
return false;
|
||||
}
|
||||
|
||||
final TaskRecord task = r.getTask();
|
||||
final ActivityStack stack = r.getStack();
|
||||
if (stack == null) {
|
||||
Slog.w(TAG, "moveActivityStackToFront: invalid task or stack: r="
|
||||
+ r + " task=" + task);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (r == getTopResumedActivity()) {
|
||||
if (DEBUG_FOCUS) Slog.d(TAG_FOCUS,
|
||||
"moveActivityStackToFront: already on top, r=" + r);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DEBUG_FOCUS) Slog.d(TAG_FOCUS,
|
||||
"moveActivityStackToFront: r=" + r);
|
||||
|
||||
stack.moveToFront(reason, task);
|
||||
// Report top activity change to tracking services and WM
|
||||
if (r == getTopResumedActivity()) {
|
||||
// TODO(b/111361570): Support multiple focused apps in WM
|
||||
mService.setResumedActivityUncheckLocked(r, reason);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ActivityRecord findTaskLocked(ActivityRecord r, int preferredDisplayId) {
|
||||
if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Looking for task of " + r);
|
||||
mTmpFindTaskResult.clear();
|
||||
|
||||
@@ -1707,7 +1707,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
return;
|
||||
}
|
||||
final ActivityRecord r = stack.topRunningActivityLocked();
|
||||
if (mStackSupervisor.moveFocusableActivityToTop(r, "setFocusedStack")) {
|
||||
if (r != null && r.moveFocusableActivityToTop("setFocusedStack")) {
|
||||
mStackSupervisor.resumeFocusedStacksTopActivitiesLocked();
|
||||
}
|
||||
}
|
||||
@@ -1728,7 +1728,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
return;
|
||||
}
|
||||
final ActivityRecord r = task.topRunningActivityLocked();
|
||||
if (mStackSupervisor.moveFocusableActivityToTop(r, "setFocusedTask")) {
|
||||
if (r != null && r.moveFocusableActivityToTop("setFocusedTask")) {
|
||||
mStackSupervisor.resumeFocusedStacksTopActivitiesLocked();
|
||||
}
|
||||
}
|
||||
@@ -5554,7 +5554,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
throw new IllegalArgumentException(
|
||||
"setFocusedActivity: No activity record matching token=" + token);
|
||||
}
|
||||
if (mStackSupervisor.moveFocusableActivityToTop(r, "setFocusedActivity")) {
|
||||
if (r.moveFocusableActivityToTop("setFocusedActivity")) {
|
||||
mStackSupervisor.resumeFocusedStacksTopActivitiesLocked();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user