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

Commit c3512eee authored by Garfield Tan's avatar Garfield Tan Committed by Android (Google) Code Review
Browse files

Merge "Update task descriptions on activity opacity changes" into main

parents f68e3826 2ec9f8c3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5101,6 +5101,7 @@ class Task extends TaskFragment {
        mTranslucentActivityWaiting = r;
        mPendingConvertFromTranslucentActivity = r;
        mUndrawnActivitiesBelowTopTranslucent.clear();
        updateTaskDescription();
        mHandler.sendEmptyMessageDelayed(TRANSLUCENT_TIMEOUT_MSG, TRANSLUCENT_CONVERSION_TIMEOUT);
    }

@@ -5110,6 +5111,7 @@ class Task extends TaskFragment {
                    + " but is " + r);
        }
        mPendingConvertFromTranslucentActivity = null;
        updateTaskDescription();
    }

    /**
+38 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ import android.util.Xml;
import android.view.Display;
import android.view.DisplayInfo;
import android.view.SurfaceControl;
import android.view.WindowInsetsController;
import android.window.TaskFragmentOrganizer;

import androidx.test.filters.MediumTest;
@@ -2109,6 +2110,43 @@ public class TaskTests extends WindowTestsBase {
        assertEquals(Color.RED, task.getTaskDescription().getBackgroundColor());
    }

    @Test
    public void testUpdateTopOpaqueSystemBarsAppearanceWhenActivityBecomesTransparent() {
        final Task task = createTask(mDisplayContent);
        final ActivityRecord activity = createActivityRecord(task);
        final ActivityManager.TaskDescription td = new ActivityManager.TaskDescription();
        td.setSystemBarsAppearance(
                WindowInsetsController.APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND);
        activity.setTaskDescription(td);

        assertEquals(WindowInsetsController.APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND,
                task.getTaskDescription().getTopOpaqueSystemBarsAppearance());

        activity.setOccludesParent(false);

        assertEquals(0, task.getTaskDescription().getTopOpaqueSystemBarsAppearance());
    }

    @Test
    public void testUpdateTopOpaqueSystemBarsAppearanceWhenActivityBecomesOpaque() {
        final Task task = createTask(mDisplayContent);
        final ActivityRecord activity = createActivityRecord(task);
        activity.setOccludesParent(false);

        final ActivityManager.TaskDescription td = new ActivityManager.TaskDescription();
        td.setSystemBarsAppearance(
                WindowInsetsController.APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND);
        activity.setTaskDescription(td);

        assertEquals(0, task.getTaskDescription().getTopOpaqueSystemBarsAppearance());

        activity.setOccludesParent(true);

        assertEquals(WindowInsetsController.APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND,
                task.getTaskDescription().getTopOpaqueSystemBarsAppearance());

    }

    private Task getTestTask() {
        return new TaskBuilder(mSupervisor).setCreateActivity(true).build();
    }