Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -4708,6 +4708,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { case KeyEvent.KEYCODE_BACK: { logKeyboardSystemsEventOnActionUp(event, KeyboardLogEvent.BACK); if (down) { // There may have other embedded activities on the same Task. Try to move the // focus before processing the back event. mWindowManagerInternal.moveFocusToTopEmbeddedWindowIfNeeded(); mBackKeyHandled = false; } else { if (!hasLongPressOnBackBehavior()) { Loading services/core/java/com/android/server/wm/BackNavigationController.java +6 −17 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.server.wm; import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.view.RemoteAnimationTarget.MODE_CLOSING; import static android.view.RemoteAnimationTarget.MODE_OPENING; import static android.view.View.FOCUS_FORWARD; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_OLD_NONE; Loading Loading @@ -61,7 +60,6 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.TransitionAnimation; import com.android.internal.protolog.common.ProtoLog; import com.android.server.wm.utils.InsetUtils; import com.android.window.flags.Flags; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -165,23 +163,14 @@ class BackNavigationController { return null; } // Move focus to the adjacent embedded window if it is higher than this window final TaskFragment taskFragment = window.getTaskFragment(); final TaskFragment adjacentTaskFragment = taskFragment != null ? taskFragment.getAdjacentTaskFragment() : null; if (adjacentTaskFragment != null && taskFragment.isEmbedded() && Flags.embeddedActivityBackNavFlag()) { final WindowContainer parent = taskFragment.getParent(); if (parent.mChildren.indexOf(taskFragment) < parent.mChildren.indexOf( adjacentTaskFragment)) { mWindowManagerService.moveFocusToAdjacentWindow(window, FOCUS_FORWARD); // Move focus to the top embedded window if possible if (mWindowManagerService.moveFocusToTopEmbeddedWindow(window)) { window = wmService.getFocusedWindowLocked(); if (window == null) { Slog.e(TAG, "Adjacent window is null, returning null."); Slog.e(TAG, "New focused window is null, returning null."); return null; } } } // This is needed to bridge the old and new back behavior with recents. While in // Overview with live tile enabled, the previous app is technically focused but we Loading services/core/java/com/android/server/wm/Session.java +8 −1 Original line number Diff line number Diff line Loading @@ -1005,7 +1005,14 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { public boolean moveFocusToAdjacentWindow(IWindow fromWindow, @FocusDirection int direction) { final long identity = Binder.clearCallingIdentity(); try { return mService.moveFocusToAdjacentWindow(this, fromWindow, direction); synchronized (mService.mGlobalLock) { final WindowState win = mService.windowForClientLocked(this, fromWindow, false /* throwOnError */); if (win == null) { return false; } return mService.moveFocusToAdjacentWindow(win, direction); } } finally { Binder.restoreCallingIdentity(identity); } Loading services/core/java/com/android/server/wm/WindowManagerInternal.java +5 −0 Original line number Diff line number Diff line Loading @@ -1047,4 +1047,9 @@ public abstract class WindowManagerInternal { * * {@link #addBlockScreenCaptureForApps(ArraySet)} */ public abstract void clearBlockedApps(); /** * Moves the current focus to the top activity window if the top activity is embedded. */ public abstract boolean moveFocusToTopEmbeddedWindowIfNeeded(); } services/core/java/com/android/server/wm/WindowManagerService.java +65 −15 Original line number Diff line number Diff line Loading @@ -346,6 +346,7 @@ import com.android.server.policy.WindowManagerPolicy.ScreenOffListener; import com.android.server.power.ShutdownThread; import com.android.server.utils.PriorityDump; import com.android.server.wallpaper.WallpaperCropper.WallpaperCropUtils; import com.android.window.flags.Flags; import dalvik.annotation.optimization.NeverCompile; Loading Loading @@ -8629,6 +8630,24 @@ public class WindowManagerService extends IWindowManager.Stub } } } @Override public boolean moveFocusToTopEmbeddedWindowIfNeeded() { synchronized (mGlobalLock) { final WindowState focusedWindow = getFocusedWindow(); if (focusedWindow == null) { return false; } if (moveFocusToTopEmbeddedWindow(focusedWindow)) { // Sync the input transactions to ensure the input focus updates as well. syncInputTransactions(false); return true; } return false; } } } private final class ImeTargetVisibilityPolicyImpl extends ImeTargetVisibilityPolicy { Loading Loading @@ -9162,18 +9181,48 @@ public class WindowManagerService extends IWindowManager.Stub win.mClient); } boolean moveFocusToAdjacentWindow(Session session, IWindow fromWindow, @FocusDirection int direction) { synchronized (mGlobalLock) { final WindowState fromWin = windowForClientLocked(session, fromWindow, false); if (fromWin == null || !fromWin.isFocused()) { /** * Move focus to the top embedded window if possible. */ boolean moveFocusToTopEmbeddedWindow(@NonNull WindowState focusedWindow) { final TaskFragment taskFragment = focusedWindow.getTaskFragment(); if (taskFragment == null) { // Skip if not an Activity window. return false; } if (!Flags.embeddedActivityBackNavFlag()) { // Skip if flag is not enabled. return false; } final ActivityRecord topActivity = taskFragment.getTask().topRunningActivity(true /* focusableOnly */); if (topActivity == null || topActivity == focusedWindow.mActivityRecord) { // Skip if the focused activity is already the top-most activity on the Task. return false; } if (!topActivity.isEmbedded()) { // Skip if the top activity is not embedded return false; } return moveFocusToAdjacentWindow(fromWin, direction); final TaskFragment topTaskFragment = topActivity.getTaskFragment(); if (topTaskFragment.isIsolatedNav() && taskFragment.getAdjacentTaskFragment() == topTaskFragment) { // Skip if the top TaskFragment is adjacent to current focus and is set to isolated nav. return false; } moveFocusToActivity(topActivity); return !focusedWindow.isFocused(); } boolean moveFocusToAdjacentWindow(WindowState fromWin, @FocusDirection int direction) { boolean moveFocusToAdjacentWindow(@NonNull WindowState fromWin, @FocusDirection int direction) { if (!fromWin.isFocused()) { return false; } final TaskFragment fromFragment = fromWin.getTaskFragment(); if (fromFragment == null) { return false; Loading Loading @@ -9222,12 +9271,13 @@ public class WindowManagerService extends IWindowManager.Stub if (topRunningActivity == null) { return false; } moveDisplayToTopInternal(topRunningActivity.getDisplayId()); handleTaskFocusChange(topRunningActivity.getTask(), topRunningActivity); if (fromWin.isFocused()) { return false; moveFocusToActivity(topRunningActivity); return !fromWin.isFocused(); } return true; private void moveFocusToActivity(@NonNull ActivityRecord activity) { moveDisplayToTopInternal(activity.getDisplayId()); handleTaskFocusChange(activity.getTask(), activity); } /** Return whether layer tracing is enabled */ Loading Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -4708,6 +4708,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { case KeyEvent.KEYCODE_BACK: { logKeyboardSystemsEventOnActionUp(event, KeyboardLogEvent.BACK); if (down) { // There may have other embedded activities on the same Task. Try to move the // focus before processing the back event. mWindowManagerInternal.moveFocusToTopEmbeddedWindowIfNeeded(); mBackKeyHandled = false; } else { if (!hasLongPressOnBackBehavior()) { Loading
services/core/java/com/android/server/wm/BackNavigationController.java +6 −17 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.server.wm; import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.view.RemoteAnimationTarget.MODE_CLOSING; import static android.view.RemoteAnimationTarget.MODE_OPENING; import static android.view.View.FOCUS_FORWARD; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_OLD_NONE; Loading Loading @@ -61,7 +60,6 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.policy.TransitionAnimation; import com.android.internal.protolog.common.ProtoLog; import com.android.server.wm.utils.InsetUtils; import com.android.window.flags.Flags; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -165,23 +163,14 @@ class BackNavigationController { return null; } // Move focus to the adjacent embedded window if it is higher than this window final TaskFragment taskFragment = window.getTaskFragment(); final TaskFragment adjacentTaskFragment = taskFragment != null ? taskFragment.getAdjacentTaskFragment() : null; if (adjacentTaskFragment != null && taskFragment.isEmbedded() && Flags.embeddedActivityBackNavFlag()) { final WindowContainer parent = taskFragment.getParent(); if (parent.mChildren.indexOf(taskFragment) < parent.mChildren.indexOf( adjacentTaskFragment)) { mWindowManagerService.moveFocusToAdjacentWindow(window, FOCUS_FORWARD); // Move focus to the top embedded window if possible if (mWindowManagerService.moveFocusToTopEmbeddedWindow(window)) { window = wmService.getFocusedWindowLocked(); if (window == null) { Slog.e(TAG, "Adjacent window is null, returning null."); Slog.e(TAG, "New focused window is null, returning null."); return null; } } } // This is needed to bridge the old and new back behavior with recents. While in // Overview with live tile enabled, the previous app is technically focused but we Loading
services/core/java/com/android/server/wm/Session.java +8 −1 Original line number Diff line number Diff line Loading @@ -1005,7 +1005,14 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { public boolean moveFocusToAdjacentWindow(IWindow fromWindow, @FocusDirection int direction) { final long identity = Binder.clearCallingIdentity(); try { return mService.moveFocusToAdjacentWindow(this, fromWindow, direction); synchronized (mService.mGlobalLock) { final WindowState win = mService.windowForClientLocked(this, fromWindow, false /* throwOnError */); if (win == null) { return false; } return mService.moveFocusToAdjacentWindow(win, direction); } } finally { Binder.restoreCallingIdentity(identity); } Loading
services/core/java/com/android/server/wm/WindowManagerInternal.java +5 −0 Original line number Diff line number Diff line Loading @@ -1047,4 +1047,9 @@ public abstract class WindowManagerInternal { * * {@link #addBlockScreenCaptureForApps(ArraySet)} */ public abstract void clearBlockedApps(); /** * Moves the current focus to the top activity window if the top activity is embedded. */ public abstract boolean moveFocusToTopEmbeddedWindowIfNeeded(); }
services/core/java/com/android/server/wm/WindowManagerService.java +65 −15 Original line number Diff line number Diff line Loading @@ -346,6 +346,7 @@ import com.android.server.policy.WindowManagerPolicy.ScreenOffListener; import com.android.server.power.ShutdownThread; import com.android.server.utils.PriorityDump; import com.android.server.wallpaper.WallpaperCropper.WallpaperCropUtils; import com.android.window.flags.Flags; import dalvik.annotation.optimization.NeverCompile; Loading Loading @@ -8629,6 +8630,24 @@ public class WindowManagerService extends IWindowManager.Stub } } } @Override public boolean moveFocusToTopEmbeddedWindowIfNeeded() { synchronized (mGlobalLock) { final WindowState focusedWindow = getFocusedWindow(); if (focusedWindow == null) { return false; } if (moveFocusToTopEmbeddedWindow(focusedWindow)) { // Sync the input transactions to ensure the input focus updates as well. syncInputTransactions(false); return true; } return false; } } } private final class ImeTargetVisibilityPolicyImpl extends ImeTargetVisibilityPolicy { Loading Loading @@ -9162,18 +9181,48 @@ public class WindowManagerService extends IWindowManager.Stub win.mClient); } boolean moveFocusToAdjacentWindow(Session session, IWindow fromWindow, @FocusDirection int direction) { synchronized (mGlobalLock) { final WindowState fromWin = windowForClientLocked(session, fromWindow, false); if (fromWin == null || !fromWin.isFocused()) { /** * Move focus to the top embedded window if possible. */ boolean moveFocusToTopEmbeddedWindow(@NonNull WindowState focusedWindow) { final TaskFragment taskFragment = focusedWindow.getTaskFragment(); if (taskFragment == null) { // Skip if not an Activity window. return false; } if (!Flags.embeddedActivityBackNavFlag()) { // Skip if flag is not enabled. return false; } final ActivityRecord topActivity = taskFragment.getTask().topRunningActivity(true /* focusableOnly */); if (topActivity == null || topActivity == focusedWindow.mActivityRecord) { // Skip if the focused activity is already the top-most activity on the Task. return false; } if (!topActivity.isEmbedded()) { // Skip if the top activity is not embedded return false; } return moveFocusToAdjacentWindow(fromWin, direction); final TaskFragment topTaskFragment = topActivity.getTaskFragment(); if (topTaskFragment.isIsolatedNav() && taskFragment.getAdjacentTaskFragment() == topTaskFragment) { // Skip if the top TaskFragment is adjacent to current focus and is set to isolated nav. return false; } moveFocusToActivity(topActivity); return !focusedWindow.isFocused(); } boolean moveFocusToAdjacentWindow(WindowState fromWin, @FocusDirection int direction) { boolean moveFocusToAdjacentWindow(@NonNull WindowState fromWin, @FocusDirection int direction) { if (!fromWin.isFocused()) { return false; } final TaskFragment fromFragment = fromWin.getTaskFragment(); if (fromFragment == null) { return false; Loading Loading @@ -9222,12 +9271,13 @@ public class WindowManagerService extends IWindowManager.Stub if (topRunningActivity == null) { return false; } moveDisplayToTopInternal(topRunningActivity.getDisplayId()); handleTaskFocusChange(topRunningActivity.getTask(), topRunningActivity); if (fromWin.isFocused()) { return false; moveFocusToActivity(topRunningActivity); return !fromWin.isFocused(); } return true; private void moveFocusToActivity(@NonNull ActivityRecord activity) { moveDisplayToTopInternal(activity.getDisplayId()); handleTaskFocusChange(activity.getTask(), activity); } /** Return whether layer tracing is enabled */ Loading