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

Commit 15428cc8 authored by Ahaan Ugale's avatar Ahaan Ugale
Browse files

Fix sensitive content Toast for multiple windows in same activity

The current logic for onWindowVisible only triggers for the first window
of an Activity. Moving to relayoutWindow makes it trigger reliably.

This behavior is already tested through
ViewSensitiveContentTest#testToastIsShown since that shows a splash
screen when launching the protected Activity. The test is currently
flaky.

Bug: 323580163
Bug: 332206566
Test: manual
Test: atest CtsSensitiveContentProtectionTestCases --iterations
Change-Id: I6170125410d27c8be48c403fc91e0025762ade48
parent 912d7519
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -2446,6 +2446,9 @@ public class WindowManagerService extends IWindowManager.Stub
            ProtoLog.i(WM_DEBUG_SCREEN_ON,
                    "Relayout %s: oldVis=%d newVis=%d. %s", win, oldVisibility,
                            viewVisibility, new RuntimeException().fillInStackTrace());
            if (becameVisible) {
                onWindowVisible(win);
            }

            win.setDisplayLayoutNeeded();
            win.mGivenInsetsPending = (flags & WindowManagerGlobal.RELAYOUT_INSETS_PENDING) != 0;
@@ -10168,7 +10171,7 @@ public class WindowManagerService extends IWindowManager.Stub
     * Called to notify WMS that the specified window has become visible. This shows a Toast if the
     * window is deemed to hold sensitive content.
     */
    void onWindowVisible(@NonNull WindowState w) {
    private void onWindowVisible(@NonNull WindowState w) {
        showToastIfBlockingScreenCapture(w);
    }

+0 −4
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import static android.graphics.GraphicsProtos.dumpPointProto;
import static android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
import static android.os.PowerManager.DRAW_WAKE_LOCK;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.permission.flags.Flags.sensitiveContentImprovements;
import static android.view.SurfaceControl.Transaction;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
@@ -2139,9 +2138,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                }
            }
            setDisplayLayoutNeeded();
            if (sensitiveContentImprovements() && visible) {
                mWmService.onWindowVisible(this);
            }
        }
    }