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

Commit e6550ab9 authored by Marzia Favaro's avatar Marzia Favaro
Browse files

Check only visible windows when looking for occluding activities

Consider only the currently visible activities when looking for opaque
ones, for the sake of deciding which dim to use.

AnnotateActivity is a fullscreen opaque activity in the same task as ChooserActivity. As Annotate opened on top of Chooser, the task became opaque without waiting for Annotate to be visible, This was causing the dim to fade out too soon.

Fix: 281632483
Test: DimmerTests
Change-Id: Idc8c3192d68eee25d4221c92909deacdca85f6c3
parent c810a96d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19,4 +19,5 @@ flag {
  namespace: "windowing_frontend"
  description: "Refactor dim to fix flickers"
  bug: "281632483,295291019"
  is_fixed_read_only: true
}
 No newline at end of file
+11 −4
Original line number Diff line number Diff line
@@ -2832,17 +2832,22 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
    static class OpaqueActivityHelper implements Predicate<ActivityRecord> {
        private ActivityRecord mStarting;
        private boolean mIncludeInvisibleAndFinishing;
        private boolean mIgnoringKeyguard;

        ActivityRecord getOpaqueActivity(@NonNull WindowContainer<?> container) {
        ActivityRecord getOpaqueActivity(
                @NonNull WindowContainer<?> container, boolean ignoringKeyguard) {
            mIncludeInvisibleAndFinishing = true;
            mIgnoringKeyguard = ignoringKeyguard;
            return container.getActivity(this,
                    true /* traverseTopToBottom */, null /* boundary */);
        }

        ActivityRecord getVisibleOpaqueActivity(@NonNull WindowContainer<?> container,
                @Nullable ActivityRecord starting) {
        ActivityRecord getVisibleOpaqueActivity(
                @NonNull WindowContainer<?> container, @Nullable ActivityRecord starting,
                boolean ignoringKeyguard) {
            mStarting = starting;
            mIncludeInvisibleAndFinishing = false;
            mIgnoringKeyguard = ignoringKeyguard;
            final ActivityRecord opaque = container.getActivity(this,
                    true /* traverseTopToBottom */, null /* boundary */);
            mStarting = null;
@@ -2851,7 +2856,9 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {

        @Override
        public boolean test(ActivityRecord r) {
            if (!mIncludeInvisibleAndFinishing && !r.visibleIgnoringKeyguard && r != mStarting) {
            if (!mIncludeInvisibleAndFinishing && r != mStarting
                    && ((mIgnoringKeyguard && !r.visibleIgnoringKeyguard)
                    || (!mIgnoringKeyguard && !r.isVisible()))) {
                // Ignore invisible activities that are not the currently starting activity
                // (about to be visible).
                return false;
+3 −1
Original line number Diff line number Diff line
@@ -199,6 +199,7 @@ import com.android.server.Watchdog;
import com.android.server.am.ActivityManagerService;
import com.android.server.am.AppTimeTracker;
import com.android.server.uri.NeededUriGrants;
import com.android.window.flags.Flags;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -3306,7 +3307,8 @@ class Task extends TaskFragment {
        // Once at the root task level, we want to check {@link #isTranslucent(ActivityRecord)}.
        // If true, we want to get the Dimmer from the level above since we don't want to animate
        // the dim with the Task.
        if (!isRootTask() || isTranslucent(null)) {
        if (!isRootTask() || (Flags.dimmerRefactor() && isTranslucentAndVisible())
                || isTranslucent(null)) {
            return super.getDimmer();
        }

+15 −2
Original line number Diff line number Diff line
@@ -971,7 +971,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
        // A TaskFragment isn't translucent if it has at least one visible activity that occludes
        // this TaskFragment.
        return mTaskSupervisor.mOpaqueActivityHelper.getVisibleOpaqueActivity(this,
                starting) == null;
                starting, true /* ignoringKeyguard */) == null;
    }

    /**
@@ -984,7 +984,20 @@ class TaskFragment extends WindowContainer<WindowContainer> {
            return true;
        }
        // Including finishing Activity if the TaskFragment is becoming invisible in the transition.
        return mTaskSupervisor.mOpaqueActivityHelper.getOpaqueActivity(this) == null;
        return mTaskSupervisor.mOpaqueActivityHelper.getOpaqueActivity(this,
                true /* ignoringKeyguard */) == null;
    }

    /**
     * Like {@link  #isTranslucent(ActivityRecord)} but evaluating the actual visibility of the
     * windows rather than their visibility ignoring keyguard.
     */
    boolean isTranslucentAndVisible() {
        if (!isAttached() || isForceHidden() || isForceTranslucent()) {
            return true;
        }
        return mTaskSupervisor.mOpaqueActivityHelper.getVisibleOpaqueActivity(this, null,
                false /* ignoringKeyguard */) == null;
    }

    ActivityRecord getTopNonFinishingActivity() {
+2 −2
Original line number Diff line number Diff line
@@ -418,8 +418,8 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
            if (transientRoot == null) continue;
            final WindowContainer<?> rootParent = transientRoot.getParent();
            if (rootParent == null || rootParent.getTopChild() == transientRoot) continue;
            final ActivityRecord topOpaque = mController.mAtm.mTaskSupervisor
                    .mOpaqueActivityHelper.getOpaqueActivity(rootParent);
            final ActivityRecord topOpaque = mController.mAtm.mTaskSupervisor.mOpaqueActivityHelper
                    .getOpaqueActivity(rootParent, true /* ignoringKeyguard */);
            if (transientRoot.compareTo(topOpaque.getRootTask()) < 0) {
                occludedCount++;
            }