Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72d581e6 authored by Galia Peycheva's avatar Galia Peycheva
Browse files

Close assistant activities on closeSystemDialogs

When the assistant is configured to be on top of the dream, it will have
higher z-order than any other activity. If it is also opaque, it will
prevent other activities from starting. We want to close the assistant
on closeSystemDialogs to allow other activities to start, e.g. on home
button press

Bug: 158117282

Test: atest AssistantStackTests
Change-Id: I226d95b82c1f5df5e5327ef85859d9b137d6e0e7
parent c744ad24
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6826,7 +6826,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                    }
                    mWindowManager.closeSystemDialogs(reason);

                    mRootWindowContainer.closeSystemDialogs();
                    mRootWindowContainer.closeSystemDialogActivities(reason);
                }
                // Call into AM outside the synchronized block.
                mAmInternal.broadcastCloseSystemDialogs(reason);
+15 −3
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import static android.view.WindowManager.TRANSIT_CRASHING_ACTIVITY_CLOSE;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_SHOW_SINGLE_TASK_DISPLAY;

import static com.android.server.policy.PhoneWindowManager.SYSTEM_DIALOG_REASON_ASSIST;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static com.android.server.wm.ActivityStack.ActivityState.FINISHING;
@@ -3121,14 +3122,25 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        return hasVisibleActivities;
    }

    void closeSystemDialogs() {
    void closeSystemDialogActivities(String reason) {
        forAllActivities((r) -> {
            if ((r.info.flags & ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) {
                r.finishIfPossible("close-sys", true /* oomAdj */);
            if ((r.info.flags & ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0
                    || shouldCloseAssistant(r, reason)) {
                r.finishIfPossible(reason, true /* oomAdj */);
            }
        });
    }

    private boolean shouldCloseAssistant(ActivityRecord r, String reason) {
        if (!r.isActivityTypeAssistant()) return false;
        if (reason == SYSTEM_DIALOG_REASON_ASSIST) return false;
        // When the assistant is configured to be on top of the dream, it will have higher z-order
        // than other activities. If it is also opaque, it will prevent other activities from
        // starting. We want to close the assistant on closeSystemDialogs to allow other activities
        // to start, e.g. on home button press.
        return mWmService.mAssistantOnTopOfDream;
    }

    FinishDisabledPackageActivitiesHelper mFinishDisabledPackageActivitiesHelper =
            new FinishDisabledPackageActivitiesHelper();
    class FinishDisabledPackageActivitiesHelper {
+1 −8
Original line number Diff line number Diff line
@@ -122,10 +122,6 @@ final class TaskDisplayArea extends DisplayArea<ActivityStack> {
    private final RootWindowContainer.FindTaskResult
            mTmpFindTaskResult = new RootWindowContainer.FindTaskResult();

    // Indicates whether the Assistant should show on top of the Dream (respectively, above
    // everything else on screen). Otherwise, it will be put under always-on-top stacks.
    private final boolean mAssistantOnTopOfDream;

    /**
     * If this is the same as {@link #getFocusedStack} then the activity on the top of the focused
     * stack has been resumed. If stacks are changing position this will hold the old stack until
@@ -151,9 +147,6 @@ final class TaskDisplayArea extends DisplayArea<ActivityStack> {
        mDisplayContent = displayContent;
        mRootWindowContainer = service.mRoot;
        mAtmService = service.mAtmService;

        mAssistantOnTopOfDream = mWmService.mContext.getResources().getBoolean(
                    com.android.internal.R.bool.config_assistantOnTopOfDream);
    }

    /**
@@ -361,7 +354,7 @@ final class TaskDisplayArea extends DisplayArea<ActivityStack> {
     * @return the priority of the stack
     */
    private int getPriority(ActivityStack stack) {
        if (mAssistantOnTopOfDream && stack.isActivityTypeAssistant()) return 4;
        if (mWmService.mAssistantOnTopOfDream && stack.isActivityTypeAssistant()) return 4;
        if (stack.isActivityTypeDream()) return 3;
        if (stack.inPinnedWindowingMode()) return 2;
        if (stack.isAlwaysOnTop()) return 1;
+6 −0
Original line number Diff line number Diff line
@@ -528,6 +528,10 @@ public class WindowManagerService extends IWindowManager.Stub

    final boolean mAllowBootMessages;

    // Indicates whether the Assistant should show on top of the Dream (respectively, above
    // everything else on screen). Otherwise, it will be put under always-on-top stacks.
    final boolean mAssistantOnTopOfDream;

    final boolean mLimitedAlphaCompositing;
    final int mMaxUiWidth;

@@ -1181,6 +1185,8 @@ public class WindowManagerService extends IWindowManager.Stub
                com.android.internal.R.bool.config_disableTransitionAnimation);
        mPerDisplayFocusEnabled = context.getResources().getBoolean(
                com.android.internal.R.bool.config_perDisplayFocusEnabled);
        mAssistantOnTopOfDream = context.getResources().getBoolean(
                com.android.internal.R.bool.config_assistantOnTopOfDream);
        mInputManager = inputManager; // Must be before createDisplayContentLocked.
        mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);