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

Commit c2791664 authored by Andrii Kulian's avatar Andrii Kulian
Browse files

Make task fullscreen when locked

Previously if we were in multi-window mode and some task called
startLockTask() or kiosk mode was started - other tasks remained
on screen. User could still interact with other tasks, locked or
pinned task could be removed.
This CL makes tasks move to fullscreen when they are locked.

Bug: 27876860
Change-Id: I547a94be50276c7f418343600877e51b6b40c7a7
parent 250c617d
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -9424,7 +9424,8 @@ public final class ActivityManagerService extends ActivityManagerNative
            if (prev != null && prev.isRecentsActivity()) {
            if (prev != null && prev.isRecentsActivity()) {
                task.setTaskToReturnTo(ActivityRecord.RECENTS_ACTIVITY_TYPE);
                task.setTaskToReturnTo(ActivityRecord.RECENTS_ACTIVITY_TYPE);
            }
            }
            mStackSupervisor.findTaskToMoveToFrontLocked(task, flags, options, "moveTaskToFront");
            mStackSupervisor.findTaskToMoveToFrontLocked(task, flags, options, "moveTaskToFront",
                    false /* forceNonResizable */);
        } finally {
        } finally {
            Binder.restoreCallingIdentity(origId);
            Binder.restoreCallingIdentity(origId);
        }
        }
+19 −8
Original line number Original line Diff line number Diff line
@@ -1759,8 +1759,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
        }
        }
    }
    }


    void findTaskToMoveToFrontLocked(
    void findTaskToMoveToFrontLocked(TaskRecord task, int flags, ActivityOptions options,
            TaskRecord task, int flags, ActivityOptions options, String reason) {
            String reason, boolean forceNonResizeable) {
        if ((flags & ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) {
        if ((flags & ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) {
            mUserLeaving = true;
            mUserLeaving = true;
        }
        }
@@ -1811,7 +1811,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
        if (DEBUG_STACK) Slog.d(TAG_STACK,
        if (DEBUG_STACK) Slog.d(TAG_STACK,
                "findTaskToMoveToFront: moved to front of stack=" + task.stack);
                "findTaskToMoveToFront: moved to front of stack=" + task.stack);


        handleNonResizableTaskIfNeeded(task, INVALID_STACK_ID, task.stack.mStackId);
        handleNonResizableTaskIfNeeded(task, INVALID_STACK_ID, task.stack.mStackId,
                forceNonResizeable);
    }
    }


    boolean canUseActivityOptionsLaunchBounds(ActivityOptions options, int launchStackId) {
    boolean canUseActivityOptionsLaunchBounds(ActivityOptions options, int launchStackId) {
@@ -3360,19 +3361,25 @@ public final class ActivityStackSupervisor implements DisplayListener {
        }
        }
    }
    }


    void handleNonResizableTaskIfNeeded(TaskRecord task, int preferredStackId, int actualStackId) {
        handleNonResizableTaskIfNeeded(task, preferredStackId, actualStackId,
                false /* forceNonResizable */);
    }

    void handleNonResizableTaskIfNeeded(
    void handleNonResizableTaskIfNeeded(
            TaskRecord task, int preferredStackId, int actualStackId) {
            TaskRecord task, int preferredStackId, int actualStackId, boolean forceNonResizable) {
        if ((!isStackDockedInEffect(actualStackId) && preferredStackId != DOCKED_STACK_ID)
        if ((!isStackDockedInEffect(actualStackId) && preferredStackId != DOCKED_STACK_ID)
                || task.isHomeTask()) {
                || task.isHomeTask()) {
            return;
            return;
        }
        }


        if (!task.canGoInDockedStack()) {
        if (!task.canGoInDockedStack() || forceNonResizable) {
            // Display a warning toast that we tried to put a non-dockable task in the docked stack.
            // Display a warning toast that we tried to put a non-dockable task in the docked stack.
            mService.mHandler.sendEmptyMessage(NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG);
            mService.mHandler.sendEmptyMessage(NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG);


            // Dismiss docked stack.
            // Dismiss docked stack. If task appeared to be in docked stack but is not resizable -
            mService.moveTasksToFullscreenStack(DOCKED_STACK_ID, false);
            // we need to move it to top of fullscreen stack, otherwise it will be covered.
            mService.moveTasksToFullscreenStack(DOCKED_STACK_ID, actualStackId == DOCKED_STACK_ID);
        } else if (task.mResizeMode == RESIZE_MODE_FORCE_RESIZEABLE) {
        } else if (task.mResizeMode == RESIZE_MODE_FORCE_RESIZEABLE) {
            String packageName = task.getTopActivity() != null
            String packageName = task.getTopActivity() != null
                    ? task.getTopActivity().appInfo.packageName : null;
                    ? task.getTopActivity().appInfo.packageName : null;
@@ -3443,8 +3450,12 @@ public final class ActivityStackSupervisor implements DisplayListener {
        }
        }


        if (andResume) {
        if (andResume) {
            findTaskToMoveToFrontLocked(task, 0, null, reason);
            findTaskToMoveToFrontLocked(task, 0, null, reason,
                    lockTaskModeState != LOCK_TASK_MODE_NONE);
            resumeFocusedStackTopActivityLocked();
            resumeFocusedStackTopActivityLocked();
        } else if (lockTaskModeState != LOCK_TASK_MODE_NONE) {
            handleNonResizableTaskIfNeeded(task, INVALID_STACK_ID, task.stack.mStackId,
                    true /* forceNonResizable */);
        }
        }
    }
    }