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

Commit 2ec9f8c3 authored by Garfield Tan's avatar Garfield Tan
Browse files

Update task descriptions on activity opacity changes

Top opaque system bar appearance depends on opacity of the top activity
Therefore, we should respect the settings of the top activity when it
change the opacity of itself.

Bug: 390368429
Test: Caption turns transparent after launching a transparent activity
in a test app.
Test: New tests pass.
Flag: com.android.window.flags.enable_desktop_windowing_mode

Change-Id: If66bbf29c981fb79fb2eb3f9d750651cf8edca9f
parent 2632c401
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5119,6 +5119,7 @@ class Task extends TaskFragment {
        mTranslucentActivityWaiting = r;
        mPendingConvertFromTranslucentActivity = r;
        mUndrawnActivitiesBelowTopTranslucent.clear();
        updateTaskDescription();
        mHandler.sendEmptyMessageDelayed(TRANSLUCENT_TIMEOUT_MSG, TRANSLUCENT_CONVERSION_TIMEOUT);
    }

@@ -5128,6 +5129,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;
@@ -2111,6 +2112,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();
    }