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

Commit b3bff5da authored by Ats Jenk's avatar Ats Jenk Committed by Automerger Merge Worker
Browse files

Merge "Clean up desktop mode logging" into tm-qpr-dev am: fac53656 am: 81f2e64c

parents e3faaa44 81f2e64c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ public class DesktopModeStatus {
        try {
            int result = Settings.System.getIntForUser(context.getContentResolver(),
                    Settings.System.DESKTOP_MODE, UserHandle.USER_CURRENT);
            ProtoLog.d(WM_SHELL_DESKTOP_MODE, "isDesktopModeEnabled=%s", result);
            return result != 0;
        } catch (Exception e) {
            ProtoLog.e(WM_SHELL_DESKTOP_MODE, "Failed to read DESKTOP_MODE setting %s", e);
+8 −2
Original line number Diff line number Diff line
@@ -69,22 +69,28 @@ class DesktopModeTaskRepository {

    /**
     * Mark a task with given [taskId] as active.
     *
     * @return `true` if the task was not active
     */
    fun addActiveTask(taskId: Int) {
    fun addActiveTask(taskId: Int): Boolean {
        val added = activeTasks.add(taskId)
        if (added) {
            activeTasksListeners.onEach { it.onActiveTasksChanged() }
        }
        return added
    }

    /**
     * Remove task with given [taskId] from active tasks.
     *
     * @return `true` if the task was active
     */
    fun removeActiveTask(taskId: Int) {
    fun removeActiveTask(taskId: Int): Boolean {
        val removed = activeTasks.remove(taskId)
        if (removed) {
            activeTasksListeners.onEach { it.onActiveTasksChanged() }
        }
        return removed
    }

    /**
+23 −17
Original line number Diff line number Diff line
@@ -87,11 +87,13 @@ public class FreeformTaskListener implements ShellTaskOrganizer.TaskListener {
        }

        if (DesktopModeStatus.IS_SUPPORTED && taskInfo.isVisible) {
            mDesktopModeTaskRepository.ifPresent(repository -> {
                if (repository.addActiveTask(taskInfo.taskId)) {
                    ProtoLog.v(ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE,
                            "Adding active freeform task: #%d", taskInfo.taskId);
            mDesktopModeTaskRepository.ifPresent(it -> it.addActiveTask(taskInfo.taskId));
            mDesktopModeTaskRepository.ifPresent(
                    it -> it.updateVisibleFreeformTasks(taskInfo.taskId, true));
                }
                repository.updateVisibleFreeformTasks(taskInfo.taskId, true);
            });
        }
    }

@@ -102,11 +104,13 @@ public class FreeformTaskListener implements ShellTaskOrganizer.TaskListener {
        mTasks.remove(taskInfo.taskId);

        if (DesktopModeStatus.IS_SUPPORTED) {
            mDesktopModeTaskRepository.ifPresent(repository -> {
                if (repository.removeActiveTask(taskInfo.taskId)) {
                    ProtoLog.v(ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE,
                            "Removing active freeform task: #%d", taskInfo.taskId);
            mDesktopModeTaskRepository.ifPresent(it -> it.removeActiveTask(taskInfo.taskId));
            mDesktopModeTaskRepository.ifPresent(
                    it -> it.updateVisibleFreeformTasks(taskInfo.taskId, false));
                }
                repository.updateVisibleFreeformTasks(taskInfo.taskId, false);
            });
        }

        if (!Transitions.ENABLE_SHELL_TRANSITIONS) {
@@ -123,13 +127,15 @@ public class FreeformTaskListener implements ShellTaskOrganizer.TaskListener {
        mWindowDecorationViewModel.onTaskInfoChanged(state.mTaskInfo);

        if (DesktopModeStatus.IS_SUPPORTED) {
            mDesktopModeTaskRepository.ifPresent(repository -> {
                if (taskInfo.isVisible) {
                    if (repository.addActiveTask(taskInfo.taskId)) {
                        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE,
                                "Adding active freeform task: #%d", taskInfo.taskId);
                mDesktopModeTaskRepository.ifPresent(it -> it.addActiveTask(taskInfo.taskId));
                    }
            mDesktopModeTaskRepository.ifPresent(
                    it -> it.updateVisibleFreeformTasks(taskInfo.taskId, taskInfo.isVisible));
                }
                repository.updateVisibleFreeformTasks(taskInfo.taskId, taskInfo.isVisible);
            });
        }
    }